update dev300-m58
[ooovba.git] / sc / source / filter / xml / xmlsubti.hxx
blob0045386cb2109b7a3867b3006cbe608343a11258
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlsubti.hxx,v $
10 * $Revision: 1.32.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef SC_XMLSUBTI_HXX
31 #define SC_XMLSUBTI_HXX
33 #include <xmloff/xmlictxt.hxx>
34 #include <xmloff/xmlimp.hxx>
35 #include <com/sun/star/sheet/XSpreadsheet.hpp>
36 #include <com/sun/star/drawing/XDrawPage.hpp>
37 #include <com/sun/star/table/CellAddress.hpp>
38 #include <com/sun/star/table/XCellRange.hpp>
39 #include <com/sun/star/table/CellRangeAddress.hpp>
40 #include <com/sun/star/frame/XModel.hpp>
42 #include <vector>
43 #include <list>
44 #include "XMLTableShapeResizer.hxx"
45 #include "formula/grammar.hxx"
46 #include "tabprotection.hxx"
48 class ScXMLImport;
50 typedef std::vector<sal_Int32> ScMysalIntVec;
51 typedef std::list<sal_Int32> ScMysalIntList;
53 const ScMysalIntVec::size_type nDefaultRowCount = 20;
54 const ScMysalIntVec::size_type nDefaultColCount = 20;
55 const ScMysalIntVec::size_type nDefaultTabCount = 10;
57 class ScMyTableData
59 private:
60 com::sun::star::table::CellAddress aTableCellPos;
61 ScMysalIntVec nColsPerCol;
62 ScMysalIntVec nRealCols;
63 ScMysalIntVec nRowsPerRow;
64 ScMysalIntVec nRealRows;
65 sal_Int32 nSpannedCols;
66 sal_Int32 nColCount;
67 sal_Int32 nSubTableSpanned;
68 ScMysalIntList nChangedCols;
69 public:
70 ScMyTableData(sal_Int32 nSheet = -1, sal_Int32 nCol = -1, sal_Int32 nRow = -1);
71 ~ScMyTableData();
72 com::sun::star::table::CellAddress GetCellPos() const { return aTableCellPos; }
73 sal_Int32 GetRow() const { return aTableCellPos.Row; }
74 sal_Int32 GetColumn() const { return aTableCellPos.Column; }
75 void AddRow();
76 void AddColumn();
77 void SetFirstColumn() { aTableCellPos.Column = -1; }
78 sal_Int32 GetColsPerCol(const sal_Int32 nIndex) const { return nColsPerCol[nIndex]; }
79 void SetColsPerCol(const sal_Int32 nIndex, sal_Int32 nValue = 1) { nColsPerCol[nIndex] = nValue; }
80 sal_Int32 GetRealCols(const sal_Int32 nIndex, const sal_Bool bIsNormal = sal_True) const;
81 void SetRealCols(const sal_Int32 nIndex, const sal_Int32 nValue) { nRealCols[nIndex] = nValue; }
82 sal_Int32 GetRowsPerRow(const sal_Int32 nIndex) const { return nRowsPerRow[nIndex]; }
83 void SetRowsPerRow(const sal_Int32 nIndex, const sal_Int32 nValue = 1) { nRowsPerRow[nIndex] = nValue; }
84 sal_Int32 GetRealRows(const sal_Int32 nIndex) const { return nIndex < 0 ? 0 : nRealRows[nIndex]; }
85 void SetRealRows(const sal_Int32 nIndex, const sal_Int32 nValue) { nRealRows[nIndex] = nValue; }
86 sal_Int32 GetSpannedCols() const { return nSpannedCols; }
87 void SetSpannedCols(const sal_Int32 nTempSpannedCols) { nSpannedCols = nTempSpannedCols; }
88 sal_Int32 GetColCount() const { return nColCount; }
89 void SetColCount(const sal_Int32 nTempColCount) { nColCount = nTempColCount; }
90 sal_Int32 GetSubTableSpanned() const { return nSubTableSpanned; }
91 void SetSubTableSpanned(const sal_Int32 nValue) { nSubTableSpanned = nValue; }
92 sal_Int32 GetChangedCols(const sal_Int32 nFromIndex, const sal_Int32 nToIndex) const;
93 void SetChangedCols(const sal_Int32 nValue);
96 //*******************************************************************************************************************************
98 struct ScMatrixRange
100 rtl::OUString sFormula;
101 rtl::OUString sFormulaNmsp;
102 formula::FormulaGrammar::Grammar eGrammar;
103 com::sun::star::table::CellRangeAddress aRange;
104 ScMatrixRange(const com::sun::star::table::CellRangeAddress& rRange, const rtl::OUString& rFormula, const rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammarP) :
105 sFormula(rFormula),
106 sFormulaNmsp(rFormulaNmsp),
107 eGrammar(eGrammarP),
108 aRange(rRange)
113 struct ScXMLTabProtectionData
115 ::rtl::OUString maPassword;
116 ScPasswordHash meHash1;
117 ScPasswordHash meHash2;
118 bool mbProtected;
119 bool mbSelectProtectedCells;
120 bool mbSelectUnprotectedCells;
122 ScXMLTabProtectionData();
125 class ScMyTables
127 private:
128 typedef std::list<ScMatrixRange> ScMyMatrixRangeList;
130 ScXMLImport& rImport;
132 ScMyShapeResizer aResizeShapes;
134 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > xCurrentSheet;
135 ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > xCurrentCellRange;
136 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > xDrawPage;
137 ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShapes > xShapes;
138 rtl::OUString sCurrentSheetName;
139 std::vector<ScMyTableData*> aTableVec;
140 ScXMLTabProtectionData maProtectionData;
141 ScMyMatrixRangeList aMatrixRangeList;
142 com::sun::star::table::CellAddress aRealCellPos;
143 sal_Int32 nCurrentColStylePos;
144 sal_Int16 nCurrentDrawPage;
145 sal_Int16 nCurrentXShapes;
146 sal_Int32 nTableCount;
147 sal_Int32 nCurrentSheet;
149 sal_Bool IsMerged (const com::sun::star::uno::Reference <com::sun::star::table::XCellRange>& xCellRange,
150 const sal_Int32 nCol, const sal_Int32 nRow,
151 com::sun::star::table::CellRangeAddress& aCellAddress) const;
152 void UnMerge();
153 void DoMerge(sal_Int32 nCount = -1);
154 void InsertRow();
155 void NewRow();
156 void InsertColumn();
157 void NewColumn(sal_Bool bIsCovered);
158 public:
159 ScMyTables(ScXMLImport& rImport);
160 ~ScMyTables();
161 void NewSheet(const rtl::OUString& sTableName, const rtl::OUString& sStyleName,
162 const ScXMLTabProtectionData& rProtectData);
163 void AddRow();
164 void SetRowStyle(const rtl::OUString& rCellStyleName);
165 void AddColumn(sal_Bool bIsCovered);
166 void NewTable(sal_Int32 nTempSpannedCols);
167 void UpdateRowHeights();
168 void ResizeShapes() { aResizeShapes.ResizeShapes(); }
169 void DeleteTable();
170 com::sun::star::table::CellAddress GetRealCellPos();
171 void AddColCount(sal_Int32 nTempColCount);
172 void AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCellStyleName);
173 ScXMLTabProtectionData& GetCurrentProtectionData() { return maProtectionData; }
174 rtl::OUString GetCurrentSheetName() const { return sCurrentSheetName; }
175 sal_Int32 GetCurrentSheet() const { return nCurrentSheet; }
176 sal_Int32 GetCurrentColumn() const { return aTableVec[nTableCount - 1]->GetColCount(); }
177 sal_Int32 GetCurrentRow() const { return aTableVec[nTableCount - 1]->GetRow(); }
178 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >
179 GetCurrentXSheet() { return xCurrentSheet; }
180 ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >
181 GetCurrentXCellRange() { return xCurrentCellRange; }
182 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
183 GetCurrentXDrawPage();
184 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
185 GetCurrentXShapes();
186 sal_Bool HasDrawPage();
187 sal_Bool HasXShapes();
188 void AddShape(com::sun::star::uno::Reference <com::sun::star::drawing::XShape>& rShape,
189 rtl::OUString* pRangeList,
190 com::sun::star::table::CellAddress& rStartAddress,
191 com::sun::star::table::CellAddress& rEndAddress,
192 sal_Int32 nEndX, sal_Int32 nEndY);
194 void AddMatrixRange( sal_Int32 nStartColumn,
195 sal_Int32 nStartRow,
196 sal_Int32 nEndColumn,
197 sal_Int32 nEndRow,
198 const rtl::OUString& rFormula,
199 const rtl::OUString& rFormulaNmsp,
200 const formula::FormulaGrammar::Grammar );
202 sal_Bool IsPartOfMatrix(sal_Int32 nColumn, sal_Int32 nRow);
203 void SetMatrix( const com::sun::star::table::CellRangeAddress& rRange,
204 const rtl::OUString& rFormula,
205 const rtl::OUString& rFormulaNmsp,
206 const formula::FormulaGrammar::Grammar );
209 #endif