00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef TABLECONTAINER_H
00051 #define TABLECONTAINER_H
00052
00053 #ifdef FMT_TEST
00054 #include <stdio.h>
00055 #endif
00056
00057 #include <vector>
00058 #include "ut_misc.h"
00059 #include "ut_types.h"
00060 #include "ut_vector.h"
00061 #include "pt_Types.h"
00062 #include "fp_Page.h"
00063 #include "fp_ContainerObject.h"
00064 #include "fp_Column.h"
00065 #include "gr_Graphics.h"
00066 #include "fl_TableLayout.h"
00067
00068 #define FP_TABLE_MIN_BROKEN_HEIGHT 60
00069
00070 class fl_TableLayout;
00071
00072 class ABI_EXPORT fp_TableRowColumn
00073 {
00074 public:
00075 fp_TableRowColumn(UT_sint32 defaultSpacing = 0);
00076 virtual ~fp_TableRowColumn(void);
00077 static bool comparePosition(UT_sint32 y, const fp_TableRowColumn * pRow);
00078 UT_sint32 requisition;
00079 UT_sint32 allocation;
00080 UT_sint32 spacing;
00081 UT_sint32 position;
00082 bool need_expand;
00083 bool need_shrink;
00084 bool expand;
00085 bool shrink;
00086 bool empty;
00087 };
00088
00089 class fp_VerticalContainer;
00090 class fp_Column;
00091 class fl_EndnoteSectionLayout;
00092 class fl_HdrFtrSectionLayout;
00093 class fl_DocSectionLayout;
00094 class fl_SectionLayout;
00095 class fl_HdrFtrShadow;
00096 class fp_Page;
00097 class PP_AttrProp;
00098 class GR_Graphics;
00099 class fp_TableContainer;
00100 struct dg_DrawArgs;
00101 struct fp_Sliver;
00102
00103 class ABI_EXPORT fp_CellContainer : public fp_VerticalContainer
00104 {
00105 public:
00106 fp_CellContainer(fl_SectionLayout* pSectionLayout);
00107 virtual ~fp_CellContainer();
00108
00109 void sizeRequest(fp_Requisition * pRequest);
00110 void sizeAllocate(fp_Allocation * pAllocate);
00111 void layout(void);
00112 fp_Container * drawSelectedCell(fp_Line * pLine);
00113 bool isSelected(void) const
00114 { return m_bIsSelected; }
00115 void clearSelection(void)
00116 { m_bIsSelected = false;
00117 m_bLinesDrawn = true;
00118 }
00119 bool doesOverlapBrokenTable(const fp_TableContainer * pBroke) const;
00120 void drawBroken(dg_DrawArgs* pDa, fp_TableContainer * pTab);
00121 virtual void clearScreen(void);
00122 void clearScreen(bool bNoRecursive);
00123 void getScreenPositions(fp_TableContainer * pBroke,GR_Graphics * pG,UT_sint32 & iLeft, UT_sint32 & iRight,UT_sint32 & iTop,UT_sint32 & iBot,UT_sint32 & col_y, fp_Column *& pCol, fp_ShadowContainer *& pShadow, bool & bDoClear ) const;
00124 bool drawLines(fp_TableContainer * pBroke,GR_Graphics * pG,bool bDoClear);
00125 void drawLinesAdjacent(void);
00126 void draw(fp_Line * pLine);
00127 fp_TableContainer * getBrokenTable(const fp_Container * pCon) const;
00128 fp_VerticalContainer * getColumn(const fp_Container *pCon) const;
00129 fp_Container * getFirstContainerInBrokenTable(const fp_TableContainer * pBroke) const;
00130 UT_sint32 wantCellVBreakAt(UT_sint32,UT_sint32) const;
00131 virtual void draw(dg_DrawArgs*);
00132 virtual void draw(GR_Graphics*) {}
00133 virtual void setContainer(fp_Container * pContainer);
00134 virtual void setWidth(UT_sint32 iWidth);
00135 virtual void setHeight(UT_sint32 iHeight);
00136 void _drawBoundaries(dg_DrawArgs* pDA, fp_TableContainer *pBroke);
00137 virtual bool isVBreakable(void);
00138 virtual bool isHBreakable(void) {return false;}
00139 virtual UT_sint32 wantHBreakAt(UT_sint32) {return 0;}
00140 virtual fp_ContainerObject * VBreakAt(UT_sint32);
00141 virtual fp_ContainerObject * HBreakAt(UT_sint32) {return NULL;}
00142 void recalcMaxWidth(bool bDontClearIfNeeded = false)
00143 { UT_UNUSED(bDontClearIfNeeded); }
00144 virtual void setAssignedScreenHeight(UT_sint32) {}
00145 virtual fp_Container * getNextContainerInSection(void) const;
00146 virtual fp_Container * getPrevContainerInSection(void) const;
00147 fp_TableContainer * getTopmostTable(void) const;
00148 void extendLeftTop(PP_PropertyMap::Line & line,GR_Graphics * pG,UT_sint32 & iextTop);
00149 void extendLeftBot(PP_PropertyMap::Line & line,GR_Graphics * pG,UT_sint32 & iextBot);
00150 void extendRightTop(PP_PropertyMap::Line & line,GR_Graphics * pG,UT_sint32 & iextTop);
00151 void extendRightBot(PP_PropertyMap::Line & line,GR_Graphics * pG,UT_sint32 & iextBot);
00152 void extendTopLeft(PP_PropertyMap::Line & line,GR_Graphics * pG,UT_sint32 & iextLeft);
00153 void extendTopRight(PP_PropertyMap::Line & line,GR_Graphics * pG,UT_sint32 & iextRight);
00154 void extendBotLeft(PP_PropertyMap::Line & line,GR_Graphics * pG,UT_sint32 & iextLeft);
00155 void extendBotRight(PP_PropertyMap::Line & line,GR_Graphics * pG,UT_sint32 & iextRight);
00156
00157 UT_sint32 getCellX(fp_Line * pLine) const;
00158 UT_sint32 getCellY(fp_Line * pLine) const;
00159 UT_sint32 getSpannedHeight(void) const;
00160 void setLineMarkers(void);
00161 void deleteBrokenTables(bool bClearFirst=true);
00162 void deleteBrokenAfter(bool bClearFirst,UT_sint32 iOldBottom);
00163 bool containsFootnoteReference(const fp_TableContainer * pBroke = NULL) const;
00164 bool getFootnoteContainers(UT_GenericVector<fp_FootnoteContainer*>* pvecFoots, const fp_TableContainer * pBroke = NULL) const;
00165 bool containsAnnotations(const fp_TableContainer * pBroke = NULL) const;
00166 bool getAnnotationContainers(UT_GenericVector<fp_AnnotationContainer*>* pvecAnns, const fp_TableContainer * pBroke = NULL) const;
00167 void getLeftTopOffsets(UT_sint32 & xoff, UT_sint32 & yoff) const;
00168 UT_sint32 getLeftAttach(void) const
00169 { return m_iLeftAttach;}
00170 UT_sint32 getRightAttach(void) const
00171 { return m_iRightAttach;}
00172 UT_sint32 getTopAttach(void) const
00173 { return m_iTopAttach;}
00174 UT_sint32 getBottomAttach(void) const
00175 { return m_iBottomAttach;}
00176 void setLeftAttach(UT_sint32 i)
00177 { m_iLeftAttach = i;}
00178 void setRightAttach(UT_sint32 i)
00179 { m_iRightAttach = i;}
00180 void setTopAttach(UT_sint32 i)
00181 { m_iTopAttach = i;}
00182 void setBottomAttach(UT_sint32 i)
00183 { m_iBottomAttach = i;}
00184 void setToAllocation(void);
00185 UT_sint32 getLeftPad(void) const
00186 { return m_iLeftPad;}
00187 UT_sint32 getRightPad(void) const
00188 { return m_iRightPad;}
00189 UT_sint32 getTopPad(void) const
00190 { return m_iTopPad;}
00191 UT_sint32 getBotPad(void) const
00192 { return m_iBotPad;}
00193 void setLeftPad(UT_sint32 i)
00194 { m_iLeftPad = i;}
00195 void setRightPad(UT_sint32 i)
00196 { m_iRightPad = i;}
00197 void setTopPad(UT_sint32 i)
00198 { m_iTopPad = i;}
00199 void setBotPad(UT_sint32 i)
00200 { m_iBotPad = i;}
00201
00202 PP_PropertyMap::Background getBackground () const;
00203
00204 void setBackground (const PP_PropertyMap::Background & style);
00205
00206
00207 PP_PropertyMap::Line getBottomStyle (const fl_TableLayout * table) const;
00208 PP_PropertyMap::Line getLeftStyle (const fl_TableLayout * table) const;
00209 PP_PropertyMap::Line getRightStyle (const fl_TableLayout * table) const;
00210 PP_PropertyMap::Line getTopStyle (const fl_TableLayout * table) const;
00211
00212 void setBottomStyle (const PP_PropertyMap::Line & style) { m_lineBottom = style; }
00213 void setLeftStyle (const PP_PropertyMap::Line & style) { m_lineLeft = style; }
00214 void setRightStyle (const PP_PropertyMap::Line & style) { m_lineRight = style; }
00215 void setTopStyle (const PP_PropertyMap::Line & style) { m_lineTop = style; }
00216
00217 bool getXexpand(void) const
00218 { return m_bXexpand;}
00219 bool getYexpand(void) const
00220 { return m_bYexpand;}
00221 bool getXshrink(void) const
00222 { return m_bXshrink;}
00223 bool getYshrink(void) const
00224 { return m_bYshrink;}
00225 void setXexpand(bool b)
00226 { m_bXexpand = b;}
00227 void setYexpand(bool b)
00228 { m_bYexpand = b;}
00229 void setXshrink(bool b)
00230 { m_bXshrink = b;}
00231 void setYshrink(bool b)
00232 { m_bYshrink = b;}
00233 bool getXfill(void) const
00234 {return m_bXfill;}
00235 bool getYfill(void)const
00236 {return m_bYfill;}
00237 void setXfill(bool b)
00238 { m_bXfill = b;}
00239 void setYfill(bool b)
00240 { m_bYfill = b;}
00241 UT_sint32 getStartY(void) const
00242 { return m_iTopY;}
00243 UT_sint32 getStopY(void) const
00244 { return m_iBotY;}
00245 UT_sint32 getLeftPos(void) const
00246 { return m_iLeft; }
00247 UT_sint32 getRightPos(void) const
00248 { return m_iRight; }
00249 void markAsDirty(void) { m_bDirty = true;}
00250 bool isDirty(void) const
00251 { return m_bDirty;}
00252 bool doesIntersectClip(fp_TableContainer * pBroke, const UT_Rect * rClip) const;
00253 bool isInNestedTable(void) const;
00254 bool containsNestedTables(void) const;
00255 bool isRepeated(void) const;
00256 void setVertAlign(UT_sint32 i) { m_iVertAlign = i; }
00257 void doVertAlign(void);
00258 #ifdef FMT_TEST
00259 void __dump(FILE * fp) const;
00260 #endif
00261
00262 private:
00263
00264 void _clear(fp_TableContainer * pBroke);
00265 void _getBrokenRect(fp_TableContainer * pBroke, fp_Page* &pPage, UT_Rect &bRec, GR_Graphics * pG) const;
00266
00267
00268
00269
00270
00271
00272
00273 UT_sint32 m_iLeftAttach;
00274
00275
00276
00277 UT_sint32 m_iRightAttach;
00278
00279
00280
00281 UT_sint32 m_iTopAttach;
00282
00283
00284
00285 UT_sint32 m_iBottomAttach;
00286
00287
00288
00289 UT_RGBColor m_borderColorNone;
00290
00291
00292
00293
00294 UT_sint32 m_iLeftPad;
00295 UT_sint32 m_iRightPad;
00296 UT_sint32 m_iTopPad;
00297 UT_sint32 m_iBotPad;
00298
00299
00300
00301 fp_CellContainer * m_pNextInTable;
00302 fp_CellContainer * m_pPrevInTable;
00303
00304
00305
00306 bool m_bXexpand;
00307 bool m_bYexpand;
00308 bool m_bXshrink;
00309 bool m_bYshrink;
00310
00311
00312
00313 bool m_bXfill;
00314 bool m_bYfill;
00315
00316
00317
00318 fp_Allocation m_MyAllocation;
00319 fp_Requisition m_MyRequest;
00320
00321
00322
00323 UT_sint32 m_iLeft;
00324 UT_sint32 m_iRight;
00325 UT_sint32 m_iTopY;
00326 UT_sint32 m_iBotY;
00327 bool m_bDrawLeft;
00328 bool m_bDrawTop;
00329 bool m_bDrawBot;
00330 bool m_bDrawRight;
00331 bool m_bLinesDrawn;
00332
00333
00334 bool m_bBgDirty;
00335
00336
00337 PP_PropertyMap::Background m_background;
00338
00339
00340 PP_PropertyMap::Line m_lineBottom;
00341 PP_PropertyMap::Line m_lineLeft;
00342 PP_PropertyMap::Line m_lineRight;
00343 PP_PropertyMap::Line m_lineTop;
00344
00345
00346 bool m_bIsSelected;
00347 bool m_bDirty;
00348
00349 bool m_bIsRepeated;
00350
00351
00352
00353 UT_sint32 m_iVertAlign;
00354 };
00355
00356 class ABI_EXPORT fp_TableContainer : public fp_VerticalContainer
00357 {
00358 public:
00359 fp_TableContainer(fl_SectionLayout* pSectionLayout);
00360 fp_TableContainer(fl_SectionLayout* pSectionLayout, fp_TableContainer * pMaster);
00361 ~fp_TableContainer();
00362
00363 void sizeRequest(fp_Requisition * pRequest);
00364 void sizeAllocate(fp_Allocation * pAllocate);
00365 virtual void mapXYToPosition(UT_sint32 x, UT_sint32 y,
00366 PT_DocPosition& pos,
00367 bool& bBOL, bool& bEOL, bool &isTOC);
00368 virtual fp_Page * getPage(void) const;
00369 fp_Line * getFirstLineInColumn(fp_Column * pCol) const;
00370 fp_Line * getLastLineInColumn(fp_Column * pCol) const;
00371 void layout(void);
00372 virtual void setY(UT_sint32 iY);
00373 virtual UT_sint32 getHeight(void) const;
00374 virtual void setContainer(fp_Container * pContainer);
00375 virtual void draw(dg_DrawArgs*);
00376 virtual void draw(GR_Graphics*) {}
00377 virtual UT_sint32 getMarginBefore(void) const;
00378 virtual UT_sint32 getMarginAfter(void) const;
00379 void setAdditionalMargin(UT_sint32 iMarg)
00380 {m_iAdditionalMarginAfter = iMarg;}
00381 fp_Column * getBrokenColumn(void) const;
00382 void drawLines();
00383 bool containsFootnoteReference(void) const;
00384 bool getFootnoteContainers(UT_GenericVector<fp_FootnoteContainer*>* pvecFoots) const;
00385 bool containsAnnotations(void) const;
00386 bool getAnnotationContainers(UT_GenericVector<fp_AnnotationContainer*>* pvecAnns) const;
00387 virtual void clearScreen(void);
00388 virtual bool isVBreakable(void);
00389 virtual bool isHBreakable(void) {return false;}
00390 virtual UT_sint32 wantVBreakAt(UT_sint32);
00391 virtual UT_sint32 wantHBreakAt(UT_sint32) {return 0;}
00392 UT_sint32 wantVBreakAtNoFootnotes(UT_sint32);
00393 UT_sint32 wantVBreakAtWithFootnotes(UT_sint32);
00394 UT_sint32 sumFootnoteHeight(void) const;
00395 virtual fp_ContainerObject * VBreakAt(UT_sint32);
00396 void breakCellsAt(UT_sint32 vpos);
00397 virtual fp_ContainerObject * HBreakAt(UT_sint32) {return NULL;}
00398 UT_sint32 getBrokenNumber(void) const;
00399 void setToAllocation(void);
00400 void tableAttach(fp_CellContainer * pCell);
00401 void setHomogeneous (bool bIsHomogeneous);
00402 void setColSpacings (UT_sint32 spacing);
00403 void setRowSpacings ( UT_sint32 spacing);
00404 void setColSpacing(UT_sint32 column,UT_sint32 spacing);
00405 void setRowSpacing (UT_sint32 row, UT_sint32 spacing);
00406 void resize(UT_sint32 n_rows, UT_sint32 n_cols);
00407 void setLineThickness(UT_sint32 iLineThickness)
00408 { m_iLineThickness = iLineThickness;}
00409 UT_sint32 getLineThickness(void) const
00410 { return m_iLineThickness;}
00411 void queueResize(void);
00412 UT_sint32 getYOfRowOrColumn(UT_sint32 row, bool bRow) const;
00413 UT_sint32 getYOfRow(UT_sint32 row, bool bBottomOffset = true) const;
00414 UT_sint32 getXOfColumn(UT_sint32 col) const;
00415 fp_CellContainer * getCellAtRowColumn(UT_sint32 row, UT_sint32 column) const;
00416 fp_CellContainer * getCellAtRowColumnLinear(UT_sint32 row, UT_sint32 column) const;
00417 virtual fp_Container * getNextContainerInSection(void) const;
00418 virtual fp_Container * getPrevContainerInSection(void) const;
00419 fp_TableContainer * getMasterTable(void) const
00420 { return m_pMasterTable; }
00421 bool isThisBroken(void) const;
00422 void setYBreakHere(UT_sint32 iBreakHere);
00423 void setYBottom(UT_sint32 iBotContainer);
00424 bool isInBrokenTable(const fp_CellContainer * pCell,
00425 const fp_Container * pCon) const;
00426
00427
00428
00429
00430
00431 UT_sint32 getYBreak(void) const
00432 {return m_iYBreakHere;}
00433
00434
00435
00436 UT_sint32 getYBottom(void) const
00437 {return m_iYBottom;}
00438 fp_TableContainer * getFirstBrokenTable(void) const;
00439 fp_TableContainer * getLastBrokenTable(void) const;
00440 fp_CellContainer * getFirstBrokenCell(bool bCacheResultOnly = false) const;
00441 void setFirstBrokenTable(fp_TableContainer * pBroke);
00442 void setLastBrokenTable(fp_TableContainer * pBroke);
00443 void deleteBrokenTables(bool bClearFirst, bool bRecurseUp = true);
00444 UT_sint32 getAdditionalBottomSpace(void) const
00445 { return m_iAdditionalBottomSpace;}
00446 void setAdditionalBottomSpace(UT_sint32 space)
00447 { m_iAdditionalBottomSpace = space;}
00448 bool getBrokenTop(void) const
00449 { return m_bBrokenTop;}
00450 bool getBrokenBottom(void) const
00451 { return m_bBrokenBottom;}
00452 void setBrokenTop(bool bTop)
00453 { m_bBrokenTop = bTop;}
00454 void setBrokenBottom(bool bBot)
00455 { m_bBrokenBottom = bBot;}
00456 UT_sint32 getNumRows(void) const;
00457 UT_sint32 getNumCols(void) const;
00458 UT_sint32 getRowHeight(UT_sint32 iRow, UT_sint32 iMeasHeight) const;
00459 UT_sint32 getTotalTableHeight(void) const;
00460 UT_sint32 getRowOrColumnAtPosition(UT_sint32 y, bool bRow) const;
00461 void setRedrawLines(void)
00462 { m_bRedrawLines = true;}
00463 bool doRedrawLines(void) const
00464 { return m_bRedrawLines;}
00465 fp_TableRowColumn * getNthCol(UT_uint32 i) const;
00466 fp_TableRowColumn * getNthRow(UT_uint32 i) const;
00467 bool containsNestedTables(void) const;
00468 void setRowHeightType(FL_RowHeightType iType)
00469 {
00470 m_iRowHeightType = iType;
00471 }
00472 void setRowHeight(UT_sint32 iHeight)
00473 {
00474 m_iRowHeight = iHeight;
00475 }
00476 virtual void setLastWantedVBreak(UT_sint32 iBreakAt)
00477 {m_iLastWantedVBreak = iBreakAt;}
00478 virtual UT_sint32 getLastWantedVBreak(void) const
00479 {return m_iLastWantedVBreak;}
00480 virtual fp_Container * getFirstBrokenContainer() const;
00481 virtual void deleteBrokenAfter(bool bClearFirst);
00482 #ifdef FMT_TEST
00483 void __dump(FILE * fp) const;
00484 #endif
00485 private:
00486 void _size_request_init(void);
00487 void _size_request_pass1(void);
00488 void _size_request_pass2(void);
00489 void _size_request_pass3(void);
00490
00491 void _size_allocate_init(void);
00492 void _size_allocate_pass1(void);
00493 void _size_allocate_pass2(void);
00494 UT_uint32 _getBottomOfLastContainer(void) const;
00495 void _drawBoundaries(dg_DrawArgs* pDA);
00496 void _drawBrokenBoundaries(dg_DrawArgs* pDA);
00497 void _brokenDraw(dg_DrawArgs* pDA);
00498
00499 UT_sint32 m_iRows;
00500 UT_sint32 m_iCols;
00501 bool m_bIsHomogeneous;
00502
00503 std::vector<fp_TableRowColumn *> m_vecRows;
00504 std::vector<fp_TableRowColumn *> m_vecColumns;
00505
00506
00507
00508 fp_Allocation m_MyAllocation;
00509 fp_Requisition m_MyRequest;
00510
00511 UT_sint32 m_iRowSpacing;
00512 UT_sint32 m_iColSpacing;
00513
00514
00515
00516 fp_TableContainer * m_pFirstBrokenTable;
00517 fp_TableContainer * m_pLastBrokenTable;
00518 bool m_bIsBroken;
00519 fp_TableContainer * m_pMasterTable;
00520 UT_sint32 m_iYBreakHere;
00521 UT_sint32 m_iYBottom;
00522 UT_sint32 m_iAdditionalBottomSpace;
00523 bool m_bBrokenTop;
00524 bool m_bBrokenBottom;
00525 bool m_bRedrawLines;
00526
00527
00528
00529 UT_sint32 m_iLineThickness;
00530
00531
00532 FL_RowHeightType m_iRowHeightType;
00533
00534 UT_sint32 m_iRowHeight;
00535
00536
00537 UT_sint32 m_iLastWantedVBreak;
00538 UT_sint32 m_iNextWantedVBreak;
00539
00540
00541
00542 fp_CellContainer * m_pFirstBrokenCell;
00543 UT_sint32 m_iAdditionalMarginAfter;
00544 };
00545
00546 #endif