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#pragma once
21
22#include <vector>
23#include <memory>
24#include <list>
25
26#include <address.hxx>
27#include <com/sun/star/table/CellRangeAddress.hpp>
28#include <com/sun/star/sheet/ConditionOperator.hpp>
29#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
30#include <com/sun/star/sheet/ValidationType.hpp>
31
32#include <mdds/flat_segment_tree.hpp>
33
34class ScDocument;
35class ScXMLExport;
36
38{
39 OUString sName;
40 OUString sErrorMessage;
41 OUString sErrorTitle;
42 OUString sInputMessage;
43 OUString sInputTitle;
44 OUString sFormula1;
45 OUString sFormula2;
47 css::sheet::ValidationAlertStyle aAlertStyle;
48 css::sheet::ValidationType aValidationType;
49 css::sheet::ConditionOperator aOperator;
50 sal_Int16 nShowList;
54
56
57 bool IsEqual(const ScMyValidation& aVal) const;
58};
59
61{
62private:
63 std::vector<ScMyValidation> aValidationVec;
64public:
67 void AddValidation(const css::uno::Any& aAny,
68 sal_Int32& nValidationIndex);
69 static OUString GetCondition(ScXMLExport& rExport, const ScMyValidation& aValidation);
70 static OUString GetBaseCellAddress(const ScDocument* pDoc, const ScAddress& aCell);
71 static void WriteMessage(ScXMLExport& rExport,
72 const OUString& sTitle, const OUString& sMessage,
73 const bool bShowMessage, const bool bIsHelpMessage);
74 void WriteValidations(ScXMLExport& rExport);
75 const OUString& GetValidationName(const sal_Int32 nIndex);
76};
77
79{
80 sal_Int32 nIndex;
81 sal_Int32 nRepeat;
83
85 bIsAutoStyle(true) {}
86};
87
88typedef std::vector<ScMyDefaultStyle> ScMyDefaultStyleList;
89
91
93{
95
96 static sal_Int32 GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles,
97 const sal_Int32 nTable, const sal_Int32 nPos,
98 const sal_Int32 i, bool& bIsAutoStyle);
99public:
100
101 void FillDefaultStyles(const sal_Int32 nTable,
102 const sal_Int32 nLastRow, const sal_Int32 nLastCol,
103 const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc);
104
106};
107
109{
110 sal_Int32 nStartColumn;
111 sal_Int32 nRepeatColumns;
112 sal_Int32 nRepeatRows;
113 sal_Int32 nIndex;
116
118 bool operator<(const ScMyRowFormatRange& rRange) const;
119};
120
122{
123 typedef std::list<ScMyRowFormatRange> ScMyRowFormatRangesList;
126 sal_uInt32 nSize;
127
128 void AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex,
129 const bool bPrevAutoStyle, const ScMyRowFormatRange& rFormatRange);
130
131public:
133 explicit ScRowFormatRanges(const ScRowFormatRanges* pRanges);
135
136 void SetColDefaults(const ScMyDefaultStyleList* pDefaults) { pColDefaults = pDefaults; }
137 void Clear();
138 void AddRange(const ScMyRowFormatRange& rFormatRange);
139 bool GetNext(ScMyRowFormatRange& rFormatRange);
140 sal_Int32 GetMaxRows() const;
141 sal_Int32 GetSize() const { return nSize;}
142 void Sort();
143};
144
145
147{
148 css::table::CellRangeAddress aRangeAddress;
151 sal_Int32 nNumberFormat;
153
155 bool operator< (const ScMyFormatRange& rRange) const;
156};
157
159{
160 typedef std::list<ScMyFormatRange> ScMyFormatRangeAddresses;
161 typedef std::vector<ScMyFormatRangeAddresses> ScMyFormatRangeListVec;
162
164 std::vector<OUString> aStyleNames;
165 std::vector<OUString> aAutoStyleNames;
167
168public:
171
172 void SetColDefaults(const ScMyDefaultStyleList* pDefaults) { pColDefaults = pDefaults; }
173 void AddNewTable(const sal_Int32 nTable);
174 bool AddStyleName(const OUString& rString, sal_Int32& rIndex, const bool bIsAutoStyle = true);
175 sal_Int32 GetIndexOfStyleName(std::u16string_view rString, std::u16string_view rPrefix, bool& bIsAutoStyle);
176 // does not delete ranges
177 sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow,
178 bool& bIsAutoStyle) const;
179 // deletes not necessary ranges if wanted
180 sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow,
181 bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Int32 nRemoveBeforeRow);
182 void GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow,
183 const sal_Int32 nTable, ScRowFormatRanges* pFormatRanges);
184 void AddRangeStyleName(const css::table::CellRangeAddress& rCellRangeAddress, const sal_Int32 nStringIndex,
185 const bool bIsAutoStyle, const sal_Int32 nValidationIndex, const sal_Int32 nNumberFormat);
186 OUString& GetStyleNameByIndex(const sal_Int32 nIndex, const bool bIsAutoStyle);
187 void Sort();
188};
189
191{
192 std::vector<OUString> aStyleNames;
193
194public:
196 virtual ~ScColumnRowStylesBase();
197
198 virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) = 0;
199 sal_Int32 AddStyleName(const OUString & rString);
200 sal_Int32 GetIndexOfStyleName(std::u16string_view rString, std::u16string_view rPrefix);
201 OUString& GetStyleNameByIndex(const sal_Int32 nIndex);
202};
203
205{
206 sal_Int32 nIndex;
208
210};
211
213{
214 typedef std::vector<ScColumnStyle> ScMyColumnStyleVec;
215 typedef std::vector<ScMyColumnStyleVec> ScMyColumnVectorVec;
217
218public:
220 virtual ~ScColumnStyles() override;
221
222 virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) override;
223 sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField,
224 bool& bIsVisible);
225 void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex, const bool bIsVisible);
226};
227
229{
230 typedef ::mdds::flat_segment_tree<sal_Int32, sal_Int32> StylesType;
231 std::vector<std::unique_ptr<StylesType> > aTables;
232 struct Cache
233 {
234 sal_Int32 mnTable;
235 sal_Int32 mnStart;
236 sal_Int32 mnEnd;
237 sal_Int32 mnStyle;
238 Cache();
239
240 bool hasCache(sal_Int32 nTable, sal_Int32 nField) const;
241 };
243
244public:
245 ScRowStyles();
246 virtual ~ScRowStyles() override;
247
248 virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) override;
249 sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField);
250 void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex);
251 void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nStartField, const sal_Int32 nStringIndex, const sal_Int32 nEndField);
252};
253
254/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< ScMyDefaultStyle > ScMyDefaultStyleList
std::vector< OUString > aStyleNames
virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)=0
OUString & GetStyleNameByIndex(const sal_Int32 nIndex)
sal_Int32 GetIndexOfStyleName(std::u16string_view rString, std::u16string_view rPrefix)
sal_Int32 AddStyleName(const OUString &rString)
sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField, bool &bIsVisible)
virtual ~ScColumnStyles() override
virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) override
void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex, const bool bIsVisible)
ScMyColumnVectorVec aTables
std::vector< ScMyColumnStyleVec > ScMyColumnVectorVec
std::vector< ScColumnStyle > ScMyColumnStyleVec
std::vector< OUString > aAutoStyleNames
std::vector< OUString > aStyleNames
std::list< ScMyFormatRange > ScMyFormatRangeAddresses
bool AddStyleName(const OUString &rString, sal_Int32 &rIndex, const bool bIsAutoStyle=true)
void AddNewTable(const sal_Int32 nTable)
sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow, bool &bIsAutoStyle) const
std::vector< ScMyFormatRangeAddresses > ScMyFormatRangeListVec
const ScMyDefaultStyleList * pColDefaults
sal_Int32 GetIndexOfStyleName(std::u16string_view rString, std::u16string_view rPrefix, bool &bIsAutoStyle)
ScMyFormatRangeListVec aTables
void SetColDefaults(const ScMyDefaultStyleList *pDefaults)
void GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow, const sal_Int32 nTable, ScRowFormatRanges *pFormatRanges)
void AddRangeStyleName(const css::table::CellRangeAddress &rCellRangeAddress, const sal_Int32 nStringIndex, const bool bIsAutoStyle, const sal_Int32 nValidationIndex, const sal_Int32 nNumberFormat)
OUString & GetStyleNameByIndex(const sal_Int32 nIndex, const bool bIsAutoStyle)
const ScMyDefaultStyleList & GetColDefaults() const
ScMyDefaultStyleList maColDefaults
static sal_Int32 GetStyleNameIndex(const ScFormatRangeStyles *pCellStyles, const sal_Int32 nTable, const sal_Int32 nPos, const sal_Int32 i, bool &bIsAutoStyle)
void FillDefaultStyles(const sal_Int32 nTable, const sal_Int32 nLastRow, const sal_Int32 nLastCol, const ScFormatRangeStyles *pCellStyles, ScDocument *pDoc)
const OUString & GetValidationName(const sal_Int32 nIndex)
static OUString GetBaseCellAddress(const ScDocument *pDoc, const ScAddress &aCell)
void AddValidation(const css::uno::Any &aAny, sal_Int32 &nValidationIndex)
static void WriteMessage(ScXMLExport &rExport, const OUString &sTitle, const OUString &sMessage, const bool bShowMessage, const bool bIsHelpMessage)
std::vector< ScMyValidation > aValidationVec
static OUString GetCondition(ScXMLExport &rExport, const ScMyValidation &aValidation)
void WriteValidations(ScXMLExport &rExport)
sal_Int32 GetMaxRows() const
void AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex, const bool bPrevAutoStyle, const ScMyRowFormatRange &rFormatRange)
const ScMyDefaultStyleList * pColDefaults
sal_Int32 GetSize() const
void SetColDefaults(const ScMyDefaultStyleList *pDefaults)
ScMyRowFormatRangesList aRowFormatRanges
std::list< ScMyRowFormatRange > ScMyRowFormatRangesList
bool GetNext(ScMyRowFormatRange &rFormatRange)
::mdds::flat_segment_tree< sal_Int32, sal_Int32 > StylesType
void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex)
virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) override
std::vector< std::unique_ptr< StylesType > > aTables
sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField)
virtual ~ScRowStyles() override
css::table::CellRangeAddress aRangeAddress
bool operator<(const ScMyFormatRange &rRange) const
bool operator<(const ScMyRowFormatRange &rRange) const
css::sheet::ValidationAlertStyle aAlertStyle
css::sheet::ConditionOperator aOperator
bool IsEqual(const ScMyValidation &aVal) const
css::sheet::ValidationType aValidationType
bool hasCache(sal_Int32 nTable, sal_Int32 nField) const