00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 UT_sint32 m_iStartAt;
00083 };
00084
00085
00086
00087 class ABI_EXPORT fl_TOCLayout : public fl_SectionLayout
00088 {
00089 friend class fl_DocListener;
00090 friend class fp_FootnoteContainer;
00091
00092 public:
00093 fl_TOCLayout(FL_DocLayout* pLayout,
00094 fl_DocSectionLayout * pDocSL,
00095 PL_StruxDocHandle sdh,
00096 PT_AttrPropIndex ap,
00097 fl_ContainerLayout * pMyContainerLayout);
00098
00099 virtual ~fl_TOCLayout();
00100
00101 virtual bool doclistener_changeStrux(const PX_ChangeRecord_StruxChange * pcrxc);
00102 virtual bool doclistener_deleteStrux(const PX_ChangeRecord_Strux * pcrx);
00103 virtual bool doclistener_deleteEndTOC(const PX_ChangeRecord_Strux * pcrx);
00104 virtual bool bl_doclistener_insertEndTOC(fl_ContainerLayout*,
00105 const PX_ChangeRecord_Strux * pcrx,
00106 PL_StruxDocHandle sdh,
00107 PL_ListenerId lid,
00108 void (* pfnBindHandles)(PL_StruxDocHandle sdhNew,
00109 PL_ListenerId lid,
00110 PL_StruxFmtHandle sfhNew));
00111
00112 virtual void format(void);
00113 virtual void updateLayout(bool bDoFull);
00114 virtual void collapse(void);
00115 virtual void markAllRunsDirty(void);
00116 virtual fl_SectionLayout * getSectionLayout(void) const;
00117 bool recalculateFields(UT_uint32 iUpdateCount);
00118 virtual void redrawUpdate(void);
00119 virtual fp_Container* getNewContainer(fp_Container* = NULL);
00120 fl_DocSectionLayout* getDocSectionLayout(void) const { return m_pDocSL; }
00121 bool isEndTOCIn(void) const {return m_bHasEndTOC;}
00122 void setTOCEndIn(void);
00123 TOCEntry * createNewEntry(fl_BlockLayout * pBL);
00124 PT_DocPosition getDocPosition(void);
00125 UT_uint32 getLength(void);
00126 fl_BlockLayout * findMatchingBlock(fl_BlockLayout * pBlock);
00127 UT_sint32 isInVector(fl_BlockLayout * pBlock, UT_GenericVector<TOCEntry *>* pVecBlocks);
00128 UT_uint32 getTOCPID(void) const { return m_iTOCPID;}
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, 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
00146 void purgeLayout(void) {_purgeLayout();}
00147
00148 private:
00149 virtual void _purgeLayout(void);
00150 virtual void _lookupProperties(const PP_AttrProp* pAP);
00151 void _createTOCContainer(void);
00152 bool _isStyleInTOC(UT_UTF8String & sStyle, UT_UTF8String & sTOCStyle);
00153 void _insertTOCContainer(fp_TOCContainer * pNewTOC);
00154 void _localCollapse();
00155
00156 void _createAndFillTOCEntry(PT_DocPosition posStart, PT_DocPosition posEnd,
00157 fl_BlockLayout * pPrevBL, const char * pszStyle,
00158 UT_sint32 iAllBlocks);
00159
00160 void _addBlockInVec(fl_BlockLayout * pBlock,UT_UTF8String & sStyle);
00161 void _removeBlockInVec(fl_BlockLayout * pBlock, bool bDontRecurse = false);
00162 void _calculateLabels(void);
00163 UT_sint32 _getStartValue(TOCEntry * pEntry);
00164 bool m_bNeedsRebuild;
00165 bool m_bNeedsFormat;
00166 bool m_bIsOnPage;
00167 UT_uint32 m_iTOCPID;
00168 fl_DocSectionLayout* m_pDocSL;
00169 bool m_bHasEndTOC;
00170 bool m_bDoingPurge;
00171 bool m_bIsSelected;
00172 UT_UTF8String m_sSourceStyle1;
00173 UT_UTF8String m_sSourceStyle2;
00174 UT_UTF8String m_sSourceStyle3;
00175 UT_UTF8String m_sSourceStyle4;
00176 UT_UTF8String m_sDestStyle1;
00177 UT_UTF8String m_sDestStyle2;
00178 UT_UTF8String m_sDestStyle3;
00179 UT_UTF8String m_sDestStyle4;
00180 UT_UTF8String m_sNumOff1;
00181 UT_UTF8String m_sNumOff2;
00182 UT_UTF8String m_sNumOff3;
00183 UT_UTF8String m_sNumOff4;
00184 FootnoteType m_iNumType1;
00185 FootnoteType m_iNumType2;
00186 FootnoteType m_iNumType3;
00187 FootnoteType m_iNumType4;
00188 eTabLeader m_iTabLeader1;
00189 eTabLeader m_iTabLeader2;
00190 eTabLeader m_iTabLeader3;
00191 eTabLeader m_iTabLeader4;
00192 UT_GenericVector<TOCEntry *> m_vecEntries;
00193 UT_sint32 m_iCurrentLevel;
00194 UT_UTF8String m_sTOCHeading;
00195 bool m_bTOCHeading;
00196 UT_UTF8String m_sTOCHeadingStyle;
00197 FootnoteType m_iLabType1;
00198 FootnoteType m_iLabType2;
00199 FootnoteType m_iLabType3;
00200 FootnoteType m_iLabType4;
00201 UT_UTF8String m_sLabBefore1;
00202 UT_UTF8String m_sLabBefore2;
00203 UT_UTF8String m_sLabBefore3;
00204 UT_UTF8String m_sLabBefore4;
00205 UT_UTF8String m_sLabAfter1;
00206 UT_UTF8String m_sLabAfter2;
00207 UT_UTF8String m_sLabAfter3;
00208 UT_UTF8String m_sLabAfter4;
00209 UT_UTF8String m_sRangeBookmark;
00210 bool m_bHasLabel1;
00211 bool m_bHasLabel2;
00212 bool m_bHasLabel3;
00213 bool m_bHasLabel4;
00214 bool m_bInherit1;
00215 bool m_bInherit2;
00216 bool m_bInherit3;
00217 bool m_bInherit4;
00218 UT_sint32 m_iStartAt1;
00219 UT_sint32 m_iStartAt2;
00220 UT_sint32 m_iStartAt3;
00221 UT_sint32 m_iStartAt4;
00222 bool m_bMissingBookmark;
00223 bool m_bFalseBookmarkEstimate;
00224 UT_NumberVector m_vecBookmarkPositions;
00225 };
00226
00227
00228 class ABI_EXPORT fl_TOCListener : public PL_Listener
00229 {
00230 public:
00231 fl_TOCListener(fl_TOCLayout* pTOCL, fl_BlockLayout * pPrevBL, PD_Style * pStyle);
00232 virtual ~fl_TOCListener();
00233
00234 virtual bool populate(PL_StruxFmtHandle sfh,
00235 const PX_ChangeRecord * pcr);
00236
00237 virtual bool populateStrux(PL_StruxDocHandle sdh,
00238 const PX_ChangeRecord * pcr,
00239 PL_StruxFmtHandle * psfh);
00240
00241 virtual bool change(PL_StruxFmtHandle sfh,
00242 const PX_ChangeRecord * pcr);
00243
00244 virtual bool insertStrux(PL_StruxFmtHandle sfh,
00245 const PX_ChangeRecord * pcr,
00246 PL_StruxDocHandle sdh,
00247 PL_ListenerId lid,
00248 void (* pfnBindHandles)(PL_StruxDocHandle sdhNew,
00249 PL_ListenerId lid,
00250 PL_StruxFmtHandle sfhNew));
00251
00252 virtual bool signal(UT_uint32 iSignal);
00253
00254 private:
00255 PD_Document* m_pDoc;
00256 fl_TOCLayout* m_pTOCL;
00257 fl_BlockLayout * m_pPrevBL;
00258 bool m_bListening;
00259 fl_ContainerLayout* m_pCurrentBL;
00260 PD_Style * m_pStyle;
00261 };
00262
00263 #endif