Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / xml / xmlfilti.hxx
blob07db8dfcba9ed0ba32032b27489c9fa966f8aa6b
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_XML_XMLFILTI_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_XML_XMLFILTI_HXX
23 #include "importcontext.hxx"
24 #include <queryentry.hxx>
25 #include <queryparam.hxx>
27 #include <stack>
28 #include <vector>
30 class ScXMLImport;
31 class ScXMLDatabaseRangeContext;
32 class ScXMLDataPilotTableContext;
33 namespace sax_fastparser { class FastAttributeList; }
35 class ScXMLFilterContext : public ScXMLImportContext
37 struct ConnStackItem
39 bool const mbOr;
40 int mnCondCount;
41 explicit ConnStackItem(bool bOr);
43 ScQueryParam& mrQueryParam;
44 ScXMLDatabaseRangeContext* pDatabaseRangeContext;
46 ScAddress aOutputPosition;
47 ScRange aConditionSourceRangeAddress;
48 bool bSkipDuplicates;
49 bool bCopyOutputData;
50 bool bConditionSourceRange;
51 std::vector<ConnStackItem> maConnStack;
53 public:
55 ScXMLFilterContext( ScXMLImport& rImport,
56 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
57 ScQueryParam& rParam,
58 ScXMLDatabaseRangeContext* pTempDatabaseRangeContext);
60 virtual ~ScXMLFilterContext() override;
62 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
63 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
65 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
67 void OpenConnection(bool b);
68 void CloseConnection();
69 bool GetConnection();
72 class ScXMLAndContext : public ScXMLImportContext
74 ScQueryParam& mrQueryParam;
75 ScXMLFilterContext* pFilterContext;
77 public:
79 ScXMLAndContext( ScXMLImport& rImport,
80 ScQueryParam& rParam,
81 ScXMLFilterContext* pTempFilterContext);
83 virtual ~ScXMLAndContext() override;
85 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
86 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
88 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
91 class ScXMLOrContext : public ScXMLImportContext
93 ScQueryParam& mrQueryParam;
94 ScXMLFilterContext* pFilterContext;
96 public:
98 ScXMLOrContext( ScXMLImport& rImport,
99 ScQueryParam& rParam,
100 ScXMLFilterContext* pTempFilterContext);
102 virtual ~ScXMLOrContext() override;
104 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
105 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
107 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
110 class ScXMLConditionContext : public ScXMLImportContext
112 ScQueryParam& mrQueryParam;
113 ScXMLFilterContext* pFilterContext;
115 ScQueryEntry::QueryItemsType maQueryItems;
116 OUString sDataType;
117 OUString sConditionValue;
118 OUString sOperator;
119 sal_Int32 nField;
120 bool bIsCaseSensitive;
122 public:
124 ScXMLConditionContext( ScXMLImport& rImport, sal_Int32 nElement,
125 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
126 ScQueryParam& rParam,
127 ScXMLFilterContext* pTempFilterContext);
129 virtual ~ScXMLConditionContext() override;
131 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
132 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
134 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
136 static void GetOperator(const OUString& aOpStr, ScQueryParam& rParam, ScQueryEntry& rEntry);
137 void AddSetItem(const ScQueryEntry::Item& rItem);
140 class ScXMLSetItemContext : public ScXMLImportContext
142 public:
143 ScXMLSetItemContext(ScXMLImport& rImport, sal_Int32 nElement,
144 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
145 ScXMLConditionContext& rParent);
147 virtual ~ScXMLSetItemContext() override;
150 // Datapilot (Core)
152 class ScXMLDPFilterContext : public ScXMLImportContext
154 ScXMLDataPilotTableContext* pDataPilotTable;
156 ScQueryParam aFilterFields;
157 utl::SearchParam::SearchType eSearchType;
158 sal_uInt8 nFilterFieldCount;
159 bool bSkipDuplicates:1;
160 bool bIsCaseSensitive:1;
161 bool bConnectionOr:1;
162 bool bNextConnectionOr:1;
163 ::std::stack<bool> aConnectionOrStack;
165 public:
167 ScXMLDPFilterContext( ScXMLImport& rImport,
168 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
169 ScXMLDataPilotTableContext* pTempDataPilotTableContext);
171 virtual ~ScXMLDPFilterContext() 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;
178 void SetIsCaseSensitive(const bool bTemp) { bIsCaseSensitive = bTemp; }
179 void SetSearchType(const utl::SearchParam::SearchType eTemp)
181 if (eSearchType == utl::SearchParam::SearchType::Normal)
182 eSearchType = eTemp;
185 void OpenConnection(const bool bVal)
187 bool bTemp = bConnectionOr;
188 bConnectionOr = bNextConnectionOr;
189 bNextConnectionOr = bVal;
190 aConnectionOrStack.push(bTemp);
193 void CloseConnection()
195 bool bTemp;
196 if (aConnectionOrStack.empty())
197 bTemp = false;
198 else
200 bTemp = aConnectionOrStack.top();
201 aConnectionOrStack.pop();
203 bConnectionOr = bTemp;
204 bNextConnectionOr = bTemp;
207 bool GetConnection() { bool bTemp = bConnectionOr; bConnectionOr = bNextConnectionOr; return bTemp; }
208 void AddFilterField (const ScQueryEntry& aFilterField);
211 class ScXMLDPAndContext : public ScXMLImportContext
213 ScXMLDPFilterContext* pFilterContext;
214 public:
216 ScXMLDPAndContext( ScXMLImport& rImport,
217 ScXMLDPFilterContext* pTempFilterContext);
219 virtual ~ScXMLDPAndContext() override;
221 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
222 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
224 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
227 class ScXMLDPOrContext : public ScXMLImportContext
229 ScXMLDPFilterContext* pFilterContext;
230 public:
232 ScXMLDPOrContext( ScXMLImport& rImport,
233 ScXMLDPFilterContext* pTempFilterContext);
235 virtual ~ScXMLDPOrContext() override;
237 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
238 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
240 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
243 class ScXMLDPConditionContext : public ScXMLImportContext
245 ScXMLDPFilterContext* pFilterContext;
247 OUString sDataType;
248 OUString sConditionValue;
249 OUString sOperator;
250 sal_Int32 nField;
251 bool bIsCaseSensitive;
253 public:
255 ScXMLDPConditionContext( ScXMLImport& rImport, sal_Int32 nElement,
256 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
257 ScXMLDPFilterContext* pTempFilterContext);
259 virtual ~ScXMLDPConditionContext() override;
261 static void getOperatorXML(
262 const OUString& sTempOperator, ScQueryOp& aFilterOperator, utl::SearchParam::SearchType& rSearchType);
263 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
266 #endif
268 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */