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>
44 #include "XMLTableShapeResizer.hxx"
45 #include "formula/grammar.hxx"
46 #include "tabprotection.hxx"
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;
60 com::sun::star::table::CellAddress aTableCellPos
;
61 ScMysalIntVec nColsPerCol
;
62 ScMysalIntVec nRealCols
;
63 ScMysalIntVec nRowsPerRow
;
64 ScMysalIntVec nRealRows
;
65 sal_Int32 nSpannedCols
;
67 sal_Int32 nSubTableSpanned
;
68 ScMysalIntList nChangedCols
;
70 ScMyTableData(sal_Int32 nSheet
= -1, sal_Int32 nCol
= -1, sal_Int32 nRow
= -1);
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
; }
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 //*******************************************************************************************************************************
100 rtl::OUString sFormula
;
101 formula::FormulaGrammar::Grammar eGrammar
;
102 com::sun::star::table::CellRangeAddress aRange
;
103 ScMatrixRange(const com::sun::star::table::CellRangeAddress
& rRange
, const rtl::OUString
& rFormula
, const formula::FormulaGrammar::Grammar eGrammarP
) :
111 struct ScXMLTabProtectionData
113 ::rtl::OUString maPassword
;
114 ScPasswordHash meHash1
;
115 ScPasswordHash meHash2
;
117 bool mbSelectProtectedCells
;
118 bool mbSelectUnprotectedCells
;
120 ScXMLTabProtectionData();
126 typedef std::list
<ScMatrixRange
> ScMyMatrixRangeList
;
128 ScXMLImport
& rImport
;
130 ScMyShapeResizer aResizeShapes
;
132 ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XSpreadsheet
> xCurrentSheet
;
133 ::com::sun::star::uno::Reference
< ::com::sun::star::table::XCellRange
> xCurrentCellRange
;
134 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
> xDrawPage
;
135 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
> xShapes
;
136 rtl::OUString sCurrentSheetName
;
137 std::vector
<ScMyTableData
*> aTableVec
;
138 ScXMLTabProtectionData maProtectionData
;
139 ScMyMatrixRangeList aMatrixRangeList
;
140 com::sun::star::table::CellAddress aRealCellPos
;
141 sal_Int32 nCurrentColStylePos
;
142 sal_Int16 nCurrentDrawPage
;
143 sal_Int16 nCurrentXShapes
;
144 sal_Int32 nTableCount
;
145 sal_Int32 nCurrentSheet
;
147 sal_Bool
IsMerged (const com::sun::star::uno::Reference
<com::sun::star::table::XCellRange
>& xCellRange
,
148 const sal_Int32 nCol
, const sal_Int32 nRow
,
149 com::sun::star::table::CellRangeAddress
& aCellAddress
) const;
151 void DoMerge(sal_Int32 nCount
= -1);
155 void NewColumn(sal_Bool bIsCovered
);
157 ScMyTables(ScXMLImport
& rImport
);
159 void NewSheet(const rtl::OUString
& sTableName
, const rtl::OUString
& sStyleName
,
160 const ScXMLTabProtectionData
& rProtectData
);
162 void SetRowStyle(const rtl::OUString
& rCellStyleName
);
163 void AddColumn(sal_Bool bIsCovered
);
164 void NewTable(sal_Int32 nTempSpannedCols
);
165 void UpdateRowHeights();
166 void ResizeShapes() { aResizeShapes
.ResizeShapes(); }
168 com::sun::star::table::CellAddress
GetRealCellPos();
169 void AddColCount(sal_Int32 nTempColCount
);
170 void AddColStyle(const sal_Int32 nRepeat
, const rtl::OUString
& rCellStyleName
);
171 ScXMLTabProtectionData
& GetCurrentProtectionData() { return maProtectionData
; }
172 rtl::OUString
GetCurrentSheetName() const { return sCurrentSheetName
; }
173 sal_Int32
GetCurrentSheet() const { return nCurrentSheet
; }
174 sal_Int32
GetCurrentColumn() const { return aTableVec
[nTableCount
- 1]->GetColCount(); }
175 sal_Int32
GetCurrentRow() const { return aTableVec
[nTableCount
- 1]->GetRow(); }
176 ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XSpreadsheet
>
177 GetCurrentXSheet() { return xCurrentSheet
; }
178 ::com::sun::star::uno::Reference
< ::com::sun::star::table::XCellRange
>
179 GetCurrentXCellRange() { return xCurrentCellRange
; }
180 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>
181 GetCurrentXDrawPage();
182 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShapes
>
184 sal_Bool
HasDrawPage();
185 sal_Bool
HasXShapes();
186 void AddShape(com::sun::star::uno::Reference
<com::sun::star::drawing::XShape
>& rShape
,
187 rtl::OUString
* pRangeList
,
188 com::sun::star::table::CellAddress
& rStartAddress
,
189 com::sun::star::table::CellAddress
& rEndAddress
,
190 sal_Int32 nEndX
, sal_Int32 nEndY
);
192 void AddMatrixRange( sal_Int32 nStartColumn
,
194 sal_Int32 nEndColumn
,
196 const rtl::OUString
& rFormula
,
197 const formula::FormulaGrammar::Grammar
);
199 sal_Bool
IsPartOfMatrix(sal_Int32 nColumn
, sal_Int32 nRow
);
200 void SetMatrix( const com::sun::star::table::CellRangeAddress
& rRange
,
201 const rtl::OUString
& rFormula
,
202 const formula::FormulaGrammar::Grammar
);