00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #ifndef INC_NODETXTS
00100 #define INC_NODETXTS
00101
00102
00103
00104
00105 class NodePath;
00106 class CaretNode;
00107 class VisibleTextNode;
00108 class TextLine;
00109 class TextStory;
00110 class BaseCamelotFilter;
00111 class ImportedStringList;
00112 class ImportedString;
00113 class DocColour;
00114 class ExtendParams;
00115 class FormatRegion;
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 class BaseTextClass: public NodeRenderableInk
00126 {
00127 CC_DECLARE_DYNAMIC(BaseTextClass)
00128
00129 public:
00130 BaseTextClass();
00131 ~BaseTextClass();
00132 BaseTextClass(Node* ContextNode, AttachNodeDirection Direction);
00133 void Init();
00134
00135 void CopyNodeContents(BaseTextClass* NodeCopy);
00136 virtual Node* SimpleCopy() { ERROR2(NULL,"BaseTextClass::SimpleCopy() - this is an abstract class!!!!"); }
00137 virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00138
00139 virtual BOOL IsABaseTextClass() const { return TRUE; }
00140 virtual BOOL IsSetCandidate() const { return FALSE; }
00141
00142
00143 virtual CCRuntimeClass* GetCurrentAttribGroup();
00144
00145 virtual BOOL AllowOp(ObjChangeParam* pParam, BOOL SetOpPermissionState=TRUE,
00146 BOOL DoPreTriggerEdit = TRUE);
00147 BOOL PreOpProcessing(ObjChangeParam* pParam);
00148
00149 TextStory* FindParentStory();
00150
00151
00152 BOOL DoHideNode(UndoableOperation* pUndoOp);
00153 BOOL DoInsertNewNode(UndoableOperation* pUndoOp, Node* pContextNode, AttachNodeDirection Direction);
00154 BOOL DoFactorOutCommonChildAttributes(UndoableOperation* pUndoOp, BOOL Global, AttrTypeSet* pAffectedAttrTypes);
00155 BOOL DoLocaliseCommonAttributes(UndoableOperation* pUndoOp, BOOL CheckForDuplicates,
00156 BOOL Global, AttrTypeSet* pAffectedAttrTypes);
00157 void GetAttachNodeAndDirectionToAttachFirstChildObject(Node** ppNode, AttachNodeDirection* pDir);
00158 BOOL AddNonLineLevelDescendantAttrsToSet(AttrTypeSet* pAttrTypeSet);
00159
00160 void UnionNodeAndDescendantsOldAndNewBounds(DocRect* pBounds, BOOL ParentModifiedByOp=FALSE);
00161 BOOL ReCacheNodeAndDescendantsMetrics(FormatRegion* pFormatRegion);
00162 virtual BOOL ReCacheMetrics(FormatRegion* pFormatRegion);
00163
00164 void FlagNodeAndDescendantsModifiedByOpAndParentsHaveDescendantModifiedByOp();
00165 void FlagNodeAndDescendantsAffectedAndParentsHaveDescendantAffected();
00166 void FlagPrevTextCharAndDescendantsModifiedByOpAndParentsHaveDescendantModifiedByOp();
00167 void ClearNodeAndDescendantsFlags();
00168
00169 inline BOOL ModifiedByOp() { return mModifiedByOpFlag; }
00170 inline BOOL DescendantModifiedByOp() { return mDescendantModifiedByOpFlag; }
00171 inline BOOL NodeOrDescendantModifiedByOp() { return mModifiedByOpFlag || mDescendantModifiedByOpFlag; }
00172 inline BOOL Affected() { return mAffectedFlag; }
00173 inline BOOL DescendantAffected() { return mDescendantAffectedFlag; }
00174 inline BOOL NodeOrDescendantAffected() { return mAffectedFlag || mDescendantAffectedFlag; }
00175 inline BOOL AlreadyWritten() { return mAlreadyWritten; }
00176
00177 inline void SetAlreadyWritten(BOOL f) { mAlreadyWritten = f; }
00178
00179 private:
00180 void FlagParentsHaveDescendantModifiedByOp();
00181 void FlagDescendantsModifiedByOp();
00182 void FlagParentsHaveDescendantAffected();
00183 void FlagDescendantsAffected();
00184
00185 inline void FlagModifiedByOp() { mModifiedByOpFlag = TRUE; mAffectedFlag = TRUE; }
00186 inline void FlagDescendantModifiedByOp() { mDescendantModifiedByOpFlag = TRUE; mDescendantAffectedFlag = TRUE; }
00187 inline void FlagAffected() { mAffectedFlag = TRUE; }
00188 inline void FlagDescendantAffected() { mDescendantAffectedFlag = TRUE; }
00189 inline void ClearFlags();
00190
00191 private:
00192
00193 BYTE mModifiedByOpFlag : 1;
00194 BYTE mDescendantModifiedByOpFlag : 1;
00195 BYTE mAffectedFlag : 1;
00196 BYTE mDescendantAffectedFlag : 1;
00197 BYTE mAlreadyWritten : 1;
00198 };
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 enum BaseShiftEnum { AlignBaseline, AlignAscenders, AlignDescenders, AlignCentres };
00211
00212
00213
00214 const double Text_SuperScriptSize = 0.5;
00215 const double Text_SuperScriptOffset = 0.33;
00216 const double Text_SubScriptSize = 0.5;
00217 const double Text_SubScriptOffset = -0.1;
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 class TextStoryInfo : public CC_CLASS_MEMDUMP
00229 {
00230 CC_DECLARE_MEMDUMP(TextStoryInfo);
00231
00232 public:
00233 TextStoryInfo();
00234
00235 UndoableOperation* pUndoOp;
00236 BOOL WordWrap;
00237
00238 MILLIPOINT StoryWidth;
00239 BOOL WordWrapping;
00240 Path* pPath;
00241 MILLIPOINT PathLength;
00242 MILLIPOINT PathClosed;
00243 double UnitDirectionVectorX;
00244 double UnitDirectionVectorY;
00245 MILLIPOINT LeftPathIndent;
00246 MILLIPOINT RightPathIndent;
00247 MILLIPOINT DescentLine;
00248 BOOL DescentLineValid;
00249 };
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 class TextStory: public BaseTextClass
00261 {
00262 CC_DECLARE_DYNAMIC(TextStory)
00263
00264 public:
00265 static TextStory* CreateTextObject(DocCoord Anchor);
00266 static TextStory* CreateTextObject(Matrix TheMatrix);
00267 static TextStory* CreateFromChars(DocCoord Pos, char* pChars, WCHAR* pWChars, Document* pCreateDoc,
00268 LOGFONT* pLogFont=NULL, BOOL ControlCodes=FALSE, DocColour* pColour=NULL);
00269 TextStory();
00270 ~TextStory();
00271 TextStory(Node* ContextNode, AttachNodeDirection Direction);
00272 void Init();
00273
00274 String_256 GetStoryAsString();
00275
00276 virtual BOOL IsSetCandidate() const { return TRUE; }
00277 virtual BOOL IsCompound() const { return TRUE; }
00278
00279 virtual Node* SimpleCopy();
00280 void CopyNodeContents(TextStory* NodeCopy);
00281 virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00282 INT32 BaseComplexCopy(CopyStage Stage, Range& RangeToCopy, Node** pOutput);
00283 INT32 BaseComplexHide(UndoableOperation *pOp);
00284 virtual BOOL HidingNode();
00285
00286 virtual BOOL CanBecomeA(BecomeA* pBecomeA);
00287 virtual BOOL DoBecomeA(BecomeA* pBecomeA);
00288
00289 virtual String Describe(BOOL Plural, BOOL Verbose);
00290 virtual UINT32 GetNodeSize() const;
00291 virtual void GetDebugDetails(StringBase* Str);
00292
00293 virtual BOOL OnNodePopUp(Spread* pSpread, DocCoord PointerPos, ContextMenu* pMenu);
00294
00295 virtual DocRect GetBlobBoundingRect();
00296 virtual void RenderObjectBlobs(RenderRegion* pRender);
00297 virtual void RenderTinyBlobs(RenderRegion* pRender);
00298 DocCoord GetBlobPosAndSize(INT32* pSize=NULL);
00299
00300
00301
00302 virtual BOOL AllowOp(ObjChangeParam* pParam, BOOL SetOpPermissionState = TRUE,
00303 BOOL DoPreTriggerEdit = TRUE);
00304 virtual BOOL AllowOp_AccountForCompound(ObjChangeParam* pParam,
00305 BOOL SetOpPermissionState=TRUE,
00306 BOOL DoPreTriggerEdit = TRUE);
00307 virtual ChangeCode OnChildChange(ObjChangeParam* pParam);
00308
00309 BOOL MoveCaretLeftAChar();
00310 BOOL MoveCaretRightAChar();
00311 BOOL MoveCaretLeftAWord();
00312 BOOL MoveCaretRightAWord();
00313 BOOL MoveCaretToStartOfLine();
00314 BOOL MoveCaretToEndOfLine();
00315 BOOL MoveCaretToCharacter(VisibleTextNode* pChar, AttachNodeDirection Dir);
00316 BOOL AttachCaretAttributes();
00317 VisibleTextNode* GetPrevWordChar(VisibleTextNode* pStartChar);
00318 VisibleTextNode* GetNextWordChar(VisibleTextNode* pStartChar);
00319
00320 VisibleTextNode* GetSelectionEnd(BOOL* pDirection = NULL);
00321 BOOL GetCharacterAtPoint(BOOL InBounds, DocCoord Point, VisibleTextNode** pHitChar, BOOL* ToLeft);
00322
00323 static TextStory* GetFocusStory();
00324 static void SetFocusStory(TextStory* pNewStory);
00325 CaretNode* GetCaret();
00326
00327 NodePath* GetTextPath() const;
00328 TextLine* FindFirstLine() const;
00329 TextLine* FindLastLine() const;
00330 VisibleTextNode* FindFirstVTN() const;
00331 VisibleTextNode* FindLastVTN() const;
00332
00333 virtual void Transform(TransformBase& transform);
00334
00335 DocRect GetUTStoryBounds();
00336 BOOL CreateUntransformedPath(TextStoryInfo* pPathInfo);
00337 void MatrixFitToPath();
00338 void MatrixRemoveFromPath();
00339
00340 virtual BOOL FormatAndChildren(UndoableOperation* pUndoOp=NULL,
00341 BOOL UseNodeFlags=FALSE, BOOL WordWrap=TRUE);
00342 BOOL UnWrapStory(UndoableOperation* pUndoOp);
00343
00344 BOOL DeleteSelectedText(UndoableOperation* pUndoOp);
00345 BOOL DeleteSelectedTextLines(UndoableOperation* pUndoOp);
00346 BOOL DeleteSelectedTextCharacters(UndoableOperation* pUndoOp);
00347
00348 void PreExportRender(RenderRegion* pRegion);
00349 BOOL ExportRender(RenderRegion* pRegion);
00350 BOOL PostImport();
00351 BOOL PostDuplicate(UndoableOperation* pOp);
00352 BOOL ImportFix_MoveScaleToAttrs();
00353 BOOL CorelStyleBaselineShift(BaseShiftEnum BaseShift);
00354
00355
00356
00357 BOOL OKToExport();
00358 virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00359 virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00360 virtual BOOL CanWriteChildrenWeb(BaseCamelotFilter* pFilter);
00361 virtual BOOL CanWriteChildrenNative(BaseCamelotFilter* pFilter);
00362 virtual BOOL WriteBeginChildRecordsWeb(BaseCamelotFilter* pFilter);
00363 virtual BOOL WriteBeginChildRecordsNative(BaseCamelotFilter* pFilter);
00364 virtual BOOL WriteEndChildRecordsWeb(BaseCamelotFilter* pFilter);
00365 virtual BOOL WriteEndChildRecordsNative(BaseCamelotFilter* pFilter);
00366
00367 void ResetStringList();
00368 void AddImportedString(ImportedString* pImportedString);
00369 BOOL EnsureStoryHasCaret();
00370
00371
00372 void Validate(BOOL EnsureOpFlagsReset=TRUE);
00373 void CheckLeaf(Node* pLeafNode);
00374 void CheckSubtree(Node* pNode, AttrTypeSet* pParentAttrSet=NULL, BOOL* pDescendantSelected=NULL);
00375 TCHAR* GetNodeInfo(Node* pNode);
00376
00377 void ResetEOLs(BOOL Status);
00378 BOOL WillStoryWrapOnPath();
00379
00380 protected:
00381 BOOL Copy(Range& RangeToCopy, Node** pOutput);
00382 void SetStoryMarkers(Range& RangeToCopy);
00383 static BOOL DeleteChildAttribute(NodeRenderableInk* pParent, CCRuntimeClass* ReqdAttrib);
00384
00385 BOOL ExpandImportedStrings();
00386
00387
00388 BOOL IsGradientFilled ();
00389
00390 public:
00391 const Matrix* GetpStoryMatrix() const { return &StoryMatrix; }
00392 Matrix* GetpStoryMatrix() { return &StoryMatrix; }
00393 Matrix GetStoryMatrix() const { return StoryMatrix; }
00394 void SetStoryMatrix(Matrix& matrix) { StoryMatrix=matrix; }
00395
00396 DocRect GetRedrawRect() const { return RedrawRect; }
00397 void SetRedrawRect(DocRect rect) { RedrawRect=rect; }
00398 void UpdateRedrawRect(DocRect rect) { RedrawRect=RedrawRect.Union(rect); }
00399
00400 MILLIPOINT GetStoryWidth() const { return StoryWidth; }
00401 void SetStoryWidth(MILLIPOINT NewValue) { StoryWidth = NewValue; }
00402
00403 MILLIPOINT GetImportFormatWidth() const { return ImportFormatWidth; }
00404 BaseShiftEnum GetImportBaseShift() const { return ImportBaseShift; }
00405 void SetImportFormatWidth(MILLIPOINT width) { ImportFormatWidth=width; }
00406 void SetImportBaseShift(BaseShiftEnum shift) { ImportBaseShift=shift; }
00407
00408 BOOL IsTextOnPathReversed() const { return TextOnPathReversed; }
00409 BOOL IsTextOnPathTangential() const { return TextOnPathTangential; }
00410 BOOL IsPrintingAsShapes() const { return PrintAsShapes; }
00411 BOOL IsWordWrapping() const { return WordWrapping; }
00412 void ReverseTextOnPath() { TextOnPathReversed = !TextOnPathReversed; }
00413 void ToggleTextOnPathTangentialness() { TextOnPathTangential = !TextOnPathTangential; }
00414 void SetPrintingAsShapes(BOOL NewValues) { PrintAsShapes = NewValues; }
00415 void SetWordWrapping( BOOL NewValues) { WordWrapping = NewValues; }
00416
00417 FIXED16 GetCharsScale() const { return CharsScale; }
00418 FIXED16 GetCharsAspect() const { return CharsAspect; }
00419 ANGLE GetCharsRotation() const { return CharsRotation; }
00420 ANGLE GetCharsShear() const { return CharsShear; }
00421 void SetCharsScale(FIXED16 scale) { CharsScale = scale; }
00422 void SetCharsAspect(FIXED16 aspect) { CharsAspect = aspect; }
00423 void SetCharsRotation(ANGLE rotation) { CharsRotation = rotation; }
00424 void SetCharsShear(ANGLE shear) { CharsShear = shear; }
00425
00426
00427 BOOL IsAutoKerning() { return AutoKern; }
00428 void SetAutoKerning(BOOL NewValue) { AutoKern = NewValue; }
00429
00430
00431 MILLIPOINT GetLeftIndent() const {return mLeftIndent;}
00432 MILLIPOINT GetRightIndent() const {return mRightIndent;}
00433 DocCoord GetLeftIndentPos() const;
00434 DocCoord GetRightIndentPos() const;
00435 static DocCoord GetPathBlobPos(MILLIPOINT IndentLength, NodePath* pPath);
00436 void SetLeftIndent(MILLIPOINT NewIndent) {mLeftIndent = NewIndent;}
00437 void SetRightIndent(MILLIPOINT NewIndent) {mRightIndent = NewIndent;}
00438
00439
00440 public:
00441
00442
00443
00444
00445 virtual BOOL IsTypeExtendible() const { return TRUE; }
00446 virtual DocRect ValidateExtend(const ExtendParams& ExtParams);
00447 virtual void Extend(const ExtendParams& ExtParams);
00448
00449
00450 DocCoord FindExtendCentre();
00451
00452
00453 Justification FindJustification();
00454
00455 private:
00456 static TextStory* pFocusStory;
00457
00458 Matrix StoryMatrix;
00459 DocRect RedrawRect;
00460 CaretNode* CachedCaret;
00461 MILLIPOINT mLeftIndent;
00462 MILLIPOINT mRightIndent;
00463 MILLIPOINT StoryWidth;
00464
00465 BOOL TextOnPathReversed : 1;
00466 BOOL TextOnPathTangential : 1;
00467 BOOL PrintAsShapes : 1;
00468 BOOL WordWrapping : 1;
00469 BOOL BeingCopied : 1;
00470
00471 MILLIPOINT ImportFormatWidth;
00472 BaseShiftEnum ImportBaseShift;
00473
00474 FIXED16 CharsScale;
00475 FIXED16 CharsAspect;
00476 ANGLE CharsRotation;
00477 ANGLE CharsShear;
00478
00479 ImportedStringList* pImportedStringList;
00480
00481
00482 bool AutoKern;
00483 };
00484 #endif