00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: t; -*- */ 00002 /* AbiSource 00003 * 00004 * Copyright (C) 2008 Firat Kiyak <firatkiyak@gmail.com> 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00019 * 02110-1301 USA. 00020 */ 00021 00022 #ifndef _OXML_ELEMENT_TABLE_H_ 00023 #define _OXML_ELEMENT_TABLE_H_ 00024 00025 #include <memory> 00026 #include <vector> 00027 00028 #include "ut_types.h" 00029 #include "ut_string.h" 00030 #include "pd_Document.h" 00031 #include "OXML_Element.h" 00032 #include "OXML_Element_Cell.h" 00033 #include "ie_exp_OpenXML.h" 00034 00035 class OXML_Element_Row; 00036 class OXML_Element_Table; 00037 00038 typedef std::shared_ptr<OXML_Element_Table> OXML_SharedElement_Table; 00039 00040 class OXML_Element_Table : public OXML_Element 00041 { 00042 public: 00043 OXML_Element_Table(const std::string & id); 00044 virtual ~OXML_Element_Table(); 00045 00046 virtual UT_Error serialize(IE_Exp_OpenXML* exporter); 00047 virtual UT_Error serializeChildren(IE_Exp_OpenXML* exporter); 00048 virtual UT_Error addToPT(PD_Document * pDocument); 00049 virtual std::string getColumnWidth(int colIndex) const; 00050 virtual std::string getRowHeight(int rowIndex) const; 00051 UT_Error addChildrenToPT(PD_Document * pDocument); 00052 00053 void addRow(OXML_Element_Row* row); 00054 00055 int getCurrentRowNumber() const; 00056 int getCurrentColNumber() const; 00057 00058 void setCurrentRowNumber(int row); 00059 void setCurrentColNumber(int col); 00060 00061 void incrementCurrentRowNumber(); 00062 void incrementCurrentColNumber(); 00063 00064 //this method increments the vertical merge start cell's bottom by one. 00065 //It traverses up the cells in the table and finds the vertical merge starting cell 00066 //and increments its bottom value by one. Should be called for the vertMerge=continue cells. 00067 //return true if successful 00068 bool incrementBottomVerticalMergeStart(const OXML_SharedElement_Cell& cell); 00069 00070 //this method increments the horizontal merge start cell's right by one. 00071 //It traverses up the cells in the table and finds the horizontal merge starting cell 00072 //and increments its right value by one. Should be called for the hMerge=continue cells. 00073 //return true if successful 00074 bool incrementRightHorizontalMergeStart(const OXML_SharedElement_Cell& cell); 00075 00076 void addMissingCell(unsigned int rowNumber, const OXML_SharedElement_Cell& cell); 00077 00078 void applyStyle(OXML_SharedStyle style); 00079 00080 int getNumberOfRows() const 00081 { 00082 return m_rows.size(); 00083 } 00084 00085 private: 00086 virtual UT_Error serializeProperties(IE_Exp_OpenXML* exporter); 00087 std::vector<std::string> columnWidth; 00088 std::vector<std::string> rowHeight; 00089 std::vector<OXML_Element_Row*> m_rows; 00090 int m_currentRowNumber; 00091 int m_currentColNumber; 00092 }; 00093 00094 #endif //_OXML_ELEMENT_TABLE_H_ 00095