1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ 2 3 /* AbiWord 4 * Copyright (C) 1998 AbiSource, Inc. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 * 02110-1301 USA. 20 */ 21 22 #ifndef PT_PIECETABLE_H 23 #define PT_PIECETABLE_H 24 25 #include <stdio.h> 26 #include <list> 27 #include "ut_types.h" 28 #include "ut_growbuf.h" 29 #include "ut_stack.h" 30 #include "pt_Types.h" 31 #include "pp_TableAttrProp.h" 32 #include "pf_Fragments.h" 33 #include "pt_VarSet.h" 34 #include "pp_Revision.h" 35 #include "px_ChangeHistory.h" 36 37 class pf_Frag_Object; 38 class pf_Frag_FmtMark; 39 class pf_Frag_Text; 40 class pf_Frag_Strux; 41 class pf_Frag_Strux_Block; 42 class pf_Frag_Strux_Section; 43 class PX_ChangeRecord_Span; 44 class PD_Style; 45 class PL_ListenerCoupleCloser; 46 class fl_ContainerLayout; 47 48 #ifdef PT_TEST 49 #include "ut_test.h" 50 #endif 51 52 ////////////////////////////////////////////////////////////////// 53 ////////////////////////////////////////////////////////////////// 54 // pt_PieceTable implements a "Piece Table" as described/suggested 55 // by .../dev/design/PieceTable.html 56 57 class ABI_EXPORT pt_PieceTable 58 { 59 friend class PX_ChangeRecord; 60 public: 61 pt_PieceTable(PD_Document * pDocument); 62 ~pt_PieceTable(); 63 64 void setPieceTableState(PTState pts); getPieceTableState()65 PTState getPieceTableState() const {return m_pts;} 66 void beginMultiStepGlob(void); 67 void endMultiStepGlob(void); 68 void beginUserAtomicGlob(void); 69 void endUserAtomicGlob(void); 70 71 void setClean(void); 72 bool isDirty(void) const; 73 74 bool canDo(bool bUndo) const; 75 UT_uint32 undoCount(bool bUndo) const; 76 bool undoCmd(void); 77 bool redoCmd(void); getNthUndo(PX_ChangeRecord ** ppcr,UT_uint32 undoNdx)78 bool getNthUndo(PX_ChangeRecord ** ppcr, UT_uint32 undoNdx) const 79 { return m_history.getNthUndo(ppcr, undoNdx); } 80 bool getUndo(PX_ChangeRecord ** ppcr, bool bStatic=false) const 81 { return m_history.getUndo(ppcr, bStatic); } getRedo(PX_ChangeRecord ** ppcr)82 bool getRedo(PX_ChangeRecord ** ppcr) const 83 { return m_history.getRedo(ppcr); } clearUndo()84 void clearUndo() {m_history.clearHistory();} 85 86 static void s_getLocalisedStyleName(const char *szStyle, std::string &utf8); 87 static const char *s_getUnlocalisedStyleName(const char *szLocStyle); 88 89 protected: 90 bool _realInsertObject(PT_DocPosition dpos, 91 PTObjectType pto, 92 const gchar ** attributes, 93 const gchar ** properties); 94 95 bool _realInsertObject(PT_DocPosition dpos, 96 PTObjectType pto, 97 const gchar ** attributes, 98 const gchar ** properties, pf_Frag_Object ** ppfo ); 99 100 bool _realInsertSpan(PT_DocPosition dpos, 101 const UT_UCSChar * p, 102 UT_uint32 length, 103 const gchar ** attributes, 104 const gchar ** properties, 105 fd_Field * pField = NULL, 106 bool bAddChangeRec = true); 107 108 bool _realDeleteSpan(PT_DocPosition dpos1, 109 PT_DocPosition dpos2, 110 PP_AttrProp *p_AttrProp_Before, 111 bool bDeleteTableStruxes, 112 bool bDontGlob=false); 113 114 #if 0 115 // this is for fields and so should not be needed with revisions 116 bool _realInsertSpan_norec(PT_DocPosition dpos, 117 const UT_UCSChar * p, 118 UT_uint32 length, fd_Field * pField = NULL); 119 bool _realDeleteFieldFrag(pf_Frag * pf); 120 #endif 121 122 // this one I am not sure about 123 void _realDeleteHdrFtrStrux(pf_Frag_Strux * pfs); 124 125 bool _realChangeSpanFmt(PTChangeFmt ptc, 126 PT_DocPosition dpos1, 127 PT_DocPosition dpos2, 128 const gchar ** attributes, 129 const gchar ** properties, 130 bool bRevisionDelete); 131 132 bool _realInsertStrux(PT_DocPosition dpos, 133 PTStruxType pts, 134 const gchar ** attributes, 135 const gchar ** properties, 136 pf_Frag_Strux ** ppfs_ret); 137 138 bool _realChangeStruxFmt(PTChangeFmt ptc, 139 PT_DocPosition dpos1, 140 PT_DocPosition dpos2, 141 const gchar ** attributes, 142 const gchar ** properties, 143 PTStruxType pts, 144 bool bRevisionDelete); 145 146 bool _realChangeStruxForLists(pf_Frag_Strux* sdh, 147 const char * pszParentID, 148 bool bRevisionDelete); 149 150 bool _realChangeSectionAttsNoUpdate(pf_Frag_Strux * pfStrux, const char * attr, const char * attvalue); 151 152 153 154 /****************************************************************** 155 these are the new revisions aware methods 156 */ 157 public: 158 bool insertObject(PT_DocPosition dpos, 159 PTObjectType pto, 160 const gchar ** attributes, 161 const gchar ** properties); 162 163 bool insertObject(PT_DocPosition dpos, 164 PTObjectType pto, 165 const gchar ** attributes, 166 const gchar ** properties, pf_Frag_Object ** ppfo ); 167 168 bool insertSpan(PT_DocPosition dpos, 169 const UT_UCSChar * p, 170 UT_uint32 length, fd_Field * pField = NULL, 171 bool bAddChangeRec = true); 172 173 pf_Frag* getEndOfBlock( PT_DocPosition currentpos, PT_DocPosition endpos ); 174 // bool deleteSpanChangeTrackingAreWeMarkingDeltaMerge( PT_DocPosition startpos, 175 // PT_DocPosition endpos ); 176 pf_Frag_Strux* inSameBlock( PT_DocPosition startpos, PT_DocPosition endpos ); 177 // bool changeTrackingAddParaAttribute( pf_Frag_Strux* pfs, 178 // const char* attr, 179 // std::string v ); 180 // bool deleteSpanChangeTrackingMaybeMarkParagraphEndDeletion( PT_DocPosition currentpos, 181 // PT_DocPosition endpos ); 182 183 bool deleteSpan(PT_DocPosition dpos1, 184 PT_DocPosition dpos2, 185 PP_AttrProp *p_AttrProp_Before, 186 UT_uint32 &iRealDeleteCount, 187 bool bDontGlob=false); 188 189 190 bool deleteSpan(PT_DocPosition dpos1, 191 PT_DocPosition dpos2, 192 PP_AttrProp *p_AttrProp_Before, 193 UT_uint32 &iRealDeleteCount, 194 bool bDeleteTableStruxes, 195 bool bDontGlob); 196 bool createAndSendCR(PT_DocPosition dpos, 197 UT_sint32 iType,bool bSave, UT_Byte iGlob); 198 199 bool createAndSendDocPropCR( const gchar ** pAtts, const gchar ** pProps); 200 201 bool deleteSpanWithTable(PT_DocPosition dpos1, 202 PT_DocPosition dpos2, 203 PP_AttrProp *p_AttrProp_Before, 204 UT_uint32 &iRealDeleteCount, 205 bool bDeleteTableStrux); 206 207 bool deleteFieldFrag(pf_Frag * pf); 208 209 void deleteHdrFtrStrux(pf_Frag_Strux * pfs); 210 211 bool changeSpanFmt(PTChangeFmt ptc, 212 PT_DocPosition dpos1, 213 PT_DocPosition dpos2, 214 const gchar ** attributes, 215 const gchar ** properties); 216 217 bool insertStrux(PT_DocPosition dpos, 218 PTStruxType pts, 219 pf_Frag_Strux ** ppfs_ret = 0); 220 221 bool insertStrux(PT_DocPosition dpos, 222 PTStruxType pts, 223 const gchar ** attributes, 224 const gchar ** properties, 225 pf_Frag_Strux ** ppfs_ret = 0 226 ); 227 228 bool changeStruxFmt(PTChangeFmt ptc, 229 PT_DocPosition dpos1, 230 PT_DocPosition dpos2, 231 const gchar ** attributes, 232 const gchar ** properties, 233 PTStruxType pts=PTX_StruxDummy); 234 235 236 bool changeStruxFmtNoUndo(PTChangeFmt ptc, 237 pf_Frag_Strux * pfs, 238 const gchar ** attributes, 239 const gchar ** properties); 240 241 bool changeStruxFormatNoUpdate(PTChangeFmt ptc, pf_Frag_Strux * pfs,const gchar ** attributes); 242 243 bool changeObjectFormatNoUpdate(PTChangeFmt ptc, pf_Frag_Object * pfo,const gchar ** attributes,const gchar ** properties); 244 245 bool changeStruxForLists(pf_Frag_Strux* sdh, 246 const char * pszParentID); 247 bool changeSectionAttsNoUpdate(pf_Frag_Strux * pfStrux, const char * attr, const char * attvalue); 248 bool deleteStruxNoUpdate(pf_Frag_Strux* sdh); 249 bool deleteFragNoUpdate(pf_Frag * pf); 250 bool deleteStruxWithNotify(pf_Frag_Strux* sdh); 251 bool insertStruxNoUpdateBefore(pf_Frag_Strux* sdh, PTStruxType pts,const gchar ** attributes ); 252 bool changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts, 253 const gchar ** attrs, const gchar ** props, 254 bool bSkipEmbededSections); 255 256 bool changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts, 257 const gchar ** attrs, const gchar * props, 258 bool bSkipEmbededSections); 259 260 261 /********************** END OF REVISIONS AWARE METHODS ******/ insertFmtMark(PTChangeFmt ptc,PT_DocPosition dpos,PP_AttrProp * p_AttrProp)262 bool insertFmtMark(PTChangeFmt ptc, 263 PT_DocPosition dpos, 264 PP_AttrProp *p_AttrProp) 265 { 266 return _insertFmtMarkFragWithNotify(ptc,dpos,p_AttrProp); 267 } 268 bool deleteFmtMark(PT_DocPosition dpos); 269 270 // the append- methods are only available while importing 271 // the document. 272 273 PD_Document * getDocument(void); 274 bool appendStrux(PTStruxType pts, const gchar ** attributes, pf_Frag_Strux ** ppfs_ret = 0); 275 bool appendStruxFmt(pf_Frag_Strux * pfs, const gchar ** attributes); 276 bool appendLastStruxFmt(PTStruxType pts, const gchar ** attrs, const gchar ** props, 277 bool bSkipEmbededSections); 278 bool appendLastStruxFmt(PTStruxType pts, const gchar ** attrs, const gchar * props, 279 bool bSkipEmbededSections); 280 281 bool appendFmt(const gchar ** attributes); 282 bool appendFmt(const UT_GenericVector<const gchar*> * pVecAttributes); 283 bool appendSpan(const UT_UCSChar * p, UT_uint32 length); 284 bool appendObject(PTObjectType pto, const gchar ** attributes); 285 bool appendFmtMark(void); 286 bool appendStyle(const gchar ** attributes); 287 288 bool insertStruxBeforeFrag(pf_Frag * pF, PTStruxType pts, 289 const gchar ** attributes, pf_Frag_Strux ** ppfs_ret = 0); 290 bool insertSpanBeforeFrag(pf_Frag * pF, const UT_UCSChar * p, UT_uint32 length); 291 bool insertObjectBeforeFrag(pf_Frag * pF, PTObjectType pto, 292 const gchar ** attributes); 293 bool insertFmtMarkBeforeFrag(pf_Frag * pF); 294 bool insertFmtMarkBeforeFrag(pf_Frag * pF, const gchar ** attributes); 295 296 bool removeStyle(const gchar * name); 297 size_t getStyleCount(void) const; 298 299 bool tellListener(PL_Listener * pListener); 300 bool tellListenerSubset( PL_Listener * pListener, 301 PD_DocumentRange * pDocRange, 302 PL_ListenerCoupleCloser* closer = 0 ); 303 304 bool addListener(PL_Listener * pListener, 305 PL_ListenerId listenerId); 306 307 bool getAttrProp(PT_AttrPropIndex indexAP, 308 const PP_AttrProp ** ppAP) const; 309 bool getSpanAttrProp(pf_Frag_Strux* sdh, UT_uint32 offset, bool bLeftSide, 310 const PP_AttrProp ** ppAP) const; 311 getPointer(PT_BufIndex bi)312 inline const UT_UCSChar *getPointer(PT_BufIndex bi) const 313 { 314 // the pointer that we return is NOT a zero-terminated 315 // string. the caller is responsible for knowing how 316 // long the data is within the span/fragment. 317 318 return m_varset.getPointer(bi); 319 } 320 321 bool getBlockBuf(pf_Frag_Strux* sdh, UT_GrowBuf * pgb) const; 322 323 PT_DocPosition getPosEnd(); 324 bool getBounds(bool bEnd, PT_DocPosition & docPos) const; 325 PT_DocPosition getStruxPosition(pf_Frag_Strux* sdh) const; 326 PT_DocPosition getFragPosition(const pf_Frag * pfToFind) const; 327 328 bool dumpDoc( const char* msg, PT_DocPosition currentpos, PT_DocPosition endpos ); 329 330 bool getFragFromPosition(PT_DocPosition docPos, 331 pf_Frag ** ppf, 332 PT_BlockOffset * pOffset) const; 333 334 bool getStruxOfTypeFromPosition(PL_ListenerId listenerId, 335 PT_DocPosition docPos, 336 PTStruxType pts, 337 fl_ContainerLayout* * psfh) const; 338 339 pf_Frag_Strux* getBlockFromPosition(PT_DocPosition pos) const; 340 341 bool getStruxOfTypeFromPosition(PT_DocPosition docPos, 342 PTStruxType pts, 343 pf_Frag_Strux* * sdh) const; 344 345 bool getStruxFromPosition(PL_ListenerId listenerId, 346 PT_DocPosition docPos, 347 fl_ContainerLayout* * psfh) const; 348 349 bool getFragsFromPositions(PT_DocPosition dPos1, PT_DocPosition dPos2, 350 pf_Frag ** ppf1, PT_BlockOffset * pOffset1, 351 pf_Frag ** ppf2, PT_BlockOffset * pOffset2) const; 352 353 bool getStyle(const char * szName, PD_Style ** ppStyle) const; 354 355 bool enumStyles(UT_uint32 k, 356 const char ** pszName, const PD_Style ** ppStyle) const; 357 358 bool enumStyles(UT_GenericVector<PD_Style*> * & pStyles) const; 359 getAllStyles()360 const std::map<std::string, PD_Style *> & getAllStyles()const {return m_hashStyles;} 361 bool isEndFootnote(pf_Frag * pf) const; 362 bool isFootnote(pf_Frag * pf) const; 363 bool isInsideFootnote(PT_DocPosition dpos, pf_Frag ** pfBegin = NULL) const; 364 bool hasEmbedStruxOfTypeInRange(PT_DocPosition posStart, PT_DocPosition posEnd, 365 PTStruxType iType) const; 366 367 void clearIfAtFmtMark(PT_DocPosition dpos); getVarSet(void)368 pt_VarSet & getVarSet(void) {return m_varset;}; getFragments(void)369 pf_Fragments & getFragments(void) {return m_fragments;}; 370 371 bool purgeFmtMarks(); isDoingTheDo(void)372 bool isDoingTheDo(void) const 373 { return m_bDoingTheDo;} 374 setDoNotTweakPosition(bool b)375 void setDoNotTweakPosition(bool b) {m_bDoNotTweakPosition = b;} 376 377 UT_uint32 getXID(); getTopXID()378 UT_uint32 getTopXID() const {return m_iXID;} setXIDThreshold(UT_uint32 i)379 void setXIDThreshold(UT_uint32 i){m_iXID = i;} 380 void fixMissingXIDs(); 381 UT_sint32 calcDocsize(void); setCRNumber(UT_sint32 iCRNumber)382 void setCRNumber(UT_sint32 iCRNumber) 383 { m_iCurCRNumber = iCRNumber;} 384 #ifdef PT_TEST 385 UT_TestStatus __test_VerifyCoalescedFrags(FILE * fp) const; 386 void __dump(FILE * fp) const; getChangeHistory(void)387 px_ChangeHistory* getChangeHistory(void) const 388 { return &m_history; } 389 #endif /* PT_TEST */ 390 391 protected: 392 393 pf_Frag_Strux* _findLastStruxOfType(pf_Frag * pfStart, 394 PTStruxType pst, 395 PTStruxType* stopConditions, 396 bool bSkipEmbededSections ); 397 pf_Frag_Strux* _findLastStruxOfType(pf_Frag * pfStart, PTStruxType pst, bool bSkipEmbeded); 398 pf_Frag * _findPrevHyperlink(pf_Frag * pfStart); 399 pf_Frag * _findNextHyperlink(pf_Frag * pfStart); 400 401 bool _tellAndMaybeAddListener(PL_Listener * pListener, 402 PL_ListenerId listenerId, 403 bool bAdd); 404 405 void _captureActiveSpan(pf_Frag_Strux_Block * pfsBlock); 406 PT_AttrPropIndex _chooseIndexAP(pf_Frag * pf, PT_BlockOffset fragOffset); 407 bool _canCoalesceInsertSpan(PX_ChangeRecord_Span * pcrSpan) const; 408 409 bool _createStrux(PTStruxType pts, 410 PT_AttrPropIndex indexAP, 411 pf_Frag_Strux ** ppfs); 412 413 void _insertStrux(pf_Frag * pf, 414 PT_BlockOffset fragOffset, 415 pf_Frag_Strux * pfsNew); 416 417 bool _insertObject(pf_Frag * pf, 418 PT_BlockOffset fragOffset, 419 PTObjectType pto, 420 PT_AttrPropIndex indexAP, 421 pf_Frag_Object * &pfo); 422 423 bool _createObject(PTObjectType pto, 424 PT_AttrPropIndex indexAP, 425 pf_Frag_Object ** ppfo); 426 427 bool _insertSpan(pf_Frag * pf, 428 PT_BufIndex bi, 429 PT_BlockOffset fragOffset, 430 UT_uint32 length, 431 PT_AttrPropIndex indexAP, 432 fd_Field * pField = NULL); 433 bool _StruxIsNotTable(pf_Frag_Strux * pfs); 434 bool _deleteSpan(pf_Frag_Text * pft, UT_uint32 fragOffset, 435 PT_BufIndex bi, UT_uint32 length, 436 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd); 437 void _unlinkFrag(pf_Frag * pf, 438 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd); 439 bool _getStruxFromPosition(PT_DocPosition docPos, 440 pf_Frag_Strux ** ppfs, bool bSkipFootnotes = false) const; 441 bool _getStruxOfTypeFromPosition(PT_DocPosition dpos, 442 PTStruxType pts, 443 pf_Frag_Strux ** ppfs) const; 444 pf_Frag_Strux* _getBlockFromPosition(PT_DocPosition pos) const; 445 bool _doTheDo(const PX_ChangeRecord * pcr, bool bUndo); 446 bool _struxHasContent(pf_Frag_Strux * pfs) const; 447 bool _struxIsEmpty(pf_Frag_Strux * pfs) const; 448 bool _unlinkStrux(pf_Frag_Strux * pfs, 449 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd); 450 bool _unlinkStrux_Block(pf_Frag_Strux * pfs, 451 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd); 452 bool _unlinkStrux_Section(pf_Frag_Strux * pfs, 453 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd); 454 455 bool _canCoalesceDeleteSpan(PX_ChangeRecord_Span * pcrSpan) const; 456 457 bool _deleteSpanWithNotify(PT_DocPosition dpos, 458 pf_Frag_Text * pft, UT_uint32 fragOffset, 459 UT_uint32 length, 460 pf_Frag_Strux * pfs, 461 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd, 462 bool bAddChangeRec = true); 463 464 bool _isSimpleDeleteSpan(PT_DocPosition dpos1, 465 PT_DocPosition dpos2) const; 466 void _tweakFieldSpan(PT_DocPosition& dpos1, 467 PT_DocPosition& dpos2) const; 468 bool _tweakDeleteSpanOnce(PT_DocPosition& dpos1, 469 PT_DocPosition& dpos2, 470 UT_Stack * pstDelayStruxDelete) const; 471 bool _tweakDeleteSpan(PT_DocPosition& dpos1, 472 PT_DocPosition& dpos2, 473 UT_Stack * pstDelayStruxDelete) const; 474 bool _deleteFormatting(PT_DocPosition dpos1, 475 PT_DocPosition dpos2); 476 477 bool _deleteComplexSpanHAR( pf_Frag_Object *pO, 478 PT_DocPosition dpos1, 479 PT_DocPosition dpos2, 480 UT_uint32& length, 481 PT_BlockOffset& fragOffset_First, 482 UT_uint32& lengthThisStep, 483 pf_Frag_Strux*& pfsContainer, 484 pf_Frag*& pfNewEnd, 485 UT_uint32& fragOffsetNewEnd, 486 const char* startAttrCSTR ); 487 488 bool _deleteComplexSpan(PT_DocPosition & dpos1, 489 PT_DocPosition & dpos2, 490 UT_Stack *stDelayStruxDelete); 491 492 493 bool _deleteComplexSpan_norec(PT_DocPosition dpos1, 494 PT_DocPosition dpos2); 495 496 bool _deleteObject(pf_Frag_Object * pfo, 497 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd); 498 499 bool _deleteObjectWithNotify(PT_DocPosition dpos, 500 pf_Frag_Object * pfo, UT_uint32 fragOffset, 501 UT_uint32 length, 502 pf_Frag_Strux * pfs, 503 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd, 504 bool bAddChangeRec = true); 505 506 507 508 bool _deleteObject_norec(PT_DocPosition dpos, 509 pf_Frag_Object * pfo, UT_uint32 fragOffset, 510 UT_uint32 length, 511 pf_Frag_Strux * pfs, 512 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd); 513 514 bool _deleteStruxWithNotify(PT_DocPosition dpos, 515 pf_Frag_Strux * pfs, 516 pf_Frag ** ppfEnd, 517 UT_uint32 * pfragOffsetEnd, 518 bool bWithRec = true); 519 520 bool _deleteHdrFtrsFromSectionStruxIfPresent(pf_Frag_Strux_Section * pfStruxSec); 521 522 void _deleteHdrFtrStruxWithNotify( pf_Frag_Strux * pfFragStruxHdrFtr); 523 524 bool _fixHdrFtrReferences(const gchar * pType, const gchar * pId, bool bNotional = false); 525 526 bool _fmtChangeStrux(pf_Frag_Strux * pfs, 527 PT_AttrPropIndex indexNewAP); 528 529 bool _fmtChangeStruxWithNotify(PTChangeFmt ptc, 530 pf_Frag_Strux * pfs, 531 const gchar ** attributes, 532 const gchar ** properties, 533 bool bRevisionDelete); 534 535 bool _fmtChangeStruxWithNotify(PTChangeFmt ptc, 536 pf_Frag_Strux * pfs, 537 const gchar ** attributes, 538 const gchar ** properties, 539 bool bDoAll, 540 bool bRevisionDelete); 541 542 bool _fmtChangeSpan(pf_Frag_Text * pft, UT_uint32 fragOffset, UT_uint32 length, 543 PT_AttrPropIndex indexNewAP, 544 pf_Frag ** ppfNewEnd, UT_uint32 * pfragOffsetNewEnd); 545 546 bool _fmtChangeSpanWithNotify(PTChangeFmt ptc, 547 pf_Frag_Text * pft, UT_uint32 fragOffset, 548 PT_DocPosition dpos, 549 UT_uint32 length, 550 const gchar ** attributes, 551 const gchar ** properties, 552 pf_Frag_Strux * pfs, 553 pf_Frag ** ppfNewEnd, 554 UT_uint32 * pfragOffsetNewEnd, 555 bool bRevisionDelete); 556 557 bool _fmtChangeObject(pf_Frag_Object * pfo, 558 PT_AttrPropIndex indexNewAP, 559 pf_Frag ** ppfNewEnd, 560 UT_uint32 * pfragOffsetNewEnd); 561 562 bool _fmtChangeObjectWithNotify(PTChangeFmt ptc, 563 pf_Frag_Object * pfo, UT_uint32 fragOffset, 564 PT_DocPosition dpos, 565 UT_uint32 length, 566 const gchar ** attributes, 567 const gchar ** properties, 568 pf_Frag_Strux * pfs, 569 pf_Frag ** ppfNewEnd, 570 UT_uint32 * pfragOffsetNewEnd, 571 bool bRevisionDelete); 572 573 bool _getStruxFromFrag(pf_Frag * pfStart, pf_Frag_Strux ** ppfs) const; 574 bool _getStruxFromFragSkip(pf_Frag * pfStart, pf_Frag_Strux ** ppfs) const; 575 576 bool _getNextStruxAfterFragSkip(pf_Frag *pfStart, pf_Frag_Strux ** ppfs); 577 578 bool _getStruxFromPositionSkip(PT_DocPosition docPos, 579 pf_Frag_Strux ** ppfs) const; 580 581 UT_uint32 _computeBlockOffset(pf_Frag_Strux * pfs,pf_Frag * pfTarget) const; 582 583 bool _loadBuiltinStyles(void); 584 bool _createBuiltinStyle(const char * szName, bool bDisplayed, const gchar ** attributes); 585 586 bool _insertFmtMarkFragWithNotify(PTChangeFmt ptc, 587 PT_DocPosition dpos, 588 const gchar ** attributes, 589 const gchar ** properties); 590 bool _insertFmtMarkFragWithNotify(PTChangeFmt ptc, 591 PT_DocPosition dpos, 592 PP_AttrProp *p_AttrProp); 593 bool _insertFmtMark(pf_Frag * pf, UT_uint32 fragOffset, PT_AttrPropIndex api); 594 bool _insertFmtMarkAfterBlockWithNotify(pf_Frag_Strux * pfsBlock, 595 PT_DocPosition dpos, 596 PT_AttrPropIndex api); 597 bool _deleteFmtMarkWithNotify(PT_DocPosition dpos, pf_Frag_FmtMark * pffm, 598 pf_Frag_Strux * pfs, 599 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd); 600 bool _deleteFmtMark(pf_Frag_FmtMark * pffm, 601 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd); 602 bool _fmtChangeFmtMarkWithNotify(PTChangeFmt ptc, pf_Frag_FmtMark * pffm, 603 PT_DocPosition dpos, 604 const gchar ** attributes, const gchar ** properties, 605 pf_Frag_Strux * pfs, 606 pf_Frag ** ppfEnd, UT_uint32 * pfragOffsetEnd); 607 bool _fmtChangeFmtMark(pf_Frag_FmtMark * pffm, 608 PT_AttrPropIndex indexNewAP, 609 pf_Frag ** ppfNewEnd, 610 UT_uint32 * pfragOffsetNewEnd); 611 bool _computeFmtMarkForNewBlock(pf_Frag_Strux * pfsBlock, 612 pf_Frag * pfCurrent, PT_BlockOffset fragOffset, 613 PT_AttrPropIndex * pFmtMarkAP); 614 bool _getSpanAttrPropHelper(pf_Frag * pf, const PP_AttrProp ** ppAP) const; 615 bool _lastUndoIsThisFmtMark(PT_DocPosition dpos); 616 617 bool _changePointWithNotify(PT_DocPosition dpos); 618 bool _checkSkipFootnote(PT_DocPosition dpos1, PT_DocPosition dpos2, pf_Frag * pf_End = NULL) const; 619 // helper methods for the appned and insert*BeforeFrag methods 620 bool _makeStrux(PTStruxType pts, const gchar ** attributes, 621 pf_Frag_Strux * &pfs); 622 bool _makeObject(PTObjectType pto, const gchar ** attributes, 623 pf_Frag_Object * &pfo); 624 bool _makeFmtMark(pf_Frag_FmtMark * &pff); 625 bool _makeFmtMark(pf_Frag_FmtMark * &pff, const gchar ** attributes); _getNextChangeRecordNumber(void)626 UT_sint32 _getNextChangeRecordNumber(void) 627 { return m_iCurCRNumber++;} 628 // implemented in pt_PT_InsertStrux.cpp 629 bool _translateRevisionAttribute(PP_RevisionAttr & Revisions, PT_AttrPropIndex indexAP, 630 PP_RevisionType eType, 631 const gchar ** & ppRevAttrib, 632 const gchar ** & ppRevProps, 633 const gchar ** ppAttrib, 634 const gchar ** ppProps); 635 bool _insertNoteInEmbeddedStruxList(pf_Frag_Strux * pfsNew); 636 637 PTState m_pts; /* are we loading or editing */ 638 pt_VarSet m_varset; 639 px_ChangeHistory m_history; 640 pf_Fragments m_fragments; 641 typedef std::map<std::string, PD_Style *> StyleMap; 642 StyleMap m_hashStyles; 643 644 struct { 645 PT_AttrPropIndex m_indexCurrentInlineAP; 646 } loading; /* stuff only valid while m_pts==PTS_Loading */ 647 648 PD_Document * m_pDocument; /* back pointer to our document */ 649 650 UT_uint32 m_atomicGlobCount; 651 bool m_bDoingTheDo; 652 bool m_bDoNotTweakPosition; 653 654 UT_uint32 m_iXID; 655 UT_sint32 m_iCurCRNumber; 656 struct embeddedStrux { 657 pf_Frag_Strux * beginNote; 658 pf_Frag_Strux * endNote; 659 PTStruxType type; 660 }; 661 662 std::list <embeddedStrux> m_embeddedStrux; 663 }; 664 665 #endif /* PT_PIECETABLE_H */ 666