1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <com/sun/star/sheet/DataImportMode.hpp>
22 #include <com/sun/star/sheet/SubTotalColumn.hpp>
23 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include "importcontext.hxx"
30 namespace sax_fastparser
{ class FastAttributeList
; }
34 class ScXMLDatabaseRangesContext
: public ScXMLImportContext
38 ScXMLDatabaseRangesContext( ScXMLImport
& rImport
);
40 virtual ~ScXMLDatabaseRangesContext() override
;
42 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
44 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
49 sal_Int16 nSubTotalRuleGroupFieldNumber
;
50 css::uno::Sequence
<css::sheet::SubTotalColumn
> aSubTotalColumns
;
53 class ScXMLDatabaseRangeContext
: public ScXMLImportContext
55 std::unique_ptr
<ScQueryParam
> mpQueryParam
;
57 OUString sDatabaseRangeName
;
58 OUString sConnectionResource
;
59 OUString sDatabaseName
;
60 OUString sSourceObject
;
61 css::uno::Sequence
<css::beans::PropertyValue
> aSortSequence
;
62 std::vector
< ScSubTotalRule
> aSubTotalRules
;
63 ScRange aFilterConditionSourceRangeAddress
;
64 css::sheet::DataImportMode nSourceType
;
66 sal_Int16 nSubTotalsUserListIndex
;
69 bool bContainsSubTotal
;
71 bool bIsSelection
; // TODO: import to document core
76 bool bSubTotalsBindFormatsToContent
;
77 bool bSubTotalsIsCaseSensitive
;
78 bool bSubTotalsInsertPageBreaks
;
79 bool bSubTotalsSummaryBelow
;
80 bool bSubTotalsSortGroups
;
81 bool bSubTotalsEnabledUserList
;
82 bool bSubTotalsAscending
;
83 bool bFilterConditionSourceRange
;
85 bool bHasFooter
; // UNO TotalsRow, ODF contains-footer
87 ScDBCollection::RangeType meRangeType
;
89 std::unique_ptr
<ScDBData
> ConvertToDBData(const OUString
& rName
);
93 ScXMLDatabaseRangeContext( ScXMLImport
& rImport
,
94 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
);
96 virtual ~ScXMLDatabaseRangeContext() override
;
98 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
99 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
101 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
103 void SetDatabaseName(const OUString
& sTempDatabaseName
) { sDatabaseName
= sTempDatabaseName
; }
104 void SetConnectionResource(const OUString
& sTempConRes
) { sConnectionResource
= sTempConRes
; }
105 void SetSourceObject(const OUString
& sTempSourceObject
) { sSourceObject
= sTempSourceObject
; }
106 void SetSourceType(const css::sheet::DataImportMode nTempSourceType
) { nSourceType
= nTempSourceType
; }
107 void SetNative(const bool bTempNative
) { bNative
= bTempNative
; }
108 void SetSubTotalsBindFormatsToContent(const bool bTemp
) { bSubTotalsBindFormatsToContent
= bTemp
; }
109 void SetSubTotalsIsCaseSensitive(const bool bTemp
) { bSubTotalsIsCaseSensitive
= bTemp
; }
110 void SetSubTotalsInsertPageBreaks(const bool bTemp
) { bSubTotalsInsertPageBreaks
= bTemp
; }
111 void SetSubTotalsSummaryBelow(const bool bTemp
) { bSubTotalsSummaryBelow
= bTemp
; }
112 void SetSubTotalsEnabledUserList(const bool bTemp
) { bSubTotalsEnabledUserList
= bTemp
; }
113 void SetSubTotalsUserListIndex(const sal_Int16 nTemp
) { nSubTotalsUserListIndex
= nTemp
; }
114 void SetSubTotalsAscending(const bool bTemp
) { bSubTotalsAscending
= bTemp
; }
115 void SetSubTotalsSortGroups(const bool bTemp
) { bSubTotalsSortGroups
= bTemp
; }
116 void AddSubTotalRule(const ScSubTotalRule
& rRule
) { aSubTotalRules
.push_back(rRule
); }
117 void SetSortSequence(const css::uno::Sequence
<css::beans::PropertyValue
>& aTempSortSequence
) { aSortSequence
= aTempSortSequence
; }
118 void SetFilterConditionSourceRangeAddress(const ScRange
& aRange
) { aFilterConditionSourceRangeAddress
= aRange
;
119 bFilterConditionSourceRange
= true; }
122 class ScXMLSourceSQLContext
: public ScXMLImportContext
124 ScXMLDatabaseRangeContext
* pDatabaseRangeContext
;
129 ScXMLSourceSQLContext( ScXMLImport
& rImport
,
130 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
131 ScXMLDatabaseRangeContext
* pTempDatabaseRangeContext
);
133 virtual ~ScXMLSourceSQLContext() override
;
135 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
136 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
138 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
141 class ScXMLSourceTableContext
: public ScXMLImportContext
143 ScXMLDatabaseRangeContext
* pDatabaseRangeContext
;
148 ScXMLSourceTableContext( ScXMLImport
& rImport
,
149 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
150 ScXMLDatabaseRangeContext
* pTempDatabaseRangeContext
);
152 virtual ~ScXMLSourceTableContext() override
;
154 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
155 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
157 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
160 class ScXMLSourceQueryContext
: public ScXMLImportContext
162 ScXMLDatabaseRangeContext
* pDatabaseRangeContext
;
167 ScXMLSourceQueryContext( ScXMLImport
& rImport
,
168 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
169 ScXMLDatabaseRangeContext
* pTempDatabaseRangeContext
);
171 virtual ~ScXMLSourceQueryContext() override
;
173 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
174 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
176 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
179 class ScXMLConResContext
: public ScXMLImportContext
183 ScXMLConResContext( ScXMLImport
& rImport
,
184 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
185 ScXMLDatabaseRangeContext
* pTempDatabaseRangeContext
);
187 virtual ~ScXMLConResContext() override
;
190 class ScXMLSubTotalRulesContext
: public ScXMLImportContext
192 ScXMLDatabaseRangeContext
* pDatabaseRangeContext
;
196 ScXMLSubTotalRulesContext( ScXMLImport
& rImport
,
197 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
198 ScXMLDatabaseRangeContext
* pTempDatabaseRangeContext
);
200 virtual ~ScXMLSubTotalRulesContext() override
;
202 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
203 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
206 class ScXMLSortGroupsContext
: public ScXMLImportContext
210 ScXMLSortGroupsContext( ScXMLImport
& rImport
,
211 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
212 ScXMLDatabaseRangeContext
* pTempDatabaseRangeContext
);
214 virtual ~ScXMLSortGroupsContext() override
;
217 class ScXMLSubTotalRuleContext
: public ScXMLImportContext
219 ScXMLDatabaseRangeContext
* pDatabaseRangeContext
;
220 ScSubTotalRule aSubTotalRule
;
224 ScXMLSubTotalRuleContext( ScXMLImport
& rImport
,
225 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
226 ScXMLDatabaseRangeContext
* pTempDatabaseRangeContext
);
228 virtual ~ScXMLSubTotalRuleContext() override
;
230 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
231 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
) override
;
233 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
235 void AddSubTotalColumn(const css::sheet::SubTotalColumn
& rSubTotalColumn
)
237 aSubTotalRule
.aSubTotalColumns
.realloc(aSubTotalRule
.aSubTotalColumns
.getLength() + 1);
238 aSubTotalRule
.aSubTotalColumns
.getArray()[aSubTotalRule
.aSubTotalColumns
.getLength() - 1] = rSubTotalColumn
;
242 class ScXMLSubTotalFieldContext
: public ScXMLImportContext
244 ScXMLSubTotalRuleContext
* pSubTotalRuleContext
;
245 OUString sFieldNumber
;
250 ScXMLSubTotalFieldContext( ScXMLImport
& rImport
,
251 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
252 ScXMLSubTotalRuleContext
* pSubTotalRuleContext
);
254 virtual ~ScXMLSubTotalFieldContext() override
;
256 virtual void SAL_CALL
endFastElement( sal_Int32 nElement
) override
;
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */