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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
/* -*- 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 .
*/
#pragma once
#include <xmloff/xmlimp.hxx>
#include <xmloff/xmlprmap.hxx>
#include "xmlsubti.hxx"
#include <formula/grammar.hxx>
#include <dociter.hxx>
#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
#include <com/sun/star/sheet/ValidationType.hpp>
#include <com/sun/star/sheet/ConditionOperator.hpp>
#include <memory>
#include <map>
#include <vector>
#include <list>
namespace com::sun::star::beans { class XPropertySet; }
namespace com::sun::star::sheet { class XSheetCellRangeContainer; }
namespace com::sun::star::table { struct CellRangeAddress; }
namespace com::sun::star::util { class XNumberFormatTypes; }
namespace com::sun::star::util { class XNumberFormats; }
namespace sax_fastparser { class FastAttributeList; }
class ScCompiler;
class ErrCode;
class ScMyStyleNumberFormats;
class XMLNumberFormatAttributesExportHelper;
class ScEditEngineDefaulter;
class ScDocumentImport;
class ScMyImpDetectiveOpArray;
class SdrPage;
namespace sc {
struct ImportPostProcessData;
struct PivotTableSources;
class ScDrawObjData;
}
class SvXMLTokenMap;
class XMLShapeImportHelper;
class ScXMLChangeTrackingImportHelper;
class SolarMutexGuard;
struct ScMyNamedExpression
{
OUString sName;
OUString sContent;
OUString sContentNmsp;
OUString sBaseCellAddress;
OUString sRangeType;
formula::FormulaGrammar::Grammar eGrammar;
bool bIsExpression;
};
typedef ::std::list<ScMyNamedExpression> ScMyNamedExpressions;
struct ScMyLabelRange
{
OUString sLabelRangeStr;
OUString sDataRangeStr;
bool bColumnOrientation;
};
typedef std::list<ScMyLabelRange> ScMyLabelRanges;
struct ScMyImportValidation
{
OUString sName;
OUString sInputTitle;
OUString sInputMessage;
OUString sErrorTitle;
OUString sErrorMessage;
OUString sFormula1;
OUString sFormula2;
OUString sFormulaNmsp1;
OUString sFormulaNmsp2;
OUString sBaseCellAddress; // string is used directly
css::sheet::ValidationAlertStyle aAlertStyle;
css::sheet::ValidationType aValidationType;
css::sheet::ConditionOperator aOperator;
formula::FormulaGrammar::Grammar eGrammar1;
formula::FormulaGrammar::Grammar eGrammar2;
sal_Int16 nShowList;
bool bShowErrorMessage;
bool bShowInputMessage;
bool bIgnoreBlanks;
};
typedef std::vector<ScMyImportValidation> ScMyImportValidations;
class ScMyStylesImportHelper;
class ScXMLEditAttributeMap;
class ScXMLImport: public SvXMLImport
{
ScXMLImport(const ScXMLImport&) = delete;
const ScXMLImport& operator=(const ScXMLImport&) = delete;
typedef ::std::map<SCTAB, ScMyNamedExpressions> SheetNamedExpMap;
ScDocument* pDoc;
std::unique_ptr<ScDocumentImport> mpDocImport;
std::unique_ptr<ScCompiler> mpComp; // For error-checking of cached string cell values.
std::unique_ptr<ScEditEngineDefaulter> mpEditEngine;
std::unique_ptr<sc::PivotTableSources> mpPivotSources;
mutable std::unique_ptr<ScXMLEditAttributeMap> mpEditAttrMap;
std::unique_ptr<ScXMLChangeTrackingImportHelper> pChangeTrackingImportHelper;
std::unique_ptr<ScMyStylesImportHelper> pStylesImportHelper;
rtl::Reference < XMLPropertyHandlerFactory > xScPropHdlFactory;
rtl::Reference < XMLPropertySetMapper > xCellStylesPropertySetMapper;
rtl::Reference < XMLPropertySetMapper > xColumnStylesPropertySetMapper;
rtl::Reference < XMLPropertySetMapper > xRowStylesPropertySetMapper;
rtl::Reference < XMLPropertySetMapper > xTableStylesPropertySetMapper;
sc::ImportPostProcessData* mpPostProcessData; /// Lift cycle managed elsewhere, no need to delete.
ScMyTables aTables;
std::vector<ScDocRowHeightUpdater::TabRanges> maRecalcRowRanges;
ScMyNamedExpressions m_aMyNamedExpressions;
SheetNamedExpMap m_SheetNamedExpressions;
ScMyLabelRanges maMyLabelRanges;
ScMyImportValidations maValidations;
std::unique_ptr<ScMyImpDetectiveOpArray> pDetectiveOpArray;
std::unique_ptr<SolarMutexGuard> pSolarMutexGuard;
std::unique_ptr<XMLNumberFormatAttributesExportHelper> pNumberFormatAttributesExportHelper;
std::unique_ptr<ScMyStyleNumberFormats> pStyleNumberFormats;
css::uno::Reference <css::util::XNumberFormats> xNumberFormats;
css::uno::Reference <css::util::XNumberFormatTypes> xNumberFormatTypes;
css::uno::Reference <css::sheet::XSheetCellRangeContainer> xSheetCellRanges;
OUString sPrevStyleName;
OUString sPrevCurrency;
sal_uInt32 nSolarMutexLocked;
sal_Int32 nProgressCount;
sal_Int16 nPrevCellType;
bool bLoadDoc; // Load doc or styles only
bool bNullDateSetted;
bool bSelfImportingXMLSet;
bool mbLockSolarMutex;
bool mbImportStyles;
bool mbHasNewCondFormatData;
protected:
// This method is called after the namespace map has been updated, but
// before a context for the current element has been pushed.
virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override;
virtual XMLShapeImportHelper* CreateShapeImport() override;
public:
ScXMLImport(
const css::uno::Reference< css::uno::XComponentContext >& rContext,
OUString const & implementationName, SvXMLImportFlags nImportFlag,
const css::uno::Sequence< OUString > & sSupportedServiceNames = {});
virtual ~ScXMLImport() noexcept override;
// XInitialization
virtual void SAL_CALL initialize( const css::uno::Sequence<css::uno::Any>& aArguments ) override;
// namespace office
// NB: in contrast to other CreateFooContexts, this particular one handles
// the root element (i.e. office:document-meta)
SvXMLImportContext *CreateMetaContext( sal_Int32 nElement );
SvXMLImportContext *CreateFontDeclsContext();
SvXMLImportContext *CreateScriptContext();
SvXMLImportContext *CreateStylesContext( bool bAutoStyles );
SvXMLImportContext *CreateBodyContext(
const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList );
virtual void SetStatistics( const css::uno::Sequence< css::beans::NamedValue> & i_rStats) override;
ScDocumentImport& GetDoc();
ScDocument* GetDocument() { return pDoc; }
const ScDocument* GetDocument() const { return pDoc; }
ScMyTables& GetTables() { return aTables; }
std::vector<ScDocRowHeightUpdater::TabRanges>& GetRecalcRowRanges() { return maRecalcRowRanges; }
bool IsStylesOnlyMode() const { return !bLoadDoc; }
static sal_Int16 GetCellType(const char* rStrValue, const sal_Int32 nStrLength);
const rtl::Reference < XMLPropertySetMapper >& GetCellStylesPropertySetMapper() const { return xCellStylesPropertySetMapper; }
const rtl::Reference < XMLPropertySetMapper >& GetColumnStylesPropertySetMapper() const { return xColumnStylesPropertySetMapper; }
const rtl::Reference < XMLPropertySetMapper >& GetRowStylesPropertySetMapper() const { return xRowStylesPropertySetMapper; }
const rtl::Reference < XMLPropertySetMapper >& GetTableStylesPropertySetMapper() const { return xTableStylesPropertySetMapper; }
void SetPostProcessData( sc::ImportPostProcessData* p );
sc::ImportPostProcessData* GetPostProcessData() { return mpPostProcessData;}
sc::PivotTableSources& GetPivotTableSources();
void AddNamedExpression(ScMyNamedExpression aMyNamedExpression)
{
m_aMyNamedExpressions.push_back(std::move(aMyNamedExpression));
}
void AddNamedExpression(SCTAB nTab, ScMyNamedExpression aNamedExp);
void AddLabelRange(ScMyLabelRange aMyLabelRange)
{
maMyLabelRanges.push_back(std::move(aMyLabelRange));
}
void AddValidation(const ScMyImportValidation& rValidation) { maValidations.push_back(rValidation); }
bool GetValidation(const OUString& sName, ScMyImportValidation& aValidation);
ScMyImpDetectiveOpArray* GetDetectiveOpArray();
ScXMLChangeTrackingImportHelper* GetChangeTrackingImportHelper();
void InsertStyles();
void SetChangeTrackingViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& rChangeProps);
virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps) override;
ScMyStylesImportHelper* GetStylesImportHelper() { return pStylesImportHelper.get(); }
sal_Int32 SetCurrencySymbol(const sal_Int32 nKey, std::u16string_view rCurrency);
bool IsCurrencySymbol(const sal_Int32 nNumberFormat, const OUString& sCurrencySymbol, std::u16string_view sBankSymbol);
void SetType(const css::uno::Reference <css::beans::XPropertySet>& rProperties,
sal_Int32& rNumberFormat,
const sal_Int16 nCellType,
std::u16string_view rCurrency);
void ProgressBarIncrement();
void SetNewCondFormatData() { mbHasNewCondFormatData = true; }
bool HasNewCondFormatData() const { return mbHasNewCondFormatData; }
private:
void SetStyleToRanges();
void ExamineDefaultStyle();
public:
void SetStyleToRanges(const ScRangeList& rRanges, const OUString* pStyleName,
const sal_Int16 nCellType, const OUString* pCurrency);
bool SetNullDateOnUnitConverter();
XMLNumberFormatAttributesExportHelper* GetNumberFormatAttributesExportHelper();
ScMyStyleNumberFormats* GetStyleNumberFormats();
void SetStylesToRangesFinished();
// XImporter
virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
virtual void SAL_CALL startDocument() override;
virtual void SAL_CALL endDocument() override;
virtual void DisposingModel() override;
/**
* Use this class to manage solar mutex locking instead of calling
* LockSolarMutex() and UnlockSolarMutex() directly.
*/
class MutexGuard
{
public:
explicit MutexGuard(ScXMLImport& rImport);
~MutexGuard();
private:
ScXMLImport& mrImport;
};
void LockSolarMutex();
void UnlockSolarMutex();
sal_Int32 GetByteOffset() const;
void SetRangeOverflowType(ErrCode nType);
static sal_Int32 GetRangeType(const OUString& sRangeType);
void SetNamedRanges();
void SetSheetNamedRanges();
void SetLabelRanges();
void SetStringRefSyntaxIfMissing();
/** Extracts the formula string, the formula grammar namespace URL, and a
grammar enum value from the passed formula attribute value.
@param rFormula
(out-parameter) Returns the plain formula string with the leading
equality sign if existing.
@param rFormulaNmsp
(out-parameter) Returns the URL of the formula grammar namespace if
the attribute value contains the prefix of an unknown namespace.
@param reGrammar
(out-parameter) Returns the exact formula grammar if the formula
is in a supported ODF format (e.g. FormulaGrammar::GRAM_PODF for
ODF 1.0/1.1 formulas, or FormulaGrammar::GRAM_ODFF for ODF 1.2
formulas a.k.a. OpenFormula). Returns the default storage grammar,
if the attribute value does not contain a namespace prefix. Returns
the special value FormulaGrammar::GRAM_EXTERNAL, if an unknown
namespace could be extracted from the formula which will be
contained in the parameter rFormulaNmsp then.
@param rAttrValue
The value of the processed formula attribute.
@param bRestrictToExternalNmsp
If set to true, only namespaces of external formula grammars will
be recognized. Internal namespace prefixes (e.g. 'oooc:' or 'of:'
will be considered to be part of the formula, e.g. an expression
with range operator.
*/
void ExtractFormulaNamespaceGrammar(
OUString& rFormula,
OUString& rFormulaNmsp,
::formula::FormulaGrammar::Grammar& reGrammar,
const OUString& rAttrValue,
bool bRestrictToExternalNmsp = false ) const;
FormulaError GetFormulaErrorConstant( const OUString& rStr ) const;
ScEditEngineDefaulter* GetEditEngine();
const ScXMLEditAttributeMap& GetEditAttributeMap() const;
virtual void NotifyContainsEmbeddedFont() override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|