#include <nodetxtl.h>
Inheritance diagram for TextLine:
Public Member Functions | |
TextLine () | |
Simple TextLine constructor, it is required so that SimpleCopy will work. | |
~TextLine () | |
Destructor. | |
TextLine (Node *ContextNode, AttachNodeDirection Direction) | |
The main TextLine constructor. | |
void | Init () |
common init function for constructors | |
virtual Node * | SimpleCopy () |
This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes of Node. | |
void | CopyNodeContents (TextLine *NodeCopy) |
This method copies the node's contents to the node pointed to by NodeCopy. | |
virtual void | PolyCopyNodeContents (NodeRenderable *pNodeCopy) |
Polymorphically copies the contents of this node to another. | |
virtual CopyType | GetCopyType () |
This function returns a type describing how this object is to be copied. The fuction is called from the low level copy operation CopyObjects. There are two options at present, these being SIMPLECOPY and COMPLEXCOPY. SIMPLECOPY indicates that the node can be copied by a call to its virtual function SimpleCopy(). COMPLEXCOPY however indicates that the node needs to do its own thing when copying and must be called via the ComplexCopy() virtual function. This virtual will likely return a tree of copied objects rather than just a copy of itself. | |
virtual INT32 | ComplexCopy (CopyStage Stage, Range &RangeToCopy, Node **pOutput) |
If the copystage is COPYOBJECT, The node has been called to copy itself and do what ever it needs to to make a sensible copy of other items such as attributes. The caller (CopyObjects) will not deep copy this node (as this is a complex copy and it expects the handler to know what its doing). In this case the TextLine object cannot exist on its own. It needs a TextStory as a parent and however many text characters that live inside it. Hence this is what is returned. SeeAlso Node::ComplexCopy(), CopyObjects(). | |
virtual INT32 | ComplexHide (UndoableOperation *pOp, Node *pNextNode) |
Override the node level virtual function ComplexHide. This gives us a chance to get in and hide the various selected members of a text story sensibly. We hide all necessary nodes when the last member of the text story is called to complex hide itself, otherwise we may corrupt the range being scanned. | |
virtual BOOL | IsSetCandidate () const |
Indicates that NodeRenderableInks are candidates for membership of Attribute gallery set. | |
virtual BOOL | IsCompound () const |
virtual UINT32 | GetNodeSize () const |
For finding the size of the node. | |
virtual void | GetDebugDetails (StringBase *Str) |
For obtaining debug information about the Node. This fn can be deleted before we ship. | |
virtual String | Describe (BOOL Plural, BOOL Verbose) |
Gives a description of the TextLine node for the status line etc. | |
DocRect | GetBlobBoundingRect () |
This function returns the blob bounding rectangle of this TextLine. There is a tiny blob on the top left of the first character on the line. | |
void | RenderObjectBlobs (RenderRegion *pRRegion) |
Renders the TextLines object blobs. | |
void | RenderTinyBlobs (RenderRegion *pRRegion) |
Renders the TextLines tiny blobs. | |
DocCoord | GetTinyBlobPos () |
This function returns the location of the tiny blob on this TextLine. It is either on the top-left of the first character on the line, or if there isn't a char, on the top-left of the line bounding rect. | |
BOOL | CreateNodeGroup (NodeGroup **ppNodeGroup, FormatRegion *pFormatRegion, BecomeA *pBecomeA) |
Creates a NodeGroup containing all chars converted to NodePaths. | |
virtual BOOL | ReCacheMetrics (FormatRegion *pFormmatRegion) |
Recache metrics in text line. | |
BOOL | Format (TextStoryInfo *pStoryInfo) |
perform line level formatting Note: on entry pStoryInfo->DescentLine hold the DescentLine of the last line (pStoryInfo->DescentLineValid indicating if there was none (eg first line) and on exit, it holds the DescentLine for this line and DescentLineValid is TRUE | |
BOOL | EnsureNextLineOfParagraphHasSameLineLevelAttrs (UndoableOperation *pUndoOp) |
Ensure the next line of a paragraph has the same line level attibutes. | |
BOOL | ReCalcLineInfo (TextLineInfo *pLineInfo) |
Recalculate line level info (absorbing space at end of line) Note: Also updates line level info in node itself. | |
BOOL | PositionCharsInLine (TextLineInfo *pLineInfo) |
set the position of each char on the line accounting for justification ALSO, flag any chars that have moved as 'affected' | |
BOOL | CalcBaseAndDescentLine (MILLIPOINT *pBaseLine, MILLIPOINT *pDescentLine, MILLIPOINT LastDescentLine, BOOL FirstLine) |
Calculate BaseLine and DescentLine for this line given the last line's DescentLine if this is the first line in the story, the baseline is 0 and the DescentLine has to be back calculated. | |
BOOL | SetCharMatrices (MILLIPOINT LinePos) |
set matrices in all VTN on a line | |
BOOL | FitTextToPath (TextStoryInfo *pPathInfo, MILLIPOINT LinePos) |
set matrices in all VTN on a line so as to fit text to the path, accounting for any transform which was applied before the text was fitted to the path | |
BOOL | Wrap (UndoableOperation *pUndoOp, MILLIPOINT WrapWidth, MILLIPOINT Indent) |
Word wrap the line. | |
VisibleTextNode * | FindBreakChar (MILLIPOINT FitWidth, BOOL SetCharPositions, MILLIPOINT Indent, MILLIPOINT CharPosOffset=0, MILLIPOINT ExtraOnChars=0, MILLIPOINT ExtraOnSpaces=0) |
Find words to fit given width, absorbing spaces, optionally formats line. | |
TextLine * | FindFirstLineOfParagraph () |
BOOL | AddChildLineLevelAttrsToSet (AttrTypeSet *pAttrSet) |
VisibleTextNode * | FindCharAtDistAlongLine (MILLIPOINT Distance, BOOL *LeftHandSide) |
Call this function to get the character at a certian distance along this TextLine. If the distance is off the right end of the line then a pointer to the EOLNode is returned. | |
VisibleTextNode * | FindFirstVTN () const |
For getting a pointer to the first Visible Text Node in this TextLine. | |
VisibleTextNode * | FindLastVTN () const |
For getting a pointer to the last Visible Text Node in this TextLine. | |
EOLNode * | FindEOLNode () const |
CaretNode * | FindCaret () const |
TextLine * | FindNextLine () const |
TextLine * | FindPrevLine () const |
MILLIPOINT | GetLastCharTracking () |
BOOL | WholeLineSelected () |
BOOL | WillLineWrapOnPath (FIXED16 xscale, MILLIPOINT PLength) |
Calculates whether the formatter will wrap this line of text around the path It calculates this by checking the position of the last character (or VTN in the line). If this wraps it is assumed the whole line will wrap. | |
virtual BOOL | WritePreChildrenWeb (BaseCamelotFilter *pFilter) |
Saves a text line record to the new file format filter. | |
virtual BOOL | WritePreChildrenNative (BaseCamelotFilter *pFilter) |
virtual BOOL | WriteBeginChildRecordsWeb (BaseCamelotFilter *pFilter) |
Begin to write out you child records, in the web format. | |
virtual BOOL | WriteBeginChildRecordsNative (BaseCamelotFilter *pFilter) |
Begin to write out you child records, in the native format. | |
virtual BOOL | WriteEndChildRecordsWeb (BaseCamelotFilter *pFilter) |
Finished writing out you child records, in the web format. | |
virtual BOOL | WriteEndChildRecordsNative (BaseCamelotFilter *pFilter) |
Finished writing out you child records, in the native format. | |
MILLIPOINT | GetLineDescent () |
MILLIPOINT | GetLineAscent () |
MILLIPOINT | GetLineSize () |
void | SetLineDescent (MILLIPOINT Descent) |
void | SetLineAscent (MILLIPOINT Ascent) |
void | SetLineSize (MILLIPOINT Size) |
void | UpdateLineDescent (MILLIPOINT Descent) |
void | UpdateLineAscent (MILLIPOINT Ascent) |
void | UpdateLineSize (MILLIPOINT Size) |
Justification | GetJustification () |
MILLIPOINT | GetLineSpacing () |
FIXED16 | GetLineSpaceRatio () |
MILLIPOINT | GetParaLeftMargin () |
MILLIPOINT | GetParaFirstIndent () |
MILLIPOINT | GetParaRightMargin () |
const TxtRuler * | GetRuler () |
void | SetJustification (Justification justification) |
void | SetLineSpacing (MILLIPOINT Spacing) |
void | SetLineSpaceRatio (FIXED16 SpaceRatio) |
void | SetParaLeftMargin (MILLIPOINT Margin) |
void | SetParaFirstIndent (MILLIPOINT Indent) |
void | SetParaRightMargin (MILLIPOINT Margin) |
void | SetRuler (const TxtRuler *pRuler) |
MILLIPOINT | GetPosInStory () |
void | SetPosInStory (MILLIPOINT pos) |
Static Public Member Functions | |
static TextLine * | CreateEmptyTextLine (Node *pContextNode=NULL, AttachNodeDirection Direction=FIRSTCHILD) |
Create a TextLine with EOL and attach it to another node if required. | |
static BOOL | IsAttrTypeLineLevel (CCRuntimeClass *pAttrType) |
Protected Member Functions | |
MILLIPOINT | GetEffectiveLeftMargin () |
Select the left margin or first indent value depending on whether this is the first line in the paragraph. | |
Private Attributes | |
MILLIPOINT | mLineDescent |
MILLIPOINT | mLineAscent |
MILLIPOINT | mLineSize |
Justification | mJustification |
MILLIPOINT | mLineSpacing |
FIXED16 | mLineSpaceRatio |
MILLIPOINT | mLeftMargin |
MILLIPOINT | mFirstIndent |
MILLIPOINT | mRightMargin |
TxtRuler * | mpRuler |
MILLIPOINT | mPosInStory |
Definition at line 287 of file nodetxtl.h.
|
Simple TextLine constructor, it is required so that SimpleCopy will work.
Definition at line 196 of file nodetxtl.cpp. 00196 : BaseTextClass() // Call the base class 00197 { 00198 Init(); 00199 }
|
|
Destructor.
Definition at line 210 of file nodetxtl.cpp. 00211 { 00212 delete mpRuler; 00213 }
|
|
The main TextLine constructor.
Specifies the direction in which the node is to be attached to the ContextNode. The values this variable can take are as follows: PREV : Attach node as a previous sibling of the context node NEXT : Attach node as a next sibling of the context node FIRSTCHILD: Attach node as the first child of the context node LASTCHILD : Attach node as a last child of the context node Definition at line 235 of file nodetxtl.cpp. 00236 :BaseTextClass(ContextNode, Direction) 00237 { 00238 Init(); 00239 }
|
|
Definition at line 1056 of file nodetxtl.cpp. 01057 { 01058 Node* pNode = FindFirstChild(); 01059 while (pNode!=NULL) 01060 { 01061 if (pNode->IsAnAttribute() && ((NodeAttribute*)pNode)->IsALineLevelAttrib()) 01062 if (!pAttrTypeSet->AddToSet(((NodeAttribute*)pNode)->GetAttributeType())) 01063 return FALSE; 01064 pNode = pNode->FindNext(); 01065 } 01066 return TRUE; 01067 }
|
|
Calculate BaseLine and DescentLine for this line given the last line's DescentLine if this is the first line in the story, the baseline is 0 and the DescentLine has to be back calculated.
Definition at line 1600 of file nodetxtl.cpp. 01602 { 01603 // get some info about the line ... 01604 MILLIPOINT LineAscent = GetLineAscent(); 01605 MILLIPOINT LineDescent = GetLineDescent(); 01606 MILLIPOINT LineHeight = LineAscent-LineDescent; 01607 MILLIPOINT LineSpacing = GetLineSpacing(); 01608 01609 MILLIPOINT BaseLine = 0; 01610 MILLIPOINT DescentLine = 0; 01611 if (LineSpacing!=0) 01612 { 01613 MILLIPOINT OffsetFromDescentLineToBaseLine = MulDiv(LineSpacing, -LineDescent, LineHeight); 01614 if (LastDescentLineValid) 01615 { 01616 DescentLine = LastDescentLine - LineSpacing; 01617 BaseLine = DescentLine + OffsetFromDescentLineToBaseLine; 01618 } 01619 else 01620 DescentLine = BaseLine - OffsetFromDescentLineToBaseLine; 01621 } 01622 else 01623 { 01624 FIXED16 LineSpaceRatio = GetLineSpaceRatio(); 01625 MILLIPOINT AbsolutLineSpacing = MILLIPOINT( XLONG(LineHeight) * LineSpaceRatio ); 01626 MILLIPOINT OffsetFromLastDescentLineToBaseLine = LineAscent; 01627 if (LineSpaceRatio<1) 01628 OffsetFromLastDescentLineToBaseLine = XLONG(LineAscent) * LineSpaceRatio; 01629 01630 if (LastDescentLineValid) 01631 { 01632 BaseLine = LastDescentLine - OffsetFromLastDescentLineToBaseLine; 01633 DescentLine = LastDescentLine - AbsolutLineSpacing; 01634 } 01635 else 01636 DescentLine = BaseLine + OffsetFromLastDescentLineToBaseLine - AbsolutLineSpacing; 01637 } 01638 01639 // set outputs 01640 *pDescentLine = DescentLine; 01641 *pBaseLine = BaseLine; 01642 01643 return TRUE; 01644 }
|
|
If the copystage is COPYOBJECT, The node has been called to copy itself and do what ever it needs to to make a sensible copy of other items such as attributes. The caller (CopyObjects) will not deep copy this node (as this is a complex copy and it expects the handler to know what its doing). In this case the TextLine object cannot exist on its own. It needs a TextStory as a parent and however many text characters that live inside it. Hence this is what is returned. SeeAlso Node::ComplexCopy(), CopyObjects().
Reimplemented from Node. Definition at line 315 of file nodetxtl.cpp. 00316 { 00317 TextStory* pTextStory = FindParentStory(); 00318 ERROR2IF(pTextStory==NULL,FALSE,"TextLine::ComplexCopy() - pTextStory==NULL"); 00319 return pTextStory->BaseComplexCopy(Stage, RangeToCopy, pOutput); 00320 }
|
|
Override the node level virtual function ComplexHide. This gives us a chance to get in and hide the various selected members of a text story sensibly. We hide all necessary nodes when the last member of the text story is called to complex hide itself, otherwise we may corrupt the range being scanned.
Reimplemented from Node. Definition at line 340 of file nodetxtl.cpp. 00341 { 00342 // if there is no next node in the range then we need to hide all nodes 00343 BOOL CallComplexHide = TRUE; 00344 TextStory* pThisStory = FindParentStory(); 00345 ERROR2IF(pThisStory==NULL,FALSE,"VisibleTextNode::ComplexHide() - pThisStory==NULL"); 00346 00347 if (pNextNode) 00348 { 00349 if ( (pNextNode->IsAVisibleTextNode()) || 00350 (IS_A(pNextNode,TextLine)) 00351 ) 00352 { 00353 TextStory* pTextStory = FindParentStory(); 00354 ERROR2IF(pTextStory==NULL,FALSE,"VisibleTextNode::ComplexHide() - pTextStory==NULL"); 00355 00356 if (pThisStory==pTextStory) 00357 CallComplexHide=FALSE; 00358 } 00359 } 00360 00361 if (CallComplexHide) 00362 return pThisStory->BaseComplexHide(pOp); 00363 else 00364 return 1; 00365 }
|
|
This method copies the node's contents to the node pointed to by NodeCopy.
Definition at line 379 of file nodetxtl.cpp. 00380 { 00381 // Ask the base class to do its bit 00382 NodeRenderableBounded::CopyNodeContents(NodeCopy); 00383 00384 // Copy specifics 00385 NodeCopy->mLineAscent = mLineAscent; 00386 NodeCopy->mLineDescent = mLineDescent; 00387 NodeCopy->mLineSize = mLineSize; 00388 00389 NodeCopy->mJustification = mJustification; 00390 NodeCopy->mLineSpacing = mLineSpacing; 00391 NodeCopy->mLineSpaceRatio = mLineSpaceRatio; 00392 NodeCopy->mLeftMargin = mLeftMargin; 00393 NodeCopy->mFirstIndent = mFirstIndent; 00394 NodeCopy->mRightMargin = mRightMargin; 00395 *NodeCopy->mpRuler = *mpRuler; 00396 00397 NodeCopy->mPosInStory = mPosInStory; 00398 }
|
|
Create a TextLine with EOL and attach it to another node if required.
Definition at line 538 of file nodetxtl.cpp. 00539 { 00540 TextLine* pTextLine = new TextLine(); 00541 if (pTextLine==NULL) 00542 return NULL; 00543 00544 EOLNode* pEOL = new EOLNode(pTextLine,FIRSTCHILD); 00545 if (pEOL==NULL) 00546 { 00547 pTextLine->CascadeDelete(); 00548 delete pTextLine; 00549 return NULL; 00550 } 00551 00552 if (pContextNode!=NULL) 00553 pTextLine->AttachNode(pContextNode,Direction); 00554 00555 return pTextLine; 00556 }
|
|
Creates a NodeGroup containing all chars converted to NodePaths.
Definition at line 437 of file nodetxtl.cpp. 00438 { 00439 #ifndef DISABLE_TEXT_RENDERING 00440 ERROR2IF(pFormatRegion==NULL,FALSE,"TextChar::CreateNodeGroup() - pFormatRegion==NULL"); 00441 ERROR2IF( pBecomeA==NULL,FALSE,"TextChar::CreateNodeGroup() - pBecomeA==NULL"); 00442 ERROR2IF( ppNodeGroup==NULL,FALSE,"TextChar::CreateNodeGroup() - ppNodeGroup==NULL"); 00443 00444 pFormatRegion->SaveContext(); 00445 00446 // here to overcome scope problem 00447 Node* pNode=NULL; 00448 TextChar* pTextChar=NULL; 00449 00450 // if not passing back, create a NodeGroup to encompass the line, and copy non-text line attributes 00451 // BODGE - should use ALLOC_WITH_FAIL 00452 NodeGroup* pLineNodeGroup=NULL; 00453 if (pBecomeA->GetReason()!=BECOMEA_PASSBACK) 00454 { 00455 pLineNodeGroup=new NodeGroup; 00456 if (pLineNodeGroup==NULL) 00457 goto Fail; 00458 } 00459 00460 pNode=FindFirstChild(); 00461 while (pNode!=NULL) 00462 { 00463 if (pNode->IsAnAttribute()) 00464 { 00465 pNode->Render(pFormatRegion); // render attributes 00466 if (pBecomeA->GetReason()!=BECOMEA_PASSBACK) 00467 if (!pNode->IsKindOfTextAttribute()) 00468 if (pNode->CopyNode(pLineNodeGroup, LASTCHILD)==FALSE) 00469 goto Fail; 00470 } 00471 pNode=pNode->FindNext(); 00472 } 00473 00474 // For each child TextChar convert it to a NodePath 00475 // then EITHER pass it back OR attach it to the line group with non-text char attributes 00476 pTextChar=(TextChar*)FindFirstChild(CC_RUNTIME_CLASS(TextChar)); 00477 while (pTextChar) 00478 { 00479 pFormatRegion->SaveContext(); 00480 pTextChar->RenderChildAttrs(pFormatRegion); 00481 NodePath* pCharNodePath=NULL; 00482 if (pTextChar->CreateNodePath(&pCharNodePath,pFormatRegion)==FALSE) 00483 goto Fail; 00484 if (pCharNodePath) 00485 { 00486 if (pBecomeA->GetReason()==BECOMEA_PASSBACK) 00487 { 00488 if (pBecomeA->PassBack(pCharNodePath,pTextChar)==FALSE) 00489 goto Fail; 00490 } 00491 else 00492 { 00493 pCharNodePath->AttachNode(pLineNodeGroup,LASTCHILD); 00494 Node* pNode=pTextChar->FindFirstChild(); 00495 while (pNode) 00496 { 00497 if (pNode->IsAnAttribute() && !pNode->IsKindOfTextAttribute()) 00498 if (pNode->CopyNode(pCharNodePath, LASTCHILD)==FALSE) 00499 goto Fail; 00500 pNode=pNode->FindNext(); 00501 } 00502 00503 pBecomeA->PassBack(pCharNodePath, pTextChar); 00504 } 00505 } 00506 pFormatRegion->RestoreContext(); 00507 pTextChar=(TextChar*)(pTextChar->FindNext(CC_RUNTIME_CLASS(TextChar))); 00508 } 00509 00510 *ppNodeGroup=pLineNodeGroup; 00511 pFormatRegion->RestoreContext(); 00512 return TRUE; 00513 00514 Fail: 00515 if (pLineNodeGroup) 00516 { 00517 pLineNodeGroup->CascadeDelete(); 00518 delete pLineNodeGroup; 00519 } 00520 pFormatRegion->RestoreContext(); 00521 #endif 00522 return FALSE; 00523 }
|
|
Gives a description of the TextLine node for the status line etc.
Reimplemented from Node. Definition at line 569 of file nodetxtl.cpp. 00570 { 00571 if (Plural) 00572 return(String(_R(IDS_DESCRIBE_TEXTLINEP))); 00573 else 00574 return(String(_R(IDS_DESCRIBE_TEXTLINES))); 00575 }
|
|
Ensure the next line of a paragraph has the same line level attibutes.
Definition at line 891 of file nodetxtl.cpp. 00892 { 00893 TRACEUSER("wuerthne", _T("EnsureNextLineOfParagraphHasSameLineLevelAttrs")); 00894 00895 ERROR2IF(FindEOLNode()!=NULL,FALSE,"TextLine::EnsureNextOfParagraphLineHasSameLineLevelAttrs() - there is no next line in the paragraph!"); 00896 TextStory* pStory = this->FindParentStory(); 00897 ERROR2IF(pStory==NULL,FALSE,"TextLine::EnsureNextOfParagraphLineHasSameLineLevelAttrs() - line has no parent story!"); 00898 TextLine* pNextLine = this->FindNextLine(); 00899 ERROR2IF(pNextLine==NULL,FALSE,"TextLine::EnsureNextOfParagraphLineHasSameLineLevelAttrs() - last line of story has no EOL!"); 00900 00901 // flag story not localised, and get the set of line level attrs to localise 00902 BOOL StoryLocalised = FALSE; 00903 AttrTypeSet LLASet; 00904 BOOL ok = this->AddChildLineLevelAttrsToSet(&LLASet); 00905 if (ok) ok = pNextLine->AddChildLineLevelAttrsToSet(&LLASet); 00906 if (!ok) return FALSE; 00907 00908 // hide any Line Level Attributes found on the next line 00909 // which are different to those on this line or do not exist on this line 00910 Node* pNextLineNode = pNextLine->FindFirstChild(); 00911 while (pNextLineNode!=NULL) 00912 { 00913 if (pNextLineNode->IsAnAttribute() && ((NodeAttribute*)pNextLineNode)->IsALineLevelAttrib()) 00914 { 00915 NodeAttribute* pNextLineLLA = (NodeAttribute*)pNextLineNode; 00916 NodeAttribute* pThisLineLLA = (NodeAttribute*)(this->FindFirstChild(pNextLineLLA->GetAttributeType())); 00917 if (pThisLineLLA==NULL || !((*pNextLineLLA)==(*pThisLineLLA)) ) 00918 { 00919 if (!StoryLocalised) 00920 if (!pStory->DoLocaliseCommonAttributes(pUndoOp,FALSE,TRUE,&LLASet)) 00921 return FALSE; 00922 StoryLocalised = TRUE; 00923 if (pUndoOp!=NULL) 00924 { 00925 if (!pUndoOp->DoHideNode(pNextLineLLA,FALSE)) 00926 return FALSE; 00927 } 00928 else 00929 { 00930 pNextLineLLA->CascadeDelete(); 00931 delete pNextLineLLA; 00932 } 00933 } 00934 } 00935 pNextLineNode = pNextLineNode->FindNext(); 00936 } 00937 00938 // hide any Line Level Attributes on next line which are different to those found on this line 00939 // then copy any Line Level Attributes from this line to the next 00940 // which don't exist (or have just been hiden) on the next line 00941 Node* pThisLineNode = this->FindFirstChild(); 00942 while (pThisLineNode!=NULL) 00943 { 00944 if (pThisLineNode->IsAnAttribute() && ((NodeAttribute*)pThisLineNode)->IsALineLevelAttrib()) 00945 { 00946 NodeAttribute* pThisLineLLA = (NodeAttribute*)pThisLineNode; 00947 NodeAttribute* pNextLineLLA = (NodeAttribute*)(pNextLine->FindFirstChild(pThisLineLLA->GetAttributeType())); 00948 00949 if (pNextLineLLA!=NULL && !((*pNextLineLLA)==(*pThisLineLLA)) ) 00950 { 00951 if (!StoryLocalised) 00952 if (!pStory->DoLocaliseCommonAttributes(pUndoOp,FALSE,TRUE,&LLASet)) 00953 return FALSE; 00954 StoryLocalised = TRUE; 00955 if (pUndoOp!=NULL) 00956 { 00957 if (!pUndoOp->DoHideNode(pNextLineLLA,FALSE)) 00958 return FALSE; 00959 } 00960 else 00961 { 00962 pNextLineLLA->CascadeDelete(); 00963 delete pNextLineLLA; 00964 } 00965 pNextLineLLA = NULL; // flag its been hidden 00966 } 00967 00968 if (pNextLineLLA==NULL) 00969 { 00970 if (!StoryLocalised) 00971 if (!pStory->DoLocaliseCommonAttributes(pUndoOp,FALSE,TRUE,&LLASet)) 00972 return FALSE; 00973 StoryLocalised = TRUE; 00974 TRACEUSER("wuerthne", _T("calling SimpleCopy for att %d %d"), IS_A(pThisLineLLA, AttrTxtLineSpace), IS_A(pThisLineLLA, AttrTxtRuler)); 00975 NodeAttribute* pNewLLA = (NodeAttribute*)pThisLineLLA->SimpleCopy(); 00976 TRACEUSER("wuerthne", _T("node copied %d %d"), IS_A(pNewLLA, AttrTxtLineSpace), IS_A(pNewLLA, AttrTxtRuler)); 00977 if (pNewLLA==NULL) 00978 return FALSE; 00979 pNewLLA->AttachNode(pNextLine,FIRSTCHILD,TRUE,FALSE); 00980 if (pUndoOp!=NULL) 00981 { 00982 Action* UndoHideAttrAction; 00983 if (HideNodeAction::Init(pUndoOp,pUndoOp->GetUndoActionList(),pNewLLA,TRUE,&UndoHideAttrAction)==AC_FAIL) 00984 return FALSE; 00985 } 00986 } 00987 } 00988 pThisLineNode = pThisLineNode->FindNext(); 00989 } 00990 00991 // if attrs localised on next line, factor out (globally) and flag line affected 00992 if (StoryLocalised) 00993 { 00994 if (!pStory->DoFactorOutCommonChildAttributes(pUndoOp,TRUE,&LLASet)) 00995 return FALSE; 00996 pNextLine->FlagNodeAndDescendantsModifiedByOpAndParentsHaveDescendantModifiedByOp(); 00997 } 00998 00999 return TRUE; 01000 }
|
|
Find words to fit given width, absorbing spaces, optionally formats line.
Definition at line 1236 of file nodetxtl.cpp. 01239 { 01240 // This routine does not just find the break char (SetCharPositions = FALSE), it 01241 // also formats lines by setting the character positions (SetCharPositions = TRUE). 01242 // With the introduction of Tabs, formatting has become more complex, so it makes 01243 // a lot of sense to have 01244 // depending on whether 01245 // Finding the break char is straightforward when no tabs are involved. 01246 // You just add up the widths and remember the last space character and 01247 // return that when the available width has been exceeded. 01248 // 01249 // With tabs, things become a bit more complex. Left tabs are easy: A left tab 01250 // is treated like a character with the width of the remaining space up to the 01251 // tab stop. When dealing with centre or right tabs we need to remember how much 01252 // space we had left to the left of the tab stop. Half (for centre tabs) or all 01253 // (for right tabs) of the width of all subsequent text goes to the left until 01254 // that space is filled up, all remaining space goes to the right only. 01255 // Decimal tabs behave like centre tabs except that distributing half the width 01256 // to the left stops as soon as the decimal point has been seen. 01257 // 01258 // The formatting algorithm below divides the line into sections delimited by 01259 // tabs or end of line. When a section is finished (i.e., when seeing a tab or 01260 // end of line), then the complete section is formatted (using FinishTabSection()). 01261 01262 TRACEUSER("wuerthne", _T("FindBreakChar, SetCharPositions = %d"), SetCharPositions); 01263 VisibleTextNode* pBreakChar = NULL; 01264 BOOL CharOnLine = FALSE; 01265 VisibleTextNode* pPrevVTN = NULL; 01266 VisibleTextNode* pVTN = this->FindFirstVTN(); 01267 01268 // create a FormatState object that takes care of the formatting 01269 FormatState State(FitWidth, SetCharPositions, pVTN, Indent, CharPosOffset, ExtraOnChars, ExtraOnSpaces); 01270 01271 while(pVTN!=NULL) 01272 { 01273 BOOL IsATab = IS_A(pVTN, HorizontalTab); 01274 BOOL IsADecimalPoint = FALSE; 01275 if (State.ActiveTabType == DecimalTab && pVTN->IsATextChar()) 01276 { 01277 // if the currently active tab is a decimal tab check whether we have hit a decimal point 01278 // NB. - the decimal point character is stored in the tab stop 01279 IsADecimalPoint = (((TextChar*)pVTN)->GetUnicodeValue() == State.DecimalPointChar); 01280 } 01281 if (IsATab) 01282 { 01283 TxtTabType ThisTabType; 01284 MILLIPOINT ThisTabPos; 01285 MILLIPOINT TabWidth; 01286 01287 // finish the previous tab 01288 State.FinishTabSection(pVTN, FALSE); 01289 01290 // find the next tab stop (always returns usable values - if there are no more 01291 // tab stops on the ruler the routine assumes left tabs at equidistant positions) 01292 WCHAR DecimalPointChar; 01293 TxtRulerAttribute::FindTabStopInRuler(mpRuler, State.Width, &ThisTabType, &ThisTabPos, 01294 &DecimalPointChar); 01295 TabWidth = ThisTabPos - State.Width; 01296 ((HorizontalTab*)pVTN)->SetCharAdvance(TabWidth); 01297 ((HorizontalTab*)pVTN)->SetCharWidth(TabWidth); 01298 State.AnchorPos = State.Width; 01299 if (ThisTabType != LeftTab) 01300 { 01301 // Space between the tab character and the stop it aligns to 01302 State.RemainingSpace = TabWidth; 01303 } 01304 if (ThisTabType == DecimalTab) 01305 { 01306 State.DecimalPointChar = DecimalPointChar; 01307 State.DecimalPointFound = FALSE; 01308 } 01309 State.pLastTabVTN = pVTN; 01310 State.ActiveTabType = ThisTabType; 01311 State.ActiveTabPos = ThisTabPos; 01312 // we allow line breaks at tabs 01313 pBreakChar = pPrevVTN; 01314 } 01315 if (!pVTN->IsACaret()) 01316 { 01317 if (pVTN->IsAnEOLNode()) 01318 { 01319 State.FinishTabSection(pVTN, TRUE); 01320 return pVTN; 01321 } 01322 else if (pVTN->IsASpace()) 01323 { 01324 State.AdvanceBy(pVTN->GetCharAdvance(), IsADecimalPoint); 01325 pBreakChar = pVTN; 01326 } 01327 else if (!CharOnLine || State.IsAvailable(pVTN->GetCharWidth(), IsATab, IsADecimalPoint)) 01328 { 01329 if (IsATab) State.Width += pVTN->GetCharAdvance(); 01330 else State.AdvanceBy(pVTN->GetCharAdvance(), IsADecimalPoint); 01331 if (pVTN->IsAHyphen()) 01332 pBreakChar = pVTN; 01333 if (State.ActiveTabType == DecimalTab && !State.DecimalPointFound && IsADecimalPoint) 01334 State.DecimalPointFound = TRUE; 01335 } 01336 else 01337 { 01338 // did not fit 01339 if (pBreakChar==NULL) 01340 pBreakChar = pPrevVTN; 01341 if (pBreakChar) State.FinishTabSection(pBreakChar, TRUE); 01342 return pBreakChar; 01343 } 01344 CharOnLine = TRUE; 01345 } 01346 pPrevVTN = pVTN; 01347 if (SetCharPositions) 01348 { 01349 // formatting run - we stay within our line and finish when we run past the end 01350 pVTN = pVTN->FindNextVTNInLine(); 01351 if (!pVTN) 01352 { 01353 State.FinishTabSection(pPrevVTN, TRUE); 01354 return NULL; 01355 } 01356 } 01357 else 01358 { 01359 pVTN = pVTN->FindNextVTNInStory(); 01360 } 01361 } 01362 ERROR2(FALSE,"FindBreakChar() - story has no final EOL!"); 01363 }
|
|
Definition at line 1818 of file nodetxtl.cpp. 01819 { 01820 return (CaretNode*)FindFirstChild(CC_RUNTIME_CLASS(CaretNode)); 01821 }
|
|
Call this function to get the character at a certian distance along this TextLine. If the distance is off the right end of the line then a pointer to the EOLNode is returned.
Definition at line 1771 of file nodetxtl.cpp. 01772 { 01773 ERROR2IF(LeftHandSide==NULL,NULL,"TextLine::FindCharAtDistAlongLine() - NULL side pointer"); 01774 01775 VisibleTextNode* pVTN = FindFirstVTN(); 01776 ERROR2IF(pVTN==NULL,NULL,"TextLine::FindCharAtDistAlongLine() - has no VTN"); 01777 while (1) 01778 { 01779 const MILLIPOINT Left = pVTN->GetPosInLine(); 01780 const MILLIPOINT Centre = Left+pVTN->GetCharWidth()/2; 01781 const MILLIPOINT Next = Left+pVTN->GetCharAdvance(); 01782 01783 // if to left of centre of this char (and to right of previous if any) 01784 // or at end of line, return char and 'to left' 01785 if (Distance<=Centre || pVTN->IsAnEOLNode()) 01786 { 01787 *LeftHandSide = TRUE; 01788 return pVTN; 01789 } 01790 01791 // if to left of next char (and right of centre of this char), 01792 // return char and 'to right' 01793 if (Distance<=Next) 01794 { 01795 *LeftHandSide = FALSE; 01796 return pVTN; 01797 } 01798 01799 // if no next VTN, return this char and 'to right' 01800 VisibleTextNode* pNextVTN = pVTN->FindNextVTNInLine(); 01801 if (pNextVTN==NULL) 01802 { 01803 *LeftHandSide = FALSE; 01804 return pVTN; 01805 } 01806 pVTN = pNextVTN; 01807 } 01808 }
|
|
Definition at line 1912 of file nodetxtl.cpp. 01913 { 01914 EOLNode* pEOL = (EOLNode*)FindFirstChild(CC_RUNTIME_CLASS(EOLNode)); 01915 ERROR3IF(pEOL!=NULL && pEOL->FindNext(CC_RUNTIME_CLASS(EOLNode))!=NULL, 01916 "TextLine::FindEOLNode() - more than one EOLNode on a line!"); 01917 return pEOL; 01918 }
|
|
Definition at line 1012 of file nodetxtl.cpp. 01013 { 01014 TextLine* pLine = this; 01015 while (1) 01016 { 01017 TextLine* pPrevLine = pLine->FindPrevLine(); 01018 if (pPrevLine==NULL || pPrevLine->FindEOLNode()!=NULL) 01019 break; 01020 pLine = pPrevLine; 01021 } 01022 return pLine; 01023 }
|
|
For getting a pointer to the first Visible Text Node in this TextLine.
Definition at line 1885 of file nodetxtl.cpp. 01886 { 01887 return (VisibleTextNode*)FindFirstChild(CC_RUNTIME_CLASS(VisibleTextNode)); 01888 }
|
|
For getting a pointer to the last Visible Text Node in this TextLine.
Definition at line 1899 of file nodetxtl.cpp. 01900 { 01901 return (VisibleTextNode*)FindLastChild(CC_RUNTIME_CLASS(VisibleTextNode)); 01902 }
|
|
Definition at line 1858 of file nodetxtl.cpp. 01859 { 01860 return (TextLine*)FindNext(CC_RUNTIME_CLASS(TextLine)); 01861 }
|
|
Definition at line 1871 of file nodetxtl.cpp. 01872 { 01873 return (TextLine*)FindPrevious(CC_RUNTIME_CLASS(TextLine)); 01874 }
|
|
set matrices in all VTN on a line so as to fit text to the path, accounting for any transform which was applied before the text was fitted to the path
Definition at line 1686 of file nodetxtl.cpp. 01687 { 01688 ERROR2IF(pStoryInfo==NULL,FALSE,"TextLine::FitTextToPath() - pStoryInfo==NULL"); 01689 TextStory* pTextStory = FindParentStory(); 01690 ERROR2IF(pTextStory==NULL,FALSE,"TextLine::FitTextToPath() - pTextStory==NULL"); 01691 01692 // get values required to account for transforms applied to text before it was fitted to the path 01693 FIXED16 scale = pTextStory->GetCharsScale(); 01694 FIXED16 xscale = (scale<0 ? -scale : scale) * pTextStory->GetCharsAspect(); 01695 FIXED16 shear = scale * tan(pTextStory->GetCharsShear().MakeDouble()); 01696 // double rotation = pTextStory->GetCharsRotation().MakeDouble(); 01697 01698 // scale the line width offset 01699 LinePos = XLONG(LinePos) * scale; 01700 MILLIPOINT LinePosX = (MILLIPOINT)(LinePos * pStoryInfo->UnitDirectionVectorX + 0.5); 01701 MILLIPOINT LinePosY = (MILLIPOINT)(LinePos * pStoryInfo->UnitDirectionVectorY + 0.5); 01702 01703 // if chars tangential, get a pointer to a double to read the angle into 01704 // else set the angle to 0 and make the pointer NULL (ie don't actually ask for the angle) 01705 double TangentAtDist=0; 01706 double* pTangentAtDist=NULL; 01707 if (pTextStory->IsTextOnPathTangential()) 01708 pTangentAtDist=&TangentAtDist; 01709 01710 // some vars used repeatedly while scanning line ... 01711 BOOL Found=FALSE; 01712 DocCoord CoordAtDist(0,0); 01713 Matrix VTNMatrix(0,0); 01714 ProcessPathDistance PathDistanceProcess(64); 01715 01716 Node* pNode=FindFirstChild(); 01717 while (pNode) 01718 { 01719 if (pNode->IsAVisibleTextNode()) 01720 { 01721 VisibleTextNode* pVTN=(VisibleTextNode*)pNode; 01722 if (pVTN->Affected()) 01723 { 01724 // get distance to centre of char accounting for pre-transform 01725 MILLIPOINT CharWidthBy2 = XLONG(pVTN->GetCharWidth()/2) * xscale; 01726 MILLIPOINT Dist=XLONG(pVTN->GetPosInLine()) * xscale + CharWidthBy2; 01727 01728 if (pStoryInfo->PathClosed) 01729 { 01730 Dist = Dist % pStoryInfo->PathLength; 01731 if (Dist<0) 01732 Dist += pStoryInfo->PathLength; 01733 } 01734 01735 // and thence the coord (and tangent) this distance along the path 01736 if (PathDistanceProcess.GetCoordAndTangent(&CoordAtDist,pTangentAtDist,&Found,Dist,pStoryInfo->pPath)==FALSE) 01737 return FALSE; 01738 01739 // set the char matrix to account for pre-transform and baseline shift, 01740 VTNMatrix=Matrix( xscale, 0, shear, scale, 0, XLONG(pVTN->GetBaseLineShift()) * scale ); 01741 // then rotate appropriately, 01742 // VTNMatrix*=Matrix(DocCoord(CharWidthBy2,0),(TangentAtDist+rotation)/PI*180); 01743 VTNMatrix*=Matrix(DocCoord(CharWidthBy2,0),TangentAtDist/PI*180); 01744 // then translate to the correct point on the path and account for line spacing 01745 VTNMatrix.translate(CoordAtDist.x-CharWidthBy2+LinePosX,CoordAtDist.y+LinePosY); 01746 pVTN->SetMatrix(VTNMatrix); 01747 } 01748 } 01749 pNode=pNode->FindNext(); 01750 } 01751 01752 return TRUE; 01753 }
|
|
perform line level formatting Note: on entry pStoryInfo->DescentLine hold the DescentLine of the last line (pStoryInfo->DescentLineValid indicating if there was none (eg first line) and on exit, it holds the DescentLine for this line and DescentLineValid is TRUE
Definition at line 810 of file nodetxtl.cpp. 00811 { 00812 ERROR2IF(pStoryInfo==NULL,FALSE,"TextLine::Format() - pStoryInfo == NULL"); 00813 00814 TRACEUSER("wuerthne", _T("TextLine::Format")); 00815 MILLIPOINT PhysicalLeftMargin = pStoryInfo->LeftPathIndent; // 0 if not on path 00816 MILLIPOINT PhysicalRightMargin = pStoryInfo->StoryWidth - pStoryInfo->RightPathIndent; 00817 BOOL WordWrapping = pStoryInfo->WordWrapping; 00818 MILLIPOINT RightMargin = PhysicalRightMargin - mRightMargin; 00819 MILLIPOINT LeftIndent = GetEffectiveLeftMargin(); 00820 00821 // if word wrapping, and not text at a point, and undoably 'do'ing op, word wrap the line 00822 MILLIPOINT WrapWidth = 0; 00823 if (WordWrapping) 00824 WrapWidth = RightMargin - PhysicalLeftMargin; // will be 0 if text at a point 00825 if (WrapWidth!=0 && pStoryInfo->WordWrap) 00826 { 00827 if (!this->Wrap(pStoryInfo->pUndoOp, WrapWidth, LeftIndent)) 00828 return FALSE; 00829 } 00830 else if (WrapWidth != 0) 00831 { 00832 // when called during undo (i.e., WordWrap = FALSE) and the story is word wrapping, 00833 // we do not want to wrap, but we still need to make sure that each tab gets its width 00834 // set correctly, otherwise PositionCharsInLine will not do the right thing 00835 FindBreakChar(WrapWidth, FALSE, LeftIndent); 00836 } 00837 00838 // if line affected in any way, reposition chars in line 00839 if (NodeOrDescendantAffected()) 00840 { 00841 TextLineInfo LineInfo; 00842 if (ReCalcLineInfo(&LineInfo)==FALSE) 00843 return FALSE; 00844 00845 LineInfo.LeftMargin = PhysicalLeftMargin; 00846 LineInfo.RightMargin = PhysicalRightMargin; 00847 LineInfo.WordWrapping = WordWrapping; 00848 if (PositionCharsInLine(&LineInfo)==FALSE) 00849 return FALSE; 00850 } 00851 00852 // calculate this line's BaseLine, and keep the DescentLine up to date 00853 MILLIPOINT BaseLine = 0; 00854 MILLIPOINT DescentLine = 0; 00855 if (CalcBaseAndDescentLine(&BaseLine,&DescentLine,pStoryInfo->DescentLine,pStoryInfo->DescentLineValid)==FALSE) 00856 return FALSE; 00857 pStoryInfo->DescentLine = DescentLine; 00858 pStoryInfo->DescentLineValid = TRUE; 00859 00860 // if the line has moved, set its' new position and flag it is 'affected' 00861 if (BaseLine!=GetPosInStory()) 00862 { 00863 SetPosInStory(BaseLine); 00864 FlagNodeAndDescendantsAffectedAndParentsHaveDescendantAffected(); 00865 } 00866 00867 // if line or descendent 'Affected' recalc matrices for affected children 00868 BOOL ok=TRUE; 00869 if (NodeOrDescendantAffected()) 00870 { 00871 if (pStoryInfo->pPath==NULL) 00872 ok = SetCharMatrices(GetPosInStory()); 00873 else 00874 ok = FitTextToPath(pStoryInfo,GetPosInStory()); 00875 } 00876 00877 return ok; 00878 }
|
|
This function returns the blob bounding rectangle of this TextLine. There is a tiny blob on the top left of the first character on the line. void TextLine::GetBlobBoundingRect()
Reimplemented from NodeRenderable. Definition at line 588 of file nodetxtl.cpp. 00589 { 00590 #if !defined(EXCLUDE_FROM_RALPH) 00591 DocCoord BlobPos=GetTinyBlobPos(); 00592 DocRect BlobBounds; 00593 BlobManager* pBlobMgr=GetApplication()->GetBlobManager(); 00594 if (pBlobMgr) 00595 pBlobMgr->GetBlobRect(BlobPos,&BlobBounds); 00596 else 00597 ERROR3("TextLine::GetBlobBoundingRect() - Couldn't find the BlobManager"); 00598 00599 IncludeChildrensBoundingRects(&BlobBounds); 00600 00601 return BlobBounds; 00602 #else 00603 return DocRect(0,0,0,0); 00604 #endif 00605 }
|
|
This function returns a type describing how this object is to be copied. The fuction is called from the low level copy operation CopyObjects. There are two options at present, these being SIMPLECOPY and COMPLEXCOPY. SIMPLECOPY indicates that the node can be copied by a call to its virtual function SimpleCopy(). COMPLEXCOPY however indicates that the node needs to do its own thing when copying and must be called via the ComplexCopy() virtual function. This virtual will likely return a tree of copied objects rather than just a copy of itself.
Reimplemented from Node. Definition at line 259 of file nodetxtl.cpp. 00260 { 00261 return COMPLEXCOPY; 00262 }
|
|
For obtaining debug information about the Node. This fn can be deleted before we ship.
Reimplemented from NodeRenderableBounded. Definition at line 712 of file nodetxtl.cpp. 00713 { 00714 NodeRenderableBounded::GetDebugDetails(Str); 00715 }
|
|
Select the left margin or first indent value depending on whether this is the first line in the paragraph.
Definition at line 780 of file nodetxtl.cpp. 00781 { 00782 // we need to find out whether this is the first line in the paragraph, so we know 00783 // whether we need to use FirstLineIndent or LeftMargin 00784 00785 TextLine* pPrevLine = FindPrevLine(); 00786 if (pPrevLine==NULL || pPrevLine->FindEOLNode() != NULL) 00787 { 00788 // first line in paragraph 00789 return mFirstIndent; 00790 } 00791 else 00792 { 00793 return mLeftMargin; 00794 } 00795 }
|
|
Definition at line 370 of file nodetxtl.h. 00370 { return mJustification; }
|
|
Definition at line 1929 of file nodetxtl.cpp. 01930 { 01931 AbstractTextChar* pATC = (AbstractTextChar*)FindFirstChild(CC_RUNTIME_CLASS(AbstractTextChar)); 01932 if (pATC->IsAnEOLNode()) 01933 pATC = (AbstractTextChar*)(pATC->FindPrevious(CC_RUNTIME_CLASS(AbstractTextChar))); 01934 01935 if (pATC==NULL) 01936 return 0; 01937 01938 return pATC->GetCharAdvance() - pATC->GetCharWidth(); 01939 }
|
|
Definition at line 361 of file nodetxtl.h. 00361 { return mLineAscent; }
|
|
Definition at line 360 of file nodetxtl.h. 00360 { return mLineDescent; }
|
|
Definition at line 362 of file nodetxtl.h. 00362 { return mLineSize; }
|
|
Definition at line 372 of file nodetxtl.h. 00372 { return mLineSpaceRatio; }
|
|
Definition at line 371 of file nodetxtl.h. 00371 { return mLineSpacing; }
|
|
For finding the size of the node.
Reimplemented from Node. Definition at line 696 of file nodetxtl.cpp. 00697 { 00698 return (sizeof(TextLine)); 00699 }
|
|
Definition at line 374 of file nodetxtl.h. 00374 { return mFirstIndent; }
|
|
Definition at line 373 of file nodetxtl.h. 00373 { return mLeftMargin; }
|
|
Definition at line 375 of file nodetxtl.h. 00375 { return mRightMargin; }
|
|
Definition at line 385 of file nodetxtl.h. 00385 { return mPosInStory; }
|
|
Definition at line 376 of file nodetxtl.h. 00376 { return mpRuler; }
|
|
This function returns the location of the tiny blob on this TextLine. It is either on the top-left of the first character on the line, or if there isn't a char, on the top-left of the line bounding rect. DocCoord TextLine::GetTinyBlobPos()
Definition at line 619 of file nodetxtl.cpp. 00620 { 00621 #if !defined(EXCLUDE_FROM_RALPH) 00622 // set a fall back position - the top left of the line bounds 00623 DocRect TempRect=GetBoundingRect(); 00624 DocCoord BlobPos=DocCoord(TempRect.lo.x,TempRect.hi.y); 00625 00626 // but really we want the top left of the first char's metrics rect 00627 AbstractTextChar* pFirstChar=(AbstractTextChar*)FindFirstChild(CC_RUNTIME_CLASS(AbstractTextChar)); 00628 if (pFirstChar) 00629 { 00630 if (pFirstChar->GetMetricsRect(&TempRect)) 00631 { 00632 BlobPos=DocCoord(TempRect.lo.x,TempRect.hi.y); 00633 Matrix matrix; 00634 if (pFirstChar->GetStoryAndCharMatrix(&matrix)) 00635 matrix.transform(&BlobPos); 00636 else 00637 ERROR3("TextLine::GetTinyBlobPos() - GetStoryAndCharMatrix() failed"); 00638 } 00639 else 00640 ERROR3("TextLine::GetTinyBlobPos() - GetMetricsRect() failed"); 00641 } 00642 00643 return BlobPos; 00644 #else 00645 return DocCoord(0,0); 00646 #endif 00647 }
|
|
common init function for constructors
Reimplemented from BaseTextClass. Definition at line 172 of file nodetxtl.cpp. 00173 { 00174 mLineAscent = 0; 00175 mLineDescent = 0; 00176 mLineSize = 0; 00177 00178 mJustification = JLEFT; 00179 mLineSpacing = 0; 00180 mLineSpaceRatio = 1; 00181 mpRuler = new TxtRuler; 00182 00183 mPosInStory = 0; 00184 }
|
|
Definition at line 1035 of file nodetxtl.cpp. 01036 { 01037 return pAttrType==CC_RUNTIME_CLASS(AttrTxtJustification) 01038 || pAttrType==CC_RUNTIME_CLASS(AttrTxtLineSpace) 01039 || pAttrType==CC_RUNTIME_CLASS(AttrTxtLeftMargin) 01040 || pAttrType==CC_RUNTIME_CLASS(AttrTxtRightMargin) 01041 || pAttrType==CC_RUNTIME_CLASS(AttrTxtFirstIndent) 01042 || pAttrType==CC_RUNTIME_CLASS(AttrTxtRuler); 01043 }
|
|
Reimplemented from Node. Definition at line 306 of file nodetxtl.h. 00306 { return TRUE; } // See also NodeCompound
|
|
Indicates that NodeRenderableInks are candidates for membership of Attribute gallery set.
Reimplemented from BaseTextClass. Definition at line 305 of file nodetxtl.h. 00305 { return TRUE; }
|
|
Polymorphically copies the contents of this node to another.
Reimplemented from BaseTextClass. Definition at line 413 of file nodetxtl.cpp. 00414 { 00415 ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node"); 00416 ENSURE(IS_A(pNodeCopy, TextLine), "PolyCopyNodeContents given wrong dest node type"); 00417 00418 if (IS_A(pNodeCopy, TextLine)) 00419 CopyNodeContents((TextLine*)pNodeCopy); 00420 }
|
|
set the position of each char on the line accounting for justification ALSO, flag any chars that have moved as 'affected'
Definition at line 1511 of file nodetxtl.cpp. 01512 { 01513 ERROR2IF(pLineInfo==NULL,FALSE,"TextLine::PositionCharsInLine() - pLineInfo==NULL"); 01514 // we have two different left/right margins: margin properties of the complete story 01515 // (only for text on path) and margins applied as attributes to paragraphs 01516 MILLIPOINT PhysicalLeftMargin = pLineInfo->LeftMargin; // story property 01517 MILLIPOINT ParagraphLeftMargin = pLineInfo->ParaLeftMargin; // paragraph attribute 01518 MILLIPOINT LeftMargin = PhysicalLeftMargin + ParagraphLeftMargin; 01519 01520 MILLIPOINT PhysicalRightMargin = pLineInfo->RightMargin; 01521 MILLIPOINT ParagraphRightMargin = pLineInfo->ParaRightMargin; 01522 MILLIPOINT RightMargin = PhysicalRightMargin - ParagraphRightMargin; 01523 01524 MILLIPOINT SumCharAdvances = pLineInfo->SumCharAdvances; 01525 BOOL WordWrapping = pLineInfo->WordWrapping; 01526 MILLIPOINT JustifyWidth = RightMargin - LeftMargin; 01527 01528 TRACEUSER("wuerthne", _T("PositionCharsInLine, Sum=%d, JWidth=%d"), SumCharAdvances, JustifyWidth); 01529 01530 // if word wrapping, fully justified, text does not fill line and end of paragraph 01531 // left justified 01532 Justification justification = pLineInfo->justification; 01533 if (WordWrapping && justification==JFULL && SumCharAdvances < JustifyWidth && FindEOLNode()!=NULL) 01534 justification = JLEFT; 01535 01536 // calc amount by which chars need to be adjusted (default to left justify) 01537 MILLIPOINT CharPosOffset = PhysicalLeftMargin; 01538 MILLIPOINT ExtraOnSpaces = 0; 01539 MILLIPOINT ExtraOnChars = 0; 01540 switch (justification) 01541 { 01542 // for both right and centre justification we subtract ParagraphLeftMargin because this 01543 // will be added in again later 01544 case JRIGHT: 01545 CharPosOffset = RightMargin - SumCharAdvances - ParagraphLeftMargin; 01546 break; 01547 case JCENTRE: 01548 CharPosOffset = (LeftMargin + RightMargin - SumCharAdvances)/2 - ParagraphLeftMargin; 01549 break; 01550 case JFULL: 01551 if (JustifyWidth!=0) 01552 { 01553 // if text does not fill line, expand spaces so it does, 01554 // but if no spaces, and word wrapping, increase inter-char spacing so word fills line 01555 // if text overflows line, reduce inter-char spacing so words fit line 01556 INT32 gap = JustifyWidth - SumCharAdvances; 01557 INT32 NumChars = pLineInfo->NumChars; 01558 INT32 NumSpaces = pLineInfo->NumSpaces; 01559 if (gap>0) 01560 { 01561 if (NumSpaces>0) 01562 ExtraOnSpaces = gap/NumSpaces; 01563 else 01564 if (WordWrapping && NumChars>1) 01565 ExtraOnChars = gap/(NumChars-1); 01566 } 01567 else 01568 if (pLineInfo->NumChars>1) 01569 ExtraOnChars = gap/(NumChars-1); 01570 } 01571 break; 01572 default: 01573 break; 01574 } 01575 01576 // run through line setting all char's 'PosInLine' (flagging those which moved) 01577 TRACEUSER("wuerthne", _T("calling FindBreakChar, Indent=%d, Offset=%d, ExtraC=%d, ExtraS=%d"), 01578 ParagraphLeftMargin, CharPosOffset, ExtraOnChars, ExtraOnSpaces); 01579 FindBreakChar(INT32_MAX, TRUE, ParagraphLeftMargin, CharPosOffset, ExtraOnChars, ExtraOnSpaces); 01580 return TRUE; 01581 }
|
|
Recache metrics in text line.
Reimplemented from BaseTextClass. Definition at line 728 of file nodetxtl.cpp. 00729 { 00730 TRACEUSER("wuerthne", _T("TextLine::ReCacheMetrics")); 00731 SetJustification( pFormatRegion->GetJustification()); 00732 SetLineSpacing( pFormatRegion->GetLineSpacing()); 00733 SetLineSpaceRatio(pFormatRegion->GetLineSpaceRatio()); 00734 00735 SetParaLeftMargin(pFormatRegion->GetLeftMargin()); 00736 SetParaFirstIndent(pFormatRegion->GetFirstIndent()); 00737 SetParaRightMargin(pFormatRegion->GetRightMargin()); 00738 SetRuler(pFormatRegion->GetRuler()); 00739 #if defined(_DEBUG) && 0 00740 String_256 TempStr; 00741 String Str(_T(" ")); 00742 for (TxtTabStopIterator It = mpRuler->begin(); It != mpRuler->end(); ++It) 00743 { 00744 switch((*It).GetType()) 00745 { 00746 case LeftTab: 00747 TempStr._MakeMsg( TEXT("L(#1%ld)"), (*It).GetPosition()); 00748 Str += TempStr; 00749 break; 00750 case RightTab: 00751 TempStr._MakeMsg( TEXT("R(#1%ld)"), (*It).GetPosition()); 00752 Str += TempStr; 00753 break; 00754 case CentreTab: 00755 TempStr._MakeMsg( TEXT("C(#1%ld)"), (*It).GetPosition()); 00756 Str += TempStr; 00757 break; 00758 case DecimalTab: 00759 TempStr._MakeMsg( TEXT("D(#1%ld)"), (*It).GetPosition()); 00760 Str += TempStr; 00761 break; 00762 } 00763 } 00764 TRACEUSER("wuerthne", _T("ruler at %08x:%s"), mpRuler, (TCHAR*)Str); 00765 #endif 00766 return TRUE; 00767 }
|
|
Recalculate line level info (absorbing space at end of line) Note: Also updates line level info in node itself.
Definition at line 1426 of file nodetxtl.cpp. 01427 { 01428 ERROR2IF(pLineInfo==NULL,FALSE,"TextLine::ReCalcLineInfo() - pLineInfo==NULL"); 01429 01430 TRACEUSER("wuerthne", _T("RecalcLineInfo")); 01431 // reset info in node to be calculated 01432 SetLineAscent(0); 01433 SetLineDescent(0); 01434 SetLineSize(0); 01435 01436 // init local info to be calculated 01437 MILLIPOINT SumCharAdvances = 0; 01438 INT32 NumChars = 0; 01439 INT32 NumSpaces = 0; 01440 MILLIPOINT SumCharAdvancesToLastNonSpace = 0; 01441 INT32 NumCharsToLastNonSpace = 0; 01442 INT32 NumSpacesToLastNonSpace = 0; 01443 01444 // for each AbstractTextChar on line ... 01445 BOOL AbstractTextCharFound = FALSE; 01446 Node* pNode = FindFirstChild(); 01447 ERROR3IF(pNode==NULL,"TextLine::ReCalcLineInfo() - line has no children!"); 01448 while (pNode!=NULL) 01449 { 01450 if (pNode->IsAnAbstractTextChar()) 01451 { 01452 AbstractTextChar* pATC= (AbstractTextChar*)pNode; 01453 01454 // update info in TextLine (but only use EOL if no chars on line) 01455 if (!pATC->IsAnEOLNode() || !AbstractTextCharFound) 01456 { 01457 UpdateLineAscent( pATC->GetFontAscent()); 01458 UpdateLineDescent(pATC->GetFontDescent()); 01459 UpdateLineSize( pATC->GetFontSize()); 01460 } 01461 01462 // update local info 01463 if (IS_A(pATC,TextChar)) 01464 NumChars += 1; 01465 if (IS_A(pATC, HorizontalTab)) 01466 { 01467 // only spaces/chars after the last tab can be stretched for full justification 01468 TRACEUSER("wuerthne", _T("tab at %08x width=%d"), pATC, pATC->GetCharAdvance()); 01469 NumSpaces = 0; 01470 NumChars = 0; 01471 } 01472 if (pATC->IsASpace()) 01473 NumSpaces += 1; 01474 else if (!pATC->IsAnEOLNode()) 01475 { 01476 NumCharsToLastNonSpace = NumChars; 01477 NumSpacesToLastNonSpace = NumSpaces; 01478 SumCharAdvancesToLastNonSpace = SumCharAdvances + pATC->GetCharWidth(); // exc tracking of this char 01479 } 01480 SumCharAdvances += pATC->GetCharAdvance(); 01481 01482 AbstractTextCharFound = TRUE; 01483 } 01484 pNode = pNode->FindNext(); 01485 } 01486 ERROR2IF(!AbstractTextCharFound,FALSE,"TextLine::ReCalcLineInfo() - line has no AbstractTextChars"); 01487 01488 // set outputs 01489 pLineInfo->SumCharAdvances = SumCharAdvancesToLastNonSpace; 01490 pLineInfo->NumChars = NumCharsToLastNonSpace; 01491 pLineInfo->NumSpaces = NumSpacesToLastNonSpace; 01492 pLineInfo->justification = GetJustification(); 01493 pLineInfo->ParaLeftMargin = GetEffectiveLeftMargin(); 01494 pLineInfo->ParaRightMargin = GetParaRightMargin(); 01495 pLineInfo->Ruler = GetRuler(); 01496 return TRUE; 01497 }
|
|
Renders the TextLines object blobs. void TextLine::RenderObjectBlobs(RenderRegion* pRRegion)
Reimplemented from NodeRenderable. Definition at line 678 of file nodetxtl.cpp. 00679 { 00680 #if !defined(EXCLUDE_FROM_RALPH) 00681 RenderTinyBlobs(pRRegion); 00682 #endif 00683 }
|
|
Renders the TextLines tiny blobs. void TextLine::RenderTinyBlobs(RenderRegion* pRRegion)
Reimplemented from NodeRenderable. Definition at line 659 of file nodetxtl.cpp. 00660 { 00661 #if !defined(EXCLUDE_FROM_RALPH) 00662 pRRegion->SetLineColour(COLOUR_NONE); 00663 pRRegion->SetFillColour(COLOUR_UNSELECTEDBLOB); 00664 pRRegion->DrawBlob(GetTinyBlobPos(), BT_UNSELECTED); 00665 #endif 00666 }
|
|
set matrices in all VTN on a line
Definition at line 1657 of file nodetxtl.cpp. 01658 { 01659 Node* pNode=FindFirstChild(); 01660 while (pNode!=NULL) 01661 { 01662 if (pNode->IsAVisibleTextNode()) 01663 { 01664 VisibleTextNode* pVTN=(VisibleTextNode*)pNode; 01665 if (pVTN->Affected()) 01666 pVTN->SetMatrix( Matrix( pVTN->GetPosInLine(), LinePos+pVTN->GetBaseLineShift() ) ); 01667 } 01668 pNode=pNode->FindNext(); 01669 } 01670 return TRUE; 01671 }
|
|
Definition at line 377 of file nodetxtl.h. 00377 { mJustification = justification; }
|
|
Definition at line 364 of file nodetxtl.h. 00364 { mLineAscent = Ascent; }
|
|
Definition at line 363 of file nodetxtl.h. 00363 { mLineDescent = Descent; }
|
|
Definition at line 365 of file nodetxtl.h. 00365 { mLineSize = Size; }
|
|
Definition at line 379 of file nodetxtl.h. 00379 { mLineSpaceRatio = SpaceRatio; }
|
|
Definition at line 378 of file nodetxtl.h. 00378 { mLineSpacing = Spacing; }
|
|
Definition at line 381 of file nodetxtl.h. 00381 { mFirstIndent = Indent; }
|
|
Definition at line 380 of file nodetxtl.h. 00380 { mLeftMargin = Margin; }
|
|
Definition at line 382 of file nodetxtl.h. 00382 { mRightMargin = Margin; }
|
|
Definition at line 386 of file nodetxtl.h. 00386 { mPosInStory=pos; }
|
|
Definition at line 383 of file nodetxtl.h.
|
|
This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes of Node.
Reimplemented from BaseTextClass. Definition at line 277 of file nodetxtl.cpp. 00278 { 00279 // Make a new TextLine and then copy things into it 00280 TextLine* NodeCopy = new TextLine(); 00281 00282 ERROR1IF(NodeCopy == NULL, NULL, _R(IDE_NOMORE_MEMORY)); 00283 00284 if (NodeCopy) 00285 CopyNodeContents(NodeCopy); 00286 00287 return NodeCopy; 00288 }
|
|
Definition at line 367 of file nodetxtl.h. 00367 { if ( Ascent>mLineAscent ) mLineAscent = Ascent; }
|
|
Definition at line 366 of file nodetxtl.h. 00366 { if (Descent<mLineDescent) mLineDescent = Descent; }
|
|
Definition at line 368 of file nodetxtl.h.
|
|
Definition at line 1833 of file nodetxtl.cpp. 01834 { 01835 if (IsSelected()==FALSE) 01836 { 01837 VisibleTextNode* pVTN = FindFirstVTN(); 01838 ERROR2IF(pVTN==NULL,FALSE,"TextLine::WholeLineSelected() - line has no VTN!"); 01839 while (pVTN!=NULL) 01840 { 01841 if (!pVTN->IsSelected() && !pVTN->IsACaret()) 01842 return FALSE; 01843 pVTN = pVTN->FindNextVTNInLine(); 01844 } 01845 } 01846 return TRUE; 01847 }
|
|
Calculates whether the formatter will wrap this line of text around the path It calculates this by checking the position of the last character (or VTN in the line). If this wraps it is assumed the whole line will wrap.
Definition at line 1956 of file nodetxtl.cpp. 01957 { 01958 TextStory* pTextStory = FindParentStory(); 01959 ERROR2IF(pTextStory==NULL,FALSE,"TextLine::IsLineWrappedOnPath() - pTextStory==NULL"); 01960 01961 BOOL found = FALSE; 01962 Node* pNode=FindLastChild(); 01963 while (pNode && !found) 01964 { 01965 if (pNode->IsAVisibleTextNode()) 01966 found = TRUE; 01967 else 01968 pNode=pNode->FindPrevious(); 01969 } 01970 01971 if (pNode) 01972 { 01973 VisibleTextNode* pVTN=(VisibleTextNode*)pNode; 01974 MILLIPOINT Dist=XLONG(pVTN->GetPosInLine()) * xscale; 01975 if (Dist>PLength) 01976 return TRUE; 01977 } 01978 return FALSE; 01979 }
|
|
Word wrap the line.
Definition at line 1378 of file nodetxtl.cpp. 01379 { 01380 VisibleTextNode* pBreakChar = this->FindBreakChar(WrapWidth, FALSE, Indent); 01381 if (pBreakChar==NULL) 01382 return FALSE; 01383 01384 // if break char on this line, wrap the rest of the line forward 01385 // else wrap all lines and chars upto the break char back on this line 01386 TextLine* pBreakLine = pBreakChar->FindParentLine(); 01387 ERROR2IF(pBreakLine==NULL,FALSE,"TextLine::Wrap() - break char has no parent line"); 01388 if (pBreakLine==this) 01389 { 01390 VisibleTextNode* pAfterBreak = pBreakChar->FindNextVTNInLine(); 01391 if (pAfterBreak!=NULL) 01392 if (!pAfterBreak->WrapRestOfLineForward(pUndoOp)) 01393 return FALSE; 01394 } 01395 else 01396 { 01397 TextLine* pNextLine = this->FindNextLine(); 01398 while (pNextLine!=pBreakLine) 01399 { 01400 ERROR2IF(pNextLine==NULL,FALSE,"TextLine::Wrap() - did not find line with break char!"); 01401 VisibleTextNode* pLastVTN = pNextLine->FindLastVTN(); 01402 ERROR2IF(pLastVTN==NULL,FALSE,"TextLine::Wrap() - no VTN on line!"); 01403 if (!pLastVTN->WrapFromStartOfLineBack(pUndoOp)) 01404 return FALSE; 01405 pNextLine = this->FindNextLine(); 01406 } 01407 if (!pBreakChar->WrapFromStartOfLineBack(pUndoOp)) 01408 return FALSE; 01409 } 01410 01411 return TRUE; 01412 }
|
|
Begin to write out you child records, in the native format.
Reimplemented from NodeRenderableInk. Definition at line 2023 of file nodetxtl.cpp. 02024 { 02025 #ifdef DO_EXPORT 02026 return CXaraFileTxtLine::WriteBeginChildRecordsNative(pFilter, this); 02027 #else 02028 return FALSE; 02029 #endif 02030 }
|
|
Begin to write out you child records, in the web format.
Reimplemented from NodeRenderableInk. Definition at line 2014 of file nodetxtl.cpp. 02015 { 02016 #ifdef DO_EXPORT 02017 return CXaraFileTxtLine::WriteBeginChildRecordsWeb(pFilter, this); 02018 #else 02019 return FALSE; 02020 #endif 02021 }
|
|
Finished writing out you child records, in the native format.
Reimplemented from NodeRenderableInk. Definition at line 2041 of file nodetxtl.cpp. 02042 { 02043 #ifdef DO_EXPORT 02044 return CXaraFileTxtLine::WriteEndChildRecordsNative(pFilter, this); 02045 #else 02046 return FALSE; 02047 #endif 02048 }
|
|
Finished writing out you child records, in the web format.
Reimplemented from NodeRenderableInk. Definition at line 2032 of file nodetxtl.cpp. 02033 { 02034 #ifdef DO_EXPORT 02035 return CXaraFileTxtLine::WriteEndChildRecordsWeb(pFilter, this); 02036 #else 02037 return FALSE; 02038 #endif 02039 }
|
|
Reimplemented from Node. Definition at line 2003 of file nodetxtl.cpp. 02004 { 02005 #ifdef DO_EXPORT 02006 return CXaraFileTxtLine::WritePreChildrenNative(pFilter, this); 02007 #else 02008 return FALSE; 02009 #endif 02010 }
|
|
Saves a text line record to the new file format filter.
Reimplemented from Node. Definition at line 1994 of file nodetxtl.cpp. 01995 { 01996 #ifdef DO_EXPORT 01997 return CXaraFileTxtLine::WritePreChildrenWeb(pFilter, this); 01998 #else 01999 return FALSE; 02000 #endif 02001 }
|
|
Definition at line 399 of file nodetxtl.h. |
|
Definition at line 395 of file nodetxtl.h. |
|
Definition at line 398 of file nodetxtl.h. |
|
Definition at line 392 of file nodetxtl.h. |
|
Definition at line 391 of file nodetxtl.h. |
|
Definition at line 393 of file nodetxtl.h. |
|
Definition at line 397 of file nodetxtl.h. |
|
Definition at line 396 of file nodetxtl.h. |
|
Definition at line 403 of file nodetxtl.h. |
|
Definition at line 401 of file nodetxtl.h. |
|
Definition at line 400 of file nodetxtl.h. |