LibreOffice Module sc (master)  1
XMLExportIterator.hxx
Go to the documentation of this file.
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 <com/sun/star/table/CellContentType.hpp>
26 #include <detfunc.hxx>
27 #include <detdata.hxx>
28 #include <cellvalue.hxx>
29 
30 #include <memory>
31 
32 namespace com::sun::star::drawing { class XShape; }
33 namespace com::sun::star::sheet { class XSpreadsheet; }
34 namespace com::sun::star::table { class XCellRange; }
35 namespace com::sun::star::table { struct CellRangeAddress; }
36 
37 class ScPostIt;
39 struct ScMyCell;
40 class ScXMLExport;
42 
44 {
45 protected:
46  virtual bool GetFirstAddress( ScAddress& rCellAddress ) = 0;
47 
48 public:
50  virtual ~ScMyIteratorBase();
51 
52  ScMyIteratorBase(ScMyIteratorBase const &) = default;
53  ScMyIteratorBase(ScMyIteratorBase &&) = default;
54  ScMyIteratorBase & operator =(ScMyIteratorBase const &) = default;
56 
57  virtual void SetCellData( ScMyCell& rMyCell ) = 0;
58  virtual void Sort() = 0;
59 
60  void UpdateAddress( ScAddress& rCellAddress );
61 };
62 
63 struct ScMyShape
64 {
67  sal_Int32 nEndX;
68  sal_Int32 nEndY;
70  css::uno::Reference<css::drawing::XShape> xShape;
71 
72  bool operator<(const ScMyShape& aShape) const;
73 };
74 
75 typedef std::list<ScMyShape> ScMyShapeList;
76 
78 {
79 private:
81 protected:
82  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
83 public:
85  virtual ~ScMyShapesContainer() override;
86 
88  void AddNewShape(const ScMyShape& aShape);
89  bool HasShapes() const { return !aShapeList.empty(); }
90  const ScMyShapeList& GetShapes() const { return aShapeList; }
91  virtual void SetCellData( ScMyCell& rMyCell ) override;
92  virtual void Sort() override;
93  void SkipTable(SCTAB nSkip);
94 };
95 
97 {
98  css::uno::Reference<css::drawing::XShape> xShape;
100 
101  bool operator<(const ScMyNoteShape& aNote) const;
102 };
103 
104 typedef std::list<ScMyNoteShape> ScMyNoteShapeList;
105 
107 {
108 private:
110 protected:
111  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
112 public:
114  virtual ~ScMyNoteShapesContainer() override;
115 
117  void AddNewNote(const ScMyNoteShape& aNote);
118  const ScMyNoteShapeList& GetNotes() const { return aNoteShapeList; }
119  virtual void SetCellData( ScMyCell& rMyCell ) override;
120  virtual void Sort() override;
121  void SkipTable(SCTAB nSkip);
122 };
123 
125 {
127  sal_Int32 nRows;
128  bool bIsFirst;
129  bool operator<(const ScMyMergedRange& aRange) const;
130 };
131 
132 typedef std::list<ScMyMergedRange> ScMyMergedRangeList;
133 
135 {
136 private:
138 protected:
139  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
140 public:
142  virtual ~ScMyMergedRangesContainer() override;
143  void AddRange(const ScRange& rMergedRange);
144 
146  virtual void SetCellData( ScMyCell& rMyCell ) override;
147  virtual void Sort() override; // + remove doublets
148  void SkipTable(SCTAB nSkip);
149 };
150 
152 {
153  OUString sFilter;
154  OUString sFilterOptions;
155  OUString sURL;
156  OUString sSourceStr;
158  sal_Int32 nRefresh;
159 
160  ScMyAreaLink() : nRefresh( 0 ) {}
161 
162  sal_Int32 GetColCount() const { return aDestRange.aEnd.Col() - aDestRange.aStart.Col() + 1; }
163  sal_Int32 GetRowCount() const { return aDestRange.aEnd.Row() - aDestRange.aStart.Row() + 1; }
164 
165  bool Compare( const ScMyAreaLink& rAreaLink ) const;
166  bool operator<(const ScMyAreaLink& rAreaLink ) const;
167 };
168 
169 typedef ::std::list< ScMyAreaLink > ScMyAreaLinkList;
170 
172 {
173 private:
175 protected:
176  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
177 public:
179  virtual ~ScMyAreaLinksContainer() override;
180 
181  void AddNewAreaLink( const ScMyAreaLink& rAreaLink )
182  { aAreaLinkList.push_back( rAreaLink ); }
183 
185  virtual void SetCellData( ScMyCell& rMyCell ) override;
186  virtual void Sort() override;
187  void SkipTable(SCTAB nSkip);
188 };
189 
190 typedef std::list<ScRange> ScMyEmptyDatabaseRangeList;
191 
193 {
194 private:
196 protected:
197  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
198 public:
200  virtual ~ScMyEmptyDatabaseRangesContainer() override;
201 
206 
207  void AddNewEmptyDatabaseRange(const css::table::CellRangeAddress& aCellRangeAddress);
208 
210  virtual void SetCellData( ScMyCell& rMyCell ) override;
211  virtual void Sort() override;
212  void SkipTable(SCTAB nSkip);
213 };
214 
216 {
220  bool bHasError;
221  bool operator<(const ScMyDetectiveObj& rDetObj) const;
222 };
223 
224 typedef ::std::list< ScMyDetectiveObj > ScMyDetectiveObjList;
225 typedef ::std::vector< ScMyDetectiveObj > ScMyDetectiveObjVec;
226 
228 {
229 private:
231 protected:
232  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
233 public:
235  virtual ~ScMyDetectiveObjContainer() override;
236 
237  void AddObject(
238  ScDetectiveObjType eObjType,
239  const SCTAB nSheet,
240  const ScAddress& rPosition,
241  const ScRange& rSourceRange,
242  bool bHasError );
243 
245  virtual void SetCellData( ScMyCell& rMyCell ) override;
246  virtual void Sort() override;
247  void SkipTable(SCTAB nSkip);
248 };
249 
251 {
254  sal_Int32 nIndex;
255  bool operator<(const ScMyDetectiveOp& rDetOp) const;
256 };
257 
258 typedef ::std::list< ScMyDetectiveOp > ScMyDetectiveOpList;
259 typedef ::std::vector< ScMyDetectiveOp > ScMyDetectiveOpVec;
260 
262 {
263 private:
265 protected:
266  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
267 public:
269  virtual ~ScMyDetectiveOpContainer() override;
270 
271  void AddOperation( ScDetOpType eOpType, const ScAddress& rPosition, sal_uInt32 nIndex );
272 
274  virtual void SetCellData( ScMyCell& rMyCell ) override;
275  virtual void Sort() override;
276  void SkipTable(SCTAB nSkip);
277 };
278 
279 // contains data to export for the current cell position
280 struct ScMyCell
281 {
283 
287 
292 
294 
295  sal_Int32 nValidationIndex;
296  sal_Int32 nStyleIndex;
297  sal_Int32 nNumberFormat;
298  css::table::CellContentType nType;
299 
301 
303 
304  bool bHasShape;
311 
315 
316  ScMyCell();
317 };
318 
320 {
323 
324  css::uno::Reference<css::sheet::XSpreadsheet> xTable;
325  css::uno::Reference<css::table::XCellRange> xCellRange;
327 
335 
337  std::unique_ptr<ScHorizontalCellIterator> mpCellItr;
338 
342 
343  void UpdateAddress( ScAddress& rAddress );
344  void SetCellData( ScMyCell& rMyCell, const ScAddress& rAddress );
345 
346  void HasAnnotation( ScMyCell& aCell );
347 public:
348  explicit ScMyNotEmptyCellsIterator(ScXMLExport& rExport);
350 
351  void Clear();
352 
353  void SetShapes(ScMyShapesContainer* pNewShapes)
354  { pShapes = pNewShapes; }
356  { pNoteShapes = pNewNoteShapes; }
358  { pEmptyDatabaseRanges = pNewEmptyDatabaseRanges; }
360  { pMergedRanges = pNewMergedRanges; }
362  { pAreaLinks = pNewAreaLinks; }
364  { pDetectiveObj = pNewDetectiveObj; }
366  { pDetectiveOp = pNewDetectiveOp; }
367 
368  void SetCurrentTable(const SCTAB nTable,
369  const css::uno::Reference<css::sheet::XSpreadsheet>& rxTable);
370  void SkipTable(SCTAB nSkip);
371 
372  bool GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles);
373 };
374 
375 #endif
376 
377 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetCellData(ScMyCell &rMyCell, const ScAddress &rAddress)
const ScMyShapeList & GetShapes() const
void UpdateAddress(ScAddress &rAddress)
virtual void Sort() override
css::uno::Reference< css::sheet::XSpreadsheet > xTable
void AddNewShape(const ScMyShape &aShape)
virtual void SetCellData(ScMyCell &rMyCell) override
ScAddress aStart
Definition: address.hxx:500
ScMyDetectiveOpList aDetectiveOpList
virtual void Sort() override
ScRefCellValue maBaseCell
bool operator<(const ScMyDetectiveObj &rDetObj) const
SCROW Row() const
Definition: address.hxx:262
ScPostIt * pNote
sal_Int32 nValidationIndex
virtual ~ScMyEmptyDatabaseRangesContainer() override
::std::list< ScMyDetectiveOp > ScMyDetectiveOpList
css::table::CellContentType nType
std::list< ScMyMergedRange > ScMyMergedRangeList
virtual bool GetFirstAddress(ScAddress &rCellAddress) override
void AddOperation(ScDetOpType eOpType, const ScAddress &rPosition, sal_uInt32 nIndex)
virtual ~ScMyNoteShapesContainer() override
void AddNewNote(const ScMyNoteShape &aNote)
ScAddress aEnd
Definition: address.hxx:501
ScMyIteratorBase & operator=(ScMyIteratorBase const &)=default
virtual ~ScMyShapesContainer() override
sal_Int32 nNumberFormat
void AddObject(ScDetectiveObjType eObjType, const SCTAB nSheet, const ScAddress &rPosition, const ScRange &rSourceRange, bool bHasError)
void SetDetectiveOp(ScMyDetectiveOpContainer *pNewDetectiveOp)
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:104
ScAddress maCellAddress
const ScMyNoteShapeList & GetNotes() const
ScAddress aAddress
virtual ~ScMyDetectiveOpContainer() override
virtual void SetCellData(ScMyCell &rMyCell) override
void SetAreaLinks(ScMyAreaLinksContainer *pNewAreaLinks)
ScMyNoteShapesContainer * pNoteShapes
virtual void SetCellData(ScMyCell &rMyCell) override
bool operator<(const ScMyMergedRange &aRange) const
::std::vector< ScMyDetectiveOp > ScMyDetectiveOpVec
std::unique_ptr< ScHorizontalCellIterator > mpCellItr
css::uno::Reference< css::table::XCellRange > xCellRange
Additional class containing cell annotation data.
Definition: postit.hxx:160
ScRange aMatrixRange
virtual bool GetFirstAddress(ScAddress &rCellAddress) override
void SkipTable(SCTAB nSkip)
virtual ~ScMyDetectiveObjContainer() override
ScMyShapesContainer * pShapes
std::list< ScMyShape > ScMyShapeList
virtual void SetCellData(ScMyCell &rMyCell) override
bool operator<(const ScMyNoteShape &aNote) const
ScMyDetectiveOpVec aDetectiveOpVec
virtual void Sort() override
ScMyEmptyDatabaseRangesContainer & operator=(ScMyEmptyDatabaseRangesContainer const &)=default
ScMyNoteShapeList aNoteShapeList
ScDetectiveObjType
Definition: detfunc.hxx:39
sal_Int16 SCCOL
Definition: types.hxx:22
ScAddress aCellAddress
Use this instead of the UNO one.
virtual bool GetFirstAddress(ScAddress &rCellAddress) override
void SetCurrentTable(const SCTAB nTable, const css::uno::Reference< css::sheet::XSpreadsheet > &rxTable)
void SetNoteShapes(ScMyNoteShapesContainer *pNewNoteShapes)
ScMyMergedRangesContainer * pMergedRanges
void UpdateAddress(ScAddress &rCellAddress)
::std::list< ScMyDetectiveObj > ScMyDetectiveObjList
std::list< ScRange > ScMyEmptyDatabaseRangeList
ScAddress aEndAddress
std::list< ScMyNoteShape > ScMyNoteShapeList
::std::list< ScMyAreaLink > ScMyAreaLinkList
sal_Int32 nEndY
::std::vector< ScMyDetectiveObj > ScMyDetectiveObjVec
ScMyDetectiveObjList aDetectiveObjList
virtual bool GetFirstAddress(ScAddress &rCellAddress) override
ScMyEmptyDatabaseRangeList aDatabaseList
SCCOL Col() const
Definition: address.hxx:267
virtual ~ScMyMergedRangesContainer() override
ScMyAreaLink aAreaLink
virtual void Sort()=0
void SetShapes(ScMyShapesContainer *pNewShapes)
css::uno::Reference< css::drawing::XShape > xShape
ScMyDetectiveOpContainer * pDetectiveOp
void AddNewEmptyDatabaseRange(const css::table::CellRangeAddress &aCellRangeAddress)
ScDetectiveObjType eObjType
sal_Int32 SCROW
Definition: types.hxx:18
css::uno::Reference< css::drawing::XShape > xShape
ScDetOpType
Definition: detdata.hxx:28
ScMyMergedRangeList aRangeList
virtual bool GetFirstAddress(ScAddress &rCellAddress)=0
virtual void SetCellData(ScMyCell &rMyCell) override
void SetDetectiveObj(ScMyDetectiveObjContainer *pNewDetectiveObj)
ScMyDetectiveObjContainer * pDetectiveObj
virtual void Sort() override
sal_Int32 nEndX
virtual void Sort() override
ScMyAreaLinksContainer * pAreaLinks
void SetMergedRanges(ScMyMergedRangesContainer *pNewMergedRanges)
const ScMyNotEmptyCellsIterator & operator=(const ScMyNotEmptyCellsIterator &)=delete
ScMyEmptyDatabaseRangesContainer * pEmptyDatabaseRanges
void SetEmptyDatabaseRanges(ScMyEmptyDatabaseRangesContainer *pNewEmptyDatabaseRanges)
bool GetNext(ScMyCell &aCell, ScFormatRangeStyles *pCellStyles)
virtual bool GetFirstAddress(ScAddress &rCellAddress) override
bool operator<(const ScMyDetectiveOp &rDetOp) const
ScRange aMergeRange
void HasAnnotation(ScMyCell &aCell)
virtual bool GetFirstAddress(ScAddress &rCellAddress) override
void AddRange(const ScRange &rMergedRange)
ScMyNotEmptyCellsIterator(const ScMyNotEmptyCellsIterator &)=delete
virtual void SetCellData(ScMyCell &rMyCell) override
ScMyDetectiveObjVec aDetectiveObjVec
ScMyShapeList aShapeList
sal_Int16 SCTAB
Definition: types.hxx:23
virtual void SetCellData(ScMyCell &rMyCell)=0
bool operator<(const ScMyShape &aShape) const
sal_Int32 nStyleIndex