• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files

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 // TODO should the filename be UT_UCSChar rather than char ?
00028 
00029 #include <stdio.h>
00030 #include "ut_types.h"
00031 #include "ut_vector.h"
00032 #include "ut_hash.h"
00033 #include "xad_Document.h"
00034 #include "ut_xml.h"
00035 #include "pt_Types.h"
00036 #include "pl_Listener.h"
00037 #include "pf_Frag.h"
00038 #include "ie_FileInfo.h"
00039 #include "fp_PageSize.h"
00040 #include "ut_string_class.h"
00041 #include "ut_misc.h"
00042 #include "px_ChangeRecord.h"
00043 
00044 #include <gsf/gsf-input.h>
00045 #include <gsf/gsf-output.h>
00046 
00047 class UT_ByteBuf;
00048 class UT_GrowBuf;
00049 class pt_PieceTable;
00050 class PP_AttrProp;
00051 class PP_Revision;
00052 class PP_RevisionAttr;
00053 class pf_Frag_Strux;
00054 class PX_ChangeRecord;
00055 class PD_Style;
00056 class PD_DocIterator;
00057 class XAP_App;
00058 class fd_Field;
00059 class po_Bookmark;
00060 class fl_AutoNum;
00061 class fl_BlockLayout;
00062 class fp_Run;
00063 class UT_UTF8String;
00064 class pp_Author;
00065 
00066 #ifdef PT_TEST
00067 #include "ut_test.h"
00068 #endif
00069 
00070 enum
00071 {
00072     PD_SIGNAL_UPDATE_LAYOUT = 0,
00073     PD_SIGNAL_REFORMAT_LAYOUT,
00074     PD_SIGNAL_DOCPROPS_CHANGED_REBUILD,
00075     PD_SIGNAL_DOCPROPS_CHANGED_NO_REBUILD,
00076     PD_SIGNAL_REVISION_MODE_CHANGED,
00077     PD_SIGNAL_DOCNAME_CHANGED,
00078     PD_SIGNAL_DOCDIRTY_CHANGED,
00079     PD_SIGNAL_SAVEDOC, 
00080     PD_SIGNAL_DOCCLOSED // TODO: remove this
00081 };
00082 
00084 // proper prefixes for the namespaces that we support
00086 
00087 // Dublin Core Namespace (http://dublincore.org/documents/dces/)
00088 #define DC_META_PREFIX      "dc."
00089 
00090 // AbiWord Namespace
00091 #define ABIWORD_META_PREFIX "abiword."
00092 
00093 // User-defined custom namespace
00094 #define CUSTOM_META_PREFIX  "custom."
00095 
00097 // The key names for our in-house metadata
00099 
00100 // A formal name given to the resource
00101 #define PD_META_KEY_TITLE        "dc.title"
00102 
00103 // An entity primarily responsible for making the content of the resource
00104 // typically a person, organization, or service
00105 #define PD_META_KEY_CREATOR      "dc.creator"
00106 
00107 // The topic of the content of the resource, *typically* including keywords
00108 #define PD_META_KEY_SUBJECT      "dc.subject"
00109 
00110 // An account of the content of the resource
00111 #define PD_META_KEY_DESCRIPTION  "dc.description"
00112 
00113 // An entity responsible for making the resource available
00114 #define PD_META_KEY_PUBLISHER    "dc.publisher"
00115 
00116 // An entity responsible for making contributions to the content of the resource
00117 #define PD_META_KEY_CONTRIBUTOR  "dc.contributor"
00118 
00119 // A date associated with an event in the life cycle of the resource
00120 #define PD_META_KEY_DATE         "dc.date"
00121 
00122 // The nature or genre of the content of the resource
00123 // See http://dublincore.org/documents/dcmi-type-vocabulary/
00124 #define PD_META_KEY_TYPE         "dc.type"
00125 
00126 // The physical or digital manifestation of the resource. mime-type-ish
00127 // always application/x-abiword
00128 #define PD_META_KEY_FORMAT       "dc.format"
00129 
00130 // A Reference to a resource from which the present resource is derived
00131 #define PD_META_KEY_SOURCE       "dc.source"
00132 
00133 // A language of the intellectual content of the resource
00134 #define PD_META_KEY_LANGUAGE     "dc.language"
00135 
00136 // A reference to a related resource (see-also)
00137 #define PD_META_KEY_RELATION     "dc.relation"
00138 
00139 // The extent or scope of the content of the resource
00140 // spatial location, temporal period, or jurisdiction
00141 #define PD_META_KEY_COVERAGE     "dc.coverage"
00142 
00143 // Information about rights held in and over the resource
00144 #define PD_META_KEY_RIGHTS       "dc.rights"
00145 
00147 // abiword extensions to the dublin core element set
00149 
00150 // searchable, indexable keywords
00151 #define PD_META_KEY_KEYWORDS          "abiword.keywords"
00152 
00153 // the last time this document was saved
00154 #define PD_META_KEY_DATE_LAST_CHANGED "abiword.date_last_changed"
00155 
00156 // the creator (product) of this document. AbiWord, KWord, etc...
00157 #define PD_META_KEY_GENERATOR         "abiword.generator"
00158 
00159 
00164 class ABI_EXPORT PD_Document : public AD_Document
00165 {
00166 public:
00167     PD_Document(XAP_App *pApp);
00168 
00169     virtual AD_DOCUMENT_TYPE getType() const {return ADDOCUMENT_ABIWORD;}
00170     
00171     virtual UT_Error        readFromFile(const char * szFilename, int ieft, const char * impProps = NULL);
00172     virtual UT_Error        importFile(const char * szFilename, int ieft, bool markClean = false, bool bImportStylesFirst = true,
00173                                        const char * impProps = NULL);
00174     UT_Error        readFromFile(GsfInput *input, int ieft, const char * impProps = NULL);
00175     UT_Error        importFile(GsfInput *input, int ieft, bool markClean = false, bool bImportStylesFirst = true,
00176                                const char * impProps = NULL);
00177     virtual UT_Error        importStyles(const char * szFilename, int ieft, bool bDocProps = false);
00178 
00179     virtual UT_Error        newDocument(void);
00180 
00181     UT_Error        saveAs(GsfOutput * output, int ieft, bool cpy = false, const char * expProps = NULL);
00182 
00183 
00184     UT_Error                createRawDocument(void);
00185     void                    finishRawCreation(void);
00186 
00187     virtual bool            isDirty(void) const;
00188     virtual void            forceDirty();
00189     bool                    isConnected(void);
00190     virtual bool            canDo(bool bUndo) const;
00191     virtual UT_uint32       undoCount(bool bUndo) const;
00192     virtual bool            undoCmd(UT_uint32 repeatCount);
00193     virtual bool            redoCmd(UT_uint32 repeatCount);
00194     bool                    isDoingTheDo(void) const;
00195 
00196     // Author methods
00197 
00198     const char *            getAuthorUUIDFromNum(UT_sint32 id);
00199     UT_sint32               getNumFromAuthorUUID(const char * szUUID);
00200     void                    setShowAuthors(bool bAuthors);
00201     bool                    isShowAuthors(void) const
00202     { return m_bShowAuthors;}
00203     bool                    addAuthorAttributeIfBlank(const gchar ** szAttsIn, const gchar **& szAttsOut);
00204     bool                    addAuthorAttributeIfBlank( PP_AttrProp *&p_AttrProp);
00205     bool                    isExportAuthorAtts(void) const;
00206     void                    setExportAuthorAtts(bool bExport);
00207     UT_sint32               getMyAuthorInt(void) const;
00208     void                    setMyAuthorInt(UT_sint32 iAuthor);
00209     UT_sint32               getLastAuthorInt(void) const;
00210     UT_sint32               getNumAuthors(void);
00211     pp_Author *             getNthAuthor(UT_sint32 i);
00212     pp_Author *             getAuthorByInt(UT_sint32 i);
00213     pp_Author *             getAuthorByUUID(const gchar * szUUID);
00214     pp_Author *             addAuthor(const gchar * szUUID, UT_sint32 iAuthor);
00215     bool                    sendAddAuthorCR(pp_Author * pAuthor);
00216     bool                    sendChangeAuthorCR(pp_Author * pAuthor);
00217     UT_sint32               findFirstFreeAuthorInt(void);
00218  private:
00219     bool                    _buildAuthorProps(pp_Author * pAuthor, const gchar **& szProps);
00220  public:
00221     //
00222     void                    beginUserAtomicGlob(void);
00223     void                    endUserAtomicGlob(void);
00224     void                    setMarginChangeOnly(bool b);
00225     bool                    isMarginChangeOnly(void) const;
00226     bool                    changeObjectFormatNoUpdate(PTChangeFmt ptc ,PL_ObjectHandle odh,const gchar ** attributes,const gchar ** properties );  
00227 PT_AttrPropIndex            getAPIFromSOH(PL_ObjectHandle odh); 
00228     bool                    insertObject(PT_DocPosition dpos,
00229                                          PTObjectType pto,
00230                                          const gchar ** attributes,
00231                                          const gchar ** properties);
00232     bool                    insertObject(PT_DocPosition dpos,
00233                                          PTObjectType pto,
00234                                          const gchar ** attributes,
00235                                          const gchar ** properties, fd_Field ** pField );
00236 
00237     bool                    insertSpan(PT_DocPosition dpos,
00238                                        const UT_UCSChar * p,
00239                                        UT_uint32 length,
00240                                        PP_AttrProp *p_AttrProp = NULL);
00241 
00242     bool                    deleteSpan(PT_DocPosition dpos1,
00243                                        PT_DocPosition dpos2,
00244                                        PP_AttrProp *p_AttrProp_Before,
00245                                        UT_uint32 &iRealDeleteCount,
00246                                        bool bDeleteTableStruxes = false);
00247 
00248     bool                    deleteFmtMark( PT_DocPosition dpos);
00249 
00250     bool                    changeSpanFmt(PTChangeFmt ptc,
00251                                           PT_DocPosition dpos1,
00252                                           PT_DocPosition dpos2,
00253                                           const gchar ** attributes,
00254                                           const gchar ** properties);
00255 
00256     bool                    insertStrux(PT_DocPosition dpos,
00257                                         PTStruxType pts, pf_Frag_Strux ** ppfs_ret = 0);
00258     bool                    deleteStrux(PT_DocPosition dpos,
00259                                         PTStruxType pts,
00260                                         bool bRecordChange);
00261 
00262     bool                    createAndSendCR(PT_DocPosition dpos,UT_sint32 iType,bool bsave,UT_Byte iGlob);
00263     virtual bool            createAndSendDocPropCR( const gchar ** pAtts,const gchar ** pProps );
00264     bool                    changeDocPropeties(const gchar ** szAtts, const gchar ** pProps);
00265 
00266     bool                    insertStrux(PT_DocPosition dpos,
00267                                         PTStruxType pts,
00268                                           const gchar ** attributes,
00269                                           const gchar ** properties, pf_Frag_Strux ** ppfs_ret = 0);
00270 
00271     void                    deleteHdrFtrStrux(PL_StruxDocHandle sdh);
00272 
00273     bool                    changeStruxFmt(PTChangeFmt ptc,
00274                                            PT_DocPosition dpos1,
00275                                            PT_DocPosition dpos2,
00276                                            const gchar ** attributes,
00277                                            const gchar ** properties,
00278                                            PTStruxType pts);
00279 
00280     bool                    changeStruxFmt(PTChangeFmt ptc,
00281                                            PT_DocPosition dpos1,
00282                                            PT_DocPosition dpos2,
00283                                            const gchar ** attributes,
00284                                            const gchar ** properties);
00285 
00286 
00287     bool                    changeStruxFmtNoUndo(PTChangeFmt ptc,
00288                                            PL_StruxDocHandle sdh,
00289                                            const gchar ** attributes,
00290                                            const gchar ** properties);
00291 
00292     bool                    changeStruxForLists(PL_StruxDocHandle sdh,
00293                                                 const char * pszParentID);
00294 
00295     bool                    insertFmtMark(PTChangeFmt ptc,
00296                                           PT_DocPosition dpos,
00297                                           PP_AttrProp *p_AttrProp);
00298 
00299     bool                    changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts,
00300                                                      const gchar ** attrs, const gchar ** props,
00301                                                      bool bSkipEmbededSections);
00302     
00303     bool                    changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts,
00304                                                      const gchar ** attrs, const gchar * props,
00305                                                      bool bSkipEmbededSections);
00306     
00307     // the append- and insertBeforeFrag methods are only available while importing
00308     // the document.
00309 
00310     bool                    appendStrux(PTStruxType pts, const gchar ** attributes, pf_Frag_Strux ** ppfs_ret = 0);
00311     bool                    appendStruxFmt(pf_Frag_Strux * pfs, const gchar ** attributes);
00312     bool                    appendLastStruxFmt(PTStruxType pts, const gchar ** attrs, const gchar ** props,
00313                                                bool bSkipEmbededSections);
00314     bool                    appendLastStruxFmt(PTStruxType pts, const gchar ** attrs, const gchar * props,
00315                                                bool bSkipEmbededSections);
00316     bool                    appendFmt(const gchar ** attributes);
00317     bool                    appendFmt(const UT_GenericVector<const gchar*> * pVecAttributes);
00318     bool                    appendSpan(const UT_UCSChar * p, UT_uint32 length);
00319     bool                    appendObject(PTObjectType pto, const gchar ** attributes);
00320     bool                    appendFmtMark(void);
00321     bool                    appendStyle(const gchar ** attributes);
00322     bool                    changeStruxFormatNoUpdate(PTChangeFmt ptc ,PL_StruxDocHandle sdh,const gchar ** attributes);    
00323     bool                    insertStruxBeforeFrag(pf_Frag * pF, PTStruxType pts,
00324                                                   const gchar ** attributes, pf_Frag_Strux ** ppfs_ret = 0);
00325     bool                    insertSpanBeforeFrag(pf_Frag * pF, const UT_UCSChar * p, UT_uint32 length);
00326     bool                    insertObjectBeforeFrag(pf_Frag * pF, PTObjectType pto,
00327                                                    const gchar ** attributes);
00328     bool                    insertFmtMarkBeforeFrag(pf_Frag * pF);
00329     bool                    insertFmtMarkBeforeFrag(pf_Frag * pF, const gchar ** attributes);
00330 
00331     pf_Frag *               findFragOfType(pf_Frag::PFType iType, UT_sint32 iSubtype = -1,
00332                                            const pf_Frag * pfStart = NULL);
00333     pf_Frag *               getLastFrag() const;
00334     bool                    checkForSuspect(void);
00335     bool                    repairDoc(void);
00336     bool                    removeStyle(const gchar * name);
00337     bool                    tellListener(PL_Listener * pListener);
00338     bool                    tellListenerSubset(PL_Listener * pListener,
00339                                                PD_DocumentRange * pDocRange);
00340     bool                    addListener(PL_Listener * pListener, PL_ListenerId * pListenerId);
00341     bool                    removeListener(PL_ListenerId listenerId);
00342     bool                    signalListeners(UT_uint32 iSignal) const;
00343     bool                    notifyListeners(const pf_Frag_Strux * pfs, const PX_ChangeRecord * pcr) const;
00344     bool                    notifyListeners(const pf_Frag_Strux * pfs,
00345                                             pf_Frag_Strux * pfsNew,
00346                                             const PX_ChangeRecord * pcr) const;
00347     void                    deferNotifications(void);
00348     void                    processDeferredNotifications(void);
00349     UT_sint32               getAdjustmentForCR(const PX_ChangeRecord * pcr) const;
00350 
00351     // the first two of these functions just retrieve the AP with the given index; the latter two
00352     // return AP that represents state of things with current revision settings
00353     bool                    getAttrProp(PT_AttrPropIndex indexAP, const PP_AttrProp ** ppAP) const;
00354     bool                    getSpanAttrProp(PL_StruxDocHandle sdh, UT_uint32 offset, bool bLeftSide,
00355                                             const PP_AttrProp ** ppAP) const;
00356 
00357     bool                    getAttrProp(PT_AttrPropIndex apIndx, const PP_AttrProp ** ppAP, PP_RevisionAttr ** pRevisions,
00358                                         bool bShowRevisions, UT_uint32 iRevisionId, bool &bHiddenRevision) const;
00359 
00360     bool                    getSpanAttrProp(PL_StruxDocHandle sdh, UT_uint32 offset, bool bLeftSide,
00361                                             const PP_AttrProp ** ppAP,
00362                                             PP_RevisionAttr ** pRevisions,
00363                                             bool bShowRevisions, UT_uint32 iRevisionId,
00364                                             bool &bHiddenRevision) const;
00365     
00366     const UT_UCSChar *      getPointer(PT_BufIndex bi) const; /* see warning on this function */
00367     bool                    getBlockBuf(PL_StruxDocHandle sdh, UT_GrowBuf * pgb) const;
00368 
00369     bool                    getBounds(bool bEnd, PT_DocPosition & docPos) const;
00370     PTStruxType             getStruxType(PL_StruxDocHandle sdh) const;
00371     PT_DocPosition          getStruxPosition(PL_StruxDocHandle sdh) const;
00372     bool                    getStruxFromPosition(PL_ListenerId listenerId,
00373                                                  PT_DocPosition docPos,
00374                                                  PL_StruxFmtHandle * psfh) const;
00375     bool                    getStruxOfTypeFromPosition(PL_ListenerId listenerId,
00376                                                        PT_DocPosition docPos,
00377                                                        PTStruxType pts,
00378                                                        PL_StruxFmtHandle * psfh) const;
00379     bool                    getStruxOfTypeFromPosition(PT_DocPosition, PTStruxType pts, PL_StruxDocHandle * sdh) const;
00380 
00381     pf_Frag *               getFragFromPosition(PT_DocPosition docPos) const;
00382 
00383     bool                    getNextStruxOfType(PL_StruxDocHandle sdh,PTStruxType pts,
00384                                                PL_StruxDocHandle * nextsdh);
00385     bool                    getPrevStruxOfType(PL_StruxDocHandle sdh,PTStruxType pts,
00386                                                PL_StruxDocHandle * prevsdh);
00387     bool                    getNextStrux(PL_StruxDocHandle sdh, PL_StruxDocHandle *nextSDH);
00388 
00389     // data items
00390 
00391     virtual bool            createDataItem(const char * szName, bool bBase64, const UT_ByteBuf * pByteBuf,
00392                                            const void* pToken, void ** ppHandle);
00393     virtual bool            replaceDataItem(const char * szName, const UT_ByteBuf * pByteBuf);
00394     virtual bool            getDataItemDataByName(const char * szName,
00395                                                   const UT_ByteBuf ** ppByteBuf, const void** ppToken, void ** ppHandle) const;
00396     bool                    setDataItemToken(void* pHandle, void* pToken);
00397     bool                    getDataItemData(void * pHandle,
00398                                             const char ** pszName, const UT_ByteBuf ** ppByteBuf, const void** ppToken) const;
00399     bool                    enumDataItems(UT_uint32 k,
00400                                           void ** ppHandle, const char ** pszName, const UT_ByteBuf ** ppByteBuf, const void** ppToken) const;
00401 
00402     PL_StruxDocHandle       findHdrFtrStrux(const gchar * pszHdtFtr,
00403                                             const gchar * pszHdrFtrID);
00404     bool                    verifySectionID(const gchar * pszId);
00405     PL_StruxDocHandle       getLastSectionSDH(void);
00406     PL_StruxDocHandle       getLastStruxOfType(PTStruxType pts);
00407 
00408     bool                    changeStruxAttsNoUpdate(PL_StruxDocHandle sdh, const char * attr, const char * attvalue);
00409     bool                    deleteStruxNoUpdate(PL_StruxDocHandle sdh);
00410     bool                    insertStruxNoUpdateBefore(PL_StruxDocHandle sdh, PTStruxType pts,const gchar ** attributes );
00411     bool                    isStruxBeforeThis(PL_StruxDocHandle sdh,  PTStruxType pts);
00412 
00413     // the function below does exactly what the name says -- returns the AP index; in revisions mode
00414     // you would need the AP at that index to have revision attribute exploded -- use one of the
00415     // functions below to retrieve props and attrs correctly reflecting revisions settings
00416     PT_AttrPropIndex        getAPIFromSDH(PL_StruxDocHandle sdh);
00417     bool                    getAttributeFromSDH(PL_StruxDocHandle sdh, bool bShowRevisions, UT_uint32 iRevisionLevel,
00418                                                 const char * szAttribute, const char ** pszValue);
00419     
00420     bool                    getPropertyFromSDH(PL_StruxDocHandle sdh, bool bShowRevisions, UT_uint32 iRevisionLevel,
00421                                                const char * szProperty, const char ** pszValue);
00422     // styles
00423     void                    getAllUsedStyles(UT_GenericVector<PD_Style*> * pVecStyles);
00424     PL_StruxFmtHandle       getNthFmtHandle(PL_StruxDocHandle sdh, UT_uint32 n);
00425     bool                    getStyle(const char * szName, PD_Style ** ppStyle) const;
00426     PD_Style *              getStyleFromSDH(PL_StruxDocHandle sdh);
00427     PL_StruxDocHandle       getPrevNumberedHeadingStyle(PL_StruxDocHandle sdh);
00428     size_t                  getStyleCount(void);
00429     bool                    enumStyles(UT_uint32 k,
00430                                        const char ** pszName, const PD_Style ** ppStyle) const;
00431     bool                    enumStyles(UT_GenericVector<PD_Style*> * & pStyles) const;
00432     
00433     bool                    addStyleProperty(const gchar * szStyleName, const gchar * szPropertyName, const gchar * szPropertyValue);
00434     bool                    addStyleProperties(const gchar * szStyleName, const gchar ** pProperties);
00435     bool                    setAllStyleAttributes(const gchar * szStyleName, const gchar ** pAttribs);
00436     bool                    addStyleAttributes(const gchar * szStyleName, const gchar ** pAttribs);
00437 
00438     PL_StruxDocHandle       findPreviousStyleStrux(const gchar * szStyle, PT_DocPosition pos);
00439     PL_StruxDocHandle       findForwardStyleStrux(const gchar * szStyle, PT_DocPosition pos);
00440     bool                    updateDocForStyleChange(const gchar * szStyleName,
00441                                                     bool isParaStyle);
00442     void                    updateAllLayoutsInDoc( PL_StruxDocHandle sdh);
00443     void                    clearIfAtFmtMark(PT_DocPosition dpos);
00444 
00445     virtual UT_uint32       getLastSavedAsType() const { return m_lastSavedAsType; }
00446     UT_uint32               getLastOpenedType() { return m_lastOpenedType; }
00447     XAP_App *               getApp() { return m_pApp; }
00448     bool                    updateFields(void);
00449     bool                    getField(PL_StruxDocHandle sdh,
00450                                      UT_uint32 offset,
00451                                      fd_Field * &pField);
00452     po_Bookmark *           getBookmark(PL_StruxDocHandle sdh, UT_uint32 offset);
00453     pf_Frag *               findBookmark(const char * pName, bool bEnd = false, pf_Frag * pfStart = NULL);
00454     
00455     void                    setDontChangeInsPoint(void);
00456     void                    allowChangeInsPoint(void);
00457     bool                    getAllowChangeInsPoint(void) const;
00458     // Footnote functions
00459     bool                    isFootnoteAtPos(PT_DocPosition pos);
00460     bool                    isEndFootnoteAtPos(PT_DocPosition pos);
00461     UT_sint32               getEmbeddedOffset(PL_StruxDocHandle sdh,PT_DocPosition posOff, PL_StruxDocHandle & sdhEmbedded);
00462 
00463     // TOC functions
00464     bool                    isTOCAtPos(PT_DocPosition pos);
00465 
00466     // FRAME function
00467     bool                    isFrameAtPos(PT_DocPosition pos);
00468     bool                    isEndFrameAtPos(PT_DocPosition pos);
00469     bool                    isHdrFtrAtPos(PT_DocPosition pos);
00470     bool                    isSectionAtPos(PT_DocPosition pos);
00471     bool                    isBlockAtPos(PT_DocPosition pos);
00472 
00473 // Table functions
00474 
00475     bool                    isTableAtPos(PT_DocPosition pos);
00476     bool                    isEndTableAtPos(PT_DocPosition pos);
00477     bool                    isCellAtPos(PT_DocPosition pos);
00478     PL_StruxDocHandle       getEndTableStruxFromTableSDH(PL_StruxDocHandle tableSDH);
00479     PL_StruxDocHandle       getEndCellStruxFromCellSDH(PL_StruxDocHandle cellSDH);
00480     PL_StruxDocHandle       getEndTableStruxFromTablePos(PT_DocPosition posTable);
00481     bool                    getRowsColsFromTableSDH(PL_StruxDocHandle tableSDH,
00482                                                     bool bShowRevisions, UT_uint32 iRevisionLevel,
00483                                                     UT_sint32 * numRows, UT_sint32 * numCols);
00484     PL_StruxDocHandle       getCellSDHFromRowCol(PL_StruxDocHandle tableSDH,
00485                                                  bool bShowRevisions, UT_uint32 iRevisionLevel,
00486                                                  UT_sint32 row, 
00487                                                  UT_sint32 col);
00488     void                    miniDump(PL_StruxDocHandle sdh, UT_sint32 nstruxes);
00489 
00490     // List Functions
00491     fl_AutoNum *            getListByID(UT_uint32 id) const;
00492     fl_AutoNum *            getNthList(UT_uint32 i) const;
00493     bool                    enumLists(UT_uint32 k, fl_AutoNum ** pAutoNum);
00494     UT_uint32               getListsCount(void) const;
00495     void                    addList(fl_AutoNum * pAutoNum);
00496     bool                    appendList(const gchar ** attributes);
00497     bool                    fixListHierarchy(void);
00498     void                    removeList(fl_AutoNum * pAutoNum,PL_StruxDocHandle sdh );
00499     void                    listUpdate(PL_StruxDocHandle sdh);
00500     void                    StopList(PL_StruxDocHandle sdh);
00501     void                    disableListUpdates(void);
00502     void                    enableListUpdates(void);
00503     void                    updateDirtyLists(void);
00504     bool                    areListUpdatesAllowed(void);
00505     void                    setHasListStopped(bool bStop) {m_bHasListStopped = bStop;}
00506     bool                    hasListStopped(void) const {return m_bHasListStopped;}
00507 
00508     void                    setDoingPaste(void);
00509     void                    clearDoingPaste(void);
00510     bool                    isDoingPaste(void);
00511 
00512     void                    setRedrawHappenning(bool bIsHappening) {m_bRedrawHappenning  = bIsHappening;}
00513     bool                    isRedrawHappenning(void) const {return m_bRedrawHappenning;}
00514 
00515     // PageSize functions
00516     bool                    convertPercentToInches(const char * szPercent, UT_UTF8String & sInches);
00517     bool                    setPageSizeFromFile(const gchar ** attributes);
00518     const   fp_PageSize *   getPageSize(void) const 
00519     { return & m_docPageSize;}
00520     fp_PageSize             m_docPageSize; // Move this to private later
00521     bool                    isBookmarkUnique(const gchar * pName) const;
00522     bool                    isBookmarkRelativeLink(const gchar * pName) const;
00523     UT_uint32               getBookmarkCount()const {return m_vBookmarkNames.getItemCount();}
00524     const gchar *       getNthBookmark(UT_uint32 n)const{return reinterpret_cast<const gchar *>(m_vBookmarkNames.getNthItem(n));}
00525     void                    addBookmark(const gchar * pName);
00526     void                    removeBookmark(const gchar * pName);
00527 
00529     // Functions for dealing with revisions
00530     //
00531     virtual void            setMarkRevisions(bool bMark);
00532     // primarly for use by the PieceTable
00533     void                    setMarkRevisionsNoNotify(bool bMark) {AD_Document::setMarkRevisions(bMark);}
00534     
00535     virtual bool            acceptRejectRevision(bool bReject,
00536                                                  UT_uint32 iStart,
00537                                                  UT_uint32 iEnd,
00538                                                  UT_uint32 iLevel);
00539 
00540     virtual bool            rejectAllHigherRevisions(UT_uint32 iLevel);
00541     virtual bool            acceptAllRevisions();
00542 
00543     const PP_AttrProp *     explodeRevisions(PP_RevisionAttr *& pRevisions, const PP_AttrProp * pAP,
00544                                              bool bShow, UT_uint32 iId, bool &bHiddenRevision) const;
00545     
00546     virtual void            purgeRevisionTable(bool bUnconditional = false);
00547 
00548     void                    notifyPieceTableChangeStart(void);
00549     void                    notifyPieceTableChangeEnd(void);
00550 
00551 
00552 
00553     pt_PieceTable *         getPieceTable(void) const
00554         { return m_pPieceTable; }
00555 #ifdef PT_TEST
00556     void                    __dump(FILE * fp) const;
00558     static PD_Document*     m_pDoc;
00559 #endif
00560 
00561     // If we're using styles to format a document, prevent accidental use of other formatting
00562         // tools.  Disable all explicit formatting tools (font, color, boldness, etc.)
00563     inline bool areStylesLocked () const { return m_bLockedStyles; }    // See also lockStyles
00564     void lockStyles(bool b);
00565 
00566     virtual void setMetaDataProp (const UT_String & key, const UT_UTF8String & value);
00567     virtual bool getMetaDataProp (const UT_String & key, UT_UTF8String & outProp) const;
00568 
00569     // RIVERA TODO not working and may not be needed
00570     virtual void setAnnotationProp (const UT_String & key, const UT_UTF8String & value);
00571     virtual bool getAnnotationProp (const UT_String & key, UT_UTF8String & outProp) const;
00572 
00573     UT_GenericStringMap<UT_UTF8String*> & getMetaData () { return m_metaDataMap ; }
00574 
00575     // document-level property handling functions
00576     const PP_AttrProp *     getAttrProp() const;
00577     PT_AttrPropIndex        getAttrPropIndex() const {return m_indexAP;}
00578     bool                    setAttrProp(const gchar ** ppAttr);
00579     bool                    setAttributes(const gchar ** ppAttr);
00580     bool                    setProperties(const gchar ** ppProps);
00581     void                     setDontImmediatelyLayout(bool b)
00582         { m_bDontImmediatelyLayout = b;}
00583     bool                     isDontImmediateLayout(void)
00584         { return m_bDontImmediatelyLayout;}
00585 
00586     /* Okay, as far as I can tell this is a non-persistent document property since it is not
00587      * written to the AbiWord file when the document is saved. In fact, it is only set if a
00588      * mail-merge source/link is given on the command line.
00589      * 
00590      * Mail merge fields are, naturally, saved and loaded, but the Insert->Mail Merge Field...
00591      * dialog doesn't reflect the current document's fields but rather some internal set of
00592      * fields, which is confusing if you are trying to work with muliple mail merge sources.
00593      */
00594     // map UT_String=>UT_UTF8String*
00595 
00596     UT_UTF8String   getMailMergeField(const UT_String & key) const;
00597     bool            mailMergeFieldExists(const UT_String & key) const;
00598     void            setMailMergeField(const UT_String & key, const UT_UTF8String & value);
00599 
00600     void            clearMailMergeMap();
00601 
00602     void setMailMergeLink (const char * file) {
00603         m_mailMergeLink = file;
00604     }
00605 
00606     const UT_UTF8String &                           getMailMergeLink() const { return m_mailMergeLink; }
00607     const UT_GenericStringMap<UT_UTF8String *> &    getMailMergeMap() const  { return m_mailMergeMap; }
00608 
00609     void invalidateCache(void);
00610 
00611     /*
00612        The purpose of the following methods is to generate and manage
00613        document-wide unique identifiers; the indetifiers are type
00614        specific, with the types defined in UT_UniqueId class (ut_mics.h).
00615        
00616        UT_uint32 getUID(type):    Generates an id of a given type or
00617                                   UT_UID_INVALID if unique id cannot
00618                                   be generated (0 <= uid < UT_UID_INVALID).
00619 
00620        bool isIdUnique(type, id): Returns true if a given id can be
00621                                   used as a unique identifier of a
00622                                   given type; before the identifier is
00623                                   used, the caller should call
00624                                   setMinUID(id+1) to ensure integrity of
00625                                   the UID generator.
00626                                   
00627        bool setMinUID(type, uid): Allows to set a minimum value for all
00628                                   future identifiers; it returns true on
00629                                   success false on failure. The purpose is
00630                                   to allow an easy insertion of
00631                                   document-stored id's into the UID space
00632                                   by document importers: if the importer
00633                                   encounters a stored value ID it should
00634                                   call setMinUID(type, ID+1).
00635     */
00636 
00637     UT_uint32 getUID(UT_UniqueId::idType t) {return m_UID.getUID(t);}
00638     bool      setMinUID(UT_UniqueId::idType t, UT_uint32 i) {return m_UID.setMinId(t,i);}
00639     bool      isIdUnique(UT_UniqueId::idType t, UT_uint32 i) {return m_UID.isIdUnique(t,i);}
00640 
00641     virtual bool  areDocumentContentsEqual(const AD_Document &d, UT_uint32 &pos) const;
00642     virtual bool  areDocumentFormatsEqual(const AD_Document &d, UT_uint32 &pos) const;
00643     virtual bool  areDocumentStylesheetsEqual(const AD_Document &d) const;
00644 
00645     bool      findFirstDifferenceInContent(PT_DocPosition &pos, UT_sint32 &iOffset2,
00646                                            const PD_Document &d) const;
00647     
00648     bool      findWhereSimilarityResumes(PT_DocPosition &pos, UT_sint32 &iOffset2,
00649                                          UT_uint32 & iKnownLength,
00650                                          const PD_Document &d) const;
00651 
00652     virtual void   setAutoRevisioning(bool autorev);
00653 
00654     virtual UT_uint32 getXID();
00655     virtual UT_uint32 getTopXID() const;
00656     void              fixMissingXIDs();
00657     UT_uint32         getFragXIDforVersion(const pf_Frag * pf, UT_uint32 iVersion) const;
00658     void              removeConnections(void);
00659     void              changeConnectedDocument(PD_Document * pDoc);
00660     UT_sint32     getNewHdrHeight(void) const
00661     { return m_iNewHdrHeight;}
00662     UT_sint32     getNewFtrHeight(void) const
00663     { return m_iNewFtrHeight;}
00664 
00665     void       setNewHdrHeight(UT_sint32 newHeight)
00666     { m_iNewHdrHeight = newHeight;}
00667     void       setNewFtrHeight(UT_sint32 newHeight)
00668     { m_iNewFtrHeight = newHeight;}
00669 
00670     bool                    purgeFmtMarks();
00671 
00672     void                    tellPTDoNotTweakPosition(bool b);
00673 
00674     void                    setVDNDinProgress(bool b) {m_bVDND = b;}
00675     bool                    isVDNDinProgress() const {return m_bVDND;}
00676     UT_sint32               getCRNumber() const { return m_iCRCounter; }
00677     void                    setCRNumber(UT_sint32 iCRCounter) { m_iCRCounter = iCRCounter; }
00678     UT_sint32               getNextCRNumber(void);
00679     void                    getAllViews(UT_GenericVector<AV_View *> * vecViews);
00680     void                    ignoreSignals(void)
00681     { m_bIgnoreSignals = true;}
00682     void                    dontIgnoreSignals(void)
00683     { m_bIgnoreSignals = false;}
00684     void                    setClean(void)
00685     { _setClean();}
00686 
00687     void                    setCoalescingMask(bool mask)
00688     { m_bCoalescingMask = mask; }
00689     bool                    isCoalescingMasked()
00690     { return m_bCoalescingMask; }
00691 protected:
00692     virtual ~PD_Document();
00693 
00694     virtual UT_Error        _saveAs(const char * szFilename, int ieft, const char * expProps = NULL);
00695     virtual UT_Error        _saveAs(const char * szFilename, int ieft, bool cpy, const char * expProps = NULL);
00696     virtual UT_Error        _saveAs(GsfOutput *output, int ieft, bool cpy, const char * expProps);
00697     virtual UT_Error        _save(void);
00698     
00699     
00700     void                    _setClean(void);
00701     void                    _destroyDataItemData(void);
00702     bool                    _syncFileTypes(bool bReadSaveWriteOpen);
00703 
00704     bool                    _acceptRejectRevision(bool bReject, UT_uint32 iStart, UT_uint32 iEnd,
00705                                                   const PP_Revision * pRev,
00706                                                   PP_RevisionAttr &RevAttr, pf_Frag * pf,
00707                                                   bool & bDeleted);
00708 
00709     virtual void            _clearUndo();
00710     
00711     UT_Error _importFile(const char * szFilename, int ieft,
00712                          bool markClean, bool bImportStylesFirst,
00713                          bool isImportFile, const char* impProps);
00714     UT_Error _importFile(GsfInput * input, int ieft,
00715                          bool markClean, bool bImportStylesFirst,
00716                          bool bIsImportFile, const char* impProps);
00717     
00718 public:
00719     // these functions allow us to retrieve visual direction at document
00720     // position pos from an associated layout. They are intended to be
00721     // used by exporters into (daft) formats where such information
00722     // might be required (e.g. RTF).
00723     bool                    exportGetVisDirectionAtPos(PT_DocPosition pos, UT_BidiCharType &