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 #pragma once
21 
22 #include <vector>
23 #include <list>
24 #include <com/sun/star/table/CellContentType.hpp>
25 #include <detfunc.hxx>
26 #include <detdata.hxx>
27 #include <cellvalue.hxx>
28 
29 #include <memory>
30 
31 namespace com::sun::star::drawing { class XShape; }
32 namespace com::sun::star::sheet { class XSpreadsheet; }
33 namespace com::sun::star::table { class XCellRange; }
34 namespace com::sun::star::table { struct CellRangeAddress; }
35 
36 class ScPostIt;
38 struct ScMyCell;
39 class ScXMLExport;
41 
43 {
44 protected:
45  virtual bool GetFirstAddress( ScAddress& rCellAddress ) = 0;
46 
47 public:
49  virtual ~ScMyIteratorBase();
50 
51  ScMyIteratorBase(ScMyIteratorBase const &) = default;
52  ScMyIteratorBase(ScMyIteratorBase &&) = default;
53  ScMyIteratorBase & operator =(ScMyIteratorBase const &) = default;
55 
56  virtual void SetCellData( ScMyCell& rMyCell ) = 0;
57  virtual void Sort() = 0;
58 
59  void UpdateAddress( ScAddress& rCellAddress );
60 };
61 
62 struct ScMyShape
63 {
66  sal_Int32 nEndX;
67  sal_Int32 nEndY;
69  css::uno::Reference<css::drawing::XShape> xShape;
70 
71  bool operator<(const ScMyShape& aShape) const;
72 };
73 
74 typedef std::list<ScMyShape> ScMyShapeList;
75 
77 {
78 private:
80 protected:
81  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
82 public:
84  virtual ~ScMyShapesContainer() override;
85 
87  void AddNewShape(const ScMyShape& aShape);
88  bool HasShapes() const { return !aShapeList.empty(); }
89  const ScMyShapeList& GetShapes() const { return aShapeList; }
90  virtual void SetCellData( ScMyCell& rMyCell ) override;
91  virtual void Sort() override;
92  void SkipTable(SCTAB nSkip);
93 };
94 
96 {
97  css::uno::Reference<css::drawing::XShape> xShape;
99 
100  bool operator<(const ScMyNoteShape& aNote) const;
101 };
102 
103 typedef std::list<ScMyNoteShape> ScMyNoteShapeList;
104 
106 {
107 private:
109 protected:
110  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
111 public:
113  virtual ~ScMyNoteShapesContainer() override;
114 
116  void AddNewNote(const ScMyNoteShape& aNote);
117  const ScMyNoteShapeList& GetNotes() const { return aNoteShapeList; }
118  virtual void SetCellData( ScMyCell& rMyCell ) override;
119  virtual void Sort() override;
120  void SkipTable(SCTAB nSkip);
121 };
122 
124 {
126  sal_Int32 nRows;
127  bool bIsFirst;
128  bool operator<(const ScMyMergedRange& aRange) const;
129 };
130 
131 typedef std::list<ScMyMergedRange> ScMyMergedRangeList;
132 
134 {
135 private:
137 protected:
138  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
139 public:
141  virtual ~ScMyMergedRangesContainer() override;
142  void AddRange(const ScRange& rMergedRange);
143 
145  virtual void SetCellData( ScMyCell& rMyCell ) override;
146  virtual void Sort() override; // + remove doublets
147  void SkipTable(SCTAB nSkip);
148 };
149 
151 {
152  OUString sFilter;
153  OUString sFilterOptions;
154  OUString sURL;
155  OUString sSourceStr;
157  sal_Int32 nRefresh;
158 
159  ScMyAreaLink() : nRefresh( 0 ) {}
160 
161  sal_Int32 GetColCount() const { return aDestRange.aEnd.Col() - aDestRange.aStart.Col() + 1; }
162  sal_Int32 GetRowCount() const { return aDestRange.aEnd.Row() - aDestRange.aStart.Row() + 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 
171 {
172 private:
174 protected:
175  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
176 public:
178  virtual ~ScMyAreaLinksContainer() override;
179 
180  void AddNewAreaLink( const ScMyAreaLink& rAreaLink )
181  { aAreaLinkList.push_back( rAreaLink ); }
182 
184  virtual void SetCellData( ScMyCell& rMyCell ) override;
185  virtual void Sort() override;
186  void SkipTable(SCTAB nSkip);
187 };
188 
189 typedef std::list<ScRange> ScMyEmptyDatabaseRangeList;
190 
192 {
193 private:
195 protected:
196  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
197 public:
199  virtual ~ScMyEmptyDatabaseRangesContainer() override;
200 
205 
206  void AddNewEmptyDatabaseRange(const css::table::CellRangeAddress& aCellRangeAddress);
207 
209  virtual void SetCellData( ScMyCell& rMyCell ) override;
210  virtual void Sort() override;
211  void SkipTable(SCTAB nSkip);
212 };
213 
215 {
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 
227 {
228 private:
230 protected:
231  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
232 public:
234  virtual ~ScMyDetectiveObjContainer() override;
235 
236  void AddObject(
237  ScDetectiveObjType eObjType,
238  const SCTAB nSheet,
239  const ScAddress& rPosition,
240  const ScRange& rSourceRange,
241  bool bHasError );
242 
244  virtual void SetCellData( ScMyCell& rMyCell ) override;
245  virtual void Sort() override;
246  void SkipTable(SCTAB nSkip);
247 };
248 
250 {
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 
261 {
262 private:
264 protected:
265  virtual bool GetFirstAddress( ScAddress& rCellAddress ) override;
266 public:
268  virtual ~ScMyDetectiveOpContainer() override;
269 
270  void AddOperation( ScDetOpType eOpType, const ScAddress& rPosition, sal_uInt32 nIndex );
271 
273  virtual void SetCellData( ScMyCell& rMyCell ) override;
274  virtual void Sort() override;
275  void SkipTable(SCTAB nSkip);
276 };
277 
278 // contains data to export for the current cell position
279 struct ScMyCell
280 {
282 
286 
291 
293 
294  sal_Int32 nValidationIndex;
295  sal_Int32 nStyleIndex;
296  sal_Int32 nNumberFormat;
297  css::table::CellContentType nType;
298 
300 
302 
303  bool bHasShape;
310 
314 
315  ScMyCell();
316 };
317 
319 {
322 
323  css::uno::Reference<css::sheet::XSpreadsheet> xTable;
324  css::uno::Reference<css::table::XCellRange> xCellRange;
326 
334 
336  std::unique_ptr<ScHorizontalCellIterator> mpCellItr;
337 
341 
342  void UpdateAddress( ScAddress& rAddress );
343  void SetCellData( ScMyCell& rMyCell, const ScAddress& rAddress );
344 
345  void HasAnnotation( ScMyCell& aCell );
346 public:
347  explicit ScMyNotEmptyCellsIterator(ScXMLExport& rExport);
349 
350  void Clear();
351 
352  void SetShapes(ScMyShapesContainer* pNewShapes)
353  { pShapes = pNewShapes; }
355  { pNoteShapes = pNewNoteShapes; }
357  { pEmptyDatabaseRanges = pNewEmptyDatabaseRanges; }
359  { pMergedRanges = pNewMergedRanges; }
361  { pAreaLinks = pNewAreaLinks; }
363  { pDetectiveObj = pNewDetectiveObj; }
365  { pDetectiveOp = pNewDetectiveOp; }
366 
367  void SetCurrentTable(const SCTAB nTable,
368  const css::uno::Reference<css::sheet::XSpreadsheet>& rxTable);
369  void SkipTable(SCTAB nSkip);
370 
371  bool GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles);
372 };
373 
374 /* 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:499
ScMyDetectiveOpList aDetectiveOpList
virtual void Sort() override
ScRefCellValue maBaseCell
bool operator<(const ScMyDetectiveObj &rDetObj) const
SCROW Row() const
Definition: address.hxx:261
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:500
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:103
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:159
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:38
sal_Int16 SCCOL
Definition: types.hxx:21
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:266
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:17
css::uno::Reference< css::drawing::XShape > xShape
ScDetOpType
Definition: detdata.hxx:27
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:22
virtual void SetCellData(ScMyCell &rMyCell)=0
bool operator<(const ScMyShape &aShape) const
sal_Int32 nStyleIndex