• 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; -*- */
00002 
00003 /* AbiWord
00004  * Copyright (C) 1998 AbiSource, Inc.
00005  * Copyright (c) 2001,2002 Tomas Frydrych
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00020  * 02111-1307, USA.
00021  */
00022 
00023 
00024 #ifndef PD_DOCUMENT_H
00025 #define PD_DOCUMENT_H
00026 
00027 #include <stdio.h>
00028 #include <string>
00029 #include <vector>
00030 #include <map>
00031 
00032 #include "ut_types.h"
00033 #include "ut_vector.h"
00034 #include "ut_hash.h"
00035 #include "xad_Document.h"
00036 #include "ut_xml.h"
00037 #include "pt_Types.h"
00038 #include "pl_Listener.h"
00039 #include "pf_Frag.h"
00040 #include "ie_FileInfo.h"
00041 #include "fp_PageSize.h"
00042 #include "ut_string_class.h"
00043 #include "ut_misc.h"
00044 #include "px_ChangeRecord.h"
00045 
00046 #include <gsf/gsf-input.h>
00047 #include <gsf/gsf-output.h>
00048 
00049 #include <list>
00050 
00051 class UT_ByteBuf;
00052 class UT_GrowBuf;
00053 class pt_PieceTable;
00054 class PP_AttrProp;
00055 class PP_Revision;
00056 class PP_RevisionAttr;
00057 class pf_Frag_Strux;
00058 class pf_Frag_Object;
00059 class PX_ChangeRecord;
00060 class PD_Style;
00061 class PD_DocIterator;
00062 class fd_Field;
00063 class po_Bookmark;
00064 class fl_AutoNum;
00065 class fl_BlockLayout;
00066 class fp_Run;
00067 class UT_UTF8String;
00068 class pp_Author;
00069 class PD_DocumentRDF;
00070 class AP_StatusBar;
00071 class PL_ListenerCoupleCloser;
00072 
00073 #include <boost/shared_ptr.hpp>
00074 typedef boost::shared_ptr<PD_DocumentRDF> PD_DocumentRDFHandle;
00075 
00076 #ifdef PT_TEST
00077 #include "ut_test.h"
00078 #endif
00079 
00080 enum
00081 {
00082     PD_SIGNAL_UPDATE_LAYOUT = 0,
00083     PD_SIGNAL_REFORMAT_LAYOUT,
00084     PD_SIGNAL_DOCPROPS_CHANGED_REBUILD,
00085     PD_SIGNAL_DOCPROPS_CHANGED_NO_REBUILD,
00086     PD_SIGNAL_REVISION_MODE_CHANGED,
00087     PD_SIGNAL_DOCNAME_CHANGED,
00088     PD_SIGNAL_DOCDIRTY_CHANGED,
00089     PD_SIGNAL_SAVEDOC,
00090     PD_SIGNAL_DOCCLOSED // TODO: remove this
00091 };
00092 
00094 // proper prefixes for the namespaces that we support
00096 
00097 // Dublin Core Namespace (http://dublincore.org/documents/dces/)
00098 #define DC_META_PREFIX      "dc."
00099 
00100 // AbiWord Namespace
00101 #define ABIWORD_META_PREFIX "abiword."
00102 
00103 // User-defined custom namespace
00104 #define CUSTOM_META_PREFIX  "custom."
00105 
00107 // The key names for our in-house metadata
00109 
00110 // A formal name given to the resource
00111 #define PD_META_KEY_TITLE        "dc.title"
00112 
00113 // An entity primarily responsible for making the content of the resource
00114 // typically a person, organization, or service
00115 #define PD_META_KEY_CREATOR      "dc.creator"
00116 
00117 // The topic of the content of the resource, *typically* including keywords
00118 #define PD_META_KEY_SUBJECT      "dc.subject"
00119 
00120 // An account of the content of the resource
00121 #define PD_META_KEY_DESCRIPTION  "dc.description"
00122 
00123 // An entity responsible for making the resource available
00124 #define PD_META_KEY_PUBLISHER    "dc.publisher"
00125 
00126 // An entity responsible for making contributions to the content of the resource
00127 #define PD_META_KEY_CONTRIBUTOR  "dc.contributor"
00128 
00129 // A date associated with an event in the life cycle of the resource
00130 #define PD_META_KEY_DATE         "dc.date"
00131 
00132 // The nature or genre of the content of the resource
00133 // See http://dublincore.org/documents/dcmi-type-vocabulary/
00134 #define PD_META_KEY_TYPE         "dc.type"
00135 
00136 // The physical or digital manifestation of the resource. mime-type-ish
00137 // always application/x-abiword
00138 #define PD_META_KEY_FORMAT       "dc.format"
00139 
00140 // A Reference to a resource from which the present resource is derived
00141 #define PD_META_KEY_SOURCE       "dc.source"
00142 
00143 // A language of the intellectual content of the resource
00144 #define PD_META_KEY_LANGUAGE     "dc.language"
00145 
00146 // A reference to a related resource (see-also)
00147 #define PD_META_KEY_RELATION     "dc.relation"
00148 
00149 // The extent or scope of the content of the resource
00150 // spatial location, temporal period, or jurisdiction
00151 #define PD_META_KEY_COVERAGE     "dc.coverage"
00152 
00153 // Information about rights held in and over the resource
00154 #define PD_META_KEY_RIGHTS       "dc.rights"
00155 
00157 // abiword extensions to the dublin core element set
00159 
00160 // searchable, indexable keywords
00161 #define PD_META_KEY_KEYWORDS          "abiword.keywords"
00162 
00163 // the last time this document was saved
00164 #define PD_META_KEY_DATE_LAST_CHANGED "abiword.date_last_changed"
00165 
00166 // the creator (product) of this document. AbiWord, KWord, etc...
00167 #define PD_META_KEY_GENERATOR         "abiword.generator"
00168 
00169 class ABI_EXPORT  ImagePage
00170 {
00171 public:
00172     ImagePage(UT_UTF8String & sImageId, UT_sint32 iPage, double xInch, double yInch, const char * pzProps);
00173     virtual ~ImagePage(void);
00174     const UT_UTF8String * getImageId(void) const;
00175     UT_sint32 getPageNo(void) const;
00176     double getXInch(void) const;
00177     double getYInch(void) const;
00178     const   UT_UTF8String * getProps(void) const;
00179 
00180 private:
00181     UT_UTF8String m_sImageId;
00182     UT_sint32 m_iPage;
00183     double m_xInch;
00184     double m_yInch;
00185     UT_UTF8String m_sProps;
00186 };
00187 
00191 class ABI_EXPORT TextboxPage
00192 {
00193 public:
00194     TextboxPage(UT_sint32 iPage, double xInch, double yInch,const char * pzProps, UT_ByteBuf & sContent);
00195     virtual ~TextboxPage(void);
00196     const UT_ByteBuf * getContent(void) const;
00197     UT_sint32 getPageNo(void) const;
00198     double getXInch(void) const;
00199     double getYInch(void) const;
00200     const UT_UTF8String * getProps(void) const;
00201 private:
00202     UT_sint32 m_iPage;
00203     double m_xInch;
00204     double m_yInch;
00205     UT_UTF8String m_sProps;
00206     UT_ByteBuf m_sContent;
00207 };
00208 
00209 class PD_XMLIDCreatorPrivate;
00210 
00211 class ABI_EXPORT PD_XMLIDCreator
00212 {
00213     friend class PD_Document;
00214     PD_Document* m_doc;
00215     PD_XMLIDCreatorPrivate* m_impl;
00216 
00217   protected:
00218 
00219     PD_XMLIDCreator( PD_Document* doc );
00220     void rebuildCache();
00221 
00222   public:
00223 
00224     ~PD_XMLIDCreator();
00225     std::string createUniqueXMLID( const std::string& desiredID, bool deepCopyRDF = false );
00226 };
00227 typedef boost::shared_ptr<PD_XMLIDCreator> PD_XMLIDCreatorHandle;
00228 
00229 
00234 class ABI_EXPORT PD_Document : public AD_Document
00235 {
00236 public:
00237     PD_Document();
00238 
00239     virtual AD_DOCUMENT_TYPE getType() const {return ADDOCUMENT_ABIWORD;}
00240 
00241     virtual UT_Error        readFromFile(const char * szFilename, int ieft, const char * impProps = NULL);
00242     virtual UT_Error        importFile(const char * szFilename, int ieft, bool markClean = false, bool bImportStylesFirst = true,
00243                                        const char * impProps = NULL);
00244     UT_Error        readFromFile(GsfInput *input, int ieft, const char * impProps = NULL);
00245     UT_Error        importFile(GsfInput *input, int ieft, bool markClean = false, bool bImportStylesFirst = true,
00246                                const char * impProps = NULL);
00247     virtual UT_Error        importStyles(const char * szFilename, int ieft, bool bDocProps = false);
00248     AP_StatusBar *          getStatusBar(void);
00249     void                    updateStatus(void);
00250     virtual UT_Error        newDocument(void);
00251 
00252     UT_Error        saveAs(GsfOutput * output, int ieft, bool cpy = false, const char * expProps = NULL);
00253 
00254 
00255     UT_Error                createRawDocument(void);
00256     void                    finishRawCreation(void);
00257 
00258     virtual bool            isDirty(void) const;
00259     virtual void            forceDirty();
00260     bool                    isConnected(void);
00261     virtual bool            canDo(bool bUndo) const;
00262     virtual UT_uint32       undoCount(bool bUndo) const;
00263     virtual bool            undoCmd(UT_uint32 repeatCount);
00264     virtual bool            redoCmd(UT_uint32 repeatCount);
00265     bool                    isDoingTheDo(void) const;
00266 
00267     // Caret Methods
00268 
00269     void                    removeCaret(const std::string& sCaretID);
00270 
00271     // Page Referenced methods
00272 
00273     void                    addPageReferencedImage(UT_UTF8String & sImageId, UT_sint32 iPage, double xInch, double yInch, const char * pzProps);
00274     void                    addPageReferencedTextbox(UT_ByteBuf & sContent,UT_sint32 iPage, double xInch, double yInch,const char * pzProps);
00275     ImagePage *             getNthImagePage(UT_sint32 iImagePage);
00276     TextboxPage *           getNthTextboxPage(UT_sint32 iTextboxPage);
00277     void                    clearAllPendingObjects(void);
00278 
00279     // Author methods
00280 
00281     void                    setShowAuthors(bool bAuthors);
00282     bool                    isShowAuthors(void) const
00283     { return m_bShowAuthors;}
00284     bool                    isExportAuthorAtts(void) const;
00285     void                    setExportAuthorAtts(bool bExport);
00286     UT_GenericVector<pp_Author*>& getAuthors()
00287     { return m_vecAuthors; }
00288     UT_sint32               getMyAuthorInt(void) const;
00289     void                    setMyAuthorInt(UT_sint32 iAuthor);
00290     UT_sint32               getLastAuthorInt(void) const;
00291     UT_sint32               getNumAuthors(void) const;
00292     pp_Author *             getNthAuthor(UT_sint32 i) const;
00293     pp_Author *             getAuthorByInt(UT_sint32 i) const;
00294     pp_Author *             addAuthor(UT_sint32 iAuthor);
00295     bool                    sendAddAuthorCR(pp_Author * pAuthor);
00296     bool                    sendChangeAuthorCR(pp_Author * pAuthor);
00297     UT_sint32               findFirstFreeAuthorInt(void) const;
00298  private:
00299     bool                    addAuthorAttributeIfBlank(const gchar ** szAttsIn, const gchar **& szAttsOut, UT_String & storage);
00300     bool                    addAuthorAttributeIfBlank( PP_AttrProp *&p_AttrProp);
00301     bool                    _buildAuthorProps(pp_Author * pAuthor, const gchar **& szProps);
00302  public:
00303     //
00304     void                    beginUserAtomicGlob(void);
00305     void                    endUserAtomicGlob(void);
00306     void                    setMarginChangeOnly(bool b);
00307     bool                    isMarginChangeOnly(void) const;
00308     bool                    changeObjectFormatNoUpdate(PTChangeFmt ptc ,pf_Frag_Object* odh,const gchar ** attributes,const gchar ** properties );
00309 PT_AttrPropIndex            getAPIFromSOH(pf_Frag_Object* odh);
00310     bool                    insertObject(PT_DocPosition dpos,
00311                                          PTObjectType pto,
00312                                          const gchar ** attributes,
00313                                          const gchar ** properties);
00314     bool                    insertObject(PT_DocPosition dpos,
00315                                          PTObjectType pto,
00316                                          const gchar ** attributes,
00317                                          const gchar ** properties, fd_Field ** pField );
00318 
00319     bool                    insertSpan(PT_DocPosition dpos,
00320                                        const UT_UCSChar * p,
00321                                        UT_uint32 length,
00322                                        PP_AttrProp *p_AttrProp = NULL);
00323     bool                    insertSpan(PT_DocPosition dpos,
00324                                        const std::string& s,
00325                                        PP_AttrProp *p_AttrProp = NULL);
00326 
00327     bool                    deleteSpan(PT_DocPosition dpos1,
00328                                        PT_DocPosition dpos2,
00329                                        PP_AttrProp *p_AttrProp_Before,
00330                                        UT_uint32 &iRealDeleteCount,
00331                                        bool bDeleteTableStruxes = false);
00332 
00333     bool                    deleteFmtMark( PT_DocPosition dpos);
00334 
00335     bool                    changeSpanFmt(PTChangeFmt ptc,
00336                                           PT_DocPosition dpos1,
00337                                           PT_DocPosition dpos2,
00338                                           const gchar ** attributes,
00339                                           const gchar ** properties);
00340 
00341     bool                    insertStrux(PT_DocPosition dpos,
00342                                         PTStruxType pts, pf_Frag_Strux ** ppfs_ret = 0);
00343     bool                    deleteStrux(PT_DocPosition dpos,
00344                                         PTStruxType pts,
00345                                         bool bRecordChange);
00346 
00347     bool                    createAndSendCR(PT_DocPosition dpos,UT_sint32 iType,bool bsave,UT_Byte iGlob);
00348     virtual bool            createAndSendDocPropCR( const gchar ** pAtts,const gchar ** pProps );
00349     bool                    changeDocPropeties(const gchar ** szAtts, const gchar ** pProps);
00350 
00351     bool                    insertStrux(PT_DocPosition dpos,
00352                                         PTStruxType pts,
00353                                           const gchar ** attributes,
00354                                           const gchar ** properties, pf_Frag_Strux ** ppfs_ret = 0);
00355 
00356     void                    deleteHdrFtrStrux(pf_Frag_Strux* sdh);
00357 
00358     bool                    changeStruxFmt(PTChangeFmt ptc,
00359                                            PT_DocPosition dpos1,
00360                                            PT_DocPosition dpos2,
00361                                            const gchar ** attributes,
00362                                            const gchar ** properties,
00363                                            PTStruxType pts);
00364 
00365     bool                    changeStruxFmt(PTChangeFmt ptc,
00366                                            PT_DocPosition dpos1,
00367                                            PT_DocPosition dpos2,
00368                                            const gchar ** attributes,
00369                                            const gchar ** properties);
00370 
00371 
00372     bool                    changeStruxFmtNoUndo(PTChangeFmt ptc,
00373                                            pf_Frag_Strux* sdh,
00374                                            const gchar ** attributes,
00375                                            const gchar ** properties);
00376 
00377     bool                    changeStruxForLists(pf_Frag_Strux* sdh,
00378                                                 const char * pszParentID);
00379 
00380     bool                    insertFmtMark(PTChangeFmt ptc,
00381                                           PT_DocPosition dpos,
00382                                           PP_AttrProp *p_AttrProp);
00383 
00384     bool                    changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts,
00385                                                      const gchar ** attrs, const gchar ** props,
00386                                                      bool bSkipEmbededSections);
00387 
00388     bool                    changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts,
00389                                                      const gchar ** attrs, const gchar * props,
00390                                                      bool bSkipEmbededSections);
00391 
00392     // the append- and insertBeforeFrag methods are only available while importing
00393     // the document.
00394 
00395     bool                    appendStrux(PTStruxType pts, const gchar ** attributes, pf_Frag_Strux ** ppfs_ret = 0);
00396     bool                    appendStruxFmt(pf_Frag_Strux * pfs, const gchar ** attributes);
00397     bool                    appendLastStruxFmt(PTStruxType pts, const gchar ** attrs, const gchar ** props,
00398                                                bool bSkipEmbededSections);
00399     bool                    appendLastStruxFmt(PTStruxType pts, const gchar ** attrs, const gchar * props,
00400                                                bool bSkipEmbededSections);
00401     bool                    appendFmt(const gchar ** attributes);
00402     bool                    appendFmt(const UT_GenericVector<const gchar*> * pVecAttributes);
00403     bool                    appendSpan(const UT_UCSChar * p, UT_uint32 length);
00404     bool                    appendObject(PTObjectType pto, const gchar ** attributes);
00405     bool                    appendFmtMark(void);
00406     bool                    appendStyle(const gchar ** attributes);
00407     bool                    changeStruxFormatNoUpdate(PTChangeFmt ptc ,pf_Frag_Strux* sdh,const gchar ** attributes);
00408     bool                    insertStruxBeforeFrag(pf_Frag * pF, PTStruxType pts,
00409                                                   const gchar ** attributes, pf_Frag_Strux ** ppfs_ret = 0);
00410     bool                    insertSpanBeforeFrag(pf_Frag * pF, const UT_UCSChar * p, UT_uint32 length);
00411     bool                    insertObjectBeforeFrag(pf_Frag * pF, PTObjectType pto,
00412                                                    const gchar ** attributes);
00413     bool                    insertFmtMarkBeforeFrag(pf_Frag * pF);
00414     bool                    insertFmtMarkBeforeFrag(pf_Frag * pF, const gchar ** attributes);
00415 
00416     pf_Frag *               findFragOfType(pf_Frag::PFType iType, UT_sint32 iSubtype = -1,
00417                                            const pf_Frag * pfStart = NULL);
00418     pf_Frag *               getLastFrag() const;
00419     bool                    checkForSuspect(void);
00420     bool                    repairDoc(void);
00421     bool                    removeStyle(const gchar * name);
00422     bool                    tellListener(PL_Listener * pListener);
00423     bool                    tellListenerSubset( PL_Listener * pListener,
00424                                                 PD_DocumentRange * pDocRange,
00425                                                 PL_ListenerCoupleCloser* closer = 0 );
00426     bool                    addListener(PL_Listener * pListener, PL_ListenerId * pListenerId);
00427     bool                    removeListener(PL_ListenerId listenerId);
00428     bool                    signalListeners(UT_uint32 iSignal) const;
00429     bool                    notifyListeners(const pf_Frag_Strux * pfs, const PX_ChangeRecord * pcr) const;
00430     bool                    notifyListeners(const pf_Frag_Strux * pfs,
00431                                             pf_Frag_Strux * pfsNew,
00432                                             const PX_ChangeRecord * pcr) const;
00433     void                    deferNotifications(void);
00434     void                    processDeferredNotifications(void);
00435     UT_sint32               getAdjustmentForCR(const PX_ChangeRecord * pcr) const;
00436 
00437     // the first two of these functions just retrieve the AP with the given index; the latter two
00438     // return AP that represents state of things with current revision settings
00439     bool                    getAttrProp(PT_AttrPropIndex indexAP, const PP_AttrProp ** ppAP) const;
00440     bool                    getSpanAttrProp(pf_Frag_Strux* sdh, UT_uint32 offset, bool bLeftSide,
00441                                             const PP_AttrProp ** ppAP) const;
00442 
00443     bool                    getAttrProp(PT_AttrPropIndex apIndx, const PP_AttrProp ** ppAP, PP_RevisionAttr ** pRevisions,
00444                                         bool bShowRevisions, UT_uint32 iRevisionId, bool &bHiddenRevision) const;
00445 
00446     bool                    getSpanAttrProp(pf_Frag_Strux* sdh, UT_uint32 offset, bool bLeftSide,
00447                                             const PP_AttrProp ** ppAP,
00448                                             PP_RevisionAttr ** pRevisions,
00449                                             bool bShowRevisions, UT_uint32 iRevisionId,
00450                                             bool &bHiddenRevision) const;
00451 
00452     const UT_UCSChar *      getPointer(PT_BufIndex bi) const; /* see warning on this function */
00453     bool                    getBlockBuf(pf_Frag_Strux* sdh, UT_GrowBuf * pgb) const;
00454 
00455     bool                    getBounds(bool bEnd, PT_DocPosition & docPos) const;
00456     PTStruxType             getStruxType(pf_Frag_Strux* sdh) const;
00457     PT_DocPosition          getStruxPosition(pf_Frag_Strux* sdh) const;
00458     bool                    getStruxFromPosition(PL_ListenerId listenerId,
00459                                                  PT_DocPosition docPos,
00460                                                  fl_ContainerLayout* * psfh) const;
00461     bool                    getStruxOfTypeFromPosition(PL_ListenerId listenerId,
00462                                                        PT_DocPosition docPos,
00463                                                        PTStruxType pts,
00464                                                        fl_ContainerLayout* * psfh) const;
00465     bool                    getStruxOfTypeFromPosition(PT_DocPosition, PTStruxType pts, pf_Frag_Strux* * sdh) const;
00466     pf_Frag_Strux*       getBlockFromPosition( PT_DocPosition pos ) const;
00467 
00468     pf_Frag *               getFragFromPosition(PT_DocPosition docPos) const;
00469 
00470     bool                    getNextStruxOfType(pf_Frag_Strux* sdh,PTStruxType pts,
00471                                                pf_Frag_Strux* * nextsdh);
00472     bool                    getPrevStruxOfType(pf_Frag_Strux* sdh,PTStruxType pts,
00473                                                pf_Frag_Strux* * prevsdh);
00474     bool                    getNextStrux(pf_Frag_Strux* sdh, pf_Frag_Strux* *nextSDH);
00475 
00476     // data items
00477 
00478     virtual bool            createDataItem(const char * szName, bool bBase64,
00479                                            const UT_ByteBuf * pByteBuf,
00480                                            const std::string & mime_type,
00481                                            PD_DataItemHandle* ppHandle);
00482     virtual bool            replaceDataItem(const char * szName, const UT_ByteBuf * pByteBuf);
00483     virtual bool            getDataItemDataByName(const char * szName,
00484                                                   const UT_ByteBuf ** ppByteBuf,
00485                                                   std::string* pMimeType,
00486                                                   PD_DataItemHandle* ppHandle) const;
00487     bool                    setDataItemToken(PD_DataItemHandle pHandle, void* pToken) const;
00488     bool                    getDataItemData(PD_DataItemHandle pHandle,
00489                                             const char ** pszName, const UT_ByteBuf ** ppByteBuf,
00490                                             const void** ppToken) const;
00491     bool                    getDataItemFileExtension(const char *szDataID, std::string &sExt, bool bDot = true) const;
00492     bool                    enumDataItems(UT_uint32 k,
00493                                           PD_DataItemHandle* ppHandle, const char ** pszName,
00494                                           const UT_ByteBuf ** ppByteBuf, std::string * pMimeType) const;
00495 
00496     pf_Frag_Strux*       findHdrFtrStrux(const gchar * pszHdtFtr,
00497                                             const gchar * pszHdrFtrID);
00498     bool                    verifySectionID(const gchar * pszId);
00499     const pf_Frag_Strux*       getLastSectionSDH(void) const;
00500     pf_Frag_Strux*       getLastSectionMutableSDH(void);
00501     pf_Frag_Strux*       getLastStruxOfType(PTStruxType pts);
00502 
00503     bool                    changeStruxAttsNoUpdate(pf_Frag_Strux* sdh, const char * attr, const char * attvalue);
00504     bool                    deleteStruxNoUpdate(pf_Frag_Strux* sdh);
00505     bool                    deleteFragNoUpdate(pf_Frag * pf);
00506     bool                    insertStruxNoUpdateBefore(pf_Frag_Strux* sdh, PTStruxType pts,const gchar ** attributes );
00507     bool                    isStruxBeforeThis(pf_Frag_Strux* sdh,  PTStruxType pts);
00508 
00509     // the function below does exactly what the name says -- returns the AP index; in revisions mode
00510     // you would need the AP at that index to have revision attribute exploded -- use one of the
00511     // functions below to retrieve props and attrs correctly reflecting revisions settings
00512     PT_AttrPropIndex        getAPIFromSDH(pf_Frag_Strux* sdh);
00513     bool                    getAttributeFromSDH(pf_Frag_Strux* sdh, bool bShowRevisions, UT_uint32 iRevisionLevel,
00514                                                 const char * szAttribute, const char ** pszValue);
00515 
00516     bool                    getPropertyFromSDH(const pf_Frag_Strux* sdh, bool bShowRevisions, UT_uint32 iRevisionLevel,
00517                                                const char * szProperty, const char ** pszValue) const;
00518     // styles
00519     void                    getAllUsedStyles(UT_GenericVector<PD_Style*> * pVecStyles);
00520     fl_ContainerLayout*       getNthFmtHandle(pf_Frag_Strux* sdh, UT_uint32 n);
00521     const char *            getDefaultStyle() const;
00522     bool                    getStyle(const char * szName, PD_Style ** ppStyle) const;
00523     PD_Style *              getStyleFromSDH(pf_Frag_Strux* sdh);
00524     pf_Frag_Strux*       getPrevNumberedHeadingStyle(pf_Frag_Strux* sdh);
00525     size_t                  getStyleCount(void);
00526     bool                    enumStyles(UT_uint32 k,
00527                                        const char ** pszName, const PD_Style ** ppStyle) const;
00528     bool                    enumStyles(UT_GenericVector<PD_Style*> * & pStyles) const;
00529 
00530     bool                    addStyleProperty(const gchar * szStyleName, const gchar * szPropertyName, const gchar * szPropertyValue);
00531     bool                    addStyleProperties(const gchar * szStyleName, const gchar ** pProperties);
00532     bool                    setAllStyleAttributes(const gchar * szStyleName, const gchar ** pAttribs);
00533     bool                    addStyleAttributes(const gchar * szStyleName, const gchar ** pAttribs);
00534 
00535     pf_Frag_Strux*       findPreviousStyleStrux(const gchar * szStyle, PT_DocPosition pos);
00536     pf_Frag_Strux*       findForwardStyleStrux(const gchar * szStyle, PT_DocPosition pos);
00537     bool                    updateDocForStyleChange(const gchar * szStyleName,
00538                                                     bool isParaStyle);
00539     void                    updateAllLayoutsInDoc( pf_Frag_Strux* sdh);
00540     void                    clearIfAtFmtMark(PT_DocPosition dpos);
00541 
00542     virtual UT_uint32       getLastSavedAsType() const { return m_lastSavedAsType; }
00543     UT_uint32               getLastOpenedType() const { return m_lastOpenedType; }
00544     bool                    updateFields(void);
00545     bool                    getField(pf_Frag_Strux* sdh,
00546                                      UT_uint32 offset,
00547                                      fd_Field * &pField);
00548     po_Bookmark *           getBookmark(pf_Frag_Strux* sdh, UT_uint32 offset);
00549     pf_Frag *               findBookmark(const char * pName, bool bEnd = false, pf_Frag * pfStart = NULL);
00550     bool                    hasMath(void);
00551 
00552     void                    setDontChangeInsPoint(void);
00553     void                    allowChangeInsPoint(void);
00554     bool                    getAllowChangeInsPoint(void) const;
00555     // Footnote functions
00556     bool                    isFootnoteAtPos(PT_DocPosition pos);
00557     bool                    isEndFootnoteAtPos(PT_DocPosition pos);
00558     UT_sint32               getEmbeddedOffset(pf_Frag_Strux* sdh,PT_DocPosition posOff, pf_Frag_Strux* & sdhEmbedded);
00559 
00560     // TOC functions
00561     bool                    isTOCAtPos(PT_DocPosition pos);
00562 
00563     // FRAME function
00564     bool                    isFrameAtPos(PT_DocPosition pos);
00565     bool                    isEndFrameAtPos(PT_DocPosition pos);
00566     bool                    isHdrFtrAtPos(PT_DocPosition pos);
00567     bool                    isSectionAtPos(PT_DocPosition pos);
00568     bool                    isBlockAtPos(PT_DocPosition pos);
00569 
00570 // Table functions
00571 
00572     bool                    isTableAtPos(PT_DocPosition pos);
00573     bool                    isEndTableAtPos(PT_DocPosition pos);
00574     bool                    isCellAtPos(PT_DocPosition pos);
00575     pf_Frag_Strux*       getEndTableStruxFromTableSDH(pf_Frag_Strux* tableSDH);
00576     pf_Frag_Strux*       getEndCellStruxFromCellSDH(pf_Frag_Strux* cellSDH);
00577     pf_Frag_Strux*       getEndTableStruxFromTablePos(PT_DocPosition posTable);
00578     bool                    getRowsColsFromTableSDH(pf_Frag_Strux* tableSDH,
00579                                                     bool bShowRevisions, UT_uint32 iRevisionLevel,
00580                                                     UT_sint32 * numRows, UT_sint32 * numCols);
00581     pf_Frag_Strux*       getCellSDHFromRowCol(pf_Frag_Strux* tableSDH,
00582                                                  bool bShowRevisions, UT_uint32 iRevisionLevel,
00583                                                  UT_sint32 row,
00584                                                  UT_sint32 col);
00585     void                    miniDump(pf_Frag_Strux* sdh, UT_sint32 nstruxes);
00586     bool                    dumpDoc( const char* msg, PT_DocPosition currentpos, PT_DocPosition endpos );
00587 
00588     bool                    isInsertHyperLinkValid(PT_DocPosition pos) const;
00589 
00590 
00591     // List Functions
00592     fl_AutoNum *            getListByID(UT_uint32 id) const;
00593     fl_AutoNum *            getNthList(UT_uint32 i) const;
00594     bool                    enumLists(UT_uint32 k, fl_AutoNum ** pAutoNum);
00595     UT_uint32               getListsCount(void) const;
00596     void                    addList(fl_AutoNum * pAutoNum);
00597     bool                    appendList(const gchar ** attributes);
00598     bool                    fixListHierarchy(void);
00599     void                    removeList(fl_AutoNum * pAutoNum,pf_Frag_Strux* sdh );
00600     void                    listUpdate(pf_Frag_Strux* sdh);
00601     void                    StopList(pf_Frag_Strux* sdh);
00602     void                    disableListUpdates(void);
00603     void                    enableListUpdates(void);
00604     void                    updateDirtyLists(void);
00605     bool                    areListUpdatesAllowed(void);
00606     void                    setHasListStopped(bool bStop) {m_bHasListStopped = bStop;}
00607     bool                    hasListStopped(void) const {return m_bHasListStopped;}
00608 
00609     void                    setDoingPaste(void);
00610     void                    clearDoingPaste(void);
00611     bool                    isDoingPaste(void);
00612 
00613     void                    setRedrawHappenning(bool bIsHappening) {m_bRedrawHappenning  = bIsHappening;}
00614     bool                    isRedrawHappenning(void) const {return m_bRedrawHappenning;}
00615 
00616     // PageSize functions
00617     bool                    convertPercentToInches(const char * szPercent, UT_UTF8String & sInches);
00618     bool                    setPageSizeFromFile(const gchar ** attributes);
00619     const   fp_PageSize *   getPageSize(void) const
00620     { return & m_docPageSize;}
00621     fp_PageSize             m_docPageSize; // Move this to private later
00622     bool                    isBookmarkUnique(const gchar * pName) const;
00623     bool                    isBookmarkRelativeLink(const gchar * pName) const;
00624     UT_sint32               getBookmarkCount() const {return m_vBookmarkNames.size();}
00625     const std::string &     getNthBookmark(UT_sint32 n) const {return m_vBookmarkNames.at(n);}
00626     void                    addBookmark(const gchar * pName);
00627     void                    removeBookmark(const gchar * pName);
00628 
00630     // Functions for dealing with revisions
00631     //
00632     virtual void            setMarkRevisions(bool bMark);
00633     // primarly for use by the PieceTable
00634     void                    setMarkRevisionsNoNotify(bool bMark) {AD_Document::setMarkRevisions(bMark);}
00635 
00636     virtual bool            acceptRejectRevision(bool bReject,
00637                                                  UT_uint32 iStart,
00638                                                  UT_uint32 iEnd,
00639                                                  UT_uint32 iLevel);
00640 
00641     virtual bool            rejectAllHigherRevisions(UT_uint32 iLevel);
00642     virtual bool            acceptAllRevisions();
00643 
00644     const PP_AttrProp *     explodeRevisions(PP_RevisionAttr *& pRevisions, const PP_AttrProp * pAP,
00645                                              bool bShow, UT_uint32 iId, bool &bHiddenRevision) const;
00646 
00647     virtual void            purgeRevisionTable(bool bUnconditional = false);
00648 
00649     void                    notifyPieceTableChangeStart(void);
00650     void                    notifyPieceTableChangeEnd(void);
00651 
00652 
00653 
00654     pt_PieceTable *         getPieceTable(void) const
00655         { return m_pPieceTable; }
00656     PD_DocumentRDFHandle    getDocumentRDF(void) const;
00657     PD_XMLIDCreatorHandle   makeXMLIDCreator();
00658 
00659 #ifdef PT_TEST
00660     void                    __dump(FILE * fp) const;
00662     static PD_Document*     m_pDoc;
00663 #endif
00664 
00665     // If we're using styles to format a document, prevent accidental use of other formatting
00666         // tools.  Disable all explicit formatting tools (font, color, boldness, etc.)
00667     inline bool areStylesLocked () const { return m_bLockedStyles; }    // See also lockStyles
00668     void lockStyles(bool b);
00669 
00670     virtual void setMetaDataProp (const std::string & key, const std::string & value);
00671     virtual bool getMetaDataProp (const std::string & key, std::string & outProp) const;
00672 
00673     // RIVERA TODO not working and may not be needed
00674     virtual void setAnnotationProp (const std::string & key, const std::string & value);
00675     virtual bool getAnnotationProp (const std::string & key, std::string & outProp) const;
00676 
00677     const std::map<std::string,std::string> & getMetaData () const
00678     {
00679         return m_metaDataMap ;
00680     }
00681 
00682     // document-level property handling functions
00683     const PP_AttrProp *     getAttrProp() const;
00684     PT_AttrPropIndex        getAttrPropIndex() const {return m_indexAP;}
00685     bool                    setAttrProp(const gchar ** ppAttr);
00686     bool                    setAttributes(const gchar ** ppAttr);
00687     bool                    setProperties(const gchar ** ppProps);
00688     void                     setDontImmediatelyLayout(bool b)
00689         { m_bDontImmediatelyLayout = b;}
00690     bool                     isDontImmediateLayout(void) const
00691         { return m_bDontImmediatelyLayout;}
00692 
00693     /* Okay, as far as I can tell this is a non-persistent document property since it is not
00694      * written to the AbiWord file when the document is saved. In fact, it is only set if a
00695      * mail-merge source/link is given on the command line.
00696      *
00697      * Mail merge fields are, naturally, saved and loaded, but the Insert->Mail Merge Field...
00698      * dialog doesn't reflect the current document's fields but rather some internal set of
00699      * fields, which is confusing if you are trying to work with muliple mail merge sources.
00700      */
00701     // map UT_String=>UT_UTF8String*
00702 
00703     UT_UTF8String   getMailMergeField(const UT_String & key) const;
00704     bool            mailMergeFieldExists(const UT_String & key) const;
00705     void            setMailMergeField(const UT_String & key, const UT_UTF8String & value);
00706 
00707     void            clearMailMergeMap();
00708 
00709     void setMailMergeLink (const char * file) {
00710         m_mailMergeLink = file;
00711     }
00712 
00713     const UT_UTF8String &                           getMailMergeLink() const { return m_mailMergeLink; }
00714     const UT_GenericStringMap<UT_UTF8String *> &    getMailMergeMap() const  { return m_mailMergeMap; }
00715 
00716     void invalidateCache(void);
00717 
00718     /*
00719        The purpose of the following methods is to generate and manage
00720        document-wide unique identifiers; the indetifiers are type
00721        specific, with the types defined in UT_UniqueId class (ut_mics.h).
00722 
00723        UT_uint32 getUID(type):    Generates an id of a given type or
00724                                   UT_UID_INVALID if unique id cannot
00725                                   be generated (0 <= uid < UT_UID_INVALID).
00726 
00727        bool isIdUnique(type, id): Returns true if a given id can be
00728                                   used as a unique identifier of a
00729                                   given type; before the identifier is
00730                                   used, the caller should call
00731                                   setMinUID(id+1) to ensure integrity of
00732                                   the UID generator.
00733 
00734        bool setMinUID(type, uid): Allows to set a minimum value for all
00735                                   future identifiers; it returns true on
00736                                   success false on failure. The purpose is
00737                                   to allow an easy insertion of
00738                                   document-stored id's into the UID space
00739                                   by document importers: if the importer
00740                                   encounters a stored value ID it should
00741                                   call setMinUID(type, ID+1).
00742     */
00743 
00744     UT_uint32 getUID(UT_UniqueId::idType t) {return m_UID.getUID(t);}
00745     bool      setMinUID(UT_UniqueId::idType t, UT_uint32 i) {return m_UID.setMinId(t,i);}
00746     bool      isIdUnique(UT_UniqueId::idType t, UT_uint32 i) const {return m_UID.isIdUnique(t,i);}
00747 
00748     virtual bool  areDocumentContentsEqual(const AD_Document &d, UT_uint32 &pos) const;
00749     virtual bool  areDocumentFormatsEqual(const AD_Document &d, UT_uint32 &pos) const;
00750     virtual bool  areDocumentStylesheetsEqual(const AD_Document &d) const;
00751 
00752     bool      findFirstDifferenceInContent(PT_DocPosition &pos, UT_sint32 &iOffset2,
00753                                            const PD_Document &d) const;
00754 
00755     bool      findWhereSimilarityResumes(PT_DocPosition &pos, UT_sint32 &iOffset2,
00756                                          UT_uint32 & iKnownLength,
00757                                          const PD_Document &d) const;
00758 
00759     virtual void   setAutoRevisioning(bool autorev);
00760 
00761     virtual UT_uint32 getXID() const;
00762     virtual UT_uint32 getTopXID() const;
00763     void              fixMissingXIDs();
00764     UT_uint32         getFragXIDforVersion(const pf_Frag * pf, UT_uint32 iVersion) const;
00765     void              removeConnections(void);
00766     void              changeConnectedDocument(PD_Document * pDoc);
00767     UT_sint32     getNewHdrHeight(void) const
00768     { return m_iNewHdrHeight;}
00769     UT_sint32     getNewFtrHeight(void) const
00770     { return m_iNewFtrHeight;}
00771 
00772     void       setNewHdrHeight(UT_sint32 newHeight)
00773     { m_iNewHdrHeight = newHeight;}
00774     void       setNewFtrHeight(UT_sint32 newHeight)
00775     { m_iNewFtrHeight = newHeight;}
00776 
00777     bool                    purgeFmtMarks();
00778 
00779     void                    tellPTDoNotTweakPosition(bool b);
00780 
00781     void                    setVDNDinProgress(bool b) {m_bVDND = b;}
00782     bool                    isVDNDinProgress() const {return m_bVDND;}
00783     UT_sint32               getCRNumber() const { return m_iCRCounter; }
00784     void                    setCRNumber(UT_sint32 iCRCounter) { m_iCRCounter = iCRCounter; }
00785     UT_sint32               getNextCRNumber(void);
00786     std::list<AV_View*>     getAllViews() const;
00787     void                    getAllViews(UT_GenericVector<AV_View *> * vecViews) const;
00788     void                    ignoreSignals(void)
00789     { m_bIgnoreSignals = true;}
00790     void                    dontIgnoreSignals(void)
00791     { m_bIgnoreSignals = false;}
00792     void                    setClean(void)
00793     { _setClean();}
00794 
00795     void                    setCoalescingMask(bool mask)
00796     { m_bCoalescingMask = mask; }
00797     bool                    isCoalescingMasked() const
00798     { return m_bCoalescingMask; }
00799 protected:
00800     virtual ~PD_Document();
00801 
00802     virtual UT_Error        _saveAs(const char * szFilename, int ieft, const char * expProps = NULL);
00803     virtual UT_Error        _saveAs(const char * szFilename, int ieft, bool cpy, const char * expProps = NULL);
00804     virtual UT_Error        _saveAs(GsfOutput *output, int ieft, bool cpy, const char * expProps);
00805     virtual UT_Error        _save(void);
00806 
00807 
00808     void                    _setClean(void);
00809     void                    _destroyDataItemData(void);
00810     bool                    _syncFileTypes(bool bReadSaveWriteOpen);
00811 
00812     bool                    _acceptRejectRevision(bool bReject, UT_uint32 iStart, UT_uint32 iEnd,
00813                                                   const PP_Revision * pRev,
00814                                                   PP_RevisionAttr &RevAttr, pf_Frag * pf,
00815                                                   bool & bDeleted);
00816 
00817     virtual void            _clearUndo();
00818 
00819     UT_Error _importFile(const char * szFilename, int ieft,
00820                          bool markClean, bool bImportStylesFirst,
00821                          bool isImportFile, const char* impProps);
00822     UT_Error _importFile(GsfInput * input, int ieft,
00823                          bool markClean, bool bImportStylesFirst,
00824                          bool bIsImportFile, const char* impProps);
00825 
00826     bool     _removeRepeatedHdrFtr(pf_Frag_Strux * pfs ,UT_GenericVector<pf_Frag_Strux *> * vecHdrFtrs, UT_sint32 i);
00827     bool     _pruneSectionAPI(pf_Frag_Strux * pfs,const char * szHType, UT_GenericVector<pf_Frag_Strux *> *vecHdrFtrs);
00828     bool     _matchSection(pf_Frag_Strux * pfs, UT_GenericVector<pf_Frag_Strux *> *vecSections);
00829     bool     _removeHdrFtr(pf_Frag_Strux * pfs);
00830     bool     _checkAndFixTable(pf_Frag_Strux * pfs);
00831 public:
00832     // these functions allow us to retrieve visual direction at document
00833     // position pos from an associated layout. They are intended to be
00834     // used by exporters into (daft) formats where such information
00835     // might be required (e.g. RTF).
00836     bool                    exportGetVisDirectionAtPos(PT_DocPosition pos, UT_BidiCharType &type);
00837 private:
00838     bool                    _exportInitVisDirection(PT_DocPosition pos);
00839     bool                    _exportFindVisDirectionRunAtPos(PT_DocPosition pos);
00840 
00841 private:
00842     bool                    m_ballowListUpdates;
00843     pt_PieceTable *         m_pPieceTable;
00844     PD_DocumentRDFHandle    m_hDocumentRDF;
00845     UT_GenericVector<PL_Listener *> m_vecListeners;
00846     UT_GenericVector<fl_AutoNum *> m_vecLists;
00847     bool                    m_bHasListStopped;
00848 
00849     typedef std::map<std::string, PD_DataItemHandle> hash_data_items_t;
00850     hash_data_items_t m_hashDataItems;
00851 public:
00852     IE_FileInfo             m_fileImpExpInfo;
00853 private:
00854     IEFileType              m_lastOpenedType;
00855     IEFileType              m_lastSavedAsType;
00856     bool                    m_bDoingPaste;
00857     bool                    m_bAllowInsertPointChange;
00858     bool                    m_bRedrawHappenning;
00859     bool                    m_bLoading;
00860     std::vector<std::string> m_vBookmarkNames;
00861     bool                    m_bLockedStyles;
00862     std::map<std::string, std::string> m_metaDataMap;
00863     PT_AttrPropIndex        m_indexAP;
00864     bool                    m_bDontImmediatelyLayout;
00865 
00866     // mapping UT_String=>UT_UTF8String pointer
00867     UT_GenericStringMap<UT_UTF8String*>  m_mailMergeMap;
00868 
00869     UT_UCS4Char             m_iLastDirMarker;
00870 
00871     UT_UTF8String           m_mailMergeLink;
00872 
00873     // these are for use with the export*VisDirection functions
00874     const fl_BlockLayout *  m_pVDBl;
00875     fp_Run *                m_pVDRun;
00876     PT_DocPosition          m_iVDLastPos;
00877     UT_UniqueId             m_UID;
00878     UT_sint32               m_iNewHdrHeight;
00879     UT_sint32               m_iNewFtrHeight;
00880     bool                    m_bMarginChangeOnly;
00881     UT_GenericVector<pf_Frag *> m_vecSuspectFrags;
00882 
00883     bool                    m_bVDND;
00884     UT_sint32               m_iCRCounter;
00885     mutable UT_sint32       m_iUpdateCount;
00886     bool                    m_bIgnoreSignals;
00887 
00888     bool                    m_bCoalescingMask;
00889     bool                    m_bShowAuthors;
00890     UT_GenericVector<pp_Author *>  m_vecAuthors;
00891     bool                    m_bExportAuthorAtts;
00892     UT_sint32               m_iMyAuthorInt;
00893     UT_sint32               m_iLastAuthorInt;
00894     UT_GenericVector<ImagePage *> m_pPendingImagePage;
00895     UT_GenericVector<TextboxPage *> m_pPendingTextboxPage;
00896     UT_sint32               m_iStruxCount;
00897     std::string             m_sUserName;
00898 public:
00899     const std::string &getUserName() const { return m_sUserName; }
00900 };
00901 
00902 #endif /* PD_DOCUMENT_H */

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1