LibreOffice Module sc (master)  1
XMLStylesExportHelper.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_XMLSTYLESEXPORTHELPER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_XML_XMLSTYLESEXPORTHELPER_HXX
22 
23 #include <vector>
24 #include <memory>
25 #include <list>
26 
27 #include <address.hxx>
28 #include <com/sun/star/table/CellRangeAddress.hpp>
29 #include <com/sun/star/sheet/ConditionOperator.hpp>
30 #include <com/sun/star/sheet/ValidationAlertStyle.hpp>
31 #include <com/sun/star/sheet/ValidationType.hpp>
32 
33 #include <mdds/flat_segment_tree.hpp>
34 
35 class ScDocument;
36 class ScXMLExport;
37 
39 {
40  OUString sName;
41  OUString sErrorMessage;
42  OUString sErrorTitle;
43  OUString sInputMessage;
44  OUString sInputTitle;
45  OUString sFormula1;
46  OUString sFormula2;
48  css::sheet::ValidationAlertStyle aAlertStyle;
49  css::sheet::ValidationType aValidationType;
50  css::sheet::ConditionOperator aOperator;
51  sal_Int16 nShowList;
55 
57 
58  bool IsEqual(const ScMyValidation& aVal) const;
59 };
60 
62 {
63 private:
64  std::vector<ScMyValidation> aValidationVec;
65 public:
68  void AddValidation(const css::uno::Any& aAny,
69  sal_Int32& nValidationIndex);
70  static OUString GetCondition(ScXMLExport& rExport, const ScMyValidation& aValidation);
71  static OUString GetBaseCellAddress(const ScDocument* pDoc, const ScAddress& aCell);
72  static void WriteMessage(ScXMLExport& rExport,
73  const OUString& sTitle, const OUString& sMessage,
74  const bool bShowMessage, const bool bIsHelpMessage);
75  void WriteValidations(ScXMLExport& rExport);
76  const OUString& GetValidationName(const sal_Int32 nIndex);
77 };
78 
80 {
81  sal_Int32 nIndex;
82  sal_Int32 nRepeat;
84 
85  ScMyDefaultStyle() : nIndex(-1), nRepeat(1),
86  bIsAutoStyle(true) {}
87 };
88 
89 typedef std::vector<ScMyDefaultStyle> ScMyDefaultStyleList;
90 
92 
94 {
96 
97  static sal_Int32 GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles,
98  const sal_Int32 nTable, const sal_Int32 nPos,
99  const sal_Int32 i, bool& bIsAutoStyle);
100 public:
101 
102  void FillDefaultStyles(const sal_Int32 nTable,
103  const sal_Int32 nLastRow, const sal_Int32 nLastCol,
104  const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc);
105 
107 };
108 
110 {
111  sal_Int32 nStartColumn;
112  sal_Int32 nRepeatColumns;
113  sal_Int32 nRepeatRows;
114  sal_Int32 nIndex;
115  sal_Int32 nValidationIndex;
117 
119  bool operator<(const ScMyRowFormatRange& rRange) const;
120 };
121 
123 {
124  typedef std::list<ScMyRowFormatRange> ScMyRowFormatRangesList;
125  ScMyRowFormatRangesList aRowFormatRanges;
127  sal_uInt32 nSize;
128 
129  void AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex,
130  const bool bPrevAutoStyle, const ScMyRowFormatRange& rFormatRange);
131 
132 public:
134  explicit ScRowFormatRanges(const ScRowFormatRanges* pRanges);
136 
137  void SetColDefaults(const ScMyDefaultStyleList* pDefaults) { pColDefaults = pDefaults; }
138  void Clear();
139  void AddRange(const ScMyRowFormatRange& rFormatRange);
140  bool GetNext(ScMyRowFormatRange& rFormatRange);
141  sal_Int32 GetMaxRows() const;
142  sal_Int32 GetSize() const { return nSize;}
143  void Sort();
144 };
145 
146 
148 {
149  css::table::CellRangeAddress aRangeAddress;
150  sal_Int32 nStyleNameIndex;
151  sal_Int32 nValidationIndex;
152  sal_Int32 nNumberFormat;
154 
155  ScMyFormatRange();
156  bool operator< (const ScMyFormatRange& rRange) const;
157 };
158 
160 {
161  typedef std::list<ScMyFormatRange> ScMyFormatRangeAddresses;
162  typedef std::vector<ScMyFormatRangeAddresses> ScMyFormatRangeListVec;
163 
164  ScMyFormatRangeListVec aTables;
165  std::vector<OUString> aStyleNames;
166  std::vector<OUString> aAutoStyleNames;
168 
169 public:
172 
173  void SetColDefaults(const ScMyDefaultStyleList* pDefaults) { pColDefaults = pDefaults; }
174  void AddNewTable(const sal_Int32 nTable);
175  bool AddStyleName(const OUString& rString, sal_Int32& rIndex, const bool bIsAutoStyle = true);
176  sal_Int32 GetIndexOfStyleName(const OUString& rString, const OUString& rPrefix, bool& bIsAutoStyle);
177  // does not delete ranges
178  sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow,
179  bool& bIsAutoStyle) const;
180  // deletes not necessary ranges if wanted
181  sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow,
182  bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Int32 nRemoveBeforeRow);
183  void GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow,
184  const sal_Int32 nTable, ScRowFormatRanges* pFormatRanges);
185  void AddRangeStyleName(const css::table::CellRangeAddress& rCellRangeAddress, const sal_Int32 nStringIndex,
186  const bool bIsAutoStyle, const sal_Int32 nValidationIndex, const sal_Int32 nNumberFormat);
187  OUString& GetStyleNameByIndex(const sal_Int32 nIndex, const bool bIsAutoStyle);
188  void Sort();
189 };
190 
192 {
193  std::vector<OUString> aStyleNames;
194 
195 public:
197  virtual ~ScColumnRowStylesBase();
198 
199  virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) = 0;
200  sal_Int32 AddStyleName(const OUString & rString);
201  sal_Int32 GetIndexOfStyleName(const OUString& rString, const OUString& rPrefix);
202  OUString& GetStyleNameByIndex(const sal_Int32 nIndex);
203 };
204 
206 {
207  sal_Int32 nIndex;
209 
210  ScColumnStyle() : nIndex(-1), bIsVisible(true) {}
211 };
212 
214 {
215  typedef std::vector<ScColumnStyle> ScMyColumnStyleVec;
216  typedef std::vector<ScMyColumnStyleVec> ScMyColumnVectorVec;
217  ScMyColumnVectorVec aTables;
218 
219 public:
220  ScColumnStyles();
221  virtual ~ScColumnStyles() override;
222 
223  virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) override;
224  sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField,
225  bool& bIsVisible);
226  void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex, const bool bIsVisible);
227 };
228 
230 {
231  typedef ::mdds::flat_segment_tree<sal_Int32, sal_Int32> StylesType;
232  std::vector<std::unique_ptr<StylesType> > aTables;
233  struct Cache
234  {
235  sal_Int32 mnTable;
236  sal_Int32 mnStart;
237  sal_Int32 mnEnd;
238  sal_Int32 mnStyle;
239  Cache();
240 
241  bool hasCache(sal_Int32 nTable, sal_Int32 nField) const;
242  };
244 
245 public:
246  ScRowStyles();
247  virtual ~ScRowStyles() override;
248 
249  virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) override;
250  sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField);
251  void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex);
252  void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nStartField, const sal_Int32 nStringIndex, const sal_Int32 nEndField);
253 };
254 
255 #endif
256 
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator<(const ScMyFormatRange &rRange) const
sal_Int32 GetIndexOfStyleName(const OUString &rString, const OUString &rPrefix)
void AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex, const bool bPrevAutoStyle, const ScMyRowFormatRange &rFormatRange)
bool operator<(const ScMyRowFormatRange &rRange) const
static OUString GetBaseCellAddress(const ScDocument *pDoc, const ScAddress &aCell)
void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex, const bool bIsVisible)
static void WriteMessage(ScXMLExport &rExport, const OUString &sTitle, const OUString &sMessage, const bool bShowMessage, const bool bIsHelpMessage)
virtual ~ScColumnStyles() override
void AddRangeStyleName(const css::table::CellRangeAddress &rCellRangeAddress, const sal_Int32 nStringIndex, const bool bIsAutoStyle, const sal_Int32 nValidationIndex, const sal_Int32 nNumberFormat)
void SetColDefaults(const ScMyDefaultStyleList *pDefaults)
sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField, bool &bIsVisible)
css::sheet::ConditionOperator aOperator
css::sheet::ValidationAlertStyle aAlertStyle
OUString & GetStyleNameByIndex(const sal_Int32 nIndex, const bool bIsAutoStyle)
const ScMyDefaultStyleList * pColDefaults
void SetColDefaults(const ScMyDefaultStyleList *pDefaults)
ScMyFormatRangeListVec aTables
std::vector< ScMyFormatRangeAddresses > ScMyFormatRangeListVec
sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow, bool &bIsAutoStyle) const
void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex)
std::list< ScMyFormatRange > ScMyFormatRangeAddresses
void AddValidation(const css::uno::Any &aAny, sal_Int32 &nValidationIndex)
sal_Int32 AddStyleName(const OUString &rString)
bool hasCache(sal_Int32 nTable, sal_Int32 nField) const
std::vector< ScColumnStyle > ScMyColumnStyleVec
::mdds::flat_segment_tree< sal_Int32, sal_Int32 > StylesType
ScMyDefaultStyleList maColDefaults
css::sheet::ValidationType aValidationType
css::table::CellRangeAddress aRangeAddress
sal_Int32 GetSize() const
virtual ~ScRowStyles() override
std::list< ScMyRowFormatRange > ScMyRowFormatRangesList
void WriteValidations(ScXMLExport &rExport)
std::vector< OUString > aStyleNames
sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField)
static OUString GetCondition(ScXMLExport &rExport, const ScMyValidation &aValidation)
virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) override
void FillDefaultStyles(const sal_Int32 nTable, const sal_Int32 nLastRow, const sal_Int32 nLastCol, const ScFormatRangeStyles *pCellStyles, ScDocument *pDoc)
static sal_Int32 GetStyleNameIndex(const ScFormatRangeStyles *pCellStyles, const sal_Int32 nTable, const sal_Int32 nPos, const sal_Int32 i, bool &bIsAutoStyle)
virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)=0
std::vector< ScMyColumnStyleVec > ScMyColumnVectorVec
const OUString & GetValidationName(const sal_Int32 nIndex)
std::vector< OUString > aAutoStyleNames
std::vector< ScMyValidation > aValidationVec
std::vector< OUString > aStyleNames
bool GetNext(ScMyRowFormatRange &rFormatRange)
bool AddStyleName(const OUString &rString, sal_Int32 &rIndex, const bool bIsAutoStyle=true)
const ScMyDefaultStyleList & GetColDefaults() const
virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) override
ScMyRowFormatRangesList aRowFormatRanges
OUString & GetStyleNameByIndex(const sal_Int32 nIndex)
void AddNewTable(const sal_Int32 nTable)
sal_Int32 GetMaxRows() const
std::vector< std::unique_ptr< StylesType > > aTables
bool IsEqual(const ScMyValidation &aVal) const
std::vector< ScMyDefaultStyle > ScMyDefaultStyleList
ScMyColumnVectorVec aTables
const ScMyDefaultStyleList * pColDefaults
void GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow, const sal_Int32 nTable, ScRowFormatRanges *pFormatRanges)
sal_Int32 GetIndexOfStyleName(const OUString &rString, const OUString &rPrefix, bool &bIsAutoStyle)