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 INCLUDED_SC_SOURCE_FILTER_XML_XMLEXPORTITERATOR_HXX
21 : #define INCLUDED_SC_SOURCE_FILTER_XML_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 : void UpdateAddress( ::com::sun::star::table::CellAddress& rCellAddress );
60 : };
61 :
62 32 : 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 4 : bool HasShapes() { return !aShapeList.empty(); }
88 4 : 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& rMergedRange);
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 420 : 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 66 : 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 354 : struct ScMyCell
280 : {
281 : ScAddress maCellAddress; /// Use this instead of the UNO one.
282 :
283 : com::sun::star::table::CellAddress aCellAddress;
284 : com::sun::star::table::CellRangeAddress aMergeRange;
285 : com::sun::star::table::CellRangeAddress aMatrixRange;
286 :
287 : ScMyAreaLink aAreaLink;
288 : ScMyShapeList aShapeList;
289 : ScMyDetectiveObjVec aDetectiveObjVec;
290 : ScMyDetectiveOpVec aDetectiveOpVec;
291 :
292 : ScPostIt* pNote;
293 :
294 : sal_Int32 nValidationIndex;
295 : sal_Int32 nStyleIndex;
296 : sal_Int32 nNumberFormat;
297 : com::sun::star::table::CellContentType nType;
298 :
299 : ScRefCellValue maBaseCell;
300 :
301 : bool bIsAutoStyle;
302 :
303 : bool bHasShape;
304 : bool bIsMergedBase;
305 : bool bIsCovered;
306 : bool bHasAreaLink;
307 : bool bHasEmptyDatabase;
308 : bool bHasDetectiveObj;
309 : bool bHasDetectiveOp;
310 :
311 : bool bIsMatrixBase;
312 : bool bIsMatrixCovered;
313 : bool bHasAnnotation;
314 :
315 : ScMyCell();
316 : ~ScMyCell();
317 : };
318 :
319 : class ScMyNotEmptyCellsIterator : boost::noncopyable
320 : {
321 : com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet> xTable;
322 : com::sun::star::uno::Reference<com::sun::star::table::XCellRange> xCellRange;
323 : com::sun::star::table::CellAddress aLastAddress;
324 :
325 : ScMyShapesContainer* pShapes;
326 : ScMyNoteShapesContainer* pNoteShapes;
327 : ScMyEmptyDatabaseRangesContainer* pEmptyDatabaseRanges;
328 : ScMyMergedRangesContainer* pMergedRanges;
329 : ScMyAreaLinksContainer* pAreaLinks;
330 : ScMyDetectiveObjContainer* pDetectiveObj;
331 : ScMyDetectiveOpContainer* pDetectiveOp;
332 :
333 : ScXMLExport& rExport;
334 : boost::scoped_ptr<ScHorizontalCellIterator> mpCellItr;
335 :
336 : SCCOL nCellCol;
337 : SCROW nCellRow;
338 : SCTAB nCurrentTable;
339 :
340 : void UpdateAddress( ::com::sun::star::table::CellAddress& rAddress );
341 : void SetCellData( ScMyCell& rMyCell, const css::table::CellAddress& rAddress );
342 :
343 : void HasAnnotation( ScMyCell& aCell );
344 : public:
345 : ScMyNotEmptyCellsIterator(ScXMLExport& rExport);
346 : ~ScMyNotEmptyCellsIterator();
347 :
348 : void Clear();
349 :
350 29 : inline void SetShapes(ScMyShapesContainer* pNewShapes)
351 29 : { pShapes = pNewShapes; }
352 29 : inline void SetNoteShapes(ScMyNoteShapesContainer* pNewNoteShapes)
353 29 : { pNoteShapes = pNewNoteShapes; }
354 29 : inline void SetEmptyDatabaseRanges(ScMyEmptyDatabaseRangesContainer* pNewEmptyDatabaseRanges)
355 29 : { pEmptyDatabaseRanges = pNewEmptyDatabaseRanges; }
356 29 : inline void SetMergedRanges(ScMyMergedRangesContainer* pNewMergedRanges)
357 29 : { pMergedRanges = pNewMergedRanges; }
358 29 : inline void SetAreaLinks(ScMyAreaLinksContainer* pNewAreaLinks)
359 29 : { pAreaLinks = pNewAreaLinks; }
360 29 : inline void SetDetectiveObj(ScMyDetectiveObjContainer* pNewDetectiveObj)
361 29 : { pDetectiveObj = pNewDetectiveObj; }
362 29 : inline void SetDetectiveOp(ScMyDetectiveOpContainer* pNewDetectiveOp)
363 29 : { pDetectiveOp = pNewDetectiveOp; }
364 :
365 : void SetCurrentTable(const SCTAB nTable,
366 : com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet>& rxTable);
367 : void SkipTable(SCTAB nSkip);
368 :
369 : bool GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles);
370 : };
371 :
372 : #endif
373 :
374 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|