Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef IE_TABLES
00024 #define IE_TABLES
00025
00026 #include <stack>
00027 #include "pd_Document.h"
00028 #include "pt_Types.h"
00029 #include "ut_wctomb.h"
00030
00031 class PD_Document;
00032 class PX_ChangeRecord_Object;
00033 class PP_AttrProp;
00034 class ie_imp_table;
00035
00036
00037 class ABI_EXPORT ie_PartTable
00038 {
00039 public:
00040 ie_PartTable(PD_Document * pDoc);
00041 virtual ~ie_PartTable(void);
00042 void setDoc(PD_Document * pDoc);
00043 void setTableApi(pf_Frag_Strux* sdh,PT_AttrPropIndex iApi);
00044 void setCellApi(PT_AttrPropIndex iApi);
00045 UT_sint32 getLeft(void);
00046 UT_sint32 getRight(void);
00047 UT_sint32 getPrevRight(void) {return m_iPrevRight;}
00048 UT_sint32 getTop(void);
00049 UT_sint32 getBot(void);
00050 const char * getTableProp(const char * pPropName);
00051 const char * getCellProp(const char * pPropName);
00052 PT_AttrPropIndex getTableAPI(void) const {return m_apiTable;}
00053 PT_AttrPropIndex getCellAPI(void) const { return m_apiCell;}
00054 UT_sint32 getNumRows(void);
00055 UT_sint32 getNumCols(void);
00056 UT_sint32 getCurRow(void) const { return m_iCurRow;}
00057 void incCurRow(void) { m_iCurRow++;}
00058 pf_Frag_Strux* getTableSDH(void)
00059 { return m_TableSDH;}
00060 void setCellJustOpenned(bool b);
00061 bool isCellJustOpenned(void);
00062 private:
00063 void _setRowsCols(void);
00064 void _clearAll(void);
00065 void _clearAllCell(void);
00066 PD_Document * m_pDoc;
00067 PT_AttrPropIndex m_apiTable;
00068 PT_AttrPropIndex m_apiCell;
00069 const PP_AttrProp * m_TableAttProp;
00070 const PP_AttrProp * m_CellAttProp;
00071 UT_sint32 m_iNumRows;
00072 UT_sint32 m_iNumCols;
00073 UT_sint32 m_iLeft;
00074 UT_sint32 m_iRight;
00075 UT_sint32 m_iTop;
00076 UT_sint32 m_iBot;
00077 UT_sint32 m_iPrevLeft;
00078 UT_sint32 m_iPrevRight;
00079 UT_sint32 m_iPrevTop;
00080 UT_sint32 m_iPrevBot;
00081 pf_Frag_Strux* m_TableSDH;
00082 bool m_bIsCellJustOpenned;
00083 UT_sint32 m_iCurRow;
00084 };
00085
00086
00087 class ABI_EXPORT ie_Table
00088 {
00089 public:
00090 ie_Table(PD_Document * pDoc);
00091 ie_Table(void);
00092 virtual ~ie_Table(void);
00093 void setDoc(PD_Document * pDoc);
00094 void OpenTable(pf_Frag_Strux* tableSDH, PT_AttrPropIndex iApi);
00095 void OpenCell(PT_AttrPropIndex iApi);
00096 void CloseTable(void);
00097 void CloseCell(void);
00098 bool isNewRow(void);
00099 UT_sint32 getLeft(void);
00100 UT_sint32 getRight(void);
00101 UT_sint32 getTop(void);
00102 UT_sint32 getBot(void);
00103 UT_sint32 getNumRows(void);
00104 UT_sint32 getNumCols(void);
00105 const char * getTableProp(const char * pPropName);
00106 const char * getCellProp(const char * pPropName);
00107 UT_sint32 getNestDepth(void);
00108 void setCellRowCol(UT_sint32 row, UT_sint32 col);
00109 pf_Frag_Strux* getTableSDH(void);
00110 void setCellJustOpenned(bool b);
00111 bool isCellJustOpenned(void);
00112 PT_AttrPropIndex getTableAPI(void);
00113 PT_AttrPropIndex getCellAPI(void);
00114 UT_sint32 getPrevNumRightMostVMerged(void);
00115 UT_sint32 getCurRow(void);
00116 void incCurRow(void);
00117 private:
00118 PD_Document * m_pDoc;
00119 std::stack<ie_PartTable*> m_sLastTable;
00120 bool m_bNewRow;
00121 pf_Frag_Strux* m_sdhLastCell;
00122 };
00123
00124
00125 class ABI_EXPORT ie_imp_cell
00126 {
00127 public:
00128 ie_imp_cell(ie_imp_table * pImpTable, PD_Document * pDoc,
00129 ie_imp_cell * pImpCell, UT_sint32 iRow);
00130 virtual ~ie_imp_cell(void);
00131 void setCellX(UT_sint32 cellx);
00132 UT_sint32 getCellX(void);
00133 void setCellLeft(ie_imp_cell * pImpCell);
00134 void setLeft(UT_sint32 iLeft);
00135 UT_sint32 getLeft(void);
00136 void setRight(UT_sint32 iRight);
00137 UT_sint32 getRight(void);
00138 void setTop(UT_sint32 iTop);
00139 UT_sint32 getTop(void);
00140 void setBot(UT_sint32 iBot);
00141 UT_sint32 getBot(void);
00142 pf_Frag_Strux* getCellSDH(void);
00143 void setCellSDH(pf_Frag_Strux* cellSDH);
00144 bool writeCellPropsInDoc(void);
00145 ie_imp_cell * getCellAbove(void);
00146 ie_imp_cell * getCellBelow(void);
00147 ie_imp_cell * getCellLeft(void);
00148 ie_imp_cell * getCellRight(void);
00149 void addPropString(const UT_String & sPropString);
00150 void setProp(const UT_String & psProp, const UT_String & psVal);
00151 UT_String getPropVal(const UT_String & psProp);
00152 void setProp(const char * szProp, const char * szVal);
00153 UT_String getPropVal(const char * szProp);
00154 UT_sint32 getRow(void) { return m_iRow;}
00155 void setMergeAbove(bool bAbove) { m_bMergeAbove = bAbove;}
00156 void setMergeRight(bool bRight) {m_bMergeRight = bRight;}
00157 void setMergeLeft(bool bLeft) {m_bMergeLeft = bLeft;}
00158 void setFirstHorizontalMerge(bool bHori) {m_bFirstHori = bHori;}
00159 void setFirstVerticalMerge( bool bVert) {m_bFirstVertical = bVert;}
00160 bool isMergedAbove(void )const {return m_bMergeAbove;}
00161 bool isMergedRight(void) const {return m_bMergeRight;}
00162 bool isMergedLeft(void) const {return m_bMergeLeft;}
00163 bool isFirstVerticalMerged(void) const {return m_bFirstVertical;}
00164 bool isFirstHorizontalMerged(void) const {return m_bFirstHori;}
00165 void copyCell(ie_imp_cell * pCell);
00166 void setImpTable(ie_imp_table * pTable) { m_pImpTable = pTable;}
00167 void setRow(UT_sint32 row) { m_iRow = row;}
00168 private:
00169 PD_Document * m_pDoc;
00170 UT_sint32 m_iCellX;
00171 UT_sint32 m_iLeft;
00172 UT_sint32 m_iRight;
00173 UT_sint32 m_iTop;
00174 UT_sint32 m_iBot;
00175 pf_Frag_Strux* m_cellSDH;
00176 ie_imp_table * m_pImpTable;
00177 ie_imp_cell * m_pCellLeft;
00178 UT_sint32 m_iRow;
00179 bool m_bMergeAbove;
00180 bool m_bMergeRight;
00181 bool m_bMergeLeft;
00182 bool m_bFirstVertical;
00183 bool m_bFirstHori;
00184 UT_String m_sCellProps;
00185 };
00186
00187
00188 class ABI_EXPORT ie_imp_table
00189 {
00190 public:
00191 ie_imp_table(PD_Document * pDoc);
00192 virtual ~ie_imp_table(void);
00193 UT_sint32 OpenCell(void);
00194 UT_sint32 NewRow(void);
00195 void setCellRowNthCell(UT_sint32 row, UT_sint32 col);
00196 ie_imp_cell * getNthCellOnRow(UT_sint32 iCell);
00197 void setCellX(UT_sint32 cellx);
00198 pf_Frag_Strux* getTableSDH(void);
00199 void setTableSDH(pf_Frag_Strux* cellSDH);
00200 void writeTablePropsInDoc(void);
00201 void writeAllCellPropsInDoc(void);
00202 void setProp(const UT_String & psProp, const UT_String & psVal);
00203 void setProp(const char *szProp, const char * szVal);
00204 UT_String getPropVal(const UT_String & psProp);
00205 UT_String getPropVal(const char * szProp);
00206 UT_String getCellPropVal(const UT_String & psProp);
00207 void setCellProp(const UT_String & psProp, const UT_String & psVal);
00208 ie_imp_cell * getCurCell(void);
00209 void setNthCellOnThisRow(UT_sint32 iCell);
00210 void buildTableStructure(void);
00211 void setAutoFit(bool bVal) {m_bAutoFit = bVal;}
00212 bool isAutoFit(void) { return m_bAutoFit;}
00213 bool isNewRow(void) { return m_bNewRow;}
00214 UT_sint32 getColNumber(ie_imp_cell * pImpCell);
00215 ie_imp_cell * getCellAtRowColX(UT_sint32 newRow,UT_sint32 cellX);
00216 void CloseCell(void);
00217 bool wasTableUsed(void) { return m_bTableUsed;}
00218 void setCell( ie_imp_cell * pCell) { m_pCurImpCell = pCell;}
00219 UT_sint32 getRow(void) { return m_iRowCounter;}
00220 void removeExtraneousCells(void);
00221 void removeOnThisCellRow(ie_imp_cell * pCell);
00222 void removeCurrentRow(void);
00223 void deleteRow(UT_sint32 row);
00224 UT_sint32 getNumRows(void);
00225 void setPosOnRow(UT_sint32 posOnRow) { m_iPosOnRow = posOnRow;}
00226 UT_sint32 getPosOnRow(void) { return m_iPosOnRow;}
00227 void setCellXOnRow(UT_sint32 cellxOnRow) { m_iCellXOnRow = cellxOnRow;}
00228 UT_sint32 getCellXOnRow(void) { return m_iCellXOnRow;}
00229 void incPosOnRow(void) { m_iPosOnRow++;}
00230 void incCellXOnRow(void) { m_iCellXOnRow++;}
00231 bool getVecOfCellsOnRow(UT_sint32 row, UT_GenericVector<ie_imp_cell*> * pVec);
00232 bool removeRow(UT_sint32 row);
00233 void appendRow(UT_GenericVector<ie_imp_cell*>* pVecRowOfCells);
00234 bool doCellXMatch(UT_sint32 iCellX1, UT_sint32 iCellX2,bool bIsLast = false);
00235 private:
00236 void _buildCellXVector(void);
00237 void _removeAllStruxes(void);
00238 PD_Document * m_pDoc;
00239 pf_Frag_Strux* m_tableSDH;
00240 ie_imp_cell * m_pCurImpCell;
00241 UT_sint32 m_iRowCounter;
00242 UT_String m_sTableProps;
00243 bool m_bAutoFit;
00244 bool m_bNewRow;
00245 bool m_bTableUsed;
00246 UT_sint32 m_iPosOnRow;
00247 UT_sint32 m_iCellXOnRow;
00248 UT_GenericVector<ie_imp_cell*> m_vecCells;
00249 UT_NumberVector m_vecCellX;
00250 UT_NumberVector m_vecSavedX;
00251 };
00252
00253 class ABI_EXPORT ie_imp_table_control
00254 {
00255 public:
00256 ie_imp_table_control(PD_Document * pDoc);
00257 virtual ~ie_imp_table_control(void);
00258 UT_sint32 getNestDepth(void);
00259 void OpenTable(void);
00260 UT_sint32 OpenCell(void);
00261 void CloseTable(void);
00262 void CloseCell(void);
00263 ie_imp_table * getTable(void);
00264 bool NewRow(void);
00265 void SaveRowInfo(void);
00266 void RemoveRowInfo(void);
00267 private:
00268 std::stack<ie_imp_table*> m_sLastTable;
00269 PD_Document * m_pDoc;
00270 };
00271
00272
00273 #define USE_IE_IMP_TABLEHELPER 1
00274
00275 #ifdef USE_IE_IMP_TABLEHELPER
00276 enum TableZone
00277 {
00278
00279 tz_head,
00280 tz_foot,
00281 tz_body
00282 };
00283 class ABI_EXPORT CellHelper
00284 {
00285 public:
00286 CellHelper ();
00287 void setProp(const char * szProp, const UT_String sVal);
00288 UT_UTF8String m_style;
00289
00290
00291
00292 pf_Frag_Strux * m_pfsCell;
00293
00294
00295
00296 UT_sint32 m_bottom;
00297 UT_sint32 m_left;
00298 UT_sint32 m_right;
00299 UT_sint32 m_top;
00300
00301 UT_sint32 m_rowspan;
00302 UT_sint32 m_colspan;
00303
00304 CellHelper * m_next;
00305 TableZone m_tzone;
00306 UT_String m_sCellProps;
00307 bool isVirtual () const { return (m_next != 0); }
00308 };
00309
00310 class ABI_EXPORT IE_Imp_TableHelper
00311 {
00312 public:
00313 IE_Imp_TableHelper (PD_Document * pDocument, pf_Frag_Strux * pfsInsertionPoint, const char * style);
00314
00315 ~IE_Imp_TableHelper ();
00316 bool tableStart ();
00317
00318 bool tableEnd ();
00319 bool theadStart (const char * style);
00320 bool tfootStart (const char * style);
00321 bool tbodyStart (const char * style = 0);
00322
00323 bool trStart (const char * style);
00324 bool tdStart (UT_sint32 rowspan, UT_sint32 colspan, const char * style, pf_Frag_Strux * pfsThis);
00325
00326
00327 bool Block (PTStruxType pts, const gchar ** attributes);
00328 bool BlockFormat (const gchar ** attributes);
00329
00330 bool Inline (const UT_UCSChar * ucs4_str, UT_sint32 length);
00331 bool InlineFormat (const gchar ** attributes);
00332
00333 bool Object (PTObjectType pto, const gchar ** attributes);
00334 void padAllRowsWithCells(UT_GenericVector<CellHelper *> & vecCells,UT_sint32 extra);
00335 void padRowWithCells(UT_GenericVector<CellHelper *> & vecCells,UT_sint32 row, UT_sint32 extra);
00336 CellHelper * getCellAtRowCol(UT_GenericVector<CellHelper *> & vecCells, UT_sint32 row, UT_sint32 col);
00337 bool setCaptionOn(void);
00338 bool setCaptionOff(void);
00339 bool tdEnd(void);
00340
00341 pf_Frag_Strux * getInsertionPoint () const { return m_pfsInsertionPoint; }
00342
00343 private:
00344
00345
00346
00347
00348
00349 bool trEnd ();
00350 void trClean ();
00351 bool tdPending ();
00352
00353 PD_Document * m_pDocument;
00354
00355 UT_UTF8String m_style_table;
00356 UT_UTF8String m_style_tzone;
00357 UT_UTF8String m_style;
00358
00359
00360
00361 pf_Frag_Strux * m_pfsInsertionPoint;
00362 pf_Frag_Strux * m_pfsTableStart;
00363 pf_Frag_Strux * m_pfsTableEnd;
00364 pf_Frag_Strux * m_pfsCellPoint;
00365 UT_sint32 m_rows;
00366 UT_sint32 m_rows_head;
00367 UT_sint32 m_rows_head_max;
00368 UT_sint32 m_rows_foot;
00369 UT_sint32 m_rows_foot_max;
00370 UT_sint32 m_rows_body;
00371 UT_sint32 m_rows_body_max;
00372
00373 UT_sint32 m_cols;
00374 UT_sint32 m_cols_max;
00375
00376 UT_sint32 m_col_next;
00377 UT_sint32 m_row_next;
00378
00379 UT_GenericVector<CellHelper *> m_thead;
00380 UT_GenericVector<CellHelper *> m_tfoot;
00381 UT_GenericVector<CellHelper *> m_tbody;
00382
00383 CellHelper * m_current;
00384 TableZone m_tzone;
00385 bool m_bBlockInsertedForCell;
00386 PD_Document * getDoc () const { return m_pDocument; }
00387 bool m_bCaptionOn;
00388 };
00389
00390 class ABI_EXPORT IE_Imp_TableHelperStack
00391 {
00392 public:
00393 IE_Imp_TableHelperStack (void);
00394
00395 ~IE_Imp_TableHelperStack ();
00396
00397 void clear ();
00398 IE_Imp_TableHelper * top () const;
00399
00400 bool tableStart (PD_Document * pDocument, const char * style);
00401 bool tableEnd ();
00402
00403 bool theadStart (const char * style);
00404 bool tfootStart (const char * style);
00405 bool tbodyStart (const char * style = 0);
00406 bool trStart (const char * style);
00407 bool tdStart (UT_sint32 rowspan, UT_sint32 colspan, const char * style);
00408
00409
00410
00411 bool Block (PTStruxType pts, const gchar ** attributes);
00412 bool BlockFormat (const gchar ** attributes);
00413
00414 bool Inline (const UT_UCSChar * ucs4_str, UT_sint32 length);
00415 bool InlineFormat (const gchar ** attributes);
00416
00417 bool Object (PTObjectType pto, const gchar ** attributes);
00418 bool setCaptionOn(void);
00419 bool setCaptionOff(void);
00420 bool tdEnd(void);
00421 private:
00422 PD_Document * m_pDocument;
00423
00424 UT_sint32 m_count;
00425 UT_sint32 m_max;
00426
00427 IE_Imp_TableHelper ** m_stack;
00428 bool push (const char * style);
00429 bool pop ();
00430 };
00431
00432 #endif
00433
00434 #endif