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

fl_TOCLayout.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 2004 Martin Sevior <msevior@physics.unimelb.edu.au>
00003  * Copyright (C) 1998 AbiSource, Inc.
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018  * 02110-1301 USA.
00019  */
00020 
00021 #ifndef TOCLAYOUT_H
00022 #define TOCLAYOUT_H
00023 
00024 #include "ut_string_class.h"
00025 #include "ut_types.h"
00026 #include "ut_vector.h"
00027 #include "pt_Types.h"
00028 #include "fl_Layout.h"
00029 #include "fl_DocLayout.h"
00030 #include "fl_BlockLayout.h"
00031 #include "fl_ContainerLayout.h"
00032 #include "fl_SectionLayout.h"
00033 #include "pl_Listener.h"
00034 #include "ut_debugmsg.h"
00035 
00036 class PD_Style;
00037 class fp_TOCContainer;
00038 
00039 class ABI_EXPORT TOCEntry
00040 {
00041 public:
00042     TOCEntry(fl_BlockLayout * pBlock,
00043              UT_sint32 iLevel,
00044              UT_UTF8String & sDispStyle,
00045              bool bHaveLabel,
00046              FootnoteType iFType,
00047              UT_UTF8String & sBefore,
00048              UT_UTF8String sAfter,
00049              bool bInherit,
00050              UT_sint32 iStartAt);
00051 
00052     virtual ~ TOCEntry(void);
00053     fl_BlockLayout *     getBlock(void)
00054         { return m_pBlock;}
00055     PT_DocPosition       getPositionInDoc(void);
00056     UT_sint32            getLevel(void)
00057         { return m_iLevel;}
00058     UT_UTF8String &      getDispStyle(void)
00059         { return m_sDispStyle;}
00060     bool                 hasLabel(void) const
00061         { return m_bHasLabel;}
00062     bool                 doesInherit(void)
00063         { return m_bInherit;}
00064     void                 setPosInList(UT_sint32 posInList);
00065     UT_sint32            getPosInList(void)
00066         { return m_iPosInList;}
00067     void                 calculateLabel(TOCEntry * pPrevLevel);
00068     UT_UTF8String &      getNumLabel(void)
00069         { return m_sLabel;}
00070     UT_UTF8String       getFullLabel(void);
00071 private:
00072     fl_BlockLayout *  m_pBlock;
00073     UT_sint32         m_iLevel;
00074     UT_UTF8String     m_sDispStyle;
00075     bool              m_bHasLabel;
00076     FootnoteType      m_iFType;
00077     UT_UTF8String     m_sBefore;
00078     UT_UTF8String     m_sAfter;
00079     bool              m_bInherit;
00080     UT_sint32         m_iPosInList;
00081     UT_UTF8String     m_sLabel;
00082 };
00083 
00084 // We have one fl_TOCLayout for each Table of Contents.
00085 
00086 class ABI_EXPORT fl_TOCLayout : public fl_SectionLayout
00087 {
00088     friend class fl_DocListener;
00089     friend class fp_FootnoteContainer;
00090 
00091 public:
00092     fl_TOCLayout(FL_DocLayout* pLayout,
00093                  fl_DocSectionLayout * pDocSL,
00094                  pf_Frag_Strux* sdh,
00095                  PT_AttrPropIndex ap,
00096                  fl_ContainerLayout * pMyContainerLayout);
00097 
00098     virtual ~fl_TOCLayout();
00099 
00100     virtual bool    doclistener_changeStrux(const PX_ChangeRecord_StruxChange * pcrxc);
00101     virtual bool    doclistener_deleteStrux(const PX_ChangeRecord_Strux * pcrx);
00102     virtual bool    doclistener_deleteEndTOC(const PX_ChangeRecord_Strux * pcrx);
00103     virtual bool    bl_doclistener_insertEndTOC(fl_ContainerLayout*,
00104                                                 const PX_ChangeRecord_Strux * pcrx,
00105                                                 pf_Frag_Strux* sdh,
00106                                                 PL_ListenerId lid,
00107                                                 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00108                                                                         PL_ListenerId lid,
00109                                                                         fl_ContainerLayout* sfhNew));
00110 
00111     virtual void             format(void);
00112     virtual void             updateLayout(bool bDoFull);
00113     virtual void             collapse(void);
00114     virtual void             markAllRunsDirty(void);
00115     virtual fl_SectionLayout *  getSectionLayout(void)  const;
00116     bool                     recalculateFields(UT_uint32 iUpdateCount);
00117     virtual void             redrawUpdate(void);
00118     virtual fp_Container*    getNewContainer(fp_Container* = NULL);
00119     fl_DocSectionLayout*     getDocSectionLayout(void) const { return m_pDocSL; }
00120     bool                     isEndTOCIn(void) const {return m_bHasEndTOC;}
00121     void                     setTOCEndIn(void);
00122     TOCEntry *               createNewEntry(fl_BlockLayout * pBL);
00123     PT_DocPosition           getDocPosition(void);
00124     UT_uint32                getLength(void);
00125     fl_BlockLayout  *        findMatchingBlock(fl_BlockLayout * pBlock);
00126     UT_sint32                isInVector(fl_BlockLayout * pBlock, UT_GenericVector<TOCEntry *>* pVecBlocks);
00127     UT_uint32                getTOCPID(void) const { return m_iTOCPID;}
00128     bool                     isTOCEmpty() const {return (m_vecEntries.getItemCount() == 0);}
00129     bool                     isStyleInTOC(UT_UTF8String & sStyle);
00130     bool                     isBlockInTOC(fl_BlockLayout * pBlock);
00131     bool                     addBlock(fl_BlockLayout * pBlock, bool bVerifyRange = true);
00132     bool                     removeBlock(fl_BlockLayout * pBlock);
00133     fl_BlockLayout *         getMatchingBlock(fl_BlockLayout * pBlock);
00134     UT_UTF8String &          getTOCListLabel(fl_BlockLayout * pBlock);
00135     UT_UTF8String &          getTOCHeading(void) { return m_sTOCHeading;}
00136     UT_sint32                getCurrentLevel(void) const { return m_iCurrentLevel;}
00137     FootnoteType             getNumType(UT_sint32 iLevel);
00138     eTabLeader               getTabLeader(UT_sint32 iLevel);
00139     UT_sint32                getTabPosition(UT_sint32 iLevel, const fl_BlockLayout * pBlock);
00140     void                     setSelected(bool bSetSelected);
00141     bool                     isSelected(void) { return m_bIsSelected;}
00142 
00143     const UT_UTF8String &    getRangeBookmarkName() const {return m_sRangeBookmark;}
00144     bool                     verifyBookmarkAssumptions();
00145     bool                     fillTOC(void);
00146     
00147     static std::string       getDefaultHeading();
00148     static UT_UTF8String     getDefaultSourceStyle(UT_uint32 iLevel);
00149     static UT_UTF8String     getDefaultDestStyle(UT_uint32 iLevel);
00150 
00151 private:
00152     virtual void             _purgeLayout(void);
00153     virtual void             _lookupProperties(const PP_AttrProp* pAP);
00154     void                     _createTOCContainer(void);
00155     bool                     _isStyleInTOC(UT_UTF8String & sStyle, UT_UTF8String & sTOCStyle);
00156     void                     _insertTOCContainer(fp_TOCContainer * pNewTOC);
00157     void                     _localCollapse();
00158 
00159     void                     _createAndFillTOCEntry(PT_DocPosition posStart, PT_DocPosition posEnd,
00160                                                     fl_BlockLayout * pPrevBL, const char * pszStyle,
00161                                                     UT_sint32 iAllBlocks);
00162 
00163     void                     _addBlockInVec(fl_BlockLayout * pBlock,UT_UTF8String & sStyle);
00164     void                     _removeBlockInVec(fl_BlockLayout * pBlock, bool bDontRecurse = false);
00165     void                     _calculateLabels(void);
00166     UT_sint32                _getStartValue(TOCEntry * pEntry);
00167     bool                     m_bNeedsRebuild;
00168     bool                     m_bNeedsFormat;
00169     bool                     m_bIsOnPage;
00170     UT_uint32                m_iTOCPID;
00171     fl_DocSectionLayout*     m_pDocSL;
00172     bool                     m_bHasEndTOC;
00173     bool                     m_bDoingPurge;
00174     bool                     m_bIsSelected;
00175     UT_UTF8String            m_sSourceStyle1;
00176     UT_UTF8String            m_sSourceStyle2;
00177     UT_UTF8String            m_sSourceStyle3;
00178     UT_UTF8String            m_sSourceStyle4;
00179     UT_UTF8String            m_sDestStyle1;
00180     UT_UTF8String            m_sDestStyle2;
00181     UT_UTF8String            m_sDestStyle3;
00182     UT_UTF8String            m_sDestStyle4;
00183     UT_UTF8String            m_sNumOff1;
00184     UT_UTF8String            m_sNumOff2;
00185     UT_UTF8String            m_sNumOff3;
00186     UT_UTF8String            m_sNumOff4;
00187     FootnoteType             m_iNumType1;
00188     FootnoteType             m_iNumType2;
00189     FootnoteType             m_iNumType3;
00190     FootnoteType             m_iNumType4;
00191     eTabLeader               m_iTabLeader1;
00192     eTabLeader               m_iTabLeader2;
00193     eTabLeader               m_iTabLeader3;
00194     eTabLeader               m_iTabLeader4;
00195     UT_GenericVector<TOCEntry *> m_vecEntries;
00196     UT_sint32                m_iCurrentLevel;
00197     UT_UTF8String            m_sTOCHeading;
00198     bool                     m_bTOCHeading;
00199     UT_UTF8String            m_sTOCHeadingStyle;
00200     FootnoteType             m_iLabType1;
00201     FootnoteType             m_iLabType2;
00202     FootnoteType             m_iLabType3;
00203     FootnoteType             m_iLabType4;
00204     UT_UTF8String            m_sLabBefore1;
00205     UT_UTF8String            m_sLabBefore2;
00206     UT_UTF8String            m_sLabBefore3;
00207     UT_UTF8String            m_sLabBefore4;
00208     UT_UTF8String            m_sLabAfter1;
00209     UT_UTF8String            m_sLabAfter2;
00210     UT_UTF8String            m_sLabAfter3;
00211     UT_UTF8String            m_sLabAfter4;
00212     UT_UTF8String            m_sRangeBookmark;
00213     bool                     m_bHasLabel1;
00214     bool                     m_bHasLabel2;
00215     bool                     m_bHasLabel3;
00216     bool                     m_bHasLabel4;
00217     bool                     m_bInherit1;
00218     bool                     m_bInherit2;
00219     bool                     m_bInherit3;
00220     bool                     m_bInherit4;
00221     UT_sint32                m_iStartAt1;
00222     UT_sint32                m_iStartAt2;
00223     UT_sint32                m_iStartAt3;
00224     UT_sint32                m_iStartAt4;
00225     bool                     m_bMissingBookmark;
00226     bool                     m_bFalseBookmarkEstimate;
00227     UT_NumberVector          m_vecBookmarkPositions;
00228 };
00229 
00230 
00231 class ABI_EXPORT fl_TOCListener : public PL_Listener
00232 {
00233 public:
00234     fl_TOCListener(fl_TOCLayout* pTOCL, fl_BlockLayout * pPrevBL, PD_Style * pStyle);
00235     virtual ~fl_TOCListener();
00236 
00237     virtual bool                populate(fl_ContainerLayout* sfh,
00238                                          const PX_ChangeRecord * pcr);
00239 
00240     virtual bool                populateStrux(pf_Frag_Strux* sdh,
00241                                               const PX_ChangeRecord * pcr,
00242                                               fl_ContainerLayout* * psfh);
00243 
00244     virtual bool                change(fl_ContainerLayout* sfh,
00245                                        const PX_ChangeRecord * pcr);
00246 
00247     virtual bool                insertStrux(fl_ContainerLayout* sfh,
00248                                             const PX_ChangeRecord * pcr,
00249                                             pf_Frag_Strux* sdh,
00250                                             PL_ListenerId lid,
00251                                             void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00252                                                                     PL_ListenerId lid,
00253                                                                     fl_ContainerLayout* sfhNew));
00254 
00255     virtual bool                signal(UT_uint32 iSignal);
00256 
00257 private:
00258     PD_Document*                m_pDoc;
00259     fl_TOCLayout*               m_pTOCL;
00260     fl_BlockLayout *            m_pPrevBL;
00261     bool                        m_bListening;
00262     fl_ContainerLayout*         m_pCurrentBL;
00263     PD_Style *                  m_pStyle;
00264 };
00265 
00266 #endif /* TOCLAYOUT_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1