1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef SC_XMLSTYLESEXPORTHELPER_HXX
#define SC_XMLSTYLESEXPORTHELPER_HXX
#include <vector>
#include <list>
#include <com/sun/star/uno/Any.h>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/sheet/ConditionOperator.hpp>
#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
#include <com/sun/star/sheet/ValidationType.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <mdds/flat_segment_tree.hpp>
class ScDocument;
class ScXMLExport;
struct ScMyValidation
{
OUString sName;
OUString sErrorMessage;
OUString sErrorTitle;
OUString sImputMessage;
OUString sImputTitle;
OUString sFormula1;
OUString sFormula2;
com::sun::star::table::CellAddress aBaseCell;
com::sun::star::sheet::ValidationAlertStyle aAlertStyle;
com::sun::star::sheet::ValidationType aValidationType;
com::sun::star::sheet::ConditionOperator aOperator;
sal_Int16 nShowList;
bool bShowErrorMessage;
bool bShowImputMessage;
bool bIgnoreBlanks;
ScMyValidation();
~ScMyValidation();
bool IsEqual(const ScMyValidation& aVal) const;
};
typedef std::vector<ScMyValidation> ScMyValidationVec;
class ScMyValidationsContainer
{
private:
ScMyValidationVec aValidationVec;
const OUString sEmptyString;
const OUString sERRALSTY;
const OUString sIGNOREBL;
const OUString sSHOWLIST;
const OUString sTYPE;
const OUString sSHOWINP;
const OUString sSHOWERR;
const OUString sINPTITLE;
const OUString sINPMESS;
const OUString sERRTITLE;
const OUString sERRMESS;
const OUString sOnError;
const OUString sEventType;
const OUString sStarBasic;
const OUString sScript;
const OUString sLibrary;
const OUString sMacroName;
public:
ScMyValidationsContainer();
~ScMyValidationsContainer();
bool AddValidation(const com::sun::star::uno::Any& aAny,
sal_Int32& nValidationIndex);
OUString GetCondition(ScXMLExport& rExport, const ScMyValidation& aValidation);
OUString GetBaseCellAddress(ScDocument* pDoc, const com::sun::star::table::CellAddress& aCell);
void WriteMessage(ScXMLExport& rExport,
const OUString& sTitle, const OUString& sMessage,
const bool bShowMessage, const bool bIsHelpMessage);
void WriteValidations(ScXMLExport& rExport);
const OUString& GetValidationName(const sal_Int32 nIndex);
};
struct ScMyDefaultStyle
{
sal_Int32 nIndex;
sal_Int32 nRepeat;
bool bIsAutoStyle;
ScMyDefaultStyle() : nIndex(-1), nRepeat(1),
bIsAutoStyle(true) {}
};
typedef std::vector<ScMyDefaultStyle> ScMyDefaultStyleList;
class ScFormatRangeStyles;
class ScMyDefaultStyles
{
ScMyDefaultStyleList maColDefaults;
sal_Int32 GetStyleNameIndex(const ScFormatRangeStyles* pCellStyles,
const sal_Int32 nTable, const sal_Int32 nPos,
const sal_Int32 i, bool& bIsAutoStyle);
public:
void FillDefaultStyles(const sal_Int32 nTable,
const sal_Int32 nLastRow, const sal_Int32 nLastCol,
const ScFormatRangeStyles* pCellStyles, ScDocument* pDoc);
const ScMyDefaultStyleList* GetColDefaults() const { return &maColDefaults; }
};
struct ScMyRowFormatRange
{
sal_Int32 nStartColumn;
sal_Int32 nRepeatColumns;
sal_Int32 nRepeatRows;
sal_Int32 nIndex;
sal_Int32 nValidationIndex;
bool bIsAutoStyle;
ScMyRowFormatRange();
bool operator<(const ScMyRowFormatRange& rRange) const;
};
class ScRowFormatRanges
{
typedef std::list<ScMyRowFormatRange> ScMyRowFormatRangesList;
ScMyRowFormatRangesList aRowFormatRanges;
const ScMyDefaultStyleList* pColDefaults;
sal_uInt32 nSize;
void AddRange(const sal_Int32 nPrevStartCol, const sal_Int32 nRepeat, const sal_Int32 nPrevIndex,
const bool bPrevAutoStyle, const ScMyRowFormatRange& rFormatRange);
public:
ScRowFormatRanges();
ScRowFormatRanges(const ScRowFormatRanges* pRanges);
~ScRowFormatRanges();
void SetColDefaults(const ScMyDefaultStyleList* pDefaults) { pColDefaults = pDefaults; }
void Clear();
void AddRange(ScMyRowFormatRange& rFormatRange);
bool GetNext(ScMyRowFormatRange& rFormatRange);
sal_Int32 GetMaxRows() const;
sal_Int32 GetSize() const;
void Sort();
};
typedef std::vector<OUString*> ScMyOUStringVec;
struct ScMyFormatRange
{
com::sun::star::table::CellRangeAddress aRangeAddress;
sal_Int32 nStyleNameIndex;
sal_Int32 nValidationIndex;
sal_Int32 nNumberFormat;
bool bIsAutoStyle;
ScMyFormatRange();
bool operator< (const ScMyFormatRange& rRange) const;
};
class ScFormatRangeStyles
{
typedef std::list<ScMyFormatRange> ScMyFormatRangeAddresses;
typedef std::vector<ScMyFormatRangeAddresses*> ScMyFormatRangeListVec;
ScMyFormatRangeListVec aTables;
ScMyOUStringVec aStyleNames;
ScMyOUStringVec aAutoStyleNames;
const ScMyDefaultStyleList* pColDefaults;
public:
ScFormatRangeStyles();
~ScFormatRangeStyles();
void SetColDefaults(const ScMyDefaultStyleList* pDefaults) { pColDefaults = pDefaults; }
void AddNewTable(const sal_Int32 nTable);
bool AddStyleName(OUString* pString, sal_Int32& rIndex, const bool bIsAutoStyle = true);
sal_Int32 GetIndexOfStyleName(const OUString& rString, const OUString& rPrefix, bool& bIsAutoStyle);
// does not delete ranges
sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow,
bool& bIsAutoStyle) const;
// deletes not necessary ranges if wanted
sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nColumn, const sal_Int32 nRow,
bool& bIsAutoStyle, sal_Int32& nValidationIndex, sal_Int32& nNumberFormat, const sal_Int32 nRemoveBeforeRow);
void GetFormatRanges(const sal_Int32 nStartColumn, const sal_Int32 nEndColumn, const sal_Int32 nRow,
const sal_Int32 nTable, ScRowFormatRanges* pFormatRanges);
void AddRangeStyleName(const com::sun::star::table::CellRangeAddress aCellRangeAddress, const sal_Int32 nStringIndex,
const bool bIsAutoStyle, const sal_Int32 nValidationIndex, const sal_Int32 nNumberFormat);
OUString* GetStyleNameByIndex(const sal_Int32 nIndex, const bool bIsAutoStyle);
void Sort();
};
class ScColumnRowStylesBase
{
ScMyOUStringVec aStyleNames;
public:
ScColumnRowStylesBase();
virtual ~ScColumnRowStylesBase();
virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) = 0;
sal_Int32 AddStyleName(OUString* pString);
sal_Int32 GetIndexOfStyleName(const OUString& rString, const OUString& rPrefix);
virtual OUString* GetStyleName(const sal_Int32 nTable, const sal_Int32 nField) = 0;
OUString* GetStyleNameByIndex(const sal_Int32 nIndex);
};
struct ScColumnStyle
{
sal_Int32 nIndex;
bool bIsVisible;
ScColumnStyle() : nIndex(-1), bIsVisible(true) {}
};
class ScColumnStyles : public ScColumnRowStylesBase
{
typedef std::vector<ScColumnStyle> ScMyColumnStyleVec;
typedef std::vector<ScMyColumnStyleVec> ScMyColumnVectorVec;
ScMyColumnVectorVec aTables;
public:
ScColumnStyles();
virtual ~ScColumnStyles();
virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) SAL_OVERRIDE;
sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField,
bool& bIsVisible);
void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex, const bool bIsVisible);
virtual OUString* GetStyleName(const sal_Int32 nTable, const sal_Int32 nField) SAL_OVERRIDE;
};
class ScRowStyles : public ScColumnRowStylesBase
{
typedef ::mdds::flat_segment_tree<sal_Int32, sal_Int32> StylesType;
::boost::ptr_vector<StylesType> aTables;
struct Cache
{
sal_Int32 mnTable;
sal_Int32 mnStart;
sal_Int32 mnEnd;
sal_Int32 mnStyle;
Cache();
bool hasCache(sal_Int32 nTable, sal_Int32 nField) const;
};
Cache maCache;
public:
ScRowStyles();
virtual ~ScRowStyles();
virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields) SAL_OVERRIDE;
sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField);
void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex);
void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nStartField, const sal_Int32 nStringIndex, const sal_Int32 nEndField);
virtual OUString* GetStyleName(const sal_Int32 nTable, const sal_Int32 nField) SAL_OVERRIDE;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|