• 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., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 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, std::string& storage);
00300     bool                    addAuthorAttributeIfBlank( PP_AttrProp *&p_AttrProp);
00301     bool                    _buildAuthorProps(pp_Author * pAuthor, const gchar **& szProps, std::string& storage);
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                                        UT_uint32 * insertedSpanLength = NULL);
00324     bool                    insertSpan(PT_DocPosition dpos,
00325                                        const std::string& s,
00326                                        PP_AttrProp *p_AttrProp = NULL);
00327 
00328     bool                    deleteSpan(PT_DocPosition dpos1,
00329                                        PT_DocPosition dpos2,
00330                                        PP_AttrProp *p_AttrProp_Before,
00331                                        UT_uint32 &iRealDeleteCount,
00332                                        bool bDeleteTableStruxes = false);
00333 
00334     bool                    deleteFmtMark( PT_DocPosition dpos);
00335 
00336     bool                    changeSpanFmt(PTChangeFmt ptc,
00337                                           PT_DocPosition dpos1,
00338                                           PT_DocPosition dpos2,
00339                                           const gchar ** attributes,
00340                                           const gchar ** properties);
00341 
00342     bool                    insertStrux(PT_DocPosition dpos,
00343                                         PTStruxType pts, pf_Frag_Strux ** ppfs_ret = 0);
00344     bool                    deleteStrux(PT_DocPosition dpos,
00345                                         PTStruxType pts,
00346                                         bool bRecordChange);
00347 
00348     bool                    createAndSendCR(PT_DocPosition dpos,UT_sint32 iType,bool bsave,UT_Byte iGlob);
00349     virtual bool            createAndSendDocPropCR( const gchar ** pAtts,const gchar ** pProps );
00350     bool                    changeDocPropeties(const gchar ** szAtts, const gchar ** pProps);
00351 
00352     bool                    insertStrux(PT_DocPosition dpos,
00353                                         PTStruxType pts,
00354                                           const gchar ** attributes,
00355                                           const gchar ** properties, pf_Frag_Strux ** ppfs_ret = 0);
00356 
00357     void                    deleteHdrFtrStrux(pf_Frag_Strux* sdh);
00358 
00359     bool                    changeStruxFmt(PTChangeFmt ptc,
00360                                            PT_DocPosition dpos1,
00361                                            PT_DocPosition dpos2,
00362                                            const gchar ** attributes,
00363                                            const gchar ** properties,
00364                                            PTStruxType pts);
00365 
00366     bool                    changeStruxFmt(PTChangeFmt ptc,
00367                                            PT_DocPosition dpos1,
00368                                            PT_DocPosition dpos2,
00369                                            const gchar ** attributes,
00370                                            const gchar ** properties);
00371 
00372 
00373     bool                    changeStruxFmtNoUndo(PTChangeFmt ptc,
00374                                            pf_Frag_Strux* sdh,
00375                                            const gchar ** attributes,
00376                                            const gchar ** properties);
00377 
00378     bool                    changeStruxForLists(pf_Frag_Strux* sdh,
00379                                                 const char * pszParentID);
00380 
00381     bool                    insertFmtMark(PTChangeFmt ptc,
00382                                           PT_DocPosition dpos,
00383                                           PP_AttrProp *p_AttrProp);
00384 
00385     bool                    changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts,
00386                                                      const gchar ** attrs, const gchar ** props,
00387                                                      bool bSkipEmbededSections);
00388 
00389     bool                    changeLastStruxFmtNoUndo(PT_DocPosition dpos, PTStruxType pts,
00390                                                      const gchar ** attrs, const gchar * props,
00391                                                      bool bSkipEmbededSections);
00392 
00393     // the append- and insertBeforeFrag methods are only available while importing
00394     // the document.
00395 
00396     bool                    appendStrux(PTStruxType pts, const gchar ** attributes, pf_Frag_Strux ** ppfs_ret = 0);
00397     bool                    appendStruxFmt(pf_Frag_Strux * pfs, const gchar ** attributes);
00398     bool                    appendLastStruxFmt(PTStruxType pts, const gchar ** attrs, const gchar ** props,
00399                                                bool bSkipEmbededSections);
00400     bool                    appendLastStruxFmt(PTStruxType pts, const gchar ** attrs, const gchar * props,
00401                                                bool bSkipEmbededSections);
00402     bool                    appendFmt(const gchar ** attributes);
00403     bool                    appendFmt(const UT_GenericVector<const gchar*> * pVecAttributes);
00404     bool                    appendSpan(const UT_UCSChar * p, UT_uint32 length);
00405     bool                    appendObject(PTObjectType pto, const gchar ** attributes);
00406     bool                    appendFmtMark(void);
00407     bool                    appendStyle(const gchar ** attributes);
00408     bool                    changeStruxFormatNoUpdate(PTChangeFmt ptc ,pf_Frag_Strux* sdh,const gchar ** attributes);
00409     bool                    insertStruxBeforeFrag(pf_Frag * pF, PTStruxType pts,
00410                                                   const gchar ** attributes, pf_Frag_Strux ** ppfs_ret = 0);
00411     bool                    insertSpanBeforeFrag(pf_Frag * pF, const UT_UCSChar * p, UT_uint32 length);
00412     bool                    insertObjectBeforeFrag(pf_Frag * pF, PTObjectType pto,
00413                                                    const gchar ** attributes);
00414     bool                    insertFmtMarkBeforeFrag(pf_Frag * pF);
00415     bool                    insertFmtMarkBeforeFrag(pf_Frag * pF, const gchar ** attributes);
00416 
00417     pf_Frag *               findFragOfType(pf_Frag::PFType iType, UT_sint32 iSubtype = -1,
00418                                            pf_Frag * pfStart = NULL) const;
00419     pf_Frag *               getLastFrag() const;
00420     bool                    checkForSuspect(void);
00421     bool                    repairDoc(void);
00422     bool                    removeStyle(const gchar * name);
00423     bool                    tellListener(PL_Listener * pListener);
00424     bool                    tellListenerSubset( PL_Listener * pListener,
00425                                                 PD_DocumentRange * pDocRange,
00426                                                 PL_ListenerCoupleCloser* closer = 0 );
00427     bool                    addListener(PL_Listener * pListener, PL_ListenerId * pListenerId);
00428     bool                    removeListener(PL_ListenerId listenerId);
00429     bool                    signalListeners(UT_uint32 iSignal) const;
00430     bool                    notifyListeners(const pf_Frag_Strux * pfs, const PX_ChangeRecord * pcr) const;
00431     bool                    notifyListeners(const pf_Frag_Strux * pfs,
00432                                             pf_Frag_Strux * pfsNew,
00433                                             const PX_ChangeRecord * pcr) const;
00434     void                    deferNotifications(void);
00435     void                    processDeferredNotifications(void);
00436     UT_sint32               getAdjustmentForCR(const PX_ChangeRecord * pcr) const;
00437 
00438     // the first two of these functions just retrieve the AP with the given index; the latter two
00439     // return AP that represents state of things with current revision settings
00440     bool                    getAttrProp(PT_AttrPropIndex indexAP, const PP_AttrProp ** ppAP) const;
00441     bool                    getSpanAttrProp(pf_Frag_Strux* sdh, UT_uint32 offset, bool bLeftSide,
00442                                             const PP_AttrProp ** ppAP) const;
00443 
00444     bool                    getAttrProp(PT_AttrPropIndex apIndx, const PP_AttrProp ** ppAP, PP_RevisionAttr ** pRevisions,
00445                                         bool bShowRevisions, UT_uint32 iRevisionId, bool &bHiddenRevision) const;
00446 
00447     bool                    getSpanAttrProp(pf_Frag_Strux* sdh, UT_uint32 offset, bool bLeftSide,
00448                                             const PP_AttrProp ** ppAP,
00449                                             PP_RevisionAttr ** pRevisions,
00450                                             bool bShowRevisions, UT_uint32 iRevisionId,
00451                                             bool &bHiddenRevision) const;
00452 
00453     const UT_UCSChar *      getPointer(PT_BufIndex bi) const; /* see warning on this function */
00454     bool                    getBlockBuf(pf_Frag_Strux* sdh, UT_GrowBuf * pgb) const;
00455 
00456     bool                    getBounds(bool bEnd, PT_DocPosition & docPos) const;
00457     PTStruxType             getStruxType(pf_Frag_Strux* sdh) const;
00458     PT_DocPosition          getStruxPosition(pf_Frag_Strux* sdh) const;
00459     bool                    getStruxFromPosition(PL_ListenerId listenerId,
00460                                                  PT_DocPosition docPos,
00461                                                  fl_ContainerLayout* * psfh) const;
00462     bool                    getStruxOfTypeFromPosition(PL_ListenerId listenerId,
00463                                                        PT_DocPosition docPos,
00464                                                        PTStruxType pts,
00465                                                        fl_ContainerLayout* * psfh) const;
00466     bool                    getStruxOfTypeFromPosition(PT_DocPosition, PTStruxType pts, pf_Frag_Strux* * sdh) const;
00467     pf_Frag_Strux*       getBlockFromPosition( PT_DocPosition pos ) const;
00468 
00469     pf_Frag *               getFragFromPosition(PT_DocPosition docPos) const;
00470 
00471     bool                    getNextStruxOfType(pf_Frag_Strux* sdh,PTStruxType pts,
00472                                                pf_Frag_Strux* * nextsdh);
00473     bool                    getPrevStruxOfType(pf_Frag_Strux* sdh,PTStruxType pts,
00474                                                pf_Frag_Strux* * prevsdh);
00475     bool                    getNextStrux(pf_Frag_Strux* sdh, pf_Frag_Strux* *nextSDH);
00476 
00477     // data items
00478 
00479     virtual bool            createDataItem(const char * szName, bool bBase64,
00480                                            const UT_ByteBuf * pByteBuf,
00481                                            const std::string & mime_type,
00482                                            PD_DataItemHandle* ppHandle);
00483     virtual bool            replaceDataItem(const char * szName, const UT_ByteBuf * pByteBuf);
00484     virtual bool            getDataItemDataByName(const char * szName,
00485                                                   const UT_ByteBuf ** ppByteBuf,
00486                                                   std::string* pMimeType,
00487                                                   PD_DataItemHandle* ppHandle) const;
00488     bool                    setDataItemToken(PD_DataItemHandle pHandle, void* pToken) const;
00489     bool                    getDataItemData(PD_DataItemHandle pHandle,
00490                                             const char ** pszName, const UT_ByteBuf ** ppByteBuf,
00491                                             const void** ppToken) const;
00492     bool                    getDataItemFileExtension(const char *szDataID, std::string &sExt, bool bDot = true) const;
00493     bool                    enumDataItems(UT_uint32 k,
00494                                           PD_DataItemHandle* ppHandle, const char ** pszName,
00495                                           const UT_ByteBuf ** ppByteBuf, std::string * pMimeType) const;
00496 
00497     pf_Frag_Strux*       findHdrFtrStrux(const gchar * pszHdtFtr,
00498                                             const gchar * pszHdrFtrID);
00499     bool                    verifySectionID(const gchar * pszId);
00500     const pf_Frag_Strux*       getLastSectionSDH(void) const;
00501     pf_Frag_Strux*       getLastSectionMutableSDH(void);
00502     pf_Frag_Strux*       getLastStruxOfType(PTStruxType pts);
00503 
00504     bool                    changeStruxAttsNoUpdate(pf_Frag_Strux* sdh, const char * attr, const char * attvalue);
00505     bool                    deleteStruxNoUpdate(pf_Frag_Strux* sdh);
00506     bool                    deleteFragNoUpdate(pf_Frag * pf);
00507     bool                    insertStruxNoUpdateBefore(pf_Frag_Strux* sdh, PTStruxType pts,const gchar ** attributes );
00508     bool                    isStruxBeforeThis(pf_Frag_Strux* sdh,  PTStruxType pts);
00509 
00510     // the function below does exactly what the name says -- returns the AP index; in revisions mode
00511     // you would need the AP at that index to have revision attribute exploded -- use one of the
00512     // functions below to retrieve props and attrs correctly reflecting revisions settings
00513     PT_AttrPropIndex        getAPIFromSDH(pf_Frag_Strux* sdh);
00514     bool                    getAttributeFromSDH(pf_Frag_Strux* sdh, bool bShowRevisions, UT_uint32 iRevisionLevel,
00515                                                 const char * szAttribute, const char ** pszValue);
00516 
00517     bool                    getPropertyFromSDH(const pf_Frag_Strux* sdh, bool bShowRevisions, UT_uint32 iRevisionLevel,
00518                                                const char * szProperty, const char ** pszValue) const;
00519     // styles
00520     void                    getAllUsedStyles(UT_GenericVector<PD_Style*> * pVecStyles);
00521     fl_ContainerLayout*       getNthFmtHandle(pf_Frag_Strux* sdh, UT_uint32 n);
00522     const char *            getDefaultStyle() const;
00523     bool                    getStyle(const char * szName, PD_Style ** ppStyle) const;
00524     PD_Style *              getStyleFromSDH(pf_Frag_Strux* sdh);
00525     pf_Frag_Strux*       getPrevNumberedHeadingStyle(pf_Frag_Strux* sdh);
00526     size_t                  getStyleCount(void);
00527     bool                    enumStyles(UT_uint32 k,
00528                                        const char ** pszName, const PD_Style ** ppStyle) const;
00529     bool                    enumStyles(UT_GenericVector<PD_Style*> * & pStyles) const;
00530     bool                    getStyleProperty(const gchar * szStyleName, const gchar * szPropertyName, const gchar *& szPropertyValue);
00531     bool                    addStyleProperty(const gchar * szStyleName, const gchar * szPropertyName, const gchar * szPropertyValue);
00532     bool                    addStyleProperties(const gchar * szStyleName, const gchar ** pProperties);
00533     bool                    setAllStyleAttributes(const gchar * szStyleName, const gchar ** pAttribs);
00534     bool                    addStyleAttributes(const gchar * szStyleName, const gchar ** pAttribs);
00535 
00536     pf_Frag_Strux*       findPreviousStyleStrux(const gchar * szStyle, PT_DocPosition pos);
00537     pf_Frag_Strux*       findForwardStyleStrux(const gchar * szStyle, PT_DocPosition pos);
00538     bool                    updateDocForStyleChange(const gchar * szStyleName,
00539                                                     bool isParaStyle);
00540     void                    updateAllLayoutsInDoc( pf_Frag_Strux* sdh);
00541     void                    clearIfAtFmtMark(PT_DocPosition dpos);
00542 
00543     virtual UT_uint32       getLastSavedAsType() const { return m_lastSavedAsType; }
00544     UT_uint32               getLastOpenedType() const { return m_lastOpenedType; }
00545     bool                    updateFields(void);
00546     bool                    getField(pf_Frag_Strux* sdh,
00547                                      UT_uint32 offset,
00548                                      fd_Field * &pField);
00549     po_Bookmark *           getBookmark(pf_Frag_Strux* sdh, UT_uint32 offset);
00550     pf_Frag *               findBookmark(const char * pName, bool bEnd = false, pf_Frag * pfStart = NULL);
00551     bool                    hasMath(void);
00552 
00553     void                    setDontChangeInsPoint(void);
00554     void                    allowChangeInsPoint(void);
00555     bool                    getAllowChangeInsPoint(void) const;
00556     // Footnote functions
00557     bool                    isFootnoteAtPos(PT_DocPosition pos);
00558     bool                    isEndFootnoteAtPos(PT_DocPosition pos);
00559     UT_sint32               getEmbeddedOffset(pf_Frag_Strux* sdh,PT_DocPosition posOff, pf_Frag_Strux* & sdhEmbedded);
00560     bool                    hasEmbedStruxOfTypeInRange(PT_DocPosition posStart, PT_DocPosition posEnd, 
00561                                                        PTStruxType iType) const;
00562 
00563     // TOC functions
00564     bool                    isTOCAtPos(PT_DocPosition pos);
00565 
00566     // FRAME function
00567     bool                    isFrameAtPos(PT_DocPosition pos);
00568     bool                    isEndFrameAtPos(PT_DocPosition pos);
00569     bool                    isHdrFtrAtPos(PT_DocPosition pos);
00570     bool                    isSectionAtPos(PT_DocPosition pos);
00571     bool                    isBlockAtPos(PT_DocPosition pos);
00572 
00573 // Table functions
00574 
00575     bool                    isTableAtPos(PT_DocPosition pos);
00576     bool                    isEndTableAtPos(PT_DocPosition pos);
00577     bool                    isCellAtPos(PT_DocPosition pos);
00578     pf_Frag_Strux*       getEndTableStruxFromTableSDH(pf_Frag_Strux* tableSDH);
00579     pf_Frag_Strux*       getEndCellStruxFromCellSDH(pf_Frag_Strux* cellSDH);
00580     pf_Frag_Strux*       getEndTableStruxFromTablePos(PT_DocPosition posTable);
00581     bool                    getRowsColsFromTableSDH(pf_Frag_Strux* tableSDH,
00582                                                     bool bShowRevisions, UT_uint32 iRevisionLevel,
00583                                                     UT_sint32 * numRows, UT_sint32 * numCols);
00584     pf_Frag_Strux*       getCellSDHFromRowCol(pf_Frag_Strux* tableSDH,
00585                                                  bool bShowRevisions, UT_uint32 iRevisionLevel,
00586                                                  UT_sint32 row,
00587                                                  UT_sint32 col);
00588     void                    miniDump(pf_Frag_Strux* sdh, UT_sint32 nstruxes);
00589     bool                    dumpDoc( const char* msg, PT_DocPosition currentpos, PT_DocPosition endpos );
00590 
00591     bool                    isInsertHyperLinkValid(PT_DocPosition pos) const;
00592 
00593 
00594     // List Functions
00595     fl_AutoNum *            getListByID(UT_uint32 id) const;
00596     fl_AutoNum *            getNthList(UT_uint32 i) const;
00597     bool                    enumLists(UT_uint32 k, fl_AutoNum ** pAutoNum);
00598     UT_uint32               getListsCount(void) const;
00599     void                    addList(fl_AutoNum * pAutoNum);
00600     bool                    appendList(const gchar ** attributes);
00601     bool                    fixListHierarchy(void);
00602     void                    removeList(fl_AutoNum * pAutoNum,pf_Frag_Strux* sdh );
00603     void                    listUpdate(pf_Frag_Strux* sdh);
00604     void                    StopList(pf_Frag_Strux* sdh);
00605     void                    disableListUpdates(void);
00606     void                    enableListUpdates(void);
00607     void                    updateDirtyLists(void);
00608     bool                    areListUpdatesAllowed(void);
00609     void                    setHasListStopped(bool bStop) {m_bHasListStopped = bStop;}
00610     bool                    hasListStopped(void) const {return m_bHasListStopped;}
00611 
00612     void                    setDoingPaste(void);
00613     void                    clearDoingPaste(void);
00614     bool                    isDoingPaste(void);
00615 
00616     void                    setRedrawHappenning(bool bIsHappening) {m_bRedrawHappenning  = bIsHappening;}
00617     bool                    isRedrawHappenning(void) const {return m_bRedrawHappenning;}
00618 
00619     // PageSize functions
00620     bool                    convertPercentToInches(const char * szPercent, UT_UTF8String & sInches);
00621     bool                    setPageSizeFromFile(const gchar ** attributes);
00622     const   fp_PageSize *   getPageSize(void) const
00623     { return & m_docPageSize;}
00624     fp_PageSize             m_docPageSize; // Move this to private later
00625     bool                    isBookmarkUnique(const gchar * pName) const;
00626     bool                    isBookmarkRelativeLink(const gchar * pName) const;
00627     UT_sint32               getBookmarkCount() const {return m_vBookmarkNames.size();}
00628     const std::string &     getNthBookmark(UT_sint32 n) const {return m_vBookmarkNames.at(n);}
00629     void                    addBookmark(const gchar * pName);
00630     void                    removeBookmark(const gchar * pName);
00631 
00633     // Functions for dealing with revisions
00634     //
00635     virtual void            setMarkRevisions(bool bMark);
00636     // primarly for use by the PieceTable
00637     void                    setMarkRevisionsNoNotify(bool bMark) {AD_Document::setMarkRevisions(bMark);}
00638 
00639     virtual bool            acceptRejectRevision(bool bReject,
00640                                                  UT_uint32 iStart,
00641                                                  UT_uint32 iEnd,
00642                                                  UT_uint32 iLevel);
00643 
00644     virtual bool            rejectAllHigherRevisions(UT_uint32 iLevel);
00645     virtual bool            acceptAllRevisions();
00646 
00647     const PP_AttrProp *     explodeRevisions(PP_RevisionAttr *& pRevisions, const PP_AttrProp * pAP,
00648                                              bool bShow, UT_uint32 iId, bool &bHiddenRevision) const;
00649 
00650     virtual void            purgeRevisionTable(bool bUnconditional = false);
00651 
00652     void                    notifyPieceTableChangeStart(void);
00653     void                    notifyPieceTableChangeEnd(void);
00654 
00655 
00656 
00657     pt_PieceTable *         getPieceTable(void) const
00658         { return m_pPieceTable; }
00659     PD_DocumentRDFHandle    getDocumentRDF(void) const;
00660     PD_XMLIDCreatorHandle   makeXMLIDCreator();
00661 
00662 #ifdef PT_TEST
00663     void                    __dump(FILE * fp) const;
00665     static PD_Document*     m_pDoc;
00666 #endif
00667 
00668     // If we're using styles to format a document, prevent accidental use of other formatting
00669         // tools.  Disable all explicit formatting tools (font, color, boldness, etc.)
00670     inline bool areStylesLocked () const { return m_bLockedStyles; }    // See also lockStyles
00671     void lockStyles(bool b);
00672 
00673     virtual void setMetaDataProp (const std::string & key, const std::string & value);
00674     virtual bool getMetaDataProp (const std::string & key, std::string & outProp) const;
00675 
00676     // RIVERA TODO not working and may not be needed
00677     virtual void setAnnotationProp (const std::string & key, const std::string & value);
00678     virtual bool getAnnotationProp (const std::string & key, std::string & outProp) const;
00679 
00680     const std::map<std::string,std::string> & getMetaData () const
00681     {
00682         return m_metaDataMap ;
00683     }
00684 
00685     // document-level property handling functions
00686     const PP_AttrProp *     getAttrProp() const;
00687     PT_AttrPropIndex        getAttrPropIndex() const {return m_indexAP;}
00688     bool                    setAttrProp(const gchar ** ppAttr);
00689     bool                    setAttributes(const gchar ** ppAttr);
00690     bool                    setProperties(const gchar ** ppProps);
00691     void                     setDontImmediatelyLayout(bool b)
00692         { m_bDontImmediatelyLayout = b;}
00693     bool                     isDontImmediateLayout(void) const
00694         { return m_bDontImmediatelyLayout;}
00695 
00696     /* Okay, as far as I can tell this is a non-persistent document property since it is not
00697      * written to the AbiWord file when the document is saved. In fact, it is only set if a
00698      * mail-merge source/link is given on the command line.
00699      *
00700      * Mail merge fields are, naturally, saved and loaded, but the Insert->Mail Merge Field...
00701      * dialog doesn't reflect the current document's fields but rather some internal set of
00702      * fields, which is confusing if you are trying to work with muliple mail merge sources.
00703      */
00704     // map UT_String=>UT_UTF8String*
00705 
00706     UT_UTF8String   getMailMergeField(const UT_String & key) const;
00707     bool            mailMergeFieldExists(const UT_String & key) const;
00708     void            setMailMergeField(const UT_String & key, const UT_UTF8String & value);
00709 
00710     void            clearMailMergeMap();
00711 
00712     void setMailMergeLink (const char * file) {
00713         m_mailMergeLink = file;
00714     }
00715 
00716     const UT_UTF8String &                           getMailMergeLink() const { return m_mailMergeLink; }
00717     const UT_GenericStringMap<UT_UTF8String *> &    getMailMergeMap() const  { return m_mailMergeMap; }
00718 
00719     void invalidateCache(void);
00720 
00721     /*
00722        The purpose of the following methods is to generate and manage
00723        document-wide unique identifiers; the indetifiers are type
00724        specific, with the types defined in UT_UniqueId class (ut_mics.h).
00725 
00726        UT_uint32 getUID(type):    Generates an id of a given type or
00727                                   UT_UID_INVALID if unique id cannot
00728                                   be generated (0 <= uid < UT_UID_INVALID).
00729 
00730        bool isIdUnique(type, id): Returns true if a given id can be
00731                                   used as a unique identifier of a
00732                                   given type; before the identifier is
00733                                   used, the caller should call
00734                                   setMinUID(id+1) to ensure integrity of
00735                                   the UID generator.
00736 
00737        bool setMinUID(type, uid): Allows to set a minimum value for all
00738                                   future identifiers; it returns true on
00739                                   success false on failure. The purpose is
00740                                   to allow an easy insertion of
00741                                   document-stored id's into the UID space
00742                                   by document importers: if the importer
00743                                   encounters a stored value ID it should
00744                                   call setMinUID(type, ID+1).
00745     */
00746 
00747     UT_uint32 getUID(UT_UniqueId::idType t) {return m_UID.getUID(t);}
00748     bool      setMinUID(UT_UniqueId::idType t, UT_uint32 i) {return m_UID.setMinId(t,i);}
00749     bool      isIdUnique(UT_UniqueId::idType t, UT_uint32 i) const {return m_UID.isIdUnique(t,i);}
00750 
00751     virtual bool  areDocumentContentsEqual(const AD_Document &d, UT_uint32 &pos) const;
00752     virtual bool  areDocumentFormatsEqual(const AD_Document &d, UT_uint32 &pos) const;
00753     virtual bool  areDocumentStylesheetsEqual(const AD_Document &d) const;
00754 
00755     bool      findFirstDifferenceInContent(PT_DocPosition &pos, UT_sint32 &iOffset2,
00756                                            const PD_Document &d) const;
00757 
00758     bool      findWhereSimilarityResumes(PT_DocPosition &pos, UT_sint32 &iOffset2,
00759                                          UT_uint32 & iKnownLength,
00760                                          const PD_Document &d) const;
00761 
00762     virtual void   setAutoRevisioning(bool autorev);
00763 
00764     virtual UT_uint32 getXID() const;
00765     virtual UT_uint32 getTopXID() const;
00766     void              fixMissingXIDs();
00767     UT_uint32         getFragXIDforVersion(const pf_Frag * pf, UT_uint32 iVersion) const;
00768     void              removeConnections(void);
00769     void              changeConnectedDocument(PD_Document * pDoc);
00770     UT_sint32     getNewHdrHeight(void) const
00771     { return m_iNewHdrHeight;}
00772     UT_sint32     getNewFtrHeight(void) const
00773     { return m_iNewFtrHeight;}
00774 
00775     void       setNewHdrHeight(UT_sint32 newHeight)
00776     { m_iNewHdrHeight = newHeight;}
00777     void       setNewFtrHeight(UT_sint32 newHeight)
00778     { m_iNewFtrHeight = newHeight;}
00779 
00780     bool                    purgeFmtMarks();
00781 
00782     void                    tellPTDoNotTweakPosition(bool b);
00783 
00784     void                    setVDNDinProgress(bool b) {m_bVDND = b;}
00785     bool                    isVDNDinProgress() const {return m_bVDND;}
00786     UT_sint32               getCRNumber() const { return m_iCRCounter; }
00787     void                    setCRNumber(UT_sint32 iCRCounter) { m_iCRCounter = iCRCounter; }
00788     UT_sint32               getNextCRNumber(void);
00789     std::list<AV_View*>     getAllViews() const;
00790     void                    getAllViews(UT_GenericVector<AV_View *> * vecViews) const;
00791     void                    ignoreSignals(void)
00792     { m_bIgnoreSignals = true;}
00793     void                    dontIgnoreSignals(void)
00794     { m_bIgnoreSignals = false;}
00795     void                    setClean(void)
00796     { _setClean();}
00797 
00798     void                    setCoalescingMask(bool mask)
00799     { m_bCoalescingMask = mask; }
00800     bool                    isCoalescingMasked() const
00801     { return m_bCoalescingMask; }
00802 protected:
00803     virtual ~PD_Document();
00804 
00805     virtual UT_Error        _saveAs(const char * szFilename, int ieft, const char * expProps = NULL);
00806     virtual UT_Error        _saveAs(const char * szFilename, int ieft, bool cpy, const char * expProps = NULL);
00807     virtual UT_Error        _saveAs(GsfOutput *output, int ieft, bool cpy, const char * expProps);
00808     virtual UT_Error        _save(void);
00809 
00810 
00811     void                    _setClean(void);
00812     void                    _destroyDataItemData(void);
00813     bool                    _syncFileTypes(bool bReadSaveWriteOpen);
00814 
00815     bool                    _acceptRejectRevision(bool bReject, UT_uint32 iStart, UT_uint32 iEnd,
00816                                                   const PP_Revision * pRev,
00817                                                   PP_RevisionAttr &RevAttr, pf_Frag * pf,
00818                                                   bool & bDeleted);
00819 
00820     virtual void            _clearUndo();
00821 
00822     UT_Error _importFile(const char * szFilename, int ieft,
00823                          bool markClean, bool bImportStylesFirst,
00824                          bool isImportFile, const char* impProps);
00825     UT_Error _importFile(GsfInput * input, int ieft,
00826                          bool markClean, bool bImportStylesFirst,
00827                          bool bIsImportFile, const char* impProps);
00828 
00829     bool     _removeRepeatedHdrFtr(pf_Frag_Strux * pfs ,UT_GenericVector<pf_Frag_Strux *> * vecHdrFtrs, UT_sint32 i);
00830     bool     _pruneSectionAPI(pf_Frag_Strux * pfs,const char * szHType, UT_GenericVector<pf_Frag_Strux *> *vecHdrFtrs);
00831     bool     _matchSection(pf_Frag_Strux * pfs, UT_GenericVector<pf_Frag_Strux *> *vecSections);
00832     bool     _removeHdrFtr(pf_Frag_Strux * pfs);
00833     bool     _checkAndFixTable(pf_Frag_Strux * pfs);
00834 public:
00835     // these functions allow us to retrieve visual direction at document
00836     // position pos from an associated layout. They are intended to be
00837     // used by exporters into (daft) formats where such information
00838     // might be required (e.g. RTF).
00839     bool                    exportGetVisDirectionAtPos(PT_DocPosition pos, UT_BidiCharType &type);
00840 private:
00841     bool                    _exportInitVisDirection(PT_DocPosition pos);
00842     bool                    _exportFindVisDirectionRunAtPos(PT_DocPosition pos);
00843 
00844 private:
00845     bool                    m_ballowListUpdates;
00846     pt_PieceTable *         m_pPieceTable;
00847     PD_DocumentRDFHandle    m_hDocumentRDF;
00848     UT_GenericVector<PL_Listener *> m_vecListeners;
00849     UT_GenericVector<fl_AutoNum *> m_vecLists;
00850     bool                    m_bHasListStopped;
00851 
00852     typedef std::map<std::string, PD_DataItemHandle> hash_data_items_t;
00853     hash_data_items_t m_hashDataItems;
00854 public:
00855     IE_FileInfo             m_fileImpExpInfo;
00856 private:
00857     IEFileType              m_lastOpenedType;
00858     IEFileType              m_lastSavedAsType;
00859     bool                    m_bDoingPaste;
00860     bool                    m_bAllowInsertPointChange;
00861     bool                    m_bRedrawHappenning;
00862     bool                    m_bLoading;
00863     std::vector<std::string> m_vBookmarkNames;
00864     bool                    m_bLockedStyles;
00865     std::map<std::string, std::string> m_metaDataMap;
00866     PT_AttrPropIndex        m_indexAP;
00867     bool                    m_bDontImmediatelyLayout;
00868 
00869     // mapping UT_String=>UT_UTF8String pointer
00870     UT_GenericStringMap<UT_UTF8String*>  m_mailMergeMap;
00871 
00872     UT_UCS4Char             m_iLastDirMarker;
00873 
00874     UT_UTF8String           m_mailMergeLink;
00875 
00876     // these are for use with the export*VisDirection functions
00877     const fl_BlockLayout *  m_pVDBl;
00878     fp_Run *                m_pVDRun;
00879     PT_DocPosition          m_iVDLastPos;
00880     UT_UniqueId             m_UID;
00881     UT_sint32               m_iNewHdrHeight;
00882     UT_sint32               m_iNewFtrHeight;
00883     bool                    m_bMarginChangeOnly;
00884     UT_GenericVector<pf_Frag *> m_vecSuspectFrags;
00885 
00886     bool                    m_bVDND;
00887     UT_sint32               m_iCRCounter;
00888     mutable UT_sint32       m_iUpdateCount;
00889     bool                    m_bIgnoreSignals;
00890 
00891     bool                    m_bCoalescingMask;
00892     bool                    m_bShowAuthors;
00893     UT_GenericVector<pp_Author *>  m_vecAuthors;
00894     bool                    m_bExportAuthorAtts;
00895     UT_sint32               m_iMyAuthorInt;
00896     UT_sint32               m_iLastAuthorInt;
00897     UT_GenericVector<ImagePage *> m_pPendingImagePage;
00898     UT_GenericVector<TextboxPage *> m_pPendingTextboxPage;
00899     UT_sint32               m_iStruxCount;
00900     std::string             m_sUserName;
00901 public:
00902     const std::string &getUserName() const { return m_sUserName; }
00903 };
00904 
00905 #endif /* PD_DOCUMENT_H */

Generated on Sun May 19 2013 for AbiWord by  doxygen 1.7.1