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
00085 class ABI_EXPORT fl_ColProps
00086 {
00087 public:
00088 UT_sint32 m_iColWidth;
00089 };
00090
00091 class ABI_EXPORT fl_RowProps
00092 {
00093 public:
00094 fl_RowProps(void)
00095 {
00096 m_iRowHeight = 0;
00097 m_iRowHeightType = FL_ROW_HEIGHT_NOT_DEFINED;
00098 }
00099 virtual ~fl_RowProps(void)
00100 {
00101 }
00102 UT_sint32 m_iRowHeight;
00103 FL_RowHeightType m_iRowHeightType;
00104 };
00105
00106
00107 class ABI_EXPORT fl_TableLayout : public fl_SectionLayout
00108 {
00109 friend class fl_DocListener;
00110
00111 public:
00112 fl_TableLayout(FL_DocLayout* pLayout, PL_StruxDocHandle sdh, PT_AttrPropIndex ap, fl_ContainerLayout * pMyContainerLayout);
00113 virtual ~fl_TableLayout();
00114
00115 SectionType getType(void) const { return m_iType; }
00116
00117 virtual bool recalculateFields(UT_uint32 iUpdateCount);
00118 virtual bool doclistener_changeStrux(const PX_ChangeRecord_StruxChange * pcrxc);
00119 virtual bool doclistener_deleteStrux(const PX_ChangeRecord_Strux * pcrx);
00120 virtual bool bl_doclistener_insertCell(fl_ContainerLayout* pCell,
00121 const PX_ChangeRecord_Strux * pcrx,
00122 PL_StruxDocHandle sdh,
00123 PL_ListenerId lid,
00124 void (* pfnBindHandles)(PL_StruxDocHandle sdhNew,
00125 PL_ListenerId lid,
00126 PL_StruxFmtHandle sfhNew));
00127 virtual bool bl_doclistener_insertBlock(fl_ContainerLayout* pCell,
00128 const PX_ChangeRecord_Strux * pcrx,
00129 PL_StruxDocHandle sdh,
00130 PL_ListenerId lid,
00131 void (* pfnBindHandles)(PL_StruxDocHandle sdhNew,
00132 PL_ListenerId lid,
00133 PL_StruxFmtHandle sfhNew));
00134
00135 virtual bool bl_doclistener_insertEndTable(fl_ContainerLayout*,
00136 const PX_ChangeRecord_Strux * pcrx,
00137 PL_StruxDocHandle sdh,
00138 PL_ListenerId lid,
00139 void (* pfnBindHandles)(PL_StruxDocHandle sdhNew,
00140 PL_ListenerId lid,
00141 PL_StruxFmtHandle sfhNew));
00142
00143 virtual bool bl_doclistener_insertTable( const PX_ChangeRecord_Strux * pcrx,
00144 SectionType iType,
00145 PL_StruxDocHandle sdh,
00146 PL_ListenerId lid,
00147 void (* pfnBindHandles)(PL_StruxDocHandle sdhNew,
00148 PL_ListenerId lid,
00149 PL_StruxFmtHandle sfhNew));
00150
00151 #ifdef FMT_TEST
00152 virtual void __dump(FILE * fp) const;
00153 #endif
00154 void setTableContainerProperties(fp_TableContainer * pTab);
00155 virtual void format(void);
00156 void attachCell(fl_ContainerLayout * pCell);
00157 void createTableContainer(void);
00158 void insertTableContainer(fp_TableContainer * pNewTab);
00159 virtual void updateLayout(bool bDoFull);
00160 void updateTable(void);
00161 virtual void collapse(void);
00162 virtual void markAllRunsDirty(void);
00163 virtual bool needsReformat(void) const;
00164 virtual PT_DocPosition getPosition(bool bActualBlockPosition = false) const;
00165 UT_uint32 getLength(void);
00166 virtual void redrawUpdate(void);
00167 virtual fp_Container* getNewContainer(fp_Container * pFirstContainer = NULL);
00168 virtual fl_SectionLayout * getSectionLayout(void) const;
00169
00170 void markForRebuild(void) { m_bNeedsRebuild = true;}
00171 void clearRebuild(void) { m_bNeedsRebuild = false;}
00172 bool needsRebuild(void) const { return m_bNeedsRebuild;}
00173 void markForReformat(void) { m_bNeedsReformat = true;}
00174 bool needsReFormat(void) const { return m_bNeedsReformat;}
00175
00176 UT_sint32 getLeftOffset(void) const;
00177 void setHeightChanged(fp_CellContainer * pCell);
00178 bool doSimpleChange(void);
00179 UT_sint32 getRightOffset(void) const;
00180 UT_sint32 getTopOffset(void) const;
00181 UT_sint32 getBottomOffset(void) const;
00182 bool isDirty(void) const
00183 { return m_bIsDirty;}
00184 void setDirty(void);
00185
00186 UT_sint32 getLineThickness(void) const;
00187 UT_sint32 getColSpacing(void) const;
00188 UT_sint32 getRowSpacing(void) const;
00189 UT_sint32 getLeftColPos(void) const
00190 { return m_iLeftColPos;}
00191 const UT_GenericVector<fl_ColProps*> * getVecColProps(void) const
00192 { return &m_vecColProps;}
00193 const UT_GenericVector<fl_RowProps*> * getVecRowProps(void) const
00194 { return &m_vecRowProps;}
00195
00196 const PP_PropertyMap::Background & getBackground () const { return m_background; }
00197
00198 const UT_RGBColor & getDefaultColor () const { return m_colorDefault; }
00199
00200 const PP_PropertyMap::Line & getBottomStyle () const { return m_lineBottom; }
00201 const PP_PropertyMap::Line & getLeftStyle () const { return m_lineLeft; }
00202 const PP_PropertyMap::Line & getRightStyle () const { return m_lineRight; }
00203 const PP_PropertyMap::Line & getTopStyle () const { return m_lineTop; }
00204 UT_sint32 getNumNestedTables(void) const;
00205 void incNumNestedTables(void);
00206 void decNumNestedTables(void);
00207
00208 void setEndTableIn(void)
00209 { m_bIsEndTableIn = true;}
00210 bool isEndTableIn(void)
00211 { return m_bIsEndTableIn;}
00212 bool isDoingDestructor(void)
00213 { return m_bDoingDestructor;}
00214 protected:
00215 virtual void _lookupProperties(const PP_AttrProp* pSectionAP);
00216 virtual void _lookupMarginProperties(const PP_AttrProp* pAP);
00217 void _purgeLayout();
00218 private:
00219 bool m_bNeedsRebuild;
00220 FL_TableJustification m_iJustification;
00221 UT_sint32 m_iLeftOffset;
00222 double m_dLeftOffsetUserUnits;
00223 UT_sint32 m_iRightOffset;
00224 double m_dRightOffsetUserUnits;
00225 UT_sint32 m_iTopOffset;
00226 double m_dTopOffsetUserUnits;
00227 UT_sint32 m_iBottomOffset;
00228 double m_dBottomOffsetUserUnits;
00229
00230 bool m_bIsHomogeneous;
00231 bool m_bSameRowOnTopOfPage;
00232 UT_sint32 m_iRowNumberForTop;
00233 UT_sint32 m_iNumberOfRows;
00234 UT_sint32 m_iNumberOfColumns;
00235 bool m_bColumnsPositionedOnPage;
00236 bool m_bRowsPositionedOnPage;
00237 bool m_bIsDirty;
00238 bool m_bDontImmediatelyLayout;
00239 UT_sint32 m_iLineThickness;
00240 UT_sint32 m_iColSpacing;
00241 UT_sint32 m_iRowSpacing;
00242 UT_sint32 m_iLeftColPos;
00243 bool m_bRecursiveFormat;
00244 UT_GenericVector<fl_ColProps *> m_vecColProps;
00245 UT_GenericVector<fl_RowProps *> m_vecRowProps;
00246 FL_RowHeightType m_iRowHeightType;
00247 UT_sint32 m_iRowHeight;
00248
00249
00250 PP_PropertyMap::Background m_background;
00251
00252
00253 UT_RGBColor m_colorDefault;
00254 PP_PropertyMap::Line m_lineBottom;
00255 PP_PropertyMap::Line m_lineLeft;
00256 PP_PropertyMap::Line m_lineRight;
00257 PP_PropertyMap::Line m_lineTop;
00258 UT_sint32 m_iNumNestedTables;
00259 bool m_bIsEndTableIn;
00260 UT_sint32 m_iHeightChanged;
00261 fp_CellContainer * m_pNewHeightCell;
00262 bool m_bDoingDestructor;
00263 };
00264
00265
00266 class ABI_EXPORT fl_CellLayout : public fl_SectionLayout
00267 {
00268 friend class fl_DocListener;
00269 friend class fp_TableContainer;
00270 friend class fp_CellContainer;
00271 public:
00272 fl_CellLayout(FL_DocLayout* pLayout, PL_StruxDocHandle sdh, PT_AttrPropIndex ap, fl_ContainerLayout * pMyContainerLayout);
00273 virtual ~fl_CellLayout();
00274
00275 bool isCellSelected(void);
00276 void checkAndAdjustCellSize(void);
00277 virtual bool doclistener_changeStrux(const PX_ChangeRecord_StruxChange * pcrxc);
00278 virtual bool doclistener_deleteStrux(const PX_ChangeRecord_Strux * pcrx);
00279 virtual bool bl_doclistener_insertCell(fl_ContainerLayout* pCell,
00280 const PX_ChangeRecord_Strux * pcrx,
00281 PL_StruxDocHandle sdh,
00282 PL_ListenerId lid,
00283 void (* pfnBindHandles)(PL_StruxDocHandle sdhNew,
00284 PL_ListenerId lid,
00285 PL_StruxFmtHandle sfhNew));
00286 virtual bool bl_doclistener_insertEndCell(fl_ContainerLayout*,
00287 const PX_ChangeRecord_Strux * pcrx,
00288 PL_StruxDocHandle sdh,
00289 PL_ListenerId lid,
00290 void (* pfnBindHandles)(PL_StruxDocHandle sdhNew,
00291 PL_ListenerId lid,
00292 PL_StruxFmtHandle sfhNew));
00293
00294 void setCellContainerProperties(fp_CellContainer * pCell);
00295 void createCellContainer(void);
00296 virtual void format(void);
00297 virtual void updateLayout(bool bDoFull);
00298 virtual void collapse(void);
00299 bool isLayedOut(void) const;
00300 bool isDoingFormat(void) const;
00301 virtual bool needsReformat(void) const;
00302 virtual void markAllRunsDirty(void);
00303 virtual fl_SectionLayout * getSectionLayout(void) const;
00304 bool recalculateFields(UT_uint32 iUpdateCount);
00305 virtual void redrawUpdate(void);
00306 virtual fp_Container* getNewContainer(fp_Container * pFirstContainer = NULL);
00307 #ifdef FMT_TEST
00308 void __dump(FILE * fp) const;
00309 #endif
00310 UT_uint32 getLength(void);
00311
00312 UT_sint32 getLeftOffset(void) const;
00313 UT_sint32 getRightOffset(void) const;
00314 UT_sint32 getTopOffset(void) const;
00315 UT_sint32 getBottomOffset(void) const;
00316 UT_sint32 getNumNestedTables(void) const;
00317 void incNumNestedTables(void);
00318 void decNumNestedTables(void);
00319 UT_sint32 getLeftAttach(void) const
00320 { return m_iLeftAttach;}
00321 UT_sint32 getRightAttach(void) const
00322 { return m_iRightAttach;}
00323 UT_sint32 getTopAttach(void) const
00324 { return m_iTopAttach;}
00325 UT_sint32 getBottomAttach(void) const
00326 { return m_iBottomAttach;}
00327 UT_sint32 getCellHeight(void) const
00328 { return m_iCellHeight;}
00329 UT_sint32 getCellWidth(void) const
00330 { return m_iCellWidth;}
00331 protected:
00332 virtual void _lookupProperties(const PP_AttrProp* pAP);
00333 virtual void _purgeLayout(void);
00334 private:
00335 bool m_bNeedsRebuild;
00336 UT_sint32 m_iLeftOffset;
00337 double m_dLeftOffsetUserUnits;
00338 UT_sint32 m_iRightOffset;
00339 double m_dRightOffsetUserUnits;
00340 UT_sint32 m_iTopOffset;
00341 double m_dTopOffsetUserUnits;
00342 UT_sint32 m_iBottomOffset;
00343 double m_dBottomOffsetUserUnits;
00344
00345 UT_sint32 m_iLeftAttach;
00346 UT_sint32 m_iRightAttach;
00347 UT_sint32 m_iTopAttach;
00348 UT_sint32 m_iBottomAttach;
00349
00350 bool m_bCellPositionedOnPage;
00351 UT_sint32 m_iCellHeight;
00352 UT_sint32 m_iCellWidth;
00353
00354
00355 PP_PropertyMap::Background m_background;
00356
00357
00358 PP_PropertyMap::Line m_lineBottom;
00359 PP_PropertyMap::Line m_lineLeft;
00360 PP_PropertyMap::Line m_lineRight;
00361 PP_PropertyMap::Line m_lineTop;
00362
00363 void _updateCell(void);
00364 void _localCollapse();
00365 UT_sint32 m_iNumNestedTables;
00366 bool m_bDoingFormat;
00367 };
00368
00374 #define FS_OFF 0 // No fill style
00375 #define FS_FILL 1 // Solid fill style
00376
00377
00383 #define LS_OFF 0 // No line style, which means no line is drawn
00384 #define LS_NORMAL 1 // A normal solid line
00385 #define LS_DOTTED 2 // A dotted line
00386 #define LS_DASHED 3 // A dashed line
00387
00388
00389 #endif