• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pd_Document.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: t -*- */
00002 
00003 /* AbiWord
00004  * Copyright (C) 1998 AbiSource, Inc.
00005  * Copyright (c) 2001,2002 Tomas Frydrych
00006  * Copyright (c) 2016 Hubert Figuière
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License
00010  * as published by the Free Software Foundation; either version 2
00011  * of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00021  * 02110-1301 USA.
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 // TODO: remove this
00094 };
00095 
00097 // proper prefixes for the namespaces that we support
00099 
00100 // Dublin Core Namespace (http://dublincore.org/documents/dces/)
00101 #define DC_META_PREFIX      "dc."
00102 
00103 // AbiWord Namespace
00104 #define ABIWORD_META_PREFIX "abiword."
00105 
00106 // User-defined custom namespace
00107 #define CUSTOM_META_PREFIX  "custom."
00108 
00110 // The key names for our in-house metadata
00112 
00113 // A formal name given to the resource
00114 #define PD_META_KEY_TITLE        "dc.title"
00115 
00116 // An entity primarily responsible for making the content of the resource
00117 // typically a person, organization, or service
00118 #define PD_META_KEY_CREATOR      "dc.creator"
00119 
00120 // The topic of the content of the resource, *typically* including keywords
00121 #define PD_META_KEY_SUBJECT      "dc.subject"
00122 
00123 // An account of the content of the resource
00124 #define PD_META_KEY_DESCRIPTION  "dc.description"
00125 
00126 // An entity responsible for making the resource available
00127 #define PD_META_KEY_PUBLISHER    "dc.publisher"
00128 
00129 // An entity responsible for making contributions to the content of the resource
00130 #define PD_META_KEY_CONTRIBUTOR  "dc.contributor"
00131 
00132 // A date associated with an event in the life cycle of the resource
00133 #define PD_META_KEY_DATE         "dc.date"
00134 
00135 // The nature or genre of the content of the resource
00136 // See http://dublincore.org/documents/dcmi-type-vocabulary/
00137 #define PD_META_KEY_TYPE         "dc.type"
00138 
00139 // The physical or digital manifestation of the resource. mime-type-ish
00140 // always application/x-abiword
00141 #define PD_META_KEY_FORMAT       "dc.format"
00142 
00143 // A Reference to a resource from which the present resource is derived
00144 #define PD_META_KEY_SOURCE       "dc.source"
00145 
00146 // A language of the intellectual content of the resource
00147 #define PD_META_KEY_LANGUAGE     "dc.language"
00148 
00149 // A reference to a related resource (see-also)
00150 #define PD_META_KEY_RELATION     "dc.relation"
00151 
00152 // The extent or scope of the content of the resource
00153 // spatial location, temporal period, or jurisdiction
00154 #define PD_META_KEY_COVERAGE     "dc.coverage"
00155 
00156 // Information about rights held in and over the resource
00157 #define PD_META_KEY_RIGHTS       "dc.rights"
00158 
00160 // abiword extensions to the dublin core element set
00162 
00163 // searchable, indexable keywords
00164 #define PD_META_KEY_KEYWORDS          "abiword.keywords"
00165 
00166 // the last time this document was saved
00167 #define PD_META_KEY_DATE_LAST_CHANGED "abiword.date_last_changed"
00168 
00169 // the creator (product) of this document. AbiWord, KWord, etc...
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     // Caret Methods
00271 
00272     void                    removeCaret(const std::string& sCaretID);
00273 
00274     // Page Referenced methods
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     // Author methods
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     // XXX PP_PropertyVector is not visible in xad_Document
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     // the append- and insertBeforeFrag methods are only available while importing
00400     // the document.
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     // the first two of these functions just retrieve the AP with the given index; the latter two
00444     // return AP that represents state of things with current revision settings
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; /* see warning on this function */
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     // data items
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     // the function below does exactly what the name says -- returns the AP index; in revisions mode
00517     // you would need the AP at that index to have revision attribute exploded -- use one of the
00518     // functions below to retrieve props and attrs correctly reflecting revisions settings
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     // styles
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     // Footnote functions
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     // TOC functions
00570     bool                    isTOCAtPos(PT_DocPosition pos);
00571 
00572     // FRAME function
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 // Table functions
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     // List Functions
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     // PageSize functions
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; // Move this to private later
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     // Functions for dealing with revisions
00640     //
00641     virtual void            setMarkRevisions(bool bMark);
00642     // primarly for use by the PieceTable
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     // If we're using styles to format a document, prevent accidental use of other formatting
00675         // tools.  Disable all explicit formatting tools (font, color, boldness, etc.)
00676     inline bool areStylesLocked () const { return m_bLockedStyles; }    // See also lockStyles
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     // RIVERA TODO not working and may not be needed
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     // document-level property handling functions
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     /* Okay, as far as I can tell this is a non-persistent document property since it is not
00703      * written to the AbiWord file when the document is saved. In fact, it is only set if a
00704      * mail-merge source/link is given on the command line.
00705      *
00706      * Mail merge fields are, naturally, saved and loaded, but the Insert->Mail Merge Field...
00707      * dialog doesn't reflect the current document's fields but rather some internal set of
00708      * fields, which is confusing if you are trying to work with muliple mail merge sources.
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        The purpose of the following methods is to generate and manage
00728        document-wide unique identifiers; the indetifiers are type
00729        specific, with the types defined in UT_UniqueId class (ut_mics.h).
00730 
00731        UT_uint32 getUID(type):    Generates an id of a given type or
00732                                   UT_UID_INVALID if unique id cannot
00733                                   be generated (0 <= uid < UT_UID_INVALID).
00734 
00735        bool isIdUnique(type, id): Returns true if a given id can be
00736                                   used as a unique identifier of a
00737                                   given type; before the identifier is
00738                                   used, the caller should call
00739                                   setMinUID(id+1) to ensure integrity of
00740                                   the UID generator.
00741 
00742        bool setMinUID(type, uid): Allows to set a minimum value for all
00743                                   future identifiers; it returns true on
00744                                   success false on failure. The purpose is
00745                                   to allow an easy insertion of
00746                                   document-stored id's into the UID space
00747                                   by document importers: if the importer
00748                                   encounters a stored value ID it should
00749                                   call setMinUID(type, ID+1).
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     // these functions allow us to retrieve visual direction at document
00841     // position pos from an associated layout. They are intended to be
00842     // used by exporters into (daft) formats where such information
00843     // might be required (e.g. RTF).
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     // these are for use with the export*VisDirection functions
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 /* PD_DOCUMENT_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1