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) const
00214 { return m_bIsEndTableIn;}
00215 bool isDoingDestructor(void) const
00216 { return m_bDoingDestructor;}
00217 bool isInitialLayoutCompleted(void) const
00218 { return m_bInitialLayoutCompleted;}
00219 bool isTableReadyForLayout(void) const;
00220 UT_sint32 getTableWaitIndex(void) const
00221 { return m_iTableWaitIndex;}
00222 double getMaxExtraMargin(void) const
00223 { return m_dMaxExtraMargin;}
00224 void setMaxExtraMargin(double margin);
00225
00226 protected:
00227 virtual void _lookupProperties(const PP_AttrProp* pSectionAP);
00228 virtual void _lookupMarginProperties(const PP_AttrProp* pAP);
00229 void _purgeLayout();
00230 private:
00231 bool m_bNeedsRebuild;
00232 FL_TableJustification m_iJustification;
00233 UT_sint32 m_iLeftOffset;
00234 double m_dLeftOffsetUserUnits;
00235 UT_sint32 m_iRightOffset;
00236 double m_dRightOffsetUserUnits;
00237 UT_sint32 m_iTopOffset;
00238 double m_dTopOffsetUserUnits;
00239 UT_sint32 m_iBottomOffset;
00240 double m_dBottomOffsetUserUnits;
00241
00242 bool m_bIsHomogeneous;
00243 bool m_bSameRowOnTopOfPage;
00244 UT_sint32 m_iRowNumberForTop;
00245 UT_sint32 m_iNumberOfRows;
00246 UT_sint32 m_iNumberOfColumns;
00247 bool m_bColumnsPositionedOnPage;
00248 bool m_bRowsPositionedOnPage;
00249 bool m_bIsDirty;
00250 bool m_bDontImmediatelyLayout;
00251 bool m_bInitialLayoutCompleted;
00252 UT_sint32 m_iTableWaitIndex;
00253 UT_sint32 m_iLineThickness;
00254 UT_sint32 m_iColSpacing;
00255 UT_sint32 m_iRowSpacing;
00256 UT_sint32 m_iLeftColPos;
00257 bool m_bRecursiveFormat;
00258 UT_GenericVector<fl_ColProps *> m_vecColProps;
00259 UT_GenericVector<fl_RowProps *> m_vecRowProps;
00260 FL_RowHeightType m_iRowHeightType;
00261 UT_sint32 m_iRowHeight;
00262
00263
00264 PP_PropertyMap::Background m_background;
00265
00266
00267 UT_RGBColor m_colorDefault;
00268 PP_PropertyMap::Line m_lineBottom;
00269 PP_PropertyMap::Line m_lineLeft;
00270 PP_PropertyMap::Line m_lineRight;
00271 PP_PropertyMap::Line m_lineTop;
00272 UT_sint32 m_iNumNestedTables;
00273 bool m_bIsEndTableIn;
00274 UT_sint32 m_iHeightChanged;
00275 fp_CellContainer * m_pNewHeightCell;
00276 bool m_bDoingDestructor;
00277 UT_sint32 m_iTableWidth;
00278 double m_dTableRelWidth;
00279 double m_dMaxExtraMargin;
00280 };
00281
00282
00283 class ABI_EXPORT fl_CellLayout : public fl_SectionLayout
00284 {
00285 friend class fl_DocListener;
00286 friend class fp_TableContainer;
00287 friend class fp_CellContainer;
00288 public:
00289 fl_CellLayout(FL_DocLayout* pLayout, pf_Frag_Strux* sdh, PT_AttrPropIndex ap, fl_ContainerLayout * pMyContainerLayout);
00290 virtual ~fl_CellLayout();
00291
00292 bool isCellSelected(void);
00293 void checkAndAdjustCellSize(void);
00294 virtual bool doclistener_changeStrux(const PX_ChangeRecord_StruxChange * pcrxc);
00295 virtual bool doclistener_deleteStrux(const PX_ChangeRecord_Strux * pcrx);
00296 virtual bool bl_doclistener_insertCell(fl_ContainerLayout* pCell,
00297 const PX_ChangeRecord_Strux * pcrx,
00298 pf_Frag_Strux* sdh,
00299 PL_ListenerId lid,
00300 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00301 PL_ListenerId lid,
00302 fl_ContainerLayout* sfhNew));
00303 virtual bool bl_doclistener_insertEndCell(fl_ContainerLayout*,
00304 const PX_ChangeRecord_Strux * pcrx,
00305 pf_Frag_Strux* sdh,
00306 PL_ListenerId lid,
00307 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew,
00308 PL_ListenerId lid,
00309 fl_ContainerLayout* sfhNew));
00310
00311 void setCellContainerProperties(fp_CellContainer * pCell);
00312 void createCellContainer(void);
00313 virtual void format(void);
00314 virtual void updateLayout(bool bDoFull);
00315 virtual void collapse(void);
00316 bool isLayedOut(void) const;
00317 bool isDoingFormat(void) const;
00318 virtual bool needsReformat(void) const;
00319 virtual void markAllRunsDirty(void);
00320 virtual fl_SectionLayout * getSectionLayout(void) const;
00321 bool recalculateFields(UT_uint32 iUpdateCount);
00322 virtual void redrawUpdate(void);
00323 virtual fp_Container* getNewContainer(fp_Container * pFirstContainer = NULL);
00324 #ifdef FMT_TEST
00325 void __dump(FILE * fp) const;
00326 #endif
00327 UT_uint32 getLength(void);
00328
00329 UT_sint32 getLeftOffset(void) const;
00330 UT_sint32 getRightOffset(void) const;
00331 UT_sint32 getTopOffset(void) const;
00332 UT_sint32 getBottomOffset(void) const;
00333 UT_sint32 getNumNestedTables(void) const;
00334 void incNumNestedTables(void);
00335 void decNumNestedTables(void);
00336 UT_sint32 getLeftAttach(void) const
00337 { return m_iLeftAttach;}
00338 UT_sint32 getRightAttach(void) const
00339 { return m_iRightAttach;}
00340 UT_sint32 getTopAttach(void) const
00341 { return m_iTopAttach;}
00342 UT_sint32 getBottomAttach(void) const
00343 { return m_iBottomAttach;}
00344 UT_sint32 getCellHeight(void) const
00345 { return m_iCellHeight;}
00346 UT_sint32 getCellWidth(void) const
00347 { return m_iCellWidth;}
00348
00349 protected:
00350 virtual void _lookupProperties(const PP_AttrProp* pAP);
00351 virtual void _purgeLayout(void);
00352 private:
00353 bool m_bNeedsRebuild;
00354 UT_sint32 m_iLeftOffset;
00355 double m_dLeftOffsetUserUnits;
00356 UT_sint32 m_iRightOffset;
00357 double m_dRightOffsetUserUnits;
00358 UT_sint32 m_iTopOffset;
00359 double m_dTopOffsetUserUnits;
00360 UT_sint32 m_iBottomOffset;
00361 double m_dBottomOffsetUserUnits;
00362
00363 UT_sint32 m_iLeftAttach;
00364 UT_sint32 m_iRightAttach;
00365 UT_sint32 m_iTopAttach;
00366 UT_sint32 m_iBottomAttach;
00367
00368 bool m_bCellPositionedOnPage;
00369 UT_sint32 m_iCellHeight;
00370 UT_sint32 m_iCellWidth;
00371
00372
00373 PP_PropertyMap::Background m_background;
00374
00375
00376 PP_PropertyMap::Line m_lineBottom;
00377 PP_PropertyMap::Line m_lineLeft;
00378 PP_PropertyMap::Line m_lineRight;
00379 PP_PropertyMap::Line m_lineTop;
00380
00381 void _updateCell(void);
00382 void _localCollapse();
00383 UT_sint32 m_iNumNestedTables;
00384 bool m_bDoingFormat;
00385
00386
00387 UT_sint32 m_iVertAlign;
00388
00389 };
00390
00396 #define FS_OFF 0 // No fill style
00397 #define FS_FILL 1 // Solid fill style
00398
00399
00405 #define LS_OFF 0 // No line style, which means no line is drawn
00406 #define LS_NORMAL 1 // A normal solid line
00407 #define LS_DOTTED 2 // A dotted line
00408 #define LS_DASHED 3 // A dashed line
00409
00410
00411 #endif