Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef SC_XMLEXPORTITERATOR_HXX
21 : #define SC_XMLEXPORTITERATOR_HXX
22 :
23 : #include <vector>
24 : #include <list>
25 : #include <set>
26 : #include <com/sun/star/sheet/XSpreadsheet.hpp>
27 : #include <com/sun/star/table/CellAddress.hpp>
28 : #include <com/sun/star/table/CellRangeAddress.hpp>
29 : #include <com/sun/star/table/XCell.hpp>
30 : #include <com/sun/star/text/XText.hpp>
31 : #include <com/sun/star/sheet/XSheetAnnotation.hpp>
32 : #include <com/sun/star/drawing/XShape.hpp>
33 : #include "global.hxx"
34 : #include "detfunc.hxx"
35 : #include "detdata.hxx"
36 : #include "postit.hxx"
37 : #include "cellvalue.hxx"
38 :
39 : #include <boost/noncopyable.hpp>
40 : #include <boost/scoped_ptr.hpp>
41 :
42 : class ScHorizontalCellIterator;
43 : struct ScMyCell;
44 : class ScXMLExport;
45 : class ScFormatRangeStyles;
46 :
47 : class ScMyIteratorBase
48 : {
49 : protected:
50 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) = 0;
51 :
52 : public:
53 : ScMyIteratorBase();
54 : virtual ~ScMyIteratorBase();
55 :
56 : virtual void SetCellData( ScMyCell& rMyCell ) = 0;
57 : virtual void Sort() = 0;
58 :
59 : virtual void UpdateAddress( ::com::sun::star::table::CellAddress& rCellAddress );
60 : };
61 :
62 16 : struct ScMyShape
63 : {
64 : ScAddress aAddress;
65 : ScAddress aEndAddress;
66 : sal_Int32 nEndX;
67 : sal_Int32 nEndY;
68 : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
69 :
70 : bool operator<(const ScMyShape& aShape) const;
71 : };
72 :
73 : typedef std::list<ScMyShape> ScMyShapeList;
74 :
75 : class ScMyShapesContainer : ScMyIteratorBase
76 : {
77 : private:
78 : ScMyShapeList aShapeList;
79 : protected:
80 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) SAL_OVERRIDE;
81 : public:
82 : ScMyShapesContainer();
83 : virtual ~ScMyShapesContainer();
84 :
85 : using ScMyIteratorBase::UpdateAddress;
86 : void AddNewShape(const ScMyShape& aShape);
87 2 : bool HasShapes() { return !aShapeList.empty(); }
88 2 : const ScMyShapeList* GetShapes() const { return &aShapeList; }
89 : virtual void SetCellData( ScMyCell& rMyCell ) SAL_OVERRIDE;
90 : virtual void Sort() SAL_OVERRIDE;
91 : void SkipTable(SCTAB nSkip);
92 : };
93 :
94 8 : struct ScMyNoteShape
95 : {
96 : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
97 : ScAddress aPos;
98 :
99 : bool operator<(const ScMyNoteShape& aNote) const;
100 : };
101 :
102 : typedef std::list<ScMyNoteShape> ScMyNoteShapeList;
103 :
104 : class ScMyNoteShapesContainer : ScMyIteratorBase
105 : {
106 : private:
107 : ScMyNoteShapeList aNoteShapeList;
108 : protected:
109 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) SAL_OVERRIDE;
110 : public:
111 : ScMyNoteShapesContainer();
112 : virtual ~ScMyNoteShapesContainer();
113 :
114 : using ScMyIteratorBase::UpdateAddress;
115 : void AddNewNote(const ScMyNoteShape& aNote);
116 : bool HasNotes() { return !aNoteShapeList.empty(); }
117 1 : const ScMyNoteShapeList* GetNotes() const { return &aNoteShapeList; }
118 : virtual void SetCellData( ScMyCell& rMyCell ) SAL_OVERRIDE;
119 : virtual void Sort() SAL_OVERRIDE;
120 : void SkipTable(SCTAB nSkip);
121 : };
122 :
123 0 : struct ScMyMergedRange
124 : {
125 : com::sun::star::table::CellRangeAddress aCellRange;
126 : sal_Int32 nRows;
127 : bool bIsFirst;
128 : bool operator<(const ScMyMergedRange& aRange) const;
129 : };
130 :
131 : typedef std::list<ScMyMergedRange> ScMyMergedRangeList;
132 :
133 : class ScMyMergedRangesContainer : ScMyIteratorBase
134 : {
135 : private:
136 : ScMyMergedRangeList aRangeList;
137 : protected:
138 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) SAL_OVERRIDE;
139 : public:
140 : ScMyMergedRangesContainer();
141 : virtual ~ScMyMergedRangesContainer();
142 : void AddRange(const com::sun::star::table::CellRangeAddress aMergedRange);
143 :
144 : using ScMyIteratorBase::UpdateAddress;
145 : virtual void SetCellData( ScMyCell& rMyCell ) SAL_OVERRIDE;
146 : virtual void Sort() SAL_OVERRIDE; // + remove doublets
147 : void SkipTable(SCTAB nSkip);
148 : };
149 :
150 356 : struct ScMyAreaLink
151 : {
152 : OUString sFilter;
153 : OUString sFilterOptions;
154 : OUString sURL;
155 : OUString sSourceStr;
156 : ::com::sun::star::table::CellRangeAddress aDestRange;
157 : sal_Int32 nRefresh;
158 :
159 44 : inline ScMyAreaLink() : nRefresh( 0 ) {}
160 :
161 0 : inline sal_Int32 GetColCount() const { return aDestRange.EndColumn - aDestRange.StartColumn + 1; }
162 0 : inline sal_Int32 GetRowCount() const { return aDestRange.EndRow - aDestRange.StartRow + 1; }
163 :
164 : bool Compare( const ScMyAreaLink& rAreaLink ) const;
165 : bool operator<(const ScMyAreaLink& rAreaLink ) const;
166 : };
167 :
168 : typedef ::std::list< ScMyAreaLink > ScMyAreaLinkList;
169 :
170 : class ScMyAreaLinksContainer : ScMyIteratorBase
171 : {
172 : private:
173 : ScMyAreaLinkList aAreaLinkList;
174 : protected:
175 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) SAL_OVERRIDE;
176 : public:
177 : ScMyAreaLinksContainer();
178 : virtual ~ScMyAreaLinksContainer();
179 :
180 0 : inline void AddNewAreaLink( const ScMyAreaLink& rAreaLink )
181 0 : { aAreaLinkList.push_back( rAreaLink ); }
182 :
183 : using ScMyIteratorBase::UpdateAddress;
184 : virtual void SetCellData( ScMyCell& rMyCell ) SAL_OVERRIDE;
185 : virtual void Sort() SAL_OVERRIDE;
186 : void SkipTable(SCTAB nSkip);
187 : };
188 :
189 : struct ScMyCellRangeAddress : com::sun::star::table::CellRangeAddress
190 : {
191 : ScMyCellRangeAddress(const com::sun::star::table::CellRangeAddress& rRange);
192 : bool operator<(const ScMyCellRangeAddress& rCellRangeAddress ) const;
193 : };
194 :
195 : typedef std::list<ScMyCellRangeAddress> ScMyEmptyDatabaseRangeList;
196 :
197 : class ScMyEmptyDatabaseRangesContainer : ScMyIteratorBase
198 : {
199 : private:
200 : ScMyEmptyDatabaseRangeList aDatabaseList;
201 : protected:
202 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) SAL_OVERRIDE;
203 : public:
204 : ScMyEmptyDatabaseRangesContainer();
205 : virtual ~ScMyEmptyDatabaseRangesContainer();
206 : void AddNewEmptyDatabaseRange(const com::sun::star::table::CellRangeAddress& aCellRangeAddress);
207 :
208 : using ScMyIteratorBase::UpdateAddress;
209 : virtual void SetCellData( ScMyCell& rMyCell ) SAL_OVERRIDE;
210 : virtual void Sort() SAL_OVERRIDE;
211 : void SkipTable(SCTAB nSkip);
212 : };
213 :
214 0 : struct ScMyDetectiveObj
215 : {
216 : ::com::sun::star::table::CellAddress aPosition;
217 : ::com::sun::star::table::CellRangeAddress aSourceRange;
218 : ScDetectiveObjType eObjType;
219 : bool bHasError;
220 : bool operator<(const ScMyDetectiveObj& rDetObj) const;
221 : };
222 :
223 : typedef ::std::list< ScMyDetectiveObj > ScMyDetectiveObjList;
224 : typedef ::std::vector< ScMyDetectiveObj > ScMyDetectiveObjVec;
225 :
226 : class ScMyDetectiveObjContainer : ScMyIteratorBase
227 : {
228 : private:
229 : ScMyDetectiveObjList aDetectiveObjList;
230 : protected:
231 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) SAL_OVERRIDE;
232 : public:
233 : ScMyDetectiveObjContainer();
234 : virtual ~ScMyDetectiveObjContainer();
235 :
236 : void AddObject(
237 : ScDetectiveObjType eObjType,
238 : const SCTAB nSheet,
239 : const ScAddress& rPosition,
240 : const ScRange& rSourceRange,
241 : bool bHasError );
242 :
243 : using ScMyIteratorBase::UpdateAddress;
244 : virtual void SetCellData( ScMyCell& rMyCell ) SAL_OVERRIDE;
245 : virtual void Sort() SAL_OVERRIDE;
246 : void SkipTable(SCTAB nSkip);
247 : };
248 :
249 0 : struct ScMyDetectiveOp
250 : {
251 : ::com::sun::star::table::CellAddress aPosition;
252 : ScDetOpType eOpType;
253 : sal_Int32 nIndex;
254 : bool operator<(const ScMyDetectiveOp& rDetOp) const;
255 : };
256 :
257 : typedef ::std::list< ScMyDetectiveOp > ScMyDetectiveOpList;
258 : typedef ::std::vector< ScMyDetectiveOp > ScMyDetectiveOpVec;
259 :
260 : class ScMyDetectiveOpContainer : ScMyIteratorBase
261 : {
262 : private:
263 : ScMyDetectiveOpList aDetectiveOpList;
264 : protected:
265 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) SAL_OVERRIDE;
266 : public:
267 : ScMyDetectiveOpContainer();
268 : virtual ~ScMyDetectiveOpContainer();
269 :
270 : void AddOperation( ScDetOpType eOpType, const ScAddress& rPosition, sal_uInt32 nIndex );
271 :
272 : using ScMyIteratorBase::UpdateAddress;
273 : virtual void SetCellData( ScMyCell& rMyCell ) SAL_OVERRIDE;
274 : virtual void Sort() SAL_OVERRIDE;
275 : void SkipTable(SCTAB nSkip);
276 : };
277 :
278 : // contains data to export for the current cell position
279 312 : struct ScMyCell
280 : {
281 : com::sun::star::table::CellAddress aCellAddress;
282 : com::sun::star::table::CellRangeAddress aMergeRange;
283 : com::sun::star::table::CellRangeAddress aMatrixRange;
284 :
285 : ScMyAreaLink aAreaLink;
286 : ScMyShapeList aShapeList;
287 : ScMyDetectiveObjVec aDetectiveObjVec;
288 : ScMyDetectiveOpVec aDetectiveOpVec;
289 :
290 : ScPostIt* pNote;
291 :
292 : sal_Int32 nValidationIndex;
293 : sal_Int32 nStyleIndex;
294 : sal_Int32 nNumberFormat;
295 : com::sun::star::table::CellContentType nType;
296 :
297 : ScRefCellValue maBaseCell;
298 :
299 : bool bIsAutoStyle;
300 :
301 : bool bHasShape;
302 : bool bIsMergedBase;
303 : bool bIsCovered;
304 : bool bHasAreaLink;
305 : bool bHasEmptyDatabase;
306 : bool bHasDetectiveObj;
307 : bool bHasDetectiveOp;
308 :
309 : bool bIsMatrixBase;
310 : bool bIsMatrixCovered;
311 : bool bHasAnnotation;
312 :
313 : ScMyCell();
314 : ~ScMyCell();
315 : };
316 :
317 : class ScMyNotEmptyCellsIterator : boost::noncopyable
318 : {
319 : com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet> xTable;
320 : com::sun::star::uno::Reference<com::sun::star::table::XCellRange> xCellRange;
321 : com::sun::star::table::CellAddress aLastAddress;
322 :
323 : ScMyShapesContainer* pShapes;
324 : ScMyNoteShapesContainer* pNoteShapes;
325 : ScMyEmptyDatabaseRangesContainer* pEmptyDatabaseRanges;
326 : ScMyMergedRangesContainer* pMergedRanges;
327 : ScMyAreaLinksContainer* pAreaLinks;
328 : ScMyDetectiveObjContainer* pDetectiveObj;
329 : ScMyDetectiveOpContainer* pDetectiveOp;
330 :
331 : ScXMLExport& rExport;
332 : boost::scoped_ptr<ScHorizontalCellIterator> mpCellItr;
333 :
334 : SCCOL nCellCol;
335 : SCROW nCellRow;
336 : SCTAB nCurrentTable;
337 :
338 : void UpdateAddress( ::com::sun::star::table::CellAddress& rAddress );
339 : void SetCellData( ScMyCell& rMyCell, ::com::sun::star::table::CellAddress& rAddress );
340 :
341 : void HasAnnotation( ScMyCell& aCell );
342 : public:
343 : ScMyNotEmptyCellsIterator(ScXMLExport& rExport);
344 : ~ScMyNotEmptyCellsIterator();
345 :
346 : void Clear();
347 :
348 18 : inline void SetShapes(ScMyShapesContainer* pNewShapes)
349 18 : { pShapes = pNewShapes; }
350 18 : inline void SetNoteShapes(ScMyNoteShapesContainer* pNewNoteShapes)
351 18 : { pNoteShapes = pNewNoteShapes; }
352 18 : inline void SetEmptyDatabaseRanges(ScMyEmptyDatabaseRangesContainer* pNewEmptyDatabaseRanges)
353 18 : { pEmptyDatabaseRanges = pNewEmptyDatabaseRanges; }
354 18 : inline void SetMergedRanges(ScMyMergedRangesContainer* pNewMergedRanges)
355 18 : { pMergedRanges = pNewMergedRanges; }
356 18 : inline void SetAreaLinks(ScMyAreaLinksContainer* pNewAreaLinks)
357 18 : { pAreaLinks = pNewAreaLinks; }
358 18 : inline void SetDetectiveObj(ScMyDetectiveObjContainer* pNewDetectiveObj)
359 18 : { pDetectiveObj = pNewDetectiveObj; }
360 18 : inline void SetDetectiveOp(ScMyDetectiveOpContainer* pNewDetectiveOp)
361 18 : { pDetectiveOp = pNewDetectiveOp; }
362 :
363 : void SetCurrentTable(const SCTAB nTable,
364 : com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet>& rxTable);
365 : void SkipTable(SCTAB nSkip);
366 :
367 : bool GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles);
368 : };
369 :
370 : #endif
371 :
372 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|