Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / xml / xmldpimp.hxx
bloba7d5f607f420098fcc01d46648c03b3c1458c4e4
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 #pragma once
21 #include <memory>
22 #include <xmloff/xmltoken.hxx>
24 #include <dpsave.hxx>
25 #include <queryparam.hxx>
26 #include "importcontext.hxx"
28 #include <unordered_map>
30 namespace com::sun::star::sheet { struct DataPilotFieldAutoShowInfo; }
31 namespace com::sun::star::sheet { struct DataPilotFieldLayoutInfo; }
32 namespace com::sun::star::sheet { struct DataPilotFieldReference; }
33 namespace com::sun::star::sheet { struct DataPilotFieldSortInfo; }
34 namespace sax_fastparser { class FastAttributeList; }
36 class ScDPSaveNumGroupDimension;
37 class ScDPSaveGroupDimension;
38 class ScDPObject;
40 enum ScMySourceType
42 SQL,
43 TABLE,
44 QUERY,
45 SERVICE,
46 CELLRANGE
49 class ScXMLDataPilotTablesContext : public ScXMLImportContext
51 public:
53 ScXMLDataPilotTablesContext( ScXMLImport& rImport);
55 virtual ~ScXMLDataPilotTablesContext() override;
57 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
58 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
61 class ScXMLDataPilotTableContext : public ScXMLImportContext
63 typedef std::unordered_map<OUString, OUString> SelectedPagesType;
65 struct GrandTotalItem
67 OUString maDisplayName;
68 bool mbVisible;
69 GrandTotalItem();
71 ScDocument* pDoc;
72 std::unique_ptr<ScDPSaveData> pDPSave;
73 std::unique_ptr<ScDPDimensionSaveData> pDPDimSaveData;
74 GrandTotalItem maRowGrandTotal;
75 GrandTotalItem maColGrandTotal;
76 OUString sDataPilotTableName;
77 OUString sApplicationData;
78 OUString sDatabaseName;
79 OUString sSourceObject;
80 OUString sServiceName;
81 OUString sServiceSourceName;
82 OUString sServiceSourceObject;
83 OUString sServiceUsername;
84 OUString sServicePassword;
85 OUString sButtons;
86 OUString sSourceRangeName;
87 ScRange aSourceCellRangeAddress;
88 ScRange aTargetRangeAddress;
89 ScQueryParam aSourceQueryParam;
90 ScMySourceType nSourceType;
91 sal_uInt32 mnRowFieldCount;
92 sal_uInt32 mnColFieldCount;
93 sal_uInt32 mnPageFieldCount;
94 sal_uInt32 mnDataFieldCount;
95 css::sheet::DataPilotFieldOrientation
96 mnDataLayoutType;
97 bool bIsNative:1;
98 bool bIgnoreEmptyRows:1;
99 bool bIdentifyCategories:1;
100 bool bTargetRangeAddress:1;
101 bool bSourceCellRange:1;
102 bool bShowFilter:1;
103 bool bDrillDown:1;
104 bool bHeaderGridLayout:1;
106 SelectedPagesType maSelectedPages;
108 public:
110 ScXMLDataPilotTableContext( ScXMLImport& rImport,
111 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList );
113 virtual ~ScXMLDataPilotTableContext() override;
115 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
116 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
118 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
120 void SetGrandTotal(::xmloff::token::XMLTokenEnum eOrientation, bool bVisible, const OUString& rDisplayName);
121 void SetDatabaseName(const OUString& sValue) { sDatabaseName = sValue; }
122 void SetSourceObject(const OUString& sValue) { sSourceObject = sValue; }
123 void SetNative(bool bValue) { bIsNative = bValue; }
124 void SetServiceName(const OUString& sValue) { sServiceName = sValue; }
125 void SetServiceSourceName(const OUString& sValue) { sServiceSourceName = sValue; }
126 void SetServiceSourceObject(const OUString& sValue) { sServiceSourceObject = sValue; }
127 void SetServiceUsername(const OUString& sValue) { sServiceUsername = sValue; }
128 void SetServicePassword(const OUString& sValue) { sServicePassword = sValue; }
129 void SetSourceRangeName(const OUString& sValue) { sSourceRangeName = sValue; bSourceCellRange = true; }
130 void SetSourceCellRangeAddress(const ScRange& aValue) { aSourceCellRangeAddress = aValue; bSourceCellRange = true; }
131 void SetSourceQueryParam(const ScQueryParam& aValue) { aSourceQueryParam = aValue; }
132 void AddDimension(ScDPSaveDimension* pDim);
133 void AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim);
134 void AddGroupDim(const ScDPSaveGroupDimension& aGroupDim);
135 void SetButtons(ScDPObject* pDPObject);
136 void SetSelectedPage( const OUString& rDimName, const OUString& rSelected );
139 class ScXMLDPSourceSQLContext : public ScXMLImportContext
141 public:
143 ScXMLDPSourceSQLContext( ScXMLImport& rImport,
144 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
145 ScXMLDataPilotTableContext* pDataPilotTable);
147 virtual ~ScXMLDPSourceSQLContext() override;
150 class ScXMLDPSourceTableContext : public ScXMLImportContext
152 public:
154 ScXMLDPSourceTableContext( ScXMLImport& rImport,
155 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
156 ScXMLDataPilotTableContext* pDataPilotTable);
158 virtual ~ScXMLDPSourceTableContext() override;
161 class ScXMLDPSourceQueryContext : public ScXMLImportContext
163 public:
165 ScXMLDPSourceQueryContext( ScXMLImport& rImport,
166 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
167 ScXMLDataPilotTableContext* pDataPilotTable);
169 virtual ~ScXMLDPSourceQueryContext() override;
172 class ScXMLSourceServiceContext : public ScXMLImportContext
174 public:
176 ScXMLSourceServiceContext( ScXMLImport& rImport,
177 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
178 ScXMLDataPilotTableContext* pDataPilotTable);
180 virtual ~ScXMLSourceServiceContext() override;
183 class ScXMLDataPilotGrandTotalContext : public ScXMLImportContext
185 enum Orientation { COLUMN, ROW, BOTH, NONE };
187 ScXMLDataPilotTableContext* mpTableContext;
188 OUString maDisplayName;
189 Orientation meOrientation;
190 bool mbVisible;
192 public:
193 ScXMLDataPilotGrandTotalContext(
194 ScXMLImport& rImport,
195 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
196 ScXMLDataPilotTableContext* pTableContext );
198 virtual ~ScXMLDataPilotGrandTotalContext() override;
200 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
203 class ScXMLSourceCellRangeContext : public ScXMLImportContext
205 ScXMLDataPilotTableContext* pDataPilotTable;
207 public:
209 ScXMLSourceCellRangeContext( ScXMLImport& rImport,
210 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
211 ScXMLDataPilotTableContext* pDataPilotTable);
213 virtual ~ScXMLSourceCellRangeContext() override;
215 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
216 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
219 struct ScXMLDataPilotGroup
221 ::std::vector<OUString> aMembers;
222 OUString aName;
225 class ScXMLDataPilotFieldContext : public ScXMLImportContext
227 ScXMLDataPilotTableContext* pDataPilotTable;
228 std::unique_ptr<ScDPSaveDimension> xDim;
230 ::std::vector<ScXMLDataPilotGroup> aGroups;
231 OUString sGroupSource;
232 OUString sSelectedPage;
233 OUString sName;
234 double fStart;
235 double fEnd;
236 double fStep;
237 sal_Int32 nUsedHierarchy;
238 sal_Int32 nGroupPart;
239 ScGeneralFunction nFunction;
240 css::sheet::DataPilotFieldOrientation
241 nOrientation;
242 bool bSelectedPage:1;
243 bool bIsGroupField:1;
244 bool bDateValue:1;
245 bool bAutoStart:1;
246 bool bAutoEnd:1;
247 bool mbHasHiddenMember:1; // TODO: import to document core
249 public:
251 ScXMLDataPilotFieldContext( ScXMLImport& rImport,
252 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
253 ScXMLDataPilotTableContext* pDataPilotTable);
255 virtual ~ScXMLDataPilotFieldContext() override;
257 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
258 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
260 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
262 void SetShowEmpty(const bool bValue) { if (xDim) xDim->SetShowEmpty(bValue); }
263 void SetRepeatItemLabels(const bool bSet) { if (xDim) xDim->SetRepeatItemLabels(bSet); }
264 void SetSubTotals(std::vector<ScGeneralFunction> && rFunctions) { if (xDim) xDim->SetSubTotals(std::move(rFunctions)); }
265 void AddMember(std::unique_ptr<ScDPSaveMember> pMember);
266 void SetSubTotalName(const OUString& rName);
267 void SetFieldReference(const css::sheet::DataPilotFieldReference& aRef) { if (xDim) xDim->SetReferenceValue(&aRef); }
268 void SetAutoShowInfo(const css::sheet::DataPilotFieldAutoShowInfo& aInfo) { if (xDim) xDim->SetAutoShowInfo(&aInfo); }
269 void SetSortInfo(const css::sheet::DataPilotFieldSortInfo& aInfo) { if (xDim) xDim->SetSortInfo(&aInfo); }
270 void SetLayoutInfo(const css::sheet::DataPilotFieldLayoutInfo& aInfo) { if (xDim) xDim->SetLayoutInfo(&aInfo); }
271 void SetGrouping(const OUString& rGroupSource, const double& rStart, const double& rEnd, const double& rStep,
272 sal_Int32 nPart, bool bDate, bool bAutoSt, bool bAutoE)
274 bIsGroupField = true;
275 sGroupSource = rGroupSource;
276 fStart = rStart;
277 fEnd = rEnd;
278 fStep = rStep;
279 nGroupPart = nPart;
280 bDateValue = bDate;
281 bAutoStart = bAutoSt;
282 bAutoEnd = bAutoE;
284 void AddGroup(::std::vector<OUString>&& rMembers, const OUString& rName);
287 class ScXMLDataPilotFieldReferenceContext : public ScXMLImportContext
289 public:
291 ScXMLDataPilotFieldReferenceContext( ScXMLImport& rImport,
292 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
293 ScXMLDataPilotFieldContext* pDataPilotField);
295 virtual ~ScXMLDataPilotFieldReferenceContext() override;
298 class ScXMLDataPilotLevelContext : public ScXMLImportContext
300 ScXMLDataPilotFieldContext* pDataPilotField;
302 public:
304 ScXMLDataPilotLevelContext( ScXMLImport& rImport,
305 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
306 ScXMLDataPilotFieldContext* pDataPilotField);
308 virtual ~ScXMLDataPilotLevelContext() override;
310 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
311 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
314 class ScXMLDataPilotDisplayInfoContext : public ScXMLImportContext
316 public:
318 ScXMLDataPilotDisplayInfoContext( ScXMLImport& rImport,
319 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
320 ScXMLDataPilotFieldContext* pDataPilotField);
322 virtual ~ScXMLDataPilotDisplayInfoContext() override;
325 class ScXMLDataPilotSortInfoContext : public ScXMLImportContext
327 public:
329 ScXMLDataPilotSortInfoContext( ScXMLImport& rImport,
330 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
331 ScXMLDataPilotFieldContext* pDataPilotField);
333 virtual ~ScXMLDataPilotSortInfoContext() override;
336 class ScXMLDataPilotLayoutInfoContext : public ScXMLImportContext
338 public:
340 ScXMLDataPilotLayoutInfoContext( ScXMLImport& rImport,
341 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
342 ScXMLDataPilotFieldContext* pDataPilotField);
344 virtual ~ScXMLDataPilotLayoutInfoContext() override;
347 class ScXMLDataPilotSubTotalsContext : public ScXMLImportContext
349 ScXMLDataPilotFieldContext* pDataPilotField;
351 std::vector<ScGeneralFunction> maFunctions;
352 OUString maDisplayName;
354 public:
355 ScXMLDataPilotSubTotalsContext( ScXMLImport& rImport,
356 ScXMLDataPilotFieldContext* pDataPilotField);
358 virtual ~ScXMLDataPilotSubTotalsContext() override;
360 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
361 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
363 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
364 void AddFunction(ScGeneralFunction nFunction);
365 void SetDisplayName(const OUString& rName);
368 class ScXMLDataPilotSubTotalContext : public ScXMLImportContext
370 public:
372 ScXMLDataPilotSubTotalContext( ScXMLImport& rImport,
373 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
374 ScXMLDataPilotSubTotalsContext* pDataPilotSubTotals);
376 virtual ~ScXMLDataPilotSubTotalContext() override;
379 class ScXMLDataPilotMembersContext : public ScXMLImportContext
381 ScXMLDataPilotFieldContext* pDataPilotField;
383 public:
385 ScXMLDataPilotMembersContext( ScXMLImport& rImport,
386 ScXMLDataPilotFieldContext* pDataPilotField);
388 virtual ~ScXMLDataPilotMembersContext() override;
390 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
391 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
394 class ScXMLDataPilotMemberContext : public ScXMLImportContext
396 ScXMLDataPilotFieldContext* pDataPilotField;
398 OUString sName;
399 OUString maDisplayName;
400 bool bDisplay;
401 bool bDisplayDetails;
402 bool bHasName;
404 public:
406 ScXMLDataPilotMemberContext( ScXMLImport& rImport,
407 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
408 ScXMLDataPilotFieldContext* pDataPilotField);
410 virtual ~ScXMLDataPilotMemberContext() override;
412 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
415 class ScXMLDataPilotGroupsContext : public ScXMLImportContext
417 ScXMLDataPilotFieldContext* pDataPilotField;
419 public:
421 ScXMLDataPilotGroupsContext( ScXMLImport& rImport,
422 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
423 ScXMLDataPilotFieldContext* pDataPilotField);
425 virtual ~ScXMLDataPilotGroupsContext() override;
427 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
428 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
431 class ScXMLDataPilotGroupContext : public ScXMLImportContext
433 ScXMLDataPilotFieldContext* pDataPilotField;
435 OUString sName;
436 ::std::vector<OUString> aMembers;
438 public:
440 ScXMLDataPilotGroupContext( ScXMLImport& rImport,
441 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
442 ScXMLDataPilotFieldContext* pDataPilotField);
444 virtual ~ScXMLDataPilotGroupContext() override;
446 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
447 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
449 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
451 void AddMember(const OUString& sMember) { aMembers.push_back(sMember); }
454 class ScXMLDataPilotGroupMemberContext : public ScXMLImportContext
456 ScXMLDataPilotGroupContext* pDataPilotGroup;
457 OUString sName;
459 public:
461 ScXMLDataPilotGroupMemberContext( ScXMLImport& rImport,
462 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
463 ScXMLDataPilotGroupContext* pDataPilotGroup);
465 virtual ~ScXMLDataPilotGroupMemberContext() override;
467 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
470 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */