Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / xml / xmldpimp.hxx
blob31bd37690efb47f755562e66290f9a33a273ff66
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SC_SOURCE_FILTER_XML_XMLDPIMP_HXX
20 #define INCLUDED_SC_SOURCE_FILTER_XML_XMLDPIMP_HXX
22 #include <memory>
23 #include <xmloff/xmltoken.hxx>
25 #include <dpsave.hxx>
26 #include <queryparam.hxx>
27 #include "importcontext.hxx"
29 #include <unordered_map>
31 namespace com { namespace sun { namespace star { namespace sheet { struct DataPilotFieldAutoShowInfo; } } } }
32 namespace com { namespace sun { namespace star { namespace sheet { struct DataPilotFieldLayoutInfo; } } } }
33 namespace com { namespace sun { namespace star { namespace sheet { struct DataPilotFieldReference; } } } }
34 namespace com { namespace sun { namespace star { namespace sheet { struct DataPilotFieldSortInfo; } } } }
35 namespace sax_fastparser { class FastAttributeList; }
37 class ScDPSaveNumGroupDimension;
38 class ScDPSaveGroupDimension;
39 class ScDPObject;
41 enum ScMySourceType
43 SQL,
44 TABLE,
45 QUERY,
46 SERVICE,
47 CELLRANGE
50 class ScXMLDataPilotTablesContext : public ScXMLImportContext
52 public:
54 ScXMLDataPilotTablesContext( ScXMLImport& rImport);
56 virtual ~ScXMLDataPilotTablesContext() override;
58 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
59 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
62 class ScXMLDataPilotTableContext : public ScXMLImportContext
64 typedef std::unordered_map<OUString, OUString> SelectedPagesType;
66 struct GrandTotalItem
68 OUString maDisplayName;
69 bool mbVisible;
70 GrandTotalItem();
72 ScDocument* pDoc;
73 std::unique_ptr<ScDPSaveData> pDPSave;
74 std::unique_ptr<ScDPDimensionSaveData> pDPDimSaveData;
75 GrandTotalItem maRowGrandTotal;
76 GrandTotalItem maColGrandTotal;
77 OUString sDataPilotTableName;
78 OUString sApplicationData;
79 OUString sDatabaseName;
80 OUString sSourceObject;
81 OUString sServiceName;
82 OUString sServiceSourceName;
83 OUString sServiceSourceObject;
84 OUString sServiceUsername;
85 OUString sServicePassword;
86 OUString sButtons;
87 OUString sSourceRangeName;
88 ScRange aSourceCellRangeAddress;
89 ScRange aTargetRangeAddress;
90 ScQueryParam aSourceQueryParam;
91 ScMySourceType nSourceType;
92 sal_uInt32 mnRowFieldCount;
93 sal_uInt32 mnColFieldCount;
94 sal_uInt32 mnPageFieldCount;
95 sal_uInt32 mnDataFieldCount;
96 css::sheet::DataPilotFieldOrientation
97 mnDataLayoutType;
98 bool bIsNative:1;
99 bool bIgnoreEmptyRows:1;
100 bool bIdentifyCategories:1;
101 bool bTargetRangeAddress:1;
102 bool bSourceCellRange:1;
103 bool bShowFilter:1;
104 bool bDrillDown:1;
105 bool bHeaderGridLayout:1;
107 SelectedPagesType maSelectedPages;
109 public:
111 ScXMLDataPilotTableContext( ScXMLImport& rImport,
112 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList );
114 virtual ~ScXMLDataPilotTableContext() override;
116 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
117 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
119 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
121 void SetGrandTotal(::xmloff::token::XMLTokenEnum eOrientation, bool bVisible, const OUString& rDisplayName);
122 void SetDatabaseName(const OUString& sValue) { sDatabaseName = sValue; }
123 void SetSourceObject(const OUString& sValue) { sSourceObject = sValue; }
124 void SetNative(bool bValue) { bIsNative = bValue; }
125 void SetServiceName(const OUString& sValue) { sServiceName = sValue; }
126 void SetServiceSourceName(const OUString& sValue) { sServiceSourceName = sValue; }
127 void SetServiceSourceObject(const OUString& sValue) { sServiceSourceObject = sValue; }
128 void SetServiceUsername(const OUString& sValue) { sServiceUsername = sValue; }
129 void SetServicePassword(const OUString& sValue) { sServicePassword = sValue; }
130 void SetSourceRangeName(const OUString& sValue) { sSourceRangeName = sValue; bSourceCellRange = true; }
131 void SetSourceCellRangeAddress(const ScRange& aValue) { aSourceCellRangeAddress = aValue; bSourceCellRange = true; }
132 void SetSourceQueryParam(const ScQueryParam& aValue) { aSourceQueryParam = aValue; }
133 void AddDimension(ScDPSaveDimension* pDim);
134 void AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim);
135 void AddGroupDim(const ScDPSaveGroupDimension& aGroupDim);
136 void SetButtons(ScDPObject* pDPObject);
137 void SetSelectedPage( const OUString& rDimName, const OUString& rSelected );
140 class ScXMLDPSourceSQLContext : public ScXMLImportContext
142 public:
144 ScXMLDPSourceSQLContext( ScXMLImport& rImport,
145 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
146 ScXMLDataPilotTableContext* pDataPilotTable);
148 virtual ~ScXMLDPSourceSQLContext() override;
151 class ScXMLDPSourceTableContext : public ScXMLImportContext
153 public:
155 ScXMLDPSourceTableContext( ScXMLImport& rImport,
156 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
157 ScXMLDataPilotTableContext* pDataPilotTable);
159 virtual ~ScXMLDPSourceTableContext() override;
162 class ScXMLDPSourceQueryContext : public ScXMLImportContext
164 public:
166 ScXMLDPSourceQueryContext( ScXMLImport& rImport,
167 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
168 ScXMLDataPilotTableContext* pDataPilotTable);
170 virtual ~ScXMLDPSourceQueryContext() override;
173 class ScXMLSourceServiceContext : public ScXMLImportContext
175 public:
177 ScXMLSourceServiceContext( ScXMLImport& rImport,
178 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
179 ScXMLDataPilotTableContext* pDataPilotTable);
181 virtual ~ScXMLSourceServiceContext() override;
184 class ScXMLDataPilotGrandTotalContext : public ScXMLImportContext
186 enum Orientation { COLUMN, ROW, BOTH, NONE };
188 ScXMLDataPilotTableContext* mpTableContext;
189 OUString maDisplayName;
190 Orientation meOrientation;
191 bool mbVisible;
193 public:
194 ScXMLDataPilotGrandTotalContext(
195 ScXMLImport& rImport,
196 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
197 ScXMLDataPilotTableContext* pTableContext );
199 virtual ~ScXMLDataPilotGrandTotalContext() override;
201 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
204 class ScXMLSourceCellRangeContext : public ScXMLImportContext
206 ScXMLDataPilotTableContext* pDataPilotTable;
208 public:
210 ScXMLSourceCellRangeContext( ScXMLImport& rImport,
211 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
212 ScXMLDataPilotTableContext* pDataPilotTable);
214 virtual ~ScXMLSourceCellRangeContext() override;
216 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
217 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
220 struct ScXMLDataPilotGroup
222 ::std::vector<OUString> aMembers;
223 OUString aName;
226 class ScXMLDataPilotFieldContext : public ScXMLImportContext
228 ScXMLDataPilotTableContext* pDataPilotTable;
229 std::unique_ptr<ScDPSaveDimension> xDim;
231 ::std::vector<ScXMLDataPilotGroup> aGroups;
232 OUString sGroupSource;
233 OUString sSelectedPage;
234 OUString sName;
235 double fStart;
236 double fEnd;
237 double fStep;
238 sal_Int32 nUsedHierarchy;
239 sal_Int32 nGroupPart;
240 ScGeneralFunction nFunction;
241 css::sheet::DataPilotFieldOrientation
242 nOrientation;
243 bool bSelectedPage:1;
244 bool bIsGroupField:1;
245 bool bDateValue:1;
246 bool bAutoStart:1;
247 bool bAutoEnd:1;
248 bool mbHasHiddenMember:1; // TODO: import to document core
250 public:
252 ScXMLDataPilotFieldContext( ScXMLImport& rImport,
253 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
254 ScXMLDataPilotTableContext* pDataPilotTable);
256 virtual ~ScXMLDataPilotFieldContext() override;
258 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
259 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
261 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
263 void SetShowEmpty(const bool bValue) { if (xDim) xDim->SetShowEmpty(bValue); }
264 void SetRepeatItemLabels(const bool bSet) { if (xDim) xDim->SetRepeatItemLabels(bSet); }
265 void SetSubTotals(std::vector<ScGeneralFunction> const & rFunctions) { if (xDim) xDim->SetSubTotals(rFunctions); }
266 void AddMember(std::unique_ptr<ScDPSaveMember> pMember);
267 void SetSubTotalName(const OUString& rName);
268 void SetFieldReference(const css::sheet::DataPilotFieldReference& aRef) { if (xDim) xDim->SetReferenceValue(&aRef); }
269 void SetAutoShowInfo(const css::sheet::DataPilotFieldAutoShowInfo& aInfo) { if (xDim) xDim->SetAutoShowInfo(&aInfo); }
270 void SetSortInfo(const css::sheet::DataPilotFieldSortInfo& aInfo) { if (xDim) xDim->SetSortInfo(&aInfo); }
271 void SetLayoutInfo(const css::sheet::DataPilotFieldLayoutInfo& aInfo) { if (xDim) xDim->SetLayoutInfo(&aInfo); }
272 void SetGrouping(const OUString& rGroupSource, const double& rStart, const double& rEnd, const double& rStep,
273 sal_Int32 nPart, bool bDate, bool bAutoSt, bool bAutoE)
275 bIsGroupField = true;
276 sGroupSource = rGroupSource;
277 fStart = rStart;
278 fEnd = rEnd;
279 fStep = rStep;
280 nGroupPart = nPart;
281 bDateValue = bDate;
282 bAutoStart = bAutoSt;
283 bAutoEnd = bAutoE;
285 void AddGroup(const ::std::vector<OUString>& rMembers, const OUString& rName);
288 class ScXMLDataPilotFieldReferenceContext : public ScXMLImportContext
290 public:
292 ScXMLDataPilotFieldReferenceContext( ScXMLImport& rImport,
293 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
294 ScXMLDataPilotFieldContext* pDataPilotField);
296 virtual ~ScXMLDataPilotFieldReferenceContext() override;
299 class ScXMLDataPilotLevelContext : public ScXMLImportContext
301 ScXMLDataPilotFieldContext* pDataPilotField;
303 public:
305 ScXMLDataPilotLevelContext( ScXMLImport& rImport,
306 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
307 ScXMLDataPilotFieldContext* pDataPilotField);
309 virtual ~ScXMLDataPilotLevelContext() override;
311 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
312 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
315 class ScXMLDataPilotDisplayInfoContext : public ScXMLImportContext
317 public:
319 ScXMLDataPilotDisplayInfoContext( ScXMLImport& rImport,
320 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
321 ScXMLDataPilotFieldContext* pDataPilotField);
323 virtual ~ScXMLDataPilotDisplayInfoContext() override;
326 class ScXMLDataPilotSortInfoContext : public ScXMLImportContext
328 public:
330 ScXMLDataPilotSortInfoContext( ScXMLImport& rImport,
331 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
332 ScXMLDataPilotFieldContext* pDataPilotField);
334 virtual ~ScXMLDataPilotSortInfoContext() override;
337 class ScXMLDataPilotLayoutInfoContext : public ScXMLImportContext
339 public:
341 ScXMLDataPilotLayoutInfoContext( ScXMLImport& rImport,
342 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
343 ScXMLDataPilotFieldContext* pDataPilotField);
345 virtual ~ScXMLDataPilotLayoutInfoContext() override;
348 class ScXMLDataPilotSubTotalsContext : public ScXMLImportContext
350 ScXMLDataPilotFieldContext* pDataPilotField;
352 std::vector<ScGeneralFunction> maFunctions;
353 OUString maDisplayName;
355 public:
356 ScXMLDataPilotSubTotalsContext( ScXMLImport& rImport,
357 ScXMLDataPilotFieldContext* pDataPilotField);
359 virtual ~ScXMLDataPilotSubTotalsContext() override;
361 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
362 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
364 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
365 void AddFunction(ScGeneralFunction nFunction);
366 void SetDisplayName(const OUString& rName);
369 class ScXMLDataPilotSubTotalContext : public ScXMLImportContext
371 public:
373 ScXMLDataPilotSubTotalContext( ScXMLImport& rImport,
374 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
375 ScXMLDataPilotSubTotalsContext* pDataPilotSubTotals);
377 virtual ~ScXMLDataPilotSubTotalContext() override;
380 class ScXMLDataPilotMembersContext : public ScXMLImportContext
382 ScXMLDataPilotFieldContext* const pDataPilotField;
384 public:
386 ScXMLDataPilotMembersContext( ScXMLImport& rImport,
387 ScXMLDataPilotFieldContext* pDataPilotField);
389 virtual ~ScXMLDataPilotMembersContext() override;
391 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
392 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
395 class ScXMLDataPilotMemberContext : public ScXMLImportContext
397 ScXMLDataPilotFieldContext* pDataPilotField;
399 OUString sName;
400 OUString maDisplayName;
401 bool bDisplay;
402 bool bDisplayDetails;
403 bool bHasName;
405 public:
407 ScXMLDataPilotMemberContext( ScXMLImport& rImport,
408 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
409 ScXMLDataPilotFieldContext* pDataPilotField);
411 virtual ~ScXMLDataPilotMemberContext() override;
413 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
416 class ScXMLDataPilotGroupsContext : public ScXMLImportContext
418 ScXMLDataPilotFieldContext* pDataPilotField;
420 public:
422 ScXMLDataPilotGroupsContext( ScXMLImport& rImport,
423 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
424 ScXMLDataPilotFieldContext* pDataPilotField);
426 virtual ~ScXMLDataPilotGroupsContext() override;
428 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
429 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
432 class ScXMLDataPilotGroupContext : public ScXMLImportContext
434 ScXMLDataPilotFieldContext* pDataPilotField;
436 OUString sName;
437 ::std::vector<OUString> aMembers;
439 public:
441 ScXMLDataPilotGroupContext( ScXMLImport& rImport,
442 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
443 ScXMLDataPilotFieldContext* pDataPilotField);
445 virtual ~ScXMLDataPilotGroupContext() override;
447 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
448 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
450 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
452 void AddMember(const OUString& sMember) { aMembers.push_back(sMember); }
455 class ScXMLDataPilotGroupMemberContext : public ScXMLImportContext
457 ScXMLDataPilotGroupContext* pDataPilotGroup;
458 OUString sName;
460 public:
462 ScXMLDataPilotGroupMemberContext( ScXMLImport& rImport,
463 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
464 ScXMLDataPilotGroupContext* pDataPilotGroup);
466 virtual ~ScXMLDataPilotGroupMemberContext() override;
468 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
471 #endif
473 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */