1 /* AbiWord 2 * Copyright (C) 2002 Patrick Lam <plam@mit.edu> 3 * Copyright (C) 1998 AbiSource, Inc. 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 * 02110-1301 USA. 19 */ 20 21 #ifndef FOOTNOTELAYOUT_H 22 #define FOOTNOTELAYOUT_H 23 24 #include "ut_types.h" 25 #include "ut_vector.h" 26 #include "pt_Types.h" 27 #include "fl_Layout.h" 28 #include "fl_ContainerLayout.h" 29 #include "fl_SectionLayout.h" 30 #include "pl_Listener.h" 31 #include "ut_debugmsg.h" 32 33 class pf_Frag_Strux; 34 class fl_BlockLayout; 35 36 // We have one fl_FootnoteLayout for each footnote. They all 37 // get physically placed at the bottom of the fp_Page in their own 38 // little container. 39 40 // The fl_FootnoteLayout lives after each block. 41 42 // Need to do cursor navigation between blocks 43 class fp_AnnotationRun; 44 45 class ABI_EXPORT fl_EmbedLayout : public fl_SectionLayout 46 { 47 friend class fl_DocListener; 48 friend class fp_FootnoteContainer; 49 50 public: 51 fl_EmbedLayout(FL_DocLayout* pLayout, 52 fl_DocSectionLayout * pDocSL, 53 pf_Frag_Strux* sdh, 54 PT_AttrPropIndex ap, 55 fl_ContainerLayout * pMyContainerLayout, 56 SectionType iSecType, 57 fl_ContainerType myType, 58 PTStruxType myStruxType); 59 virtual ~fl_EmbedLayout(); 60 virtual void setNeedsReformat(fl_ContainerLayout * pCL, UT_uint32 offset = 0); 61 virtual void updateLayout(bool bDoAll); 62 63 virtual bool doclistener_changeStrux(const PX_ChangeRecord_StruxChange * pcrxc); 64 virtual bool doclistener_deleteStrux(const PX_ChangeRecord_Strux * pcrx); 65 virtual bool doclistener_deleteEndEmbed(const PX_ChangeRecord_Strux * pcrx); 66 virtual bool bl_doclistener_insertEndEmbed(fl_ContainerLayout*, 67 const PX_ChangeRecord_Strux * pcrx, 68 pf_Frag_Strux* sdh, 69 PL_ListenerId lid, 70 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew, 71 PL_ListenerId lid, 72 fl_ContainerLayout* sfhNew)); 73 74 virtual void format(void) = 0; 75 virtual void updateLayout(void); 76 virtual void collapse(void) = 0; 77 virtual void markAllRunsDirty(void); 78 virtual fl_SectionLayout * getSectionLayout(void) const; 79 bool recalculateFields(UT_uint32 iUpdateCount); 80 fl_BlockLayout * getContainingBlock(void); 81 virtual void redrawUpdate(void); 82 virtual fp_Container* getNewContainer(fp_Container* = NULL) =0; getDocSectionLayout(void)83 fl_DocSectionLayout* getDocSectionLayout(void) const { return m_pDocSL; } setDocSectionLayout(fl_DocSectionLayout * pDSL)84 void setDocSectionLayout(fl_DocSectionLayout * pDSL) 85 { m_pDocSL = pDSL;} isEndFootnoteIn(void)86 bool isEndFootnoteIn(void) const 87 {return m_bHasEndFootnote;} setFootnoteEndIn(void)88 void setFootnoteEndIn(void) 89 { m_bHasEndFootnote = true;} 90 PT_DocPosition getDocPosition(void); 91 UT_uint32 getLength(void); getOldSize(void)92 UT_sint32 getOldSize(void) const 93 { return m_iOldSize;} setOldSize(UT_sint32 i)94 void setOldSize(UT_sint32 i) 95 { m_iOldSize = i;} 96 protected: 97 virtual void _purgeLayout(void); 98 bool m_bNeedsRebuild; 99 bool m_bNeedsFormat; 100 bool m_bIsOnPage; 101 private: 102 103 fl_DocSectionLayout* m_pDocSL; 104 bool m_bHasEndFootnote; 105 UT_sint32 m_iOldSize; 106 }; 107 108 class ABI_EXPORT fl_FootnoteLayout : public fl_EmbedLayout 109 { 110 friend class fl_DocListener; 111 friend class fp_FootnoteContainer; 112 113 public: 114 fl_FootnoteLayout(FL_DocLayout* pLayout, 115 fl_DocSectionLayout * pDocSL, 116 pf_Frag_Strux* sdh, 117 PT_AttrPropIndex ap, 118 fl_ContainerLayout * pMyContainerLayout); 119 virtual ~fl_FootnoteLayout(); 120 121 virtual void format(void); 122 virtual void collapse(void); 123 virtual fp_Container* getNewContainer(fp_Container* = NULL); getFootnotePID(void)124 UT_uint32 getFootnotePID(void) const 125 {return m_iFootnotePID;} 126 protected: 127 virtual void _lookupProperties(const PP_AttrProp* pAP); 128 private: 129 void _createFootnoteContainer(void); 130 void _insertFootnoteContainer(fp_Container * pNewFC); 131 void _localCollapse(); 132 UT_uint32 m_iFootnotePID; 133 }; 134 135 136 class ABI_EXPORT fl_EndnoteLayout : public fl_EmbedLayout 137 { 138 friend class fl_DocListener; 139 friend class fp_EndnoteContainer; 140 141 public: 142 fl_EndnoteLayout(FL_DocLayout* pLayout, fl_DocSectionLayout * pDocSL, pf_Frag_Strux* sdh, PT_AttrPropIndex ap, fl_ContainerLayout * pMyContainerLayout); 143 virtual ~fl_EndnoteLayout(); 144 145 virtual void format(void); 146 virtual void collapse(void); 147 virtual fp_Container* getNewContainer(fp_Container* = NULL); getEndnotePID(void)148 UT_uint32 getEndnotePID(void) const 149 {return m_iEndnotePID;} 150 protected: 151 virtual void _lookupProperties(const PP_AttrProp* pAP); 152 private: 153 void _createEndnoteContainer(void); 154 void _insertEndnoteContainer(fp_Container * pNewFC); 155 void _localCollapse(); 156 157 UT_uint32 m_iEndnotePID; 158 }; 159 160 161 class ABI_EXPORT fl_AnnotationLayout : public fl_EmbedLayout 162 { 163 friend class fl_DocListener; 164 friend class fp_AnnotationContainer; 165 166 public: 167 fl_AnnotationLayout(FL_DocLayout* pLayout, 168 fl_DocSectionLayout * pDocSL, 169 pf_Frag_Strux* sdh, 170 PT_AttrPropIndex ap, 171 fl_ContainerLayout * pMyContainerLayout); 172 virtual ~fl_AnnotationLayout(); 173 fp_AnnotationRun * getAnnotationRun(void); 174 virtual void format(void); 175 virtual void collapse(void); 176 virtual fp_Container* getNewContainer(fp_Container* = NULL); getAnnotationPID(void)177 UT_uint32 getAnnotationPID(void) const 178 {return m_iAnnotationPID;} getAuthor(void)179 const char * getAuthor(void) const 180 { return m_sAuthor.utf8_str();} getDate(void)181 const char * getDate(void) const 182 { return m_sDate.utf8_str();} getTitle(void)183 const char * getTitle(void) const 184 { return m_sTitle.utf8_str();} 185 protected: 186 virtual void _lookupProperties(const PP_AttrProp* pAP); 187 private: 188 void _createAnnotationContainer(void); 189 void _insertAnnotationContainer(fp_Container * pNewFC); 190 void _localCollapse(); 191 UT_uint32 m_iAnnotationPID; 192 UT_UTF8String m_sAuthor; 193 UT_UTF8String m_sDate; 194 UT_UTF8String m_sTitle; 195 }; 196 197 198 #endif /* FOOTNOTELAYOUT_H */ 199