00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef TABLELAYOUT_H
00022 #define TABLELAYOUT_H
00023
00024 #ifdef FMT_TEST
00025 #include <stdio.h>
00026 #endif
00027
00028 #include "ut_types.h"
00029 #include "ut_vector.h"
00030 #include "pt_Types.h"
00031 #include "fl_Layout.h"
00032 #include "fl_ContainerLayout.h"
00033 #include "fl_SectionLayout.h"
00034 #include "pp_PropertyMap.h"
00035 #include "pl_Listener.h"
00036 #include "ut_debugmsg.h"
00037 #include "ut_misc.h"
00038
00039 enum FL_TableJustification
00040 {
00041 FL_TABLE_LEFT,
00042 FL_TABLE_CENTER,
00043 FL_TABLE_RIGHT,
00044 FL_TABLE_FULL
00045 };
00046
00047 enum FL_RowHeightType
00048 {
00049 FL_ROW_HEIGHT_NOT_DEFINED,
00050 FL_ROW_HEIGHT_AUTO,
00051 FL_ROW_HEIGHT_AT_LEAST,
00052 FL_ROW_HEIGHT_EXACTLY
00053 };
00054
00055 class fp_Page;
00056 class FL_DocLayout;
00057 class fl_Layout;
00058 class fl_ContainerLayout;
00059 class fl_BlockLayout;
00060 class fl_SectionLayout;
00061 class fl_DocSectionLayout;
00062 class fl_HdrFtrSectionLayout;
00063 class fl_HdrFtrShadow;
00064 class fl_CellLayout;
00065 class fb_LineBreaker;
00066 class fp_ShadowContainer;
00067 class fp_Column;
00068 class fp_Run;
00069 class fp_Line;
00070 class fp_Container;
00071 class fp_HdrFtrContainer;
00072 class fp_TableContainer;
00073 class fp_CellContainer;
00074 class PD_Document;
00075 class PP_AttrProp;
00076 class PX_ChangeRecord_FmtMark;
00077 class PX_ChangeRecord_FmtMarkChange;
00078 class PX_ChangeRecord_Object;
00079 class PX_ChangeRecord_ObjectChange;
00080 class PX_ChangeRecord_Span;
00081 class PX_ChangeRecord_SpanChange;
00082 class PX_ChangeRecord_Strux;
00083 class PX_ChangeRecord_StruxChange;
00084 class pf_Frag_Strux;
00085
00086 class ABI_EXPORT fl_ColProps
00087 {
00088 public:
00089 UT_sint32 m_iColWidth;
00090 double m_dColRelWidth;
00091 };
00092
00093 class ABI_EXPORT fl_RowProps
00094 {
00095 public:
00096 fl_RowProps(void)
00097 {
00098 m_iRowHeight = 0;
00099 m_iRowHeightType = FL_ROW_HEIGHT_NOT_DEFINED;
00100 }
00101 virtual ~fl_RowProps(void)
00102 {
00103 }
00104 UT_sint32 m_iRowHeight;
00105 FL_RowHeightType m_iRowHeightType;
00106 };
00107
00108
00109 class ABI_EXPORT fl_TableLayout : public fl_SectionLayout
00110 {
00111 friend class fl_DocListener;
00112
00113 public:
00114 fl_TableLayout(FL_DocLayout* pLayout, pf_Frag_Strux* sdh, PT_AttrPropIndex ap, fl_ContainerLayout * pMyContainerLayout);
00115 virtual ~fl_TableLayout();
00116
00117 SectionType getType(void) const { return m_iType; }
00118
00119 virtual bool recalculateFields(UT_uint32 iUpdateCount);
00120 virtual bool doclistener_changeStrux(const PX_ChangeRecord_StruxChange * pcrxc);
00121 virtual bool doclistener_deleteStrux(const PX_ChangeRecord_Strux * pcrx);
00122 virtual bool bl_doclistener_insertCell(fl_ContainerLayout* pCell,
00123 const PX_ChangeRecord_Strux * pcrx,
00124 pf_Frag_Strux* sdh,
00125 PL_ListenerId lid,
00126 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00127 PL_ListenerId lid,
00128 fl_ContainerLayout* sfhNew));
00129 virtual bool bl_doclistener_insertBlock(fl_ContainerLayout* pCell,
00130 const PX_ChangeRecord_Strux * pcrx,
00131 pf_Frag_Strux* sdh,
00132 PL_ListenerId lid,
00133 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00134 PL_ListenerId lid,
00135 fl_ContainerLayout* sfhNew));
00136
00137 virtual bool bl_doclistener_insertEndTable(fl_ContainerLayout*,
00138 const PX_ChangeRecord_Strux * pcrx,
00139 pf_Frag_Strux* sdh,
00140 PL_ListenerId lid,
00141 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00142 PL_ListenerId lid,
00143 fl_ContainerLayout* sfhNew));
00144
00145 virtual bool bl_doclistener_insertTable( const PX_ChangeRecord_Strux * pcrx,
00146 SectionType iType,
00147 pf_Frag_Strux* sdh,
00148 PL_ListenerId lid,
00149 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00150 PL_ListenerId lid,
00151 fl_ContainerLayout* sfhNew));
00152
00153 #ifdef FMT_TEST
00154 virtual void __dump(FILE * fp) const;
00155 #endif
00156 void setTableContainerProperties(fp_TableContainer * pTab);
00157 virtual void format(void);
00158 void attachCell(fl_ContainerLayout * pCell);
00159 void createTableContainer(void);
00160 void insertTableContainer(fp_TableContainer * pNewTab);
00161 virtual void updateLayout(bool bDoFull);
00162 void updateTable(void);
00163 virtual void collapse(void);
00164 virtual void markAllRunsDirty(void);
00165 virtual bool needsReformat(void) const;
00166 virtual PT_DocPosition getPosition(bool bActualBlockPosition = false) const;
00167 UT_uint32 getLength(void);
00168 virtual void redrawUpdate(void);
00169 virtual fp_Container* getNewContainer(fp_Container * pFirstContainer = NULL);
00170 virtual fl_SectionLayout * getSectionLayout(void) const;
00171
00172 void markForRebuild(void) { m_bNeedsRebuild = true;}
00173 void clearRebuild(void) { m_bNeedsRebuild = false;}
00174 bool needsRebuild(void) const { return m_bNeedsRebuild;}
00175 void markForReformat(void) { m_bNeedsReformat = true;}
00176 bool needsReFormat(void) const { return m_bNeedsReformat;}
00177
00178 UT_sint32 getLeftOffset(void) const;
00179 void setHeightChanged(fp_CellContainer * pCell);
00180 bool doSimpleChange(void);
00181 UT_sint32 getRightOffset(void) const;
00182 UT_sint32 getTopOffset(void) const;
00183 UT_sint32 getBottomOffset(void) const;
00184 bool isDirty(void) const
00185 { return m_bIsDirty;}
00186 void setDirty(void);
00187 double getTableRelWidth(void) const
00188 { return m_dTableRelWidth;}
00189 UT_sint32 getLineThickness(void) const;
00190 UT_sint32 getColSpacing(void) const;
00191 UT_sint32 getRowSpacing(void) const;
00192 UT_sint32 getLeftColPos(void) const
00193 { return m_iLeftColPos;}
00194 const UT_GenericVector<fl_ColProps*> * getVecColProps(void) const
00195 { return &m_vecColProps;}
00196 const UT_GenericVector<fl_RowProps*> * getVecRowProps(void) const
00197 { return &m_vecRowProps;}
00198
00199 const PP_PropertyMap::Background & getBackground () const { return m_background; }
00200
00201 const UT_RGBColor & getDefaultColor () const { return m_colorDefault; }
00202
00203 const PP_PropertyMap::Line & getBottomStyle () const { return m_lineBottom; }
00204 const PP_PropertyMap::Line & getLeftStyle () const { return m_lineLeft; }
00205 const PP_PropertyMap::Line & getRightStyle () const { return m_lineRight; }
00206 const PP_PropertyMap::Line & getTopStyle () const { return m_lineTop; }
00207 UT_sint32 getNumNestedTables(void) const;
00208 void incNumNestedTables(void);
00209 void decNumNestedTables(void);
00210
00211 void setEndTableIn(void)
00212 { m_bIsEndTableIn = true;}
00213 bool isEndTableIn(void)
00214 { return m_bIsEndTableIn;}
00215 bool isDoingDestructor(void)
00216 { return m_bDoingDestructor;}
00217
00218 protected:
00219 virtual void _lookupProperties(const PP_AttrProp* pSectionAP);
00220 virtual void _lookupMarginProperties(const PP_AttrProp* pAP);
00221 void _purgeLayout();
00222 private:
00223 bool m_bNeedsRebuild;
00224 FL_TableJustification m_iJustification;
00225 UT_sint32 m_iLeftOffset;
00226 double m_dLeftOffsetUserUnits;
00227 UT_sint32 m_iRightOffset;
00228 double m_dRightOffsetUserUnits;
00229 UT_sint32 m_iTopOffset;
00230 double m_dTopOffsetUserUnits;
00231 UT_sint32 m_iBottomOffset;
00232 double m_dBottomOffsetUserUnits;
00233
00234 bool m_bIsHomogeneous;
00235 bool m_bSameRowOnTopOfPage;
00236 UT_sint32 m_iRowNumberForTop;
00237 UT_sint32 m_iNumberOfRows;
00238 UT_sint32 m_iNumberOfColumns;
00239 bool m_bColumnsPositionedOnPage;
00240 bool m_bRowsPositionedOnPage;
00241 bool m_bIsDirty;
00242 bool m_bDontImmediatelyLayout;
00243 UT_sint32 m_iLineThickness;
00244 UT_sint32 m_iColSpacing;
00245 UT_sint32 m_iRowSpacing;
00246 UT_sint32 m_iLeftColPos;
00247 bool m_bRecursiveFormat;
00248 UT_GenericVector<fl_ColProps *> m_vecColProps;
00249 UT_GenericVector<fl_RowProps *> m_vecRowProps;
00250 FL_RowHeightType m_iRowHeightType;
00251 UT_sint32 m_iRowHeight;
00252
00253
00254 PP_PropertyMap::Background m_background;
00255
00256
00257 UT_RGBColor m_colorDefault;
00258 PP_PropertyMap::Line m_lineBottom;
00259 PP_PropertyMap::Line m_lineLeft;
00260 PP_PropertyMap::Line m_lineRight;
00261 PP_PropertyMap::Line m_lineTop;
00262 UT_sint32 m_iNumNestedTables;
00263 bool m_bIsEndTableIn;
00264 UT_sint32 m_iHeightChanged;
00265 fp_CellContainer * m_pNewHeightCell;
00266 bool m_bDoingDestructor;
00267 UT_sint32 m_iTableWidth;
00268 double m_dTableRelWidth;
00269 };
00270
00271
00272 class ABI_EXPORT fl_CellLayout : public fl_SectionLayout
00273 {
00274 friend class fl_DocListener;
00275 friend class fp_TableContainer;
00276 friend class fp_CellContainer;
00277 public:
00278 fl_CellLayout(FL_DocLayout* pLayout, pf_Frag_Strux* sdh, PT_AttrPropIndex ap, fl_ContainerLayout * pMyContainerLayout);
00279 virtual ~fl_CellLayout();
00280
00281 bool isCellSelected(void);
00282 void checkAndAdjustCellSize(void);
00283 virtual bool doclistener_changeStrux(const PX_ChangeRecord_StruxChange * pcrxc);
00284 virtual bool doclistener_deleteStrux(const PX_ChangeRecord_Strux * pcrx);
00285 virtual bool bl_doclistener_insertCell(fl_ContainerLayout* pCell,
00286 const PX_ChangeRecord_Strux * pcrx,
00287 pf_Frag_Strux* sdh,
00288 PL_ListenerId lid,
00289 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00290 PL_ListenerId lid,
00291 fl_ContainerLayout* sfhNew));
00292 virtual bool bl_doclistener_insertEndCell(fl_ContainerLayout*,
00293 const PX_ChangeRecord_Strux * pcrx,
00294 pf_Frag_Strux* sdh,
00295 PL_ListenerId lid,
00296 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00297 PL_ListenerId lid,
00298 fl_ContainerLayout* sfhNew));
00299
00300 void setCellContainerProperties(fp_CellContainer * pCell);
00301 void createCellContainer(void);
00302 virtual void format(void);
00303 virtual void updateLayout(bool bDoFull);
00304 virtual void collapse(void);
00305 bool isLayedOut(void) const;
00306 bool isDoingFormat(void) const;
00307 virtual bool needsReformat(void) const;
00308 virtual void markAllRunsDirty(void);
00309 virtual fl_SectionLayout * getSectionLayout(void) const;
00310 bool recalculateFields(UT_uint32 iUpdateCount);
00311 virtual void redrawUpdate(void);
00312 virtual fp_Container* getNewContainer(fp_Container * pFirstContainer = NULL);
00313 #ifdef FMT_TEST
00314 void __dump(FILE * fp) const;
00315 #endif
00316 UT_uint32 getLength(void);
00317
00318 UT_sint32 getLeftOffset(void) const;
00319 UT_sint32 getRightOffset(void) const;
00320 UT_sint32 getTopOffset(void) const;
00321 UT_sint32 getBottomOffset(void) const;
00322 UT_sint32 getNumNestedTables(void) const;
00323 void incNumNestedTables(void);
00324 void decNumNestedTables(void);
00325 UT_sint32 getLeftAttach(void) const
00326 { return m_iLeftAttach;}
00327 UT_sint32 getRightAttach(void) const
00328 { return m_iRightAttach;}
00329 UT_sint32 getTopAttach(void) const
00330 { return m_iTopAttach;}
00331 UT_sint32 getBottomAttach(void) const
00332 { return m_iBottomAttach;}
00333 UT_sint32 getCellHeight(void) const
00334 { return m_iCellHeight;}
00335 UT_sint32 getCellWidth(void) const
00336 { return m_iCellWidth;}
00337
00338 protected:
00339 virtual void _lookupProperties(const PP_AttrProp* pAP);
00340 virtual void _purgeLayout(void);
00341 private:
00342 bool m_bNeedsRebuild;
00343 UT_sint32 m_iLeftOffset;
00344 double m_dLeftOffsetUserUnits;
00345 UT_sint32 m_iRightOffset;
00346 double m_dRightOffsetUserUnits;
00347 UT_sint32 m_iTopOffset;
00348 double m_dTopOffsetUserUnits;
00349 UT_sint32 m_iBottomOffset;
00350 double m_dBottomOffsetUserUnits;
00351
00352 UT_sint32 m_iLeftAttach;
00353 UT_sint32 m_iRightAttach;
00354 UT_sint32 m_iTopAttach;
00355 UT_sint32 m_iBottomAttach;
00356
00357 bool m_bCellPositionedOnPage;
00358 UT_sint32 m_iCellHeight;
00359 UT_sint32 m_iCellWidth;
00360
00361
00362 PP_PropertyMap::Background m_background;
00363
00364
00365 PP_PropertyMap::Line m_lineBottom;
00366 PP_PropertyMap::Line m_lineLeft;
00367 PP_PropertyMap::Line m_lineRight;
00368 PP_PropertyMap::Line m_lineTop;
00369
00370 void _updateCell(void);
00371 void _localCollapse();
00372 UT_sint32 m_iNumNestedTables;
00373 bool m_bDoingFormat;
00374
00375
00376 UT_sint32 m_iVertAlign;
00377
00378 };
00379
00385 #define FS_OFF 0 // No fill style
00386 #define FS_FILL 1 // Solid fill style
00387
00388
00394 #define LS_OFF 0 // No line style, which means no line is drawn
00395 #define LS_NORMAL 1 // A normal solid line
00396 #define LS_DOTTED 2 // A dotted line
00397 #define LS_DASHED 3 // A dashed line
00398
00399
00400 #endif