00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef DOCLAYOUT_H
00021 #define DOCLAYOUT_H
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include "config.h"
00025 #endif
00026
00027 #include <stdio.h>
00028 #include "ut_types.h"
00029 #include "ut_vector.h"
00030 #include "ut_hash.h"
00031 #include "pt_Types.h"
00032 #include "fp_PageSize.h"
00033 #include "fl_Layout.h"
00034 #include "ut_units.h"
00035 #include "xav_Listener.h"
00036
00037
00038 typedef enum _FootnoteType
00039 {
00040 FOOTNOTE_TYPE_NUMERIC = 0,
00041 FOOTNOTE_TYPE_NUMERIC_SQUARE_BRACKETS,
00042 FOOTNOTE_TYPE_NUMERIC_PAREN,
00043 FOOTNOTE_TYPE_NUMERIC_OPEN_PAREN,
00044 FOOTNOTE_TYPE_LOWER,
00045 FOOTNOTE_TYPE_LOWER_PAREN,
00046 FOOTNOTE_TYPE_LOWER_OPEN_PAREN,
00047 FOOTNOTE_TYPE_UPPER,
00048 FOOTNOTE_TYPE_UPPER_PAREN,
00049 FOOTNOTE_TYPE_UPPER_OPEN_PAREN,
00050 FOOTNOTE_TYPE_LOWER_ROMAN,
00051 FOOTNOTE_TYPE_LOWER_ROMAN_PAREN,
00052 FOOTNOTE_TYPE_UPPER_ROMAN,
00053 FOOTNOTE_TYPE_UPPER_ROMAN_PAREN
00054 } FootnoteType;
00055
00056 extern const char * s_FootnoteTypeDesc[];
00057
00058 class FV_View;
00059 class fl_DocListener;
00060 class fl_SectionLayout;
00061 class fl_DocSectionLayout;
00062 class fl_BlockLayout;
00063 class fl_TOCLayout;
00064 class fp_Page;
00065 class PD_Document;
00066 class PP_AttrProp;
00067 class GR_Graphics;
00068 class GR_Font;
00069 class UT_Timer;
00070 class UT_Worker;
00071 class fl_PartOfBlock;
00072 class fl_AutoNum;
00073 class PX_ChangeRecord_StruxChange;
00074 class fl_FootnoteLayout;
00075 class fl_AnnotationLayout;
00076 class fl_EndnoteLayout;
00077 class fp_EndnoteContainer;
00078 class GR_EmbedManager;
00079 class fl_FrameLayout;
00080
00081
00082
00083 #define fl_PAGEVIEW_PAGE_SEP m_pG->tlu(20) // must be <= MARGIN_Y
00084 #define fl_PAGEVIEW_MARGIN_X m_pG->tlu(25)
00085 #define fl_PAGEVIEW_MARGIN_Y m_pG->tlu(25)
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 class ABI_EXPORT FL_DocLayout
00096 {
00097 friend class fl_DocListener;
00098 friend class fl_BlockLayout;
00099 public:
00100 FL_DocLayout(PD_Document* doc, GR_Graphics* pG);
00101 ~FL_DocLayout();
00102
00103 void fillLayouts(void);
00104 void setView(FV_View*);
00105
00106 inline FV_View * getView(void) const { return m_pView; }
00107 inline GR_Graphics* getGraphics(void) const { return m_pG; }
00108 void setGraphics(GR_Graphics * pG);
00109 UT_uint32 getGraphicTick(void) const { return m_iGraphicTick;}
00110 void incrementGraphicTick(void) { m_iGraphicTick++;}
00111 inline PD_Document* getDocument(void) const { return m_pDoc; }
00112 #ifdef ENABLE_SPELL
00113 inline fl_BlockLayout* getPendingBlockForSpell(void) const { return m_pPendingBlockForSpell; };
00114 inline fl_PartOfBlock* getPendingWordForSpell(void) const { return m_pPendingWordForSpell; };
00115 #endif
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 inline fl_BlockLayout* getPendingBlockForSmartQuote(void) const { return m_pPendingBlockForSmartQuote; };
00127 inline UT_uint32 getOffsetForSmartQuote(void) const { return m_uOffsetForSmartQuote; };
00128 void setPendingSmartQuote(fl_BlockLayout *block, UT_uint32 offset);
00129 void considerSmartQuoteCandidateAt(fl_BlockLayout *block, UT_uint32 offset);
00130 inline void considerPendingSmartQuoteCandidate() {considerSmartQuoteCandidateAt(m_pPendingBlockForSmartQuote, m_uOffsetForSmartQuote); }
00131
00132 void notifyBlockIsBeingDeleted(fl_BlockLayout *pBlock);
00133 void setSkipUpdates(UT_uint32 numSkips) {m_iSkipUpdates = numSkips;}
00134 UT_uint32 getSkipUpdates(void) { return m_iSkipUpdates;}
00135 UT_sint32 getHeight();
00136 UT_sint32 getWidth();
00137 void refreshRunProperties(void);
00138 const GR_Font* findFont(const PP_AttrProp * pSpanAP,
00139 const PP_AttrProp * pBlockAP,
00140 const PP_AttrProp * pSectionAP,
00141 bool isField = false
00142 );
00143
00144 const GR_Font* findFont(const PP_AttrProp * pSpanAP,
00145 const PP_AttrProp * pBlockAP,
00146 const PP_AttrProp * pSectionAP,
00147 GR_Graphics * pG,
00148 bool isField = false
00149 );
00150
00151 void changeDocSections(const PX_ChangeRecord_StruxChange * pcrx, fl_DocSectionLayout * pDSL);
00152 fp_Page* addNewPage(fl_DocSectionLayout* pOwner, bool bNoUpdate=false);
00153 fp_Page* getFirstPage();
00154 fp_Page* getLastPage();
00155 fp_Page* getNthPage(int n);
00156 UT_uint32 countPages();
00157 UT_sint32 findPage(fp_Page * pPage);
00158 void setFramePageNumbers(UT_sint32 iStartPage);
00159 void relocateFrame(fl_FrameLayout * pFrame);
00160
00161 UT_sint32 getPercentFilled(void)
00162 { return m_iFilled;}
00163 void setPercentFilled(UT_sint32 iFill)
00164 { m_iFilled = iFill;}
00165 void setLayoutIsFilling(bool bisFill) { m_bisLayoutFilling = bisFill;}
00166 bool isLayoutFilling(void) const { return m_bisLayoutFilling;}
00167 fl_BlockLayout* findBlockAtPosition(PT_DocPosition pos) const;
00168 fl_BlockLayout* findBlockAtPositionReverse(PT_DocPosition pos);
00169 void deletePage(fp_Page* pPage, bool bDontNotify);
00170
00171 void formatAll();
00172 void updateLayout();
00173 void updateOnViewModeChange();
00174 void rebuildFromHere(fl_DocSectionLayout * pDSL);
00175 void updateColor();
00176
00177 #ifdef ENABLE_SPELL
00178 bool isPendingWordForSpell(void) const;
00179 bool touchesPendingWordForSpell(fl_BlockLayout *pBlock,
00180 UT_sint32 iOffset,
00181 UT_sint32 chg) const;
00182 void setPendingWordForSpell(fl_BlockLayout *pBlock, fl_PartOfBlock* pWord);
00183 bool checkPendingWordForSpell(void);
00184 void dequeueAll(void);
00185 void queueAll(UT_uint32 iReason);
00186 void queueBlockForBackgroundCheck(UT_uint32 reason, fl_BlockLayout *pBlock, bool bHead=false);
00187 bool dequeueBlockForBackgroundCheck(fl_BlockLayout *pBlock);
00188
00189 fl_BlockLayout *spellQueueHead(void) const
00190 {
00191 return m_toSpellCheckHead;
00192 }
00193 void setSpellQueueHead(fl_BlockLayout *h)
00194 {
00195 m_toSpellCheckHead = h;
00196 }
00197 fl_BlockLayout *spellQueueTail(void) const
00198 {
00199 return m_toSpellCheckTail;
00200 }
00201 void setSpellQueueTail(fl_BlockLayout *t)
00202 {
00203 m_toSpellCheckTail = t;
00204 }
00205 #endif
00206 void addSection(fl_DocSectionLayout*);
00207 void removeSection(fl_DocSectionLayout*);
00208 void insertSectionAfter(fl_DocSectionLayout* pAfter, fl_DocSectionLayout* pNewSL);
00209 void addHdrFtrSection(fl_SectionLayout* pHdrFtrSL);
00210 void removeHdrFtrSection(fl_SectionLayout* pHdrFtrSL);
00211
00212 inline fl_DocSectionLayout* getFirstSection(void) const { return m_pFirstSection; }
00213 inline fl_DocSectionLayout* getLastSection(void) const { return m_pLastSection; }
00214
00215 fl_DocSectionLayout* findSectionForHdrFtr(const char* pszHdrFtrID) const;
00216 void deleteEmptyColumnsAndPages(void);
00217 void deleteEmptyPages( bool bDontNotify = false);
00218 GR_EmbedManager * getEmbedManager(const char * szEmbedType);
00219
00220
00221
00222
00223
00224 UT_uint32 countFootnotes(void);
00225 void addFootnote(fl_FootnoteLayout *);
00226 void removeFootnote(fl_FootnoteLayout *);
00227 fl_FootnoteLayout * getNthFootnote(UT_sint32 i);
00228 UT_sint32 getFootnoteVal(UT_uint32 footpid);
00229 fl_FootnoteLayout * findFootnoteLayout(UT_uint32 footpid);
00230 FootnoteType getFootnoteType(void) const;
00231 void getStringFromFootnoteVal(UT_String & sVal, UT_sint32 iVal, FootnoteType iFootType);
00232
00233 UT_sint32 getInitialFootVal(void) const
00234 { return m_iFootnoteVal;}
00235 bool getRestartFootOnSection(void) const
00236 { return m_bRestartFootSection;}
00237 bool getRestartFootOnPage(void) const
00238 { return m_bRestartFootPage;}
00239 FootnoteType FootnoteTypeFromString( const gchar * pszStr);
00240
00241 void insertEndnoteContainer(fp_EndnoteContainer * pECon);
00242 void removeEndnoteContainer(fp_EndnoteContainer * pECon);
00243 fl_DocSectionLayout * getDocSecForEndnote(fp_EndnoteContainer * pECon );
00244 UT_uint32 countEndnotes(void);
00245 void addEndnote(fl_EndnoteLayout *);
00246 void removeEndnote(fl_EndnoteLayout *);
00247 fl_EndnoteLayout * getNthEndnote(UT_sint32 i);
00248 UT_sint32 getEndnoteVal(UT_uint32 endpid);
00249 fl_EndnoteLayout * findEndnoteLayout(UT_uint32 endpid);
00250
00251 FootnoteType getEndnoteType(void) const
00252 { return m_EndnoteType; }
00253 UT_sint32 getInitialEndVal(void) const
00254 { return m_iEndnoteVal;}
00255 bool getRestartEndOnSection(void) const
00256 { return m_bRestartEndSection;}
00257 bool getPlaceEndAtDocEnd(void) const
00258 { return m_bPlaceAtDocEnd;}
00259 bool getPlaceEndAtSecEnd(void) const
00260 { return m_bPlaceAtSecEnd;}
00261
00262
00263
00264
00265
00266 UT_uint32 countAnnotations(void);
00267 void addAnnotation(fl_AnnotationLayout * pAL);
00268 void removeAnnotation(fl_AnnotationLayout * pAL);
00269 fl_AnnotationLayout * getNthAnnotation(UT_sint32 i);
00270 UT_sint32 getAnnotationVal(UT_uint32 footpid);
00271 fl_AnnotationLayout * findAnnotationLayout(UT_uint32 footpid);
00272 bool displayAnnotations(void);
00273 void setDisplayAnnotations(bool bDisplayAnnotations);
00274 bool collapseAnnotations(void);
00275
00276
00277
00278 UT_sint32 getNumTOCs(void);
00279 fl_TOCLayout * getNthTOC(UT_sint32 i);
00280 bool addOrRemoveBlockFromTOC(fl_BlockLayout * pBlock);
00281 bool removeBlockFromTOC(fl_BlockLayout * pBlock);
00282 bool isBlockInTOC(fl_BlockLayout * pBlock);
00283 bool getMatchingBlocksFromTOCs(fl_BlockLayout * pBlock, UT_GenericVector<fl_BlockLayout*>* pVecBlock);
00284 bool addTOC(fl_TOCLayout * pTOC);
00285 bool removeTOC(fl_TOCLayout * pTOC);
00286 bool fillTOC(fl_TOCLayout * pTOC);
00287 void recalculateTOCFields(void);
00288 bool updateTOCsOnBookmarkChange(const gchar * pBookmark);
00289
00290 #ifdef ENABLE_SPELL
00291 bool getAutoSpellCheck(void) const { return (hasBackgroundCheckReason(bgcrSpelling)); }
00292 bool getAutoGrammarCheck(void) const { return (hasBackgroundCheckReason(bgcrGrammar)); }
00293 bool getSpellCheckCaps(void) const { return m_bSpellCheckCaps; }
00294 bool getSpellCheckNumbers(void) const { return m_bSpellCheckNumbers; }
00295 bool getSpellCheckInternet(void) const { return m_bSpellCheckInternet; }
00296 void recheckIgnoredWords();
00297 #endif
00298
00299 bool getSmartQuotes(void) const { return (hasBackgroundCheckReason(bgcrSmartQuotes)); }
00300
00301
00302 inline void addBackgroundCheckReason(UT_uint32 reason) {m_uDocBackgroundCheckReasons |= reason;}
00303 inline void removeBackgroundCheckReason(UT_uint32 reason) {m_uDocBackgroundCheckReasons &= ~reason;}
00304 inline bool hasBackgroundCheckReason(UT_uint32 reason) const {return ((m_uDocBackgroundCheckReasons & reason) ? true : false);}
00305 inline UT_uint32 getBackgroundCheckReasons() const {return (m_uDocBackgroundCheckReasons);}
00306
00307 #ifdef ENABLE_SPELL
00308 fl_BlockLayout * getPendingBlockForGrammar(void)
00309 {
00310 return m_PendingBlockForGrammar;
00311 }
00312 void setPendingBlockForGrammar(fl_BlockLayout * pBL);
00313 #endif
00314 void triggerPendingBlock(fl_BlockLayout * pBL);
00315
00316
00317
00318 enum backgroundCheckReason
00319 {
00320 bgcrNone = 0,
00321 bgcrDebugFlash = (1 << 0),
00322 bgcrSpelling = (1 << 1),
00323 bgcrSmartQuotes = (1 << 2),
00324 bgcrGrammar = (1 << 3)
00325 };
00326
00327
00328 inline fl_AutoNum * getListByID(UT_uint32 id) const;
00329 inline fl_AutoNum * getNthList(UT_uint32 i) const;
00330 inline UT_uint32 getListsCount(void) const;
00331 inline void addList(fl_AutoNum * pAutoNum);
00332 bool isLayoutDeleting(void) const {return m_bDeletingLayout;}
00333 UT_uint32 getRedrawCount() {return m_iRedrawCount;}
00334
00335
00336 void updatePropsNoRebuild(void);
00337 void updatePropsRebuild(void);
00338 PT_DocPosition getDocSize(void)
00339 { return m_iDocSize;}
00340 UT_uint32 getLID(void) const
00341 { return m_lid;}
00342 void notifyListeners(AV_ChangeMask mask);
00343 void setQuickPrint(GR_Graphics * pGraphics);
00344 bool isQuickPrint(void)
00345 { return m_bIsQuickPrint;}
00346 GR_EmbedManager * getQuickPrintEmbedManager(const char * szEmbedType);
00347 fp_PageSize m_docViewPageSize;
00348 bool setDocViewPageSize(const PP_AttrProp * pAP);
00349
00350 #ifdef FMT_TEST
00352 static FL_DocLayout* m_pDocLayout;
00353
00354 void __dump(FILE * fp) const;
00355 #endif
00356
00357 protected:
00358 static void _backgroundCheck(UT_Worker * pTimer);
00359 #ifdef ENABLE_SPELL
00360 void _toggleAutoSpell(bool bSpell);
00361 void _toggleAutoGrammar(bool bGrammar);
00362 #endif
00363 void _toggleAutoSmartQuotes(bool bSQ);
00364
00365 static void _prefsListener(class XAP_App *, class XAP_Prefs *,
00366 UT_StringPtrMap *, void *);
00367
00368
00369 static void _redrawUpdate(UT_Worker * pTimer);
00370
00371 private:
00372 void _lookupProperties(void);
00373 GR_Graphics* m_pG;
00374 PD_Document* m_pDoc;
00375 FV_View* m_pView;
00376 fl_DocListener* m_pDocListener;
00377 PL_ListenerId m_lid;
00378
00379 UT_GenericVector<fp_Page *> m_vecPages;
00380 fl_DocSectionLayout*m_pFirstSection;
00381 fl_DocSectionLayout*m_pLastSection;
00382
00383
00384
00385 fl_BlockLayout *m_toSpellCheckHead;
00386 fl_BlockLayout *m_toSpellCheckTail;
00387 fl_BlockLayout* m_pPendingBlockForSpell;
00388 fl_PartOfBlock* m_pPendingWordForSpell;
00389 bool m_bSpellCheckCaps;
00390 bool m_bSpellCheckNumbers;
00391 bool m_bSpellCheckInternet;
00392 bool m_bAutoSpellCheck;
00393 UT_uint32 m_uDocBackgroundCheckReasons;
00394 bool m_bStopSpellChecking;
00395 bool m_bImSpellCheckingNow;
00396
00397 fl_BlockLayout* m_pPendingBlockForSmartQuote;
00398 UT_uint32 m_uOffsetForSmartQuote;
00399 char m_szCurrentTransparentColor[10];
00400 UT_Worker* m_pBackgroundCheckTimer;
00401
00402 XAP_Prefs * m_pPrefs;
00403
00404 UT_Timer* m_pRedrawUpdateTimer;
00405 UT_uint32 m_iSkipUpdates;
00406 bool m_bDeletingLayout;
00407 bool m_bisLayoutFilling;
00408 UT_uint32 m_iRedrawCount;
00409 UT_GenericVector<fl_FootnoteLayout *> m_vecFootnotes;
00410 UT_GenericVector<fl_AnnotationLayout *> m_vecAnnotations;
00411 UT_GenericVector<fl_EndnoteLayout *> m_vecEndnotes;
00412 FootnoteType m_FootnoteType;
00413 UT_sint32 m_iFootnoteVal;
00414 bool m_bRestartFootSection;
00415 bool m_bRestartFootPage;
00416 UT_sint32 m_iEndnoteVal;
00417 FootnoteType m_EndnoteType;
00418 bool m_bRestartEndSection;
00419 bool m_bPlaceAtDocEnd;
00420 bool m_bPlaceAtSecEnd;
00421 UT_uint32 m_iGraphicTick;
00422 UT_GenericVector<fl_TOCLayout *> m_vecTOC;
00423 PT_DocPosition m_iDocSize;
00424 UT_sint32 m_iFilled;
00425 bool m_bSpellCheckInProgress;
00426 UT_GenericVector<GR_EmbedManager *> m_vecEmbedManager;
00427 bool m_bAutoGrammarCheck;
00428 fl_BlockLayout * m_PendingBlockForGrammar;
00429 UT_sint32 m_iGrammarCount;
00430 bool m_bFinishedInitialCheck;
00431 PT_DocPosition m_iPrevPos;
00432 UT_GenericVector<GR_EmbedManager *> m_vecQuickPrintEmbedManager;
00433 GR_Graphics * m_pQuickPrintGraphics;
00434 bool m_bIsQuickPrint;
00435 bool m_bDisplayAnnotations;
00436 };
00437
00438 #endif
00439
00440