Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_XMLEXPORTITERATOR_HXX
30 : : #define SC_XMLEXPORTITERATOR_HXX
31 : :
32 : : #include <vector>
33 : : #include <list>
34 : : #include <set>
35 : : #include <com/sun/star/sheet/XSpreadsheet.hpp>
36 : : #include <com/sun/star/table/CellAddress.hpp>
37 : : #include <com/sun/star/table/CellRangeAddress.hpp>
38 : : #include <com/sun/star/table/XCell.hpp>
39 : : #include <com/sun/star/text/XText.hpp>
40 : : #include <com/sun/star/sheet/XSheetAnnotation.hpp>
41 : : #include <com/sun/star/drawing/XShape.hpp>
42 : : #include "global.hxx"
43 : : #include "detfunc.hxx"
44 : : #include "detdata.hxx"
45 : : #include "postit.hxx"
46 : :
47 : : class ScHorizontalCellIterator;
48 : : struct ScMyCell;
49 : : class ScXMLExport;
50 : : class ScFormatRangeStyles;
51 : : class ScBaseCell;
52 : :
53 : : //==============================================================================
54 : :
55 : : class ScMyIteratorBase
56 : : {
57 : : protected:
58 : : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress ) = 0;
59 : :
60 : : public:
61 : : ScMyIteratorBase();
62 : : virtual ~ScMyIteratorBase();
63 : :
64 : : virtual void SetCellData( ScMyCell& rMyCell ) = 0;
65 : : virtual void Sort() = 0;
66 : :
67 : : virtual void UpdateAddress( ::com::sun::star::table::CellAddress& rCellAddress );
68 : : };
69 : :
70 : : //==============================================================================
71 : :
72 : 0 : struct ScMyShape
73 : : {
74 : : ScAddress aAddress;
75 : : ScAddress aEndAddress;
76 : : sal_Int32 nEndX;
77 : : sal_Int32 nEndY;
78 : : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
79 : :
80 : : bool operator<(const ScMyShape& aShape) const;
81 : : };
82 : :
83 : : typedef std::list<ScMyShape> ScMyShapeList;
84 : :
85 : : class ScMyShapesContainer : ScMyIteratorBase
86 : : {
87 : : private:
88 : : ScMyShapeList aShapeList;
89 : : protected:
90 : : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
91 : : public:
92 : : ScMyShapesContainer();
93 : : virtual ~ScMyShapesContainer();
94 : :
95 : : using ScMyIteratorBase::UpdateAddress;
96 : : void AddNewShape(const ScMyShape& aShape);
97 : 0 : bool HasShapes() { return !aShapeList.empty(); }
98 : 0 : const ScMyShapeList* GetShapes() const { return &aShapeList; }
99 : : virtual void SetCellData( ScMyCell& rMyCell );
100 : : virtual void Sort();
101 : : void SkipTable(SCTAB nSkip);
102 : : };
103 : :
104 : 0 : struct ScMyNoteShape
105 : : {
106 : : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape;
107 : : ScAddress aPos;
108 : :
109 : : bool operator<(const ScMyNoteShape& aNote) const;
110 : : };
111 : :
112 : : typedef std::list<ScMyNoteShape> ScMyNoteShapeList;
113 : :
114 : : class ScMyNoteShapesContainer : ScMyIteratorBase
115 : : {
116 : : private:
117 : : ScMyNoteShapeList aNoteShapeList;
118 : : protected:
119 : : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
120 : : public:
121 : : ScMyNoteShapesContainer();
122 : : virtual ~ScMyNoteShapesContainer();
123 : :
124 : : using ScMyIteratorBase::UpdateAddress;
125 : : void AddNewNote(const ScMyNoteShape& aNote);
126 : : bool HasNotes() { return !aNoteShapeList.empty(); }
127 : 0 : const ScMyNoteShapeList* GetNotes() const { return &aNoteShapeList; }
128 : : virtual void SetCellData( ScMyCell& rMyCell );
129 : : virtual void Sort();
130 : : void SkipTable(SCTAB nSkip);
131 : : };
132 : :
133 : : //==============================================================================
134 : :
135 : 0 : struct ScMyMergedRange
136 : : {
137 : : com::sun::star::table::CellRangeAddress aCellRange;
138 : : sal_Int32 nRows;
139 : : bool bIsFirst;
140 : : bool operator<(const ScMyMergedRange& aRange) const;
141 : : };
142 : :
143 : : typedef std::list<ScMyMergedRange> ScMyMergedRangeList;
144 : :
145 : : class ScMyMergedRangesContainer : ScMyIteratorBase
146 : : {
147 : : private:
148 : : ScMyMergedRangeList aRangeList;
149 : : protected:
150 : : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
151 : : public:
152 : : ScMyMergedRangesContainer();
153 : : virtual ~ScMyMergedRangesContainer();
154 : : void AddRange(const com::sun::star::table::CellRangeAddress aMergedRange);
155 : :
156 : : using ScMyIteratorBase::UpdateAddress;
157 : : virtual void SetCellData( ScMyCell& rMyCell );
158 : : virtual void Sort(); // + remove doublets
159 : : void SkipTable(SCTAB nSkip);
160 : : };
161 : :
162 : : //==============================================================================
163 : :
164 : 8 : struct ScMyAreaLink
165 : : {
166 : : ::rtl::OUString sFilter;
167 : : ::rtl::OUString sFilterOptions;
168 : : ::rtl::OUString sURL;
169 : : ::rtl::OUString sSourceStr;
170 : : ::com::sun::star::table::CellRangeAddress aDestRange;
171 : : sal_Int32 nRefresh;
172 : :
173 : 8 : inline ScMyAreaLink() : nRefresh( 0 ) {}
174 : :
175 : 0 : inline sal_Int32 GetColCount() const { return aDestRange.EndColumn - aDestRange.StartColumn + 1; }
176 : 0 : inline sal_Int32 GetRowCount() const { return aDestRange.EndRow - aDestRange.StartRow + 1; }
177 : :
178 : : bool Compare( const ScMyAreaLink& rAreaLink ) const;
179 : : bool operator<(const ScMyAreaLink& rAreaLink ) const;
180 : : };
181 : :
182 : : typedef ::std::list< ScMyAreaLink > ScMyAreaLinkList;
183 : :
184 : : class ScMyAreaLinksContainer : ScMyIteratorBase
185 : : {
186 : : private:
187 : : ScMyAreaLinkList aAreaLinkList;
188 : : protected:
189 : : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
190 : : public:
191 : : ScMyAreaLinksContainer();
192 : : virtual ~ScMyAreaLinksContainer();
193 : :
194 : 0 : inline void AddNewAreaLink( const ScMyAreaLink& rAreaLink )
195 : 0 : { aAreaLinkList.push_back( rAreaLink ); }
196 : :
197 : : using ScMyIteratorBase::UpdateAddress;
198 : : virtual void SetCellData( ScMyCell& rMyCell );
199 : : virtual void Sort();
200 : : void SkipTable(SCTAB nSkip);
201 : : };
202 : :
203 : : //==============================================================================
204 : :
205 : : struct ScMyCellRangeAddress : com::sun::star::table::CellRangeAddress
206 : : {
207 : : ScMyCellRangeAddress(const com::sun::star::table::CellRangeAddress& rRange);
208 : : bool operator<(const ScMyCellRangeAddress& rCellRangeAddress ) const;
209 : : };
210 : :
211 : : typedef std::list<ScMyCellRangeAddress> ScMyEmptyDatabaseRangeList;
212 : :
213 : : class ScMyEmptyDatabaseRangesContainer : ScMyIteratorBase
214 : : {
215 : : private:
216 : : ScMyEmptyDatabaseRangeList aDatabaseList;
217 : : protected:
218 : : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
219 : : public:
220 : : ScMyEmptyDatabaseRangesContainer();
221 : : virtual ~ScMyEmptyDatabaseRangesContainer();
222 : : void AddNewEmptyDatabaseRange(const com::sun::star::table::CellRangeAddress& aCellRangeAddress);
223 : :
224 : : using ScMyIteratorBase::UpdateAddress;
225 : : virtual void SetCellData( ScMyCell& rMyCell );
226 : : virtual void Sort();
227 : : void SkipTable(SCTAB nSkip);
228 : : };
229 : :
230 : : //==============================================================================
231 : :
232 : 0 : struct ScMyDetectiveObj
233 : : {
234 : : ::com::sun::star::table::CellAddress aPosition;
235 : : ::com::sun::star::table::CellRangeAddress aSourceRange;
236 : : ScDetectiveObjType eObjType;
237 : : bool bHasError;
238 : : bool operator<(const ScMyDetectiveObj& rDetObj) const;
239 : : };
240 : :
241 : : typedef ::std::list< ScMyDetectiveObj > ScMyDetectiveObjList;
242 : : typedef ::std::vector< ScMyDetectiveObj > ScMyDetectiveObjVec;
243 : :
244 : : class ScMyDetectiveObjContainer : ScMyIteratorBase
245 : : {
246 : : private:
247 : : ScMyDetectiveObjList aDetectiveObjList;
248 : : protected:
249 : : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
250 : : public:
251 : : ScMyDetectiveObjContainer();
252 : : virtual ~ScMyDetectiveObjContainer();
253 : :
254 : : void AddObject(
255 : : ScDetectiveObjType eObjType,
256 : : const SCTAB nSheet,
257 : : const ScAddress& rPosition,
258 : : const ScRange& rSourceRange,
259 : : bool bHasError );
260 : :
261 : : using ScMyIteratorBase::UpdateAddress;
262 : : virtual void SetCellData( ScMyCell& rMyCell );
263 : : virtual void Sort();
264 : : void SkipTable(SCTAB nSkip);
265 : : };
266 : :
267 : : //==============================================================================
268 : :
269 : 0 : struct ScMyDetectiveOp
270 : : {
271 : : ::com::sun::star::table::CellAddress aPosition;
272 : : ScDetOpType eOpType;
273 : : sal_Int32 nIndex;
274 : : bool operator<(const ScMyDetectiveOp& rDetOp) const;
275 : : };
276 : :
277 : : typedef ::std::list< ScMyDetectiveOp > ScMyDetectiveOpList;
278 : : typedef ::std::vector< ScMyDetectiveOp > ScMyDetectiveOpVec;
279 : :
280 : : class ScMyDetectiveOpContainer : ScMyIteratorBase
281 : : {
282 : : private:
283 : : ScMyDetectiveOpList aDetectiveOpList;
284 : : protected:
285 : : virtual bool GetFirstAddress( ::com::sun::star::table::CellAddress& rCellAddress );
286 : : public:
287 : : ScMyDetectiveOpContainer();
288 : : virtual ~ScMyDetectiveOpContainer();
289 : :
290 : : void AddOperation( ScDetOpType eOpType, const ScAddress& rPosition, sal_uInt32 nIndex );
291 : :
292 : : using ScMyIteratorBase::UpdateAddress;
293 : : virtual void SetCellData( ScMyCell& rMyCell );
294 : : virtual void Sort();
295 : : void SkipTable(SCTAB nSkip);
296 : : };
297 : :
298 : : //==============================================================================
299 : :
300 : : // contains data to export for the current cell position
301 : 0 : struct ScMyCell
302 : : {
303 : : // com::sun::star::uno::Reference<com::sun::star::table::XCell> xCell;
304 : : // com::sun::star::uno::Reference<com::sun::star::text::XText> xText;
305 : : com::sun::star::uno::Reference<com::sun::star::sheet::XSheetAnnotation> xAnnotation;
306 : : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xNoteShape;
307 : : com::sun::star::table::CellAddress aCellAddress;
308 : : com::sun::star::table::CellRangeAddress aMergeRange;
309 : : com::sun::star::table::CellRangeAddress aMatrixRange;
310 : :
311 : : rtl::OUString sStringValue;
312 : : rtl::OUString sAnnotationText;
313 : :
314 : : ScMyAreaLink aAreaLink;
315 : : ScMyShapeList aShapeList;
316 : : ScMyDetectiveObjVec aDetectiveObjVec;
317 : : ScMyDetectiveOpVec aDetectiveOpVec;
318 : :
319 : : double fValue;
320 : : sal_Int32 nValidationIndex;
321 : : sal_Int32 nStyleIndex;
322 : : sal_Int32 nNumberFormat;
323 : : com::sun::star::table::CellContentType nType;
324 : :
325 : : ScBaseCell* pBaseCell;
326 : :
327 : : bool bIsAutoStyle;
328 : :
329 : : bool bHasShape;
330 : : bool bIsMergedBase;
331 : : bool bIsCovered;
332 : : bool bHasAreaLink;
333 : : bool bHasEmptyDatabase;
334 : : bool bHasDetectiveObj;
335 : : bool bHasDetectiveOp;
336 : :
337 : : bool bIsEditCell;
338 : : bool bKnowWhetherIsEditCell;
339 : : bool bHasStringValue;
340 : : bool bHasDoubleValue;
341 : : bool bHasXText;
342 : :
343 : : bool bIsMatrixBase;
344 : : bool bIsMatrixCovered;
345 : : bool bHasAnnotation;
346 : :
347 : : ScMyCell();
348 : : ~ScMyCell();
349 : : };
350 : :
351 : : //==============================================================================
352 : :
353 : 0 : struct ScMyExportAnnotation
354 : : {
355 : : com::sun::star::uno::Reference<com::sun::star::sheet::XSheetAnnotation> xAnnotation;
356 : : com::sun::star::table::CellAddress aCellAddress;
357 : : bool operator<(const ScMyExportAnnotation& rAnno) const;
358 : : };
359 : :
360 : : struct ScNoteExportData
361 : : {
362 : : SCROW nRow;
363 : : SCCOL nCol;
364 : : ScPostIt* pNote;
365 : :
366 : 0 : bool operator<(const ScNoteExportData& r) const
367 : : {
368 [ # # ]: 0 : if(nRow < r.nRow)
369 : 0 : return true;
370 [ # # ]: 0 : else if(nRow > r.nRow)
371 : 0 : return false;
372 : : else
373 : : {
374 [ # # ]: 0 : if(nCol < r.nCol)
375 : 0 : return true;
376 : : else
377 : 0 : return false;
378 : : }
379 : : }
380 : : };
381 : :
382 : : typedef ::std::list< ScMyExportAnnotation > ScMyExportAnnotationList;
383 : : typedef ::std::set< ScNoteExportData > ScMyNoteExportDataList;
384 : :
385 : : class ScMyNotEmptyCellsIterator
386 : : {
387 : : com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet> xTable;
388 : : com::sun::star::uno::Reference<com::sun::star::table::XCellRange> xCellRange;
389 : : com::sun::star::table::CellAddress aLastAddress;
390 : : ScMyExportAnnotationList aAnnotations;
391 : :
392 : : ScMyShapesContainer* pShapes;
393 : : ScMyNoteShapesContainer* pNoteShapes;
394 : : ScMyEmptyDatabaseRangesContainer* pEmptyDatabaseRanges;
395 : : ScMyMergedRangesContainer* pMergedRanges;
396 : : ScMyAreaLinksContainer* pAreaLinks;
397 : : ScMyDetectiveObjContainer* pDetectiveObj;
398 : : ScMyDetectiveOpContainer* pDetectiveOp;
399 : : ScMyNoteExportDataList maNoteExportList;
400 : : ScMyNoteExportDataList::iterator maNoteExportListItr;
401 : :
402 : : ScXMLExport& rExport;
403 : : ScHorizontalCellIterator* pCellItr;
404 : :
405 : : SCCOL nCellCol;
406 : : SCROW nCellRow;
407 : : SCTAB nCurrentTable;
408 : :
409 : : void UpdateAddress( ::com::sun::star::table::CellAddress& rAddress );
410 : : void SetCellData( ScMyCell& rMyCell, ::com::sun::star::table::CellAddress& rAddress );
411 : :
412 : : void SetMatrixCellData( ScMyCell& rMyCell );
413 : : void HasAnnotation( ScMyCell& aCell );
414 : : public:
415 : : ScMyNotEmptyCellsIterator(ScXMLExport& rExport);
416 : : ~ScMyNotEmptyCellsIterator();
417 : :
418 : : void Clear();
419 : :
420 : 4 : inline void SetShapes(ScMyShapesContainer* pNewShapes)
421 : 4 : { pShapes = pNewShapes; }
422 : 4 : inline void SetNoteShapes(ScMyNoteShapesContainer* pNewNoteShapes)
423 : 4 : { pNoteShapes = pNewNoteShapes; }
424 : 4 : inline void SetEmptyDatabaseRanges(ScMyEmptyDatabaseRangesContainer* pNewEmptyDatabaseRanges)
425 : 4 : { pEmptyDatabaseRanges = pNewEmptyDatabaseRanges; }
426 : 4 : inline void SetMergedRanges(ScMyMergedRangesContainer* pNewMergedRanges)
427 : 4 : { pMergedRanges = pNewMergedRanges; }
428 : 4 : inline void SetAreaLinks(ScMyAreaLinksContainer* pNewAreaLinks)
429 : 4 : { pAreaLinks = pNewAreaLinks; }
430 : 4 : inline void SetDetectiveObj(ScMyDetectiveObjContainer* pNewDetectiveObj)
431 : 4 : { pDetectiveObj = pNewDetectiveObj; }
432 : 4 : inline void SetDetectiveOp(ScMyDetectiveOpContainer* pNewDetectiveOp)
433 : 4 : { pDetectiveOp = pNewDetectiveOp; }
434 : :
435 : : void SetCurrentTable(const SCTAB nTable,
436 : : com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet>& rxTable);
437 : : void SkipTable(SCTAB nSkip);
438 : :
439 : : bool GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles);
440 : : };
441 : :
442 : : #endif
443 : :
444 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|