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 #ifndef PD_DOCUMENT_H
00026 #define PD_DOCUMENT_H
00027
00028 #include <stdio.h>
00029 #include <string>
00030 #include <vector>
00031 #include <unordered_set>
00032 #include <map>
00033
00034 #include "ut_types.h"
00035 #include "ut_vector.h"
00036 #include "ut_hash.h"
00037 #include "xad_Document.h"
00038 #include "ut_xml.h"
00039 #include "pt_Types.h"
00040 #include "pl_Listener.h"
00041 #include "pf_Frag.h"
00042 #include "ie_FileInfo.h"
00043 #include "fp_PageSize.h"
00044 #include "fl_AutoNum.h"
00045 #include "ut_string_class.h"
00046 #include "ut_misc.h"
00047 #include "px_ChangeRecord.h"
00048 #include "pp_Property.h"
00049
00050 #include <gsf/gsf-input.h>
00051 #include <gsf/gsf-output.h>
00052
00053 #include <list>
00054 #include <memory>
00055
00056 class UT_ByteBuf;
00057 class UT_GrowBuf;
00058 class pt_PieceTable;
00059 class PP_AttrProp;
00060 class PP_Revision;
00061 class PP_RevisionAttr;
00062 class pf_Frag_Strux;
00063 class pf_Frag_Object;
00064 class PX_ChangeRecord;
00065 class PD_Style;
00066 class PD_DocIterator;
00067 class fd_Field;
00068 class po_Bookmark;
00069 class fl_BlockLayout;
00070 class fp_Run;
00071 class UT_UTF8String;
00072 class pp_Author;
00073 class PD_DocumentRDF;
00074 class AP_StatusBar;
00075 class PL_ListenerCoupleCloser;
00076
00077 typedef std::shared_ptr<PD_DocumentRDF> PD_DocumentRDFHandle;
00078
00079 #ifdef PT_TEST
00080 #include "ut_test.h"
00081 #endif
00082
00083 enum
00084 {
00085 PD_SIGNAL_UPDATE_LAYOUT = 0,
00086 PD_SIGNAL_REFORMAT_LAYOUT,
00087 PD_SIGNAL_DOCPROPS_CHANGED_REBUILD,
00088 PD_SIGNAL_DOCPROPS_CHANGED_NO_REBUILD,
00089 PD_SIGNAL_REVISION_MODE_CHANGED,
00090 PD_SIGNAL_DOCNAME_CHANGED,
00091 PD_SIGNAL_DOCDIRTY_CHANGED,
00092 PD_SIGNAL_SAVEDOC,
00093 PD_SIGNAL_DOCCLOSED
00094 };
00095
00097
00099
00100
00101 #define DC_META_PREFIX "dc."
00102
00103
00104 #define ABIWORD_META_PREFIX "abiword."
00105
00106
00107 #define CUSTOM_META_PREFIX "custom."
00108
00110
00112
00113
00114 #define PD_META_KEY_TITLE "dc.title"
00115
00116
00117
00118 #define PD_META_KEY_CREATOR "dc.creator"
00119
00120
00121 #define PD_META_KEY_SUBJECT "dc.subject"
00122
00123
00124 #define PD_META_KEY_DESCRIPTION "dc.description"
00125
00126
00127 #define PD_META_KEY_PUBLISHER "dc.publisher"
00128
00129
00130 #define PD_META_KEY_CONTRIBUTOR "dc.contributor"
00131
00132
00133 #define PD_META_KEY_DATE "dc.date"
00134
00135
00136
00137 #define PD_META_KEY_TYPE "dc.type"
00138
00139
00140
00141 #define PD_META_KEY_FORMAT "dc.format"
00142
00143
00144 #define PD_META_KEY_SOURCE "dc.source"
00145
00146
00147 #define PD_META_KEY_LANGUAGE "dc.language"
00148
00149
00150 #define PD_META_KEY_RELATION "dc.relation"
00151
00152
00153
00154 #define PD_META_KEY_COVERAGE "dc.coverage"
00155
00156
00157 #define PD_META_KEY_RIGHTS "dc.rights"
00158
00160
00162
00163
00164 #define PD_META_KEY_KEYWORDS "abiword.keywords"
00165
00166
00167 #define PD_META_KEY_DATE_LAST_CHANGED "abiword.date_last_changed"
00168
00169
00170 #define PD_META_KEY_GENERATOR "abiword.generator"
00171
00172 class ABI_EXPORT ImagePage
00173 {
00174 public:
00175 ImagePage(UT_UTF8String & sImageId, UT_sint32 iPage, double xInch, double yInch, const char * pzProps);
00176 virtual ~ImagePage(void);
00177 const UT_UTF8String * getImageId(void) const;
00178 UT_sint32 getPageNo(void) const;
00179 double getXInch(void) const;
00180 double getYInch(void) const;
00181 const UT_UTF8String * getProps(void) const;
00182
00183 private:
00184 UT_UTF8String m_sImageId;
00185 UT_sint32 m_iPage;
00186 double m_xInch;
00187 double m_yInch;
00188 UT_UTF8String m_sProps;
00189 };
00190
00194 class ABI_EXPORT TextboxPage
00195 {
00196 public:
00197 TextboxPage(UT_sint32 iPage, double xInch, double yInch,const char * pzProps, UT_ByteBuf & sContent);
00198 virtual ~TextboxPage(void);
00199 const UT_ByteBuf * getContent(void) const;
00200 UT_sint32 getPageNo(void) const;
00201 double getXInch(void) const;
00202 double getYInch(void) const;
00203 const UT_UTF8String * getProps(void) const;
00204 private:
00205 UT_sint32 m_iPage;
00206 double m_xInch;
00207 double m_yInch;
00208 UT_UTF8String m_sProps;
00209 UT_ByteBuf m_sContent;
00210 };
00211
00212 class PD_XMLIDCreatorPrivate;
00213
00214 class ABI_EXPORT PD_XMLIDCreator
00215 {
00216 friend class PD_Document;
00217 PD_Document* m_doc;
00218 PD_XMLIDCreatorPrivate* m_impl;
00219
00220 protected:
00221
00222 PD_XMLIDCreator( PD_Document* doc );
00223 void rebuildCache();
00224
00225 public:
00226
00227 ~PD_XMLIDCreator();
00228 std::string createUniqueXMLID( const std::string& desiredID, bool deepCopyRDF = false );
00229 };
00230 typedef std::shared_ptr<PD_XMLIDCreator> PD_XMLIDCreatorHandle;
00231
00232
00237 class ABI_EXPORT PD_Document : public AD_Document
00238 {
00239 public:
00240 PD_Document();
00241
00242 virtual AD_DOCUMENT_TYPE getType() const {return ADDOCUMENT_ABIWORD;}
00243
00244 virtual UT_Error readFromFile(const char * szFilename, int ieft, const char * impProps = NULL);
00245 virtual UT_Error importFile(const char * szFilename, int ieft, bool markClean = false, bool bImportStylesFirst = true,
00246 const char * impProps = NULL);
00247 UT_Error readFromFile(GsfInput *input, int ieft, const char * impProps = NULL);
00248 UT_Error importFile(GsfInput *input, int ieft, bool markClean = false, bool bImportStylesFirst = true,
00249 const char * impProps = NULL);
00250 virtual UT_Error importStyles(const char * szFilename, int ieft, bool bDocProps = false);
00251 AP_StatusBar * getStatusBar(void);
00252 void updateStatus(void);
00253 virtual UT_Error newDocument(void);
00254
00255 UT_Error saveAs(GsfOutput * output, int ieft, bool cpy = false, const char * expProps = NULL);
00256
00257
00258 UT_Error createRawDocument(void);
00259 void finishRawCreation(void);
00260
00261 virtual bool isDirty(void) const;
00262 virtual void forceDirty();
00263 bool isConnected(void);
00264 virtual bool canDo(bool bUndo) const;
00265 virtual UT_uint32 undoCount(bool bUndo) const;
00266 virtual bool undoCmd(UT_uint32 repeatCount);
00267 virtual bool redoCmd(UT_uint32 repeatCount);
00268 bool isDoingTheDo(void) const;
00269
00270
00271
00272 void removeCaret(const std::string& sCaretID);
00273
00274
00275
00276 void addPageReferencedImage(UT_UTF8String & sImageId, UT_sint32 iPage, double xInch, double yInch, const char * pzProps);
00277 void addPageReferencedTextbox(UT_ByteBuf & sContent,UT_sint32 iPage, double xInch, double yInch,const char * pzProps);
00278 ImagePage * getNthImagePage(UT_sint32 iImagePage);
00279 TextboxPage * getNthTextboxPage(UT_sint32 iTextboxPage);
00280 void clearAllPendingObjects(void);
00281
00282
00283
00284 void setShowAuthors(bool bAuthors);
00285 bool isShowAuthors(void) const
00286 { return m_bShowAuthors;}
00287 bool isExportAuthorAtts(void) const;
00288 void setExportAuthorAtts(bool bExport);
00289 UT_GenericVector<pp_Author*>& getAuthors()
00290 { return m_vecAuthors; }
00291 UT_sint32 getMyAuthorInt(void) const;
00292 void setMyAuthorInt(UT_sint32 iAuthor);
00293 UT_sint32 getLastAuthorInt(void) const;
00294 UT_sint32 getNumAuthors(void) const;
00295 pp_Author * getNthAuthor(UT_sint32 i) const;
00296 pp_Author * getAuthorByInt(UT_sint32 i) const;
00297 pp_Author * addAuthor(UT_sint32 iAuthor);
00298 bool sendAddAuthorCR(pp_Author * pAuthor);
00299 bool sendChangeAuthorCR(pp_Author * pAuthor);
00300 UT_sint32 findFirstFreeAuthorInt(void) const;
00301 private:
00302 bool addAuthorAttributeIfBlank(PP_PropertyVector & atts);
00303 bool addAuthorAttributeIfBlank( PP_AttrProp *&p_AttrProp);
00304 bool _buildAuthorProps(pp_Author * pAuthor, PP_PropertyVector & props);
00305 public:
00306
00307 void beginUserAtomicGlob(void);
00308 void endUserAtomicGlob(void);
00309 void setMarginChangeOnly(bool b);
00310 bool isMarginChangeOnly(void) const;
00311 bool changeObjectFormatNoUpdate(PTChangeFmt ptc, pf_Frag_Object* odh, const PP_PropertyVector & attributes,const PP_PropertyVector & properties );
00312 PT_AttrPropIndex getAPIFromSOH(pf_Frag_Object* odh);
00313 bool insertObject(PT_DocPosition dpos,
00314 PTObjectType pto,
00315 const PP_PropertyVector & attributes,
00316 const PP_PropertyVector & properties);
00317 bool insertObject(PT_DocPosition dpos,
00318 PTObjectType pto,
00319 const PP_PropertyVector & attributes,
00320 const PP_PropertyVector & properties, fd_Field ** pField );
00321
00322 bool insertSpan(PT_DocPosition dpos,
00323 const UT_UCSChar * p,
00324 UT_uint32 length,
00325 PP_AttrProp *p_AttrProp = NULL,
00326 UT_uint32 * insertedSpanLength = NULL);
00327 bool insertSpan(PT_DocPosition dpos,
00328 const std::string& s,
00329 PP_AttrProp *p_AttrProp = NULL);
00330
00331 bool deleteSpan(PT_DocPosition dpos1,
00332 PT_DocPosition dpos2,
00333 PP_AttrProp *p_AttrProp_Before,
00334 UT_uint32 &iRealDeleteCount,
00335 bool bDeleteTableStruxes = false);
00336
00337 bool deleteFmtMark( PT_DocPosition dpos);
00338
00339 bool changeSpanFmt(PTChangeFmt ptc,
00340 PT_DocPosition dpos1,
00341 PT_DocPosition dpos2,
00342 const PP_PropertyVector & attributes,
00343 const PP_PropertyVector & properties);
00344
00345 bool insertStrux(PT_DocPosition dpos,
00346 PTStruxType pts, pf_Frag_Strux ** ppfs_ret = 0);
00347 bool deleteStrux(PT_DocPosition dpos,
00348 PTStruxType pts,
00349 bool bRecordChange);
00350
00351 bool createAndSendCR(PT_DocPosition dpos,UT_sint32 iType,bool bsave,UT_Byte iGlob);
00352
00353 virtual bool createAndSendDocPropCR( const gchar ** pAtts,const gchar ** pProps );
00354 bool createAndSendDocPropCR(const PP_PropertyVector & pAtts,const PP_PropertyVector & pProps);
00355 bool changeDocPropeties(const PP_PropertyVector & szAtts, const PP_PropertyVector & pProps);
00356
00357 bool insertStrux(PT_DocPosition dpos,
00358 PTStruxType pts,
00359 const PP_PropertyVector & attributes,
00360 const PP_PropertyVector & properties,
00361 pf_Frag_Strux ** ppfs_ret = NULL);
00362
00363 void deleteHdrFtrStrux(pf_Frag_Strux* sdh);
00364
00365 bool changeStruxFmt(PTChangeFmt ptc,
00366 PT_DocPosition dpos1,
00367 PT_DocPosition dpos2,
00368 const PP_PropertyVector & attributes,
00369 const PP_PropertyVector & properties,
00370 PTStruxType pts);
00371
00372 bool changeStruxFmt(PTChangeFmt ptc,
00373 PT_DocPosition dpos1,
00374 PT_DocPosition dpos2,
00375 const PP_PropertyVector & attributes,
00376 const PP_PropertyVector & properties);
00377
00378
00379 bool changeStruxFmtNoUndo(PTChangeFmt ptc,
00380 pf_Frag_Strux* sdh,
00381 const PP_PropertyVector & attributes,
00382 const PP_PropertyVector & properties);
00383
00384 bool changeStruxForLists(pf_Frag_Strux* sdh,
00385 const char * pszParentID);
00386
00387 bool insertFmtMark(PTChangeFmt ptc,
00388 PT_DocPosition dpos,
00389 PP_AttrProp *p_AttrProp);
00390
00391 bool changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts,
00392 const PP_PropertyVector & attrs, const PP_PropertyVector & props,
00393 bool bSkipEmbededSections);
00394
00395 bool changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts,
00396 const PP_PropertyVector & attrs, const std::string & props,
00397 bool bSkipEmbededSections);
00398
00399
00400
00401
00402 bool appendStrux(PTStruxType pts, const PP_PropertyVector & attributes, pf_Frag_Strux ** ppfs_ret = 0);
00403 bool appendStruxFmt(pf_Frag_Strux * pfs, const PP_PropertyVector & attributes);
00404 bool appendLastStruxFmt(PTStruxType pts, const PP_PropertyVector & attrs, const PP_PropertyVector & props,
00405 bool bSkipEmbededSections);
00406 bool appendLastStruxFmt(PTStruxType pts, const PP_PropertyVector & attrs, const std::string & props,
00407 bool bSkipEmbededSections);
00408 bool appendFmt(const PP_PropertyVector & vecAttributes);
00409 bool appendSpan(const UT_UCSChar * p, UT_uint32 length);
00410 bool appendObject(PTObjectType pto, const PP_PropertyVector & attributes);
00411 bool appendFmtMark(void);
00412 bool appendStyle(const PP_PropertyVector & attributes);
00413 bool changeStruxFormatNoUpdate(PTChangeFmt ptc, pf_Frag_Strux* sdh, const PP_PropertyVector & attributes);
00414 bool insertStruxBeforeFrag(pf_Frag * pF, PTStruxType pts,
00415 const PP_PropertyVector & attributes, pf_Frag_Strux ** ppfs_ret = 0);
00416 bool insertSpanBeforeFrag(pf_Frag * pF, const UT_UCSChar * p, UT_uint32 length);
00417 bool insertObjectBeforeFrag(pf_Frag * pF, PTObjectType pto,
00418 const PP_PropertyVector & attributes);
00419 bool insertFmtMarkBeforeFrag(pf_Frag * pF);
00420 bool insertFmtMarkBeforeFrag(pf_Frag * pF, const PP_PropertyVector & attributes);
00421
00422 pf_Frag * findFragOfType(pf_Frag::PFType iType, UT_sint32 iSubtype = -1,
00423 pf_Frag * pfStart = NULL) const;
00424 pf_Frag * getLastFrag() const;
00425 bool checkForSuspect(void);
00426 bool repairDoc(void);
00427 bool removeStyle(const gchar * name);
00428 bool tellListener(PL_Listener * pListener);
00429 bool tellListenerSubset( PL_Listener * pListener,
00430 PD_DocumentRange * pDocRange,
00431 PL_ListenerCoupleCloser* closer = 0 );
00432 bool addListener(PL_Listener * pListener, PL_ListenerId * pListenerId);
00433 bool removeListener(PL_ListenerId listenerId);
00434 bool signalListeners(UT_uint32 iSignal) const;
00435 bool notifyListeners(const pf_Frag_Strux * pfs, const PX_ChangeRecord * pcr) const;
00436 bool notifyListeners(const pf_Frag_Strux * pfs,
00437 pf_Frag_Strux * pfsNew,
00438 const PX_ChangeRecord * pcr) const;
00439 void deferNotifications(void);
00440 void processDeferredNotifications(void);
00441 UT_sint32 getAdjustmentForCR(const PX_ChangeRecord * pcr) const;
00442
00443
00444
00445 bool getAttrProp(PT_AttrPropIndex indexAP, const PP_AttrProp ** ppAP) const;
00446 bool getSpanAttrProp(pf_Frag_Strux* sdh, UT_uint32 offset, bool bLeftSide,
00447 const PP_AttrProp ** ppAP) const;
00448
00449 bool getAttrProp(PT_AttrPropIndex apIndx, const PP_AttrProp ** ppAP, std::unique_ptr<PP_RevisionAttr>& pRevisions,
00450 bool bShowRevisions, UT_uint32 iRevisionId, bool &bHiddenRevision) const;
00451
00452 bool getSpanAttrProp(pf_Frag_Strux* sdh, UT_uint32 offset, bool bLeftSide,
00453 const PP_AttrProp ** ppAP,
00454 std::unique_ptr<PP_RevisionAttr>& pRevisions,
00455 bool bShowRevisions, UT_uint32 iRevisionId,
00456 bool &bHiddenRevision) const;
00457
00458 const UT_UCSChar * getPointer(PT_BufIndex bi) const;
00459 bool getBlockBuf(pf_Frag_Strux* sdh, UT_GrowBuf * pgb) const;
00460
00461 bool getBounds(bool bEnd, PT_DocPosition & docPos) const;
00462 PTStruxType getStruxType(pf_Frag_Strux* sdh) const;
00463 PT_DocPosition getStruxPosition(pf_Frag_Strux* sdh) const;
00464 bool getStruxFromPosition(PL_ListenerId listenerId,
00465 PT_DocPosition docPos,
00466 fl_ContainerLayout* * psfh) const;
00467 bool getStruxOfTypeFromPosition(PL_ListenerId listenerId,
00468 PT_DocPosition docPos,
00469 PTStruxType pts,
00470 fl_ContainerLayout* * psfh) const;
00471 bool getStruxOfTypeFromPosition(PT_DocPosition, PTStruxType pts, pf_Frag_Strux* * sdh) const;
00472 pf_Frag_Strux* getBlockFromPosition( PT_DocPosition pos ) const;
00473
00474 pf_Frag * getFragFromPosition(PT_DocPosition docPos) const;
00475
00476 bool getNextStruxOfType(pf_Frag_Strux* sdh,PTStruxType pts,
00477 pf_Frag_Strux* * nextsdh);
00478 bool getPrevStruxOfType(pf_Frag_Strux* sdh,PTStruxType pts,
00479 pf_Frag_Strux* * prevsdh);
00480 bool getNextStrux(pf_Frag_Strux* sdh, pf_Frag_Strux* *nextSDH);
00481
00482
00483
00484 virtual bool createDataItem(const char * szName, bool bBase64,
00485 const UT_ConstByteBufPtr & pByteBuf,
00486 const std::string & mime_type,
00487 PD_DataItemHandle* ppHandle);
00488 virtual bool replaceDataItem(const char * szName,
00489 const UT_ConstByteBufPtr & pByteBuf);
00490 virtual bool getDataItemDataByName(const char * szName,
00491 UT_ConstByteBufPtr & pByteBuf,
00492 std::string* pMimeType,
00493 PD_DataItemHandle* ppHandle) const;
00494 bool setDataItemToken(PD_DataItemHandle pHandle, void* pToken) const;
00495 bool getDataItemData(PD_DataItemHandle pHandle,
00496 const char ** pszName, UT_ConstByteBufPtr & pByteBuf,
00497 const void** ppToken) const;
00498 bool getDataItemFileExtension(const char *szDataID, std::string &sExt, bool bDot = true) const;
00499 bool enumDataItems(UT_uint32 k,
00500 PD_DataItemHandle* ppHandle, const char ** pszName,
00501 UT_ConstByteBufPtr & pByteBuf, std::string * pMimeType) const;
00502
00503 pf_Frag_Strux* findHdrFtrStrux(const gchar * pszHdtFtr,
00504 const gchar * pszHdrFtrID);
00505 bool verifySectionID(const gchar * pszId);
00506 const pf_Frag_Strux* getLastSectionSDH(void) const;
00507 pf_Frag_Strux* getLastSectionMutableSDH(void);
00508 pf_Frag_Strux* getLastStruxOfType(PTStruxType pts);
00509
00510 bool changeStruxAttsNoUpdate(pf_Frag_Strux* sdh, const char * attr, const char * attvalue);
00511 bool deleteStruxNoUpdate(pf_Frag_Strux* sdh);
00512 bool deleteFragNoUpdate(pf_Frag * pf);
00513 bool insertStruxNoUpdateBefore(pf_Frag_Strux* sdh, PTStruxType pts, const PP_PropertyVector & attributes );
00514 bool isStruxBeforeThis(pf_Frag_Strux* sdh, PTStruxType pts);
00515
00516
00517
00518
00519 PT_AttrPropIndex getAPIFromSDH(pf_Frag_Strux* sdh);
00520 bool getAttributeFromSDH(pf_Frag_Strux* sdh, bool bShowRevisions, UT_uint32 iRevisionLevel,
00521 const char * szAttribute, const char ** pszValue);
00522
00523 bool getPropertyFromSDH(const pf_Frag_Strux* sdh, bool bShowRevisions, UT_uint32 iRevisionLevel,
00524 const char * szProperty, const char ** pszValue) const;
00525
00526 void getAllUsedStyles(UT_GenericVector<PD_Style*> * pVecStyles);
00527 fl_ContainerLayout* getNthFmtHandle(pf_Frag_Strux* sdh, UT_uint32 n);
00528 const char * getDefaultStyle() const;
00529 bool getStyle(const char * szName, PD_Style ** ppStyle) const;
00530 PD_Style * getStyleFromSDH(pf_Frag_Strux* sdh);
00531 pf_Frag_Strux* getPrevNumberedHeadingStyle(pf_Frag_Strux* sdh);
00532 size_t getStyleCount(void);
00533 bool enumStyles(UT_uint32 k,
00534 const char ** pszName, const PD_Style ** ppStyle) const;
00535 bool enumStyles(UT_GenericVector<PD_Style*> * & pStyles) const;
00536 bool getStyleProperty(const gchar * szStyleName, const gchar * szPropertyName, const gchar *& szPropertyValue);
00537 bool addStyleProperty(const gchar * szStyleName, const gchar * szPropertyName, const gchar * szPropertyValue);
00538 bool addStyleProperties(const gchar * szStyleName, const PP_PropertyVector & pProperties);
00539 bool setAllStyleAttributes(const gchar * szStyleName, const PP_PropertyVector & pAttribs);
00540 bool addStyleAttributes(const gchar * szStyleName, const PP_PropertyVector & pAttribs);
00541
00542 pf_Frag_Strux* findPreviousStyleStrux(const gchar * szStyle, PT_DocPosition pos);
00543 pf_Frag_Strux* findForwardStyleStrux(const gchar * szStyle, PT_DocPosition pos);
00544 bool updateDocForStyleChange(const gchar * szStyleName,
00545 bool isParaStyle);
00546 void updateAllLayoutsInDoc( pf_Frag_Strux* sdh);
00547 void clearIfAtFmtMark(PT_DocPosition dpos);
00548
00549 virtual UT_uint32 getLastSavedAsType() const { return m_lastSavedAsType; }
00550 UT_uint32 getLastOpenedType() const { return m_lastOpenedType; }
00551 bool updateFields(void);
00552 bool getField(pf_Frag_Strux* sdh,
00553 UT_uint32 offset,
00554 fd_Field * &pField);
00555 po_Bookmark * getBookmark(pf_Frag_Strux* sdh, UT_uint32 offset);
00556 pf_Frag * findBookmark(const char * pName, bool bEnd = false, pf_Frag * pfStart = NULL);
00557 bool hasMath(void);
00558
00559 void setDontChangeInsPoint(void);
00560 void allowChangeInsPoint(void);
00561 bool getAllowChangeInsPoint(void) const;
00562
00563 bool isFootnoteAtPos(PT_DocPosition pos);
00564 bool isEndFootnoteAtPos(PT_DocPosition pos);
00565 UT_sint32 getEmbeddedOffset(pf_Frag_Strux* sdh,PT_DocPosition posOff, pf_Frag_Strux* & sdhEmbedded);
00566 bool hasEmbedStruxOfTypeInRange(PT_DocPosition posStart, PT_DocPosition posEnd,
00567 PTStruxType iType) const;
00568
00569
00570 bool isTOCAtPos(PT_DocPosition pos);
00571
00572
00573 bool isFrameAtPos(PT_DocPosition pos);
00574 bool isEndFrameAtPos(PT_DocPosition pos);
00575 bool isHdrFtrAtPos(PT_DocPosition pos);
00576 bool isSectionAtPos(PT_DocPosition pos);
00577 bool isBlockAtPos(PT_DocPosition pos);
00578
00579
00580
00581 bool isTableAtPos(PT_DocPosition pos);
00582 bool isEndTableAtPos(PT_DocPosition pos);
00583 bool isCellAtPos(PT_DocPosition pos);
00584 pf_Frag_Strux* getEndTableStruxFromTableSDH(pf_Frag_Strux* tableSDH);
00585 pf_Frag_Strux* getEndCellStruxFromCellSDH(pf_Frag_Strux* cellSDH);
00586 pf_Frag_Strux* getEndTableStruxFromTablePos(PT_DocPosition posTable);
00587 bool getRowsColsFromTableSDH(pf_Frag_Strux* tableSDH,
00588 bool bShowRevisions, UT_uint32 iRevisionLevel,
00589 UT_sint32 * numRows, UT_sint32 * numCols);
00590 pf_Frag_Strux* getCellSDHFromRowCol(pf_Frag_Strux* tableSDH,
00591 bool bShowRevisions, UT_uint32 iRevisionLevel,
00592 UT_sint32 row,
00593 UT_sint32 col);
00594 void miniDump(pf_Frag_Strux* sdh, UT_sint32 nstruxes);
00595 bool dumpDoc( const char* msg, PT_DocPosition currentpos, PT_DocPosition endpos );
00596
00597 bool isInsertHyperLinkValid(PT_DocPosition pos) const;
00598
00599
00600
00601 fl_AutoNumPtr getListByID(UT_uint32 id) const;
00602 fl_AutoNumPtr getNthList(UT_uint32 i) const;
00603 bool enumLists(UT_uint32 k, fl_AutoNumConstPtr & pAutoNum);
00604 UT_uint32 getListsCount(void) const;
00605 void addList(const fl_AutoNumPtr & pAutoNum);
00606 bool appendList(const PP_PropertyVector & attributes);
00607 bool fixListHierarchy(void);
00608 void removeList(const fl_AutoNumPtr & pAutoNum, pf_Frag_Strux* sdh);
00609 void listUpdate(pf_Frag_Strux* sdh);
00610 void StopList(pf_Frag_Strux* sdh);
00611 void disableListUpdates(void);
00612 void enableListUpdates(void);
00613 void updateDirtyLists(void);
00614 bool areListUpdatesAllowed(void);
00615 void setHasListStopped(bool bStop) {m_bHasListStopped = bStop;}
00616 bool hasListStopped(void) const {return m_bHasListStopped;}
00617
00618 void setDoingPaste(void);
00619 void clearDoingPaste(void);
00620 bool isDoingPaste(void);
00621
00622 void setRedrawHappenning(bool bIsHappening) {m_bRedrawHappenning = bIsHappening;}
00623 bool isRedrawHappenning(void) const {return m_bRedrawHappenning;}
00624
00625
00626 bool convertPercentToInches(const char * szPercent, UT_UTF8String & sInches);
00627 bool setPageSizeFromFile(const PP_PropertyVector & attributes);
00628 const fp_PageSize * getPageSize(void) const
00629 { return & m_docPageSize;}
00630 fp_PageSize m_docPageSize;
00631 bool isBookmarkUnique(const gchar * pName) const;
00632 bool isBookmarkRelativeLink(const gchar * pName) const;
00633 UT_sint32 getBookmarkCount() const {return m_vBookmarkNames.size();}
00634 const std::string & getNthBookmark(UT_sint32 n) const {return m_vBookmarkNames.at(n);}
00635 void addBookmark(const gchar * pName);
00636 void removeBookmark(const gchar * pName);
00637
00639
00640
00641 virtual void setMarkRevisions(bool bMark);
00642
00643 void setMarkRevisionsNoNotify(bool bMark) {AD_Document::setMarkRevisions(bMark);}
00644
00645 virtual bool acceptRejectRevision(bool bReject,
00646 UT_uint32 iStart,
00647 UT_uint32 iEnd,
00648 UT_uint32 iLevel);
00649
00650 virtual bool rejectAllHigherRevisions(UT_uint32 iLevel);
00651 virtual bool acceptAllRevisions();
00652
00653 const PP_AttrProp * explodeRevisions(std::unique_ptr<PP_RevisionAttr>& pRevisions, const PP_AttrProp * pAP,
00654 bool bShow, UT_uint32 iId, bool &bHiddenRevision) const;
00655
00656 virtual void purgeRevisionTable(bool bUnconditional = false);
00657
00658 void notifyPieceTableChangeStart(void);
00659 void notifyPieceTableChangeEnd(void);
00660
00661
00662
00663 pt_PieceTable * getPieceTable(void) const
00664 { return m_pPieceTable; }
00665 PD_DocumentRDFHandle getDocumentRDF(void) const;
00666 PD_XMLIDCreatorHandle makeXMLIDCreator();
00667
00668 #ifdef PT_TEST
00669 void __dump(FILE * fp) const;
00671 static PD_Document* m_pDoc;
00672 #endif
00673
00674
00675
00676 inline bool areStylesLocked () const { return m_bLockedStyles; }
00677 void lockStyles(bool b);
00678
00679 virtual void setMetaDataProp (const std::string & key, const std::string & value);
00680 virtual bool getMetaDataProp (const std::string & key, std::string & outProp) const;
00681
00682
00683 virtual void setAnnotationProp (const std::string & key, const std::string & value);
00684 virtual bool getAnnotationProp (const std::string & key, std::string & outProp) const;
00685
00686 const std::map<std::string,std::string> & getMetaData () const
00687 {
00688 return m_metaDataMap ;
00689 }
00690
00691
00692 const PP_AttrProp * getAttrProp() const;
00693 PT_AttrPropIndex getAttrPropIndex() const {return m_indexAP;}
00694 bool setAttrProp(const PP_PropertyVector & ppAttr);
00695 bool setAttributes(const PP_PropertyVector & ppAttr);
00696 bool setProperties(const PP_PropertyVector & ppProps);
00697 void setDontImmediatelyLayout(bool b)
00698 { m_bDontImmediatelyLayout = b;}
00699 bool isDontImmediateLayout(void) const
00700 { return m_bDontImmediatelyLayout;}
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711 std::string getMailMergeField(const std::string & key) const;
00712 bool mailMergeFieldExists(const std::string & key) const;
00713 void setMailMergeField(const std::string & key, const std::string & value);
00714
00715 void clearMailMergeMap();
00716
00717 void setMailMergeLink (const char * file) {
00718 m_mailMergeLink = file;
00719 }
00720
00721 const std::string & getMailMergeLink() const { return m_mailMergeLink; }
00722 const std::map<std::string, std::string> & getMailMergeMap() const { return m_mailMergeMap; }
00723
00724 void invalidateCache(void);
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752 UT_uint32 getUID(UT_UniqueId::idType t) {return m_UID.getUID(t);}
00753 bool setMinUID(UT_UniqueId::idType t, UT_uint32 i) {return m_UID.setMinId(t,i);}
00754 bool isIdUnique(UT_UniqueId::idType t, UT_uint32 i) const {return m_UID.isIdUnique(t,i);}
00755
00756 virtual bool areDocumentContentsEqual(const AD_Document &d, UT_uint32 &pos) const;
00757 virtual bool areDocumentFormatsEqual(const AD_Document &d, UT_uint32 &pos) const;
00758 virtual bool areDocumentStylesheetsEqual(const AD_Document &d) const;
00759
00760 bool findFirstDifferenceInContent(PT_DocPosition &pos, UT_sint32 &iOffset2,
00761 const PD_Document &d) const;
00762
00763 bool findWhereSimilarityResumes(PT_DocPosition &pos, UT_sint32 &iOffset2,
00764 UT_uint32 & iKnownLength,
00765 const PD_Document &d) const;
00766
00767 virtual void setAutoRevisioning(bool autorev);
00768
00769 virtual UT_uint32 getXID() const;
00770 virtual UT_uint32 getTopXID() const;
00771 void fixMissingXIDs();
00772 UT_uint32 getFragXIDforVersion(const pf_Frag * pf, UT_uint32 iVersion) const;
00773 void removeConnections(void);
00774 void changeConnectedDocument(PD_Document * pDoc);
00775 UT_sint32 getNewHdrHeight(void) const
00776 { return m_iNewHdrHeight;}
00777 UT_sint32 getNewFtrHeight(void) const
00778 { return m_iNewFtrHeight;}
00779
00780 void setNewHdrHeight(UT_sint32 newHeight)
00781 { m_iNewHdrHeight = newHeight;}
00782 void setNewFtrHeight(UT_sint32 newHeight)
00783 { m_iNewFtrHeight = newHeight;}
00784
00785 bool purgeFmtMarks();
00786
00787 void tellPTDoNotTweakPosition(bool b);
00788
00789 void setVDNDinProgress(bool b) {m_bVDND = b;}
00790 bool isVDNDinProgress() const {return m_bVDND;}
00791 UT_sint32 getCRNumber() const { return m_iCRCounter; }
00792 void setCRNumber(UT_sint32 iCRCounter) { m_iCRCounter = iCRCounter; }
00793 UT_sint32 getNextCRNumber(void);
00794 std::list<AV_View*> getAllViews() const;
00795 void getAllViews(UT_GenericVector<AV_View *> * vecViews) const;
00796 void ignoreSignals(void)
00797 { m_bIgnoreSignals = true;}
00798 void dontIgnoreSignals(void)
00799 { m_bIgnoreSignals = false;}
00800 void setClean(void)
00801 { _setClean();}
00802
00803 void setCoalescingMask(bool mask)
00804 { m_bCoalescingMask = mask; }
00805 bool isCoalescingMasked() const
00806 { return m_bCoalescingMask; }
00807 protected:
00808 virtual ~PD_Document();
00809
00810 virtual UT_Error _saveAs(const char * szFilename, int ieft, const char * expProps = NULL);
00811 virtual UT_Error _saveAs(const char * szFilename, int ieft, bool cpy, const char * expProps = NULL);
00812 virtual UT_Error _saveAs(GsfOutput *output, int ieft, bool cpy, const char * expProps);
00813 virtual UT_Error _save(void);
00814
00815
00816 void _setClean(void);
00817 void _destroyDataItemData(void);
00818 bool _syncFileTypes(bool bReadSaveWriteOpen);
00819
00820 bool _acceptRejectRevision(bool bReject, UT_uint32 iStart, UT_uint32 iEnd,
00821 const PP_Revision * pRev,
00822 PP_RevisionAttr &RevAttr, pf_Frag * pf,
00823 bool & bDeleted);
00824
00825 virtual void _clearUndo();
00826
00827 UT_Error _importFile(const char * szFilename, int ieft,
00828 bool markClean, bool bImportStylesFirst,
00829 bool isImportFile, const char* impProps);
00830 UT_Error _importFile(GsfInput * input, int ieft,
00831 bool markClean, bool bImportStylesFirst,
00832 bool bIsImportFile, const char* impProps);
00833
00834 bool _removeRepeatedHdrFtr(pf_Frag_Strux * pfs ,UT_GenericVector<pf_Frag_Strux *> * vecHdrFtrs, UT_sint32 i);
00835 bool _pruneSectionAPI(pf_Frag_Strux * pfs,const char * szHType, UT_GenericVector<pf_Frag_Strux *> *vecHdrFtrs);
00836 bool _matchSection(pf_Frag_Strux * pfs, UT_GenericVector<pf_Frag_Strux *> *vecSections);
00837 bool _removeHdrFtr(pf_Frag_Strux * pfs);
00838 bool _checkAndFixTable(pf_Frag_Strux * pfs);
00839 public:
00840
00841
00842
00843
00844 bool exportGetVisDirectionAtPos(PT_DocPosition pos, UT_BidiCharType &type);
00845 private:
00846 bool _exportInitVisDirection(PT_DocPosition pos);
00847 bool _exportFindVisDirectionRunAtPos(PT_DocPosition pos);
00848
00849 bool _sendAuthorCR(const char *attrName,
00850 pp_Author *pAuthor);
00851 private:
00852 bool m_ballowListUpdates;
00853 pt_PieceTable * m_pPieceTable;
00854 PD_DocumentRDFHandle m_hDocumentRDF;
00855 UT_GenericVector<PL_Listener *> m_vecListeners;
00856 std::vector<fl_AutoNumPtr> m_vecLists;
00857 std::unordered_map<UT_uint32, fl_AutoNumPtr> m_mapLists;
00858 bool m_bHasListStopped;
00859
00860 typedef std::map<std::string, PD_DataItemHandle> hash_data_items_t;
00861 hash_data_items_t m_hashDataItems;
00862 public:
00863 IE_FileInfo m_fileImpExpInfo;
00864 private:
00865 IEFileType m_lastOpenedType;
00866 IEFileType m_lastSavedAsType;
00867 bool m_bDoingPaste;
00868 bool m_bAllowInsertPointChange;
00869 bool m_bRedrawHappenning;
00870 bool m_bLoading;
00871 std::vector<std::string> m_vBookmarkNames;
00872 bool m_bLockedStyles;
00873 std::map<std::string, std::string> m_metaDataMap;
00874 PT_AttrPropIndex m_indexAP;
00875 bool m_bDontImmediatelyLayout;
00876
00877 std::map<std::string, std::string> m_mailMergeMap;
00878
00879 UT_UCS4Char m_iLastDirMarker;
00880
00881 std::string m_mailMergeLink;
00882
00883
00884 const fl_BlockLayout * m_pVDBl;
00885 fp_Run * m_pVDRun;
00886 PT_DocPosition m_iVDLastPos;
00887 UT_UniqueId m_UID;
00888 UT_sint32 m_iNewHdrHeight;
00889 UT_sint32 m_iNewFtrHeight;
00890 bool m_bMarginChangeOnly;
00891 UT_GenericVector<pf_Frag *> m_vecSuspectFrags;
00892
00893 bool m_bVDND;
00894 UT_sint32 m_iCRCounter;
00895 mutable UT_sint32 m_iUpdateCount;
00896 bool m_bIgnoreSignals;
00897
00898 bool m_bCoalescingMask;
00899 bool m_bShowAuthors;
00900 UT_GenericVector<pp_Author *> m_vecAuthors;
00901 bool m_bExportAuthorAtts;
00902 UT_sint32 m_iMyAuthorInt;
00903 UT_sint32 m_iLastAuthorInt;
00904 UT_GenericVector<ImagePage *> m_pPendingImagePage;
00905 UT_GenericVector<TextboxPage *> m_pPendingTextboxPage;
00906 UT_sint32 m_iStruxCount;
00907 std::string m_sUserName;
00908 public:
00909 const std::string &getUserName() const { return m_sUserName; }
00910 };
00911
00912 #endif