1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ 2 3 /* AbiSource 4 * 5 * Copyright (C) 2008 Firat Kiyak <firatkiyak@gmail.com> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 * 02110-1301 USA. 21 */ 22 23 #ifndef _OXML_ELEMENT_TABLE_H_ 24 #define _OXML_ELEMENT_TABLE_H_ 25 26 // Internal includes 27 #include <OXML_Element.h> 28 #include <OXML_Element_Row.h> 29 #include <ie_exp_OpenXML.h> 30 31 // AbiWord includes 32 #include <ut_types.h> 33 #include <ut_string.h> 34 #include <pd_Document.h> 35 #include <vector> 36 37 class OXML_Element_Table : public OXML_Element 38 { 39 public: 40 OXML_Element_Table(const std::string & id); 41 virtual ~OXML_Element_Table(); 42 43 virtual UT_Error serialize(IE_Exp_OpenXML* exporter); 44 virtual UT_Error serializeChildren(IE_Exp_OpenXML* exporter); 45 virtual UT_Error addToPT(PD_Document * pDocument); 46 virtual std::string getColumnWidth(int colIndex) const; 47 virtual std::string getRowHeight(int rowIndex) const; 48 UT_Error addChildrenToPT(PD_Document * pDocument); 49 50 void addRow(OXML_Element_Row* row); 51 52 int getCurrentRowNumber() const; 53 int getCurrentColNumber() const; 54 55 void setCurrentRowNumber(int row); 56 void setCurrentColNumber(int col); 57 58 void incrementCurrentRowNumber(); 59 void incrementCurrentColNumber(); 60 61 //this method increments the vertical merge start cell's bottom by one. 62 //It traverses up the cells in the table and finds the vertical merge starting cell 63 //and increments its bottom value by one. Should be called for the vertMerge=continue cells. 64 //return true if successful 65 bool incrementBottomVerticalMergeStart(OXML_Element_Cell* cell); 66 67 //this method increments the horizontal merge start cell's right by one. 68 //It traverses up the cells in the table and finds the horizontal merge starting cell 69 //and increments its right value by one. Should be called for the hMerge=continue cells. 70 //return true if successful 71 bool incrementRightHorizontalMergeStart(OXML_Element_Cell* cell); 72 73 void addMissingCell(unsigned int rowNumber, OXML_Element_Cell* cell); 74 75 void applyStyle(OXML_SharedStyle style); 76 getNumberOfRows()77 int getNumberOfRows() const 78 { 79 return m_rows.size(); 80 } 81 82 private: 83 virtual UT_Error serializeProperties(IE_Exp_OpenXML* exporter); 84 std::vector<std::string> columnWidth; 85 std::vector<std::string> rowHeight; 86 std::vector<OXML_Element_Row*> m_rows; 87 int m_currentRowNumber; 88 int m_currentColNumber; 89 }; 90 91 #endif //_OXML_ELEMENT_TABLE_H_ 92 93