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 : class ScHorizontalCellIterator;
40 : struct ScMyCell;
41 : class ScXMLExport;
42 : class ScFormatRangeStyles;
43 :
44 : //==============================================================================
45 :
46 : class ScMyIteratorBase
47 : {
48 : protected:
49 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) = 0;
50 :
51 : public:
52 : ScMyIteratorBase();
53 : virtual ~ScMyIteratorBase();
54 :
55 : virtual void SetCellData( ScMyCell& rMyCell ) = 0;
56 : virtual void Sort() = 0;
57 :
58 : virtual void UpdateAddress( ::com::sun::star::table::CellAddress& rCellAddress );
59 : };
60 :
61 : //==============================================================================
62 :
63 16 : struct ScMyShape
64 : {
65 : ScAddress aAddress;
66 : ScAddress aEndAddress;
67 : sal_Int32 nEndX;
68 : sal_Int32 nEndY;
69 : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
70 :
71 : bool operator<(const ScMyShape& aShape) const;
72 : };
73 :
74 : typedef std::list<ScMyShape> ScMyShapeList;
75 :
76 : class ScMyShapesContainer : ScMyIteratorBase
77 : {
78 : private:
79 : ScMyShapeList aShapeList;
80 : protected:
81 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
82 : public:
83 : ScMyShapesContainer();
84 : virtual ~ScMyShapesContainer();
85 :
86 : using ScMyIteratorBase::UpdateAddress;
87 : void AddNewShape(const ScMyShape& aShape);
88 2 : bool HasShapes() { return !aShapeList.empty(); }
89 2 : const ScMyShapeList* GetShapes() const { return &aShapeList; }
90 : virtual void SetCellData( ScMyCell& rMyCell );
91 : virtual void Sort();
92 : void SkipTable(SCTAB nSkip);
93 : };
94 :
95 0 : struct ScMyNoteShape
96 : {
97 : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
98 : ScAddress aPos;
99 :
100 : bool operator<(const ScMyNoteShape& aNote) const;
101 : };
102 :
103 : typedef std::list<ScMyNoteShape> ScMyNoteShapeList;
104 :
105 : class ScMyNoteShapesContainer : ScMyIteratorBase
106 : {
107 : private:
108 : ScMyNoteShapeList aNoteShapeList;
109 : protected:
110 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
111 : public:
112 : ScMyNoteShapesContainer();
113 : virtual ~ScMyNoteShapesContainer();
114 :
115 : using ScMyIteratorBase::UpdateAddress;
116 : void AddNewNote(const ScMyNoteShape& aNote);
117 : bool HasNotes() { return !aNoteShapeList.empty(); }
118 0 : const ScMyNoteShapeList* GetNotes() const { return &aNoteShapeList; }
119 : virtual void SetCellData( ScMyCell& rMyCell );
120 : virtual void Sort();
121 : void SkipTable(SCTAB nSkip);
122 : };
123 :
124 : //==============================================================================
125 :
126 0 : struct ScMyMergedRange
127 : {
128 : com::sun::star::table::CellRangeAddress aCellRange;
129 : sal_Int32 nRows;
130 : bool bIsFirst;
131 : bool operator<(const ScMyMergedRange& aRange) const;
132 : };
133 :
134 : typedef std::list<ScMyMergedRange> ScMyMergedRangeList;
135 :
136 : class ScMyMergedRangesContainer : ScMyIteratorBase
137 : {
138 : private:
139 : ScMyMergedRangeList aRangeList;
140 : protected:
141 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
142 : public:
143 : ScMyMergedRangesContainer();
144 : virtual ~ScMyMergedRangesContainer();
145 : void AddRange(const com::sun::star::table::CellRangeAddress aMergedRange);
146 :
147 : using ScMyIteratorBase::UpdateAddress;
148 : virtual void SetCellData( ScMyCell& rMyCell );
149 : virtual void Sort(); // + remove doublets
150 : void SkipTable(SCTAB nSkip);
151 : };
152 :
153 : //==============================================================================
154 :
155 230 : struct ScMyAreaLink
156 : {
157 : OUString sFilter;
158 : OUString sFilterOptions;
159 : OUString sURL;
160 : OUString sSourceStr;
161 : ::com::sun::star::table::CellRangeAddress aDestRange;
162 : sal_Int32 nRefresh;
163 :
164 18 : inline ScMyAreaLink() : nRefresh( 0 ) {}
165 :
166 0 : inline sal_Int32 GetColCount() const { return aDestRange.EndColumn - aDestRange.StartColumn + 1; }
167 0 : inline sal_Int32 GetRowCount() const { return aDestRange.EndRow - aDestRange.StartRow + 1; }
168 :
169 : bool Compare( const ScMyAreaLink& rAreaLink ) const;
170 : bool operator<(const ScMyAreaLink& rAreaLink ) const;
171 : };
172 :
173 : typedef ::std::list< ScMyAreaLink > ScMyAreaLinkList;
174 :
175 : class ScMyAreaLinksContainer : ScMyIteratorBase
176 : {
177 : private:
178 : ScMyAreaLinkList aAreaLinkList;
179 : protected:
180 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
181 : public:
182 : ScMyAreaLinksContainer();
183 : virtual ~ScMyAreaLinksContainer();
184 :
185 0 : inline void AddNewAreaLink( const ScMyAreaLink& rAreaLink )
186 0 : { aAreaLinkList.push_back( rAreaLink ); }
187 :
188 : using ScMyIteratorBase::UpdateAddress;
189 : virtual void SetCellData( ScMyCell& rMyCell );
190 : virtual void Sort();
191 : void SkipTable(SCTAB nSkip);
192 : };
193 :
194 : //==============================================================================
195 :
196 : struct ScMyCellRangeAddress : com::sun::star::table::CellRangeAddress
197 : {
198 : ScMyCellRangeAddress(const com::sun::star::table::CellRangeAddress& rRange);
199 : bool operator<(const ScMyCellRangeAddress& rCellRangeAddress ) const;
200 : };
201 :
202 : typedef std::list<ScMyCellRangeAddress> ScMyEmptyDatabaseRangeList;
203 :
204 : class ScMyEmptyDatabaseRangesContainer : ScMyIteratorBase
205 : {
206 : private:
207 : ScMyEmptyDatabaseRangeList aDatabaseList;
208 : protected:
209 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
210 : public:
211 : ScMyEmptyDatabaseRangesContainer();
212 : virtual ~ScMyEmptyDatabaseRangesContainer();
213 : void AddNewEmptyDatabaseRange(const com::sun::star::table::CellRangeAddress& aCellRangeAddress);
214 :
215 : using ScMyIteratorBase::UpdateAddress;
216 : virtual void SetCellData( ScMyCell& rMyCell );
217 : virtual void Sort();
218 : void SkipTable(SCTAB nSkip);
219 : };
220 :
221 : //==============================================================================
222 :
223 0 : struct ScMyDetectiveObj
224 : {
225 : ::com::sun::star::table::CellAddress aPosition;
226 : ::com::sun::star::table::CellRangeAddress aSourceRange;
227 : ScDetectiveObjType eObjType;
228 : bool bHasError;
229 : bool operator<(const ScMyDetectiveObj& rDetObj) const;
230 : };
231 :
232 : typedef ::std::list< ScMyDetectiveObj > ScMyDetectiveObjList;
233 : typedef ::std::vector< ScMyDetectiveObj > ScMyDetectiveObjVec;
234 :
235 : class ScMyDetectiveObjContainer : ScMyIteratorBase
236 : {
237 : private:
238 : ScMyDetectiveObjList aDetectiveObjList;
239 : protected:
240 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
241 : public:
242 : ScMyDetectiveObjContainer();
243 : virtual ~ScMyDetectiveObjContainer();
244 :
245 : void AddObject(
246 : ScDetectiveObjType eObjType,
247 : const SCTAB nSheet,
248 : const ScAddress& rPosition,
249 : const ScRange& rSourceRange,
250 : bool bHasError );
251 :
252 : using ScMyIteratorBase::UpdateAddress;
253 : virtual void SetCellData( ScMyCell& rMyCell );
254 : virtual void Sort();
255 : void SkipTable(SCTAB nSkip);
256 : };
257 :
258 : //==============================================================================
259 :
260 0 : struct ScMyDetectiveOp
261 : {
262 : ::com::sun::star::table::CellAddress aPosition;
263 : ScDetOpType eOpType;
264 : sal_Int32 nIndex;
265 : bool operator<(const ScMyDetectiveOp& rDetOp) const;
266 : };
267 :
268 : typedef ::std::list< ScMyDetectiveOp > ScMyDetectiveOpList;
269 : typedef ::std::vector< ScMyDetectiveOp > ScMyDetectiveOpVec;
270 :
271 : class ScMyDetectiveOpContainer : ScMyIteratorBase
272 : {
273 : private:
274 : ScMyDetectiveOpList aDetectiveOpList;
275 : protected:
276 : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
277 : public:
278 : ScMyDetectiveOpContainer();
279 : virtual ~ScMyDetectiveOpContainer();
280 :
281 : void AddOperation( ScDetOpType eOpType, const ScAddress& rPosition, sal_uInt32 nIndex );
282 :
283 : using ScMyIteratorBase::UpdateAddress;
284 : virtual void SetCellData( ScMyCell& rMyCell );
285 : virtual void Sort();
286 : void SkipTable(SCTAB nSkip);
287 : };
288 :
289 : //==============================================================================
290 :
291 : // contains data to export for the current cell position
292 212 : struct ScMyCell
293 : {
294 : com::sun::star::uno::Reference<com::sun::star::sheet::XSheetAnnotation> xAnnotation;
295 : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xNoteShape;
296 : com::sun::star::table::CellAddress aCellAddress;
297 : com::sun::star::table::CellRangeAddress aMergeRange;
298 : com::sun::star::table::CellRangeAddress aMatrixRange;
299 :
300 : OUString sStringValue;
301 : OUString sAnnotationText;
302 :
303 : ScMyAreaLink aAreaLink;
304 : ScMyShapeList aShapeList;
305 : ScMyDetectiveObjVec aDetectiveObjVec;
306 : ScMyDetectiveOpVec aDetectiveOpVec;
307 :
308 : double fValue;
309 : sal_Int32 nValidationIndex;
310 : sal_Int32 nStyleIndex;
311 : sal_Int32 nNumberFormat;
312 : com::sun::star::table::CellContentType nType;
313 :
314 : ScRefCellValue maBaseCell;
315 :
316 : bool bIsAutoStyle;
317 :
318 : bool bHasShape;
319 : bool bIsMergedBase;
320 : bool bIsCovered;
321 : bool bHasAreaLink;
322 : bool bHasEmptyDatabase;
323 : bool bHasDetectiveObj;
324 : bool bHasDetectiveOp;
325 :
326 : bool bIsEditCell;
327 : bool bKnowWhetherIsEditCell;
328 : bool bHasStringValue;
329 : bool bHasDoubleValue;
330 : bool bHasXText;
331 :
332 : bool bIsMatrixBase;
333 : bool bIsMatrixCovered;
334 : bool bHasAnnotation;
335 :
336 : ScMyCell();
337 : ~ScMyCell();
338 : };
339 :
340 : //==============================================================================
341 :
342 0 : struct ScMyExportAnnotation
343 : {
344 : com::sun::star::uno::Reference<com::sun::star::sheet::XSheetAnnotation> xAnnotation;
345 : com::sun::star::table::CellAddress aCellAddress;
346 : bool operator<(const ScMyExportAnnotation& rAnno) const;
347 : };
348 :
349 : struct ScNoteExportData
350 : {
351 : SCROW nRow;
352 : SCCOL nCol;
353 : ScPostIt* pNote;
354 :
355 0 : bool operator<(const ScNoteExportData& r) const
356 : {
357 0 : if(nRow < r.nRow)
358 0 : return true;
359 0 : else if(nRow > r.nRow)
360 0 : return false;
361 : else
362 : {
363 0 : if(nCol < r.nCol)
364 0 : return true;
365 : else
366 0 : return false;
367 : }
368 : }
369 : };
370 :
371 : typedef ::std::list< ScMyExportAnnotation > ScMyExportAnnotationList;
372 : typedef ::std::set< ScNoteExportData > ScMyNoteExportDataList;
373 :
374 : class ScMyNotEmptyCellsIterator
375 : {
376 : com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet> xTable;
377 : com::sun::star::uno::Reference<com::sun::star::table::XCellRange> xCellRange;
378 : com::sun::star::table::CellAddress aLastAddress;
379 : ScMyExportAnnotationList aAnnotations;
380 :
381 : ScMyShapesContainer* pShapes;
382 : ScMyNoteShapesContainer* pNoteShapes;
383 : ScMyEmptyDatabaseRangesContainer* pEmptyDatabaseRanges;
384 : ScMyMergedRangesContainer* pMergedRanges;
385 : ScMyAreaLinksContainer* pAreaLinks;
386 : ScMyDetectiveObjContainer* pDetectiveObj;
387 : ScMyDetectiveOpContainer* pDetectiveOp;
388 : ScMyNoteExportDataList maNoteExportList;
389 : ScMyNoteExportDataList::iterator maNoteExportListItr;
390 :
391 : ScXMLExport& rExport;
392 : ScHorizontalCellIterator* pCellItr;
393 :
394 : SCCOL nCellCol;
395 : SCROW nCellRow;
396 : SCTAB nCurrentTable;
397 :
398 : void UpdateAddress( ::com::sun::star::table::CellAddress& rAddress );
399 : void SetCellData( ScMyCell& rMyCell, ::com::sun::star::table::CellAddress& rAddress );
400 :
401 : void SetMatrixCellData( ScMyCell& rMyCell );
402 : void HasAnnotation( ScMyCell& aCell );
403 : public:
404 : ScMyNotEmptyCellsIterator(ScXMLExport& rExport);
405 : ~ScMyNotEmptyCellsIterator();
406 :
407 : void Clear();
408 :
409 8 : inline void SetShapes(ScMyShapesContainer* pNewShapes)
410 8 : { pShapes = pNewShapes; }
411 8 : inline void SetNoteShapes(ScMyNoteShapesContainer* pNewNoteShapes)
412 8 : { pNoteShapes = pNewNoteShapes; }
413 8 : inline void SetEmptyDatabaseRanges(ScMyEmptyDatabaseRangesContainer* pNewEmptyDatabaseRanges)
414 8 : { pEmptyDatabaseRanges = pNewEmptyDatabaseRanges; }
415 8 : inline void SetMergedRanges(ScMyMergedRangesContainer* pNewMergedRanges)
416 8 : { pMergedRanges = pNewMergedRanges; }
417 8 : inline void SetAreaLinks(ScMyAreaLinksContainer* pNewAreaLinks)
418 8 : { pAreaLinks = pNewAreaLinks; }
419 8 : inline void SetDetectiveObj(ScMyDetectiveObjContainer* pNewDetectiveObj)
420 8 : { pDetectiveObj = pNewDetectiveObj; }
421 8 : inline void SetDetectiveOp(ScMyDetectiveOpContainer* pNewDetectiveOp)
422 8 : { pDetectiveOp = pNewDetectiveOp; }
423 :
424 : void SetCurrentTable(const SCTAB nTable,
425 : com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet>& rxTable);
426 : void SkipTable(SCTAB nSkip);
427 :
428 : bool GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles);
429 : };
430 :
431 : #endif
432 :
433 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|