cid#1607171 Data race condition
[LibreOffice.git] / sc / source / filter / xml / xmlfilti.hxx
blob02a2a9e6c877610db5ba62f6313b641de72bfd35
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 #pragma once
22 #include "importcontext.hxx"
23 #include <queryentry.hxx>
24 #include <queryparam.hxx>
26 #include <stack>
27 #include <vector>
29 class ScXMLImport;
30 class ScXMLDatabaseRangeContext;
31 class ScXMLDataPilotTableContext;
32 namespace sax_fastparser { class FastAttributeList; }
34 class ScXMLFilterContext : public ScXMLImportContext
36 struct ConnStackItem
38 bool mbOr;
39 int mnCondCount;
40 explicit ConnStackItem(bool bOr);
42 ScQueryParam& mrQueryParam;
43 ScXMLDatabaseRangeContext* pDatabaseRangeContext;
45 ScAddress aOutputPosition;
46 ScRange aConditionSourceRangeAddress;
47 bool bSkipDuplicates;
48 bool bCopyOutputData;
49 bool bConditionSourceRange;
50 std::vector<ConnStackItem> maConnStack;
52 public:
54 ScXMLFilterContext( ScXMLImport& rImport,
55 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
56 ScQueryParam& rParam,
57 ScXMLDatabaseRangeContext* pTempDatabaseRangeContext);
59 virtual ~ScXMLFilterContext() override;
61 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
62 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
64 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
66 void OpenConnection(bool b);
67 void CloseConnection();
68 bool GetConnection();
71 class ScXMLAndContext : public ScXMLImportContext
73 ScQueryParam& mrQueryParam;
74 ScXMLFilterContext* pFilterContext;
76 public:
78 ScXMLAndContext( ScXMLImport& rImport,
79 ScQueryParam& rParam,
80 ScXMLFilterContext* pTempFilterContext);
82 virtual ~ScXMLAndContext() override;
84 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
85 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
87 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
90 class ScXMLOrContext : public ScXMLImportContext
92 ScQueryParam& mrQueryParam;
93 ScXMLFilterContext* pFilterContext;
95 public:
97 ScXMLOrContext( ScXMLImport& rImport,
98 ScQueryParam& rParam,
99 ScXMLFilterContext* pTempFilterContext);
101 virtual ~ScXMLOrContext() override;
103 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
104 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
106 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
109 class ScXMLConditionContext : public ScXMLImportContext
111 ScQueryParam& mrQueryParam;
112 ScXMLFilterContext* pFilterContext;
114 ScQueryEntry::QueryItemsType maQueryItems;
115 OUString sDataType;
116 OUString sConditionValue;
117 OUString sOperator;
118 sal_Int32 nField;
119 bool bIsCaseSensitive;
121 public:
123 ScXMLConditionContext( ScXMLImport& rImport, sal_Int32 nElement,
124 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
125 ScQueryParam& rParam,
126 ScXMLFilterContext* pTempFilterContext);
128 virtual ~ScXMLConditionContext() override;
130 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
131 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
133 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
135 static void GetOperator(std::u16string_view aOpStr, ScQueryParam& rParam, ScQueryEntry& rEntry);
136 void AddSetItem(const ScQueryEntry::Item& rItem);
139 class ScXMLSetItemContext : public ScXMLImportContext
141 public:
142 ScXMLSetItemContext(ScXMLImport& rImport, sal_Int32 nElement,
143 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
144 ScXMLConditionContext& rParent);
146 virtual ~ScXMLSetItemContext() override;
149 // Datapilot (Core)
151 class ScXMLDPFilterContext : public ScXMLImportContext
153 ScXMLDataPilotTableContext* pDataPilotTable;
155 ScQueryParam aFilterFields;
156 utl::SearchParam::SearchType eSearchType;
157 sal_uInt8 nFilterFieldCount;
158 bool bSkipDuplicates:1;
159 bool bIsCaseSensitive:1;
160 bool bConnectionOr:1;
161 bool bNextConnectionOr:1;
162 ::std::stack<bool> aConnectionOrStack;
164 public:
166 ScXMLDPFilterContext( ScXMLImport& rImport,
167 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
168 ScXMLDataPilotTableContext* pTempDataPilotTableContext);
170 virtual ~ScXMLDPFilterContext() override;
172 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
173 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
175 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
177 void SetIsCaseSensitive(const bool bTemp) { bIsCaseSensitive = bTemp; }
178 void SetSearchType(const utl::SearchParam::SearchType eTemp)
180 if (eSearchType == utl::SearchParam::SearchType::Normal)
181 eSearchType = eTemp;
184 void OpenConnection(const bool bVal)
186 bool bTemp = bConnectionOr;
187 bConnectionOr = bNextConnectionOr;
188 bNextConnectionOr = bVal;
189 aConnectionOrStack.push(bTemp);
192 void CloseConnection()
194 bool bTemp;
195 if (aConnectionOrStack.empty())
196 bTemp = false;
197 else
199 bTemp = aConnectionOrStack.top();
200 aConnectionOrStack.pop();
202 bConnectionOr = bTemp;
203 bNextConnectionOr = bTemp;
206 bool GetConnection() { bool bTemp = bConnectionOr; bConnectionOr = bNextConnectionOr; return bTemp; }
207 void AddFilterField (const ScQueryEntry& aFilterField);
210 class ScXMLDPAndContext : public ScXMLImportContext
212 ScXMLDPFilterContext* pFilterContext;
213 public:
215 ScXMLDPAndContext( ScXMLImport& rImport,
216 ScXMLDPFilterContext* pTempFilterContext);
218 virtual ~ScXMLDPAndContext() override;
220 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
221 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
223 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
226 class ScXMLDPOrContext : public ScXMLImportContext
228 ScXMLDPFilterContext* pFilterContext;
229 public:
231 ScXMLDPOrContext( ScXMLImport& rImport,
232 ScXMLDPFilterContext* pTempFilterContext);
234 virtual ~ScXMLDPOrContext() override;
236 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
237 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
239 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
242 class ScXMLDPConditionContext : public ScXMLImportContext
244 ScXMLDPFilterContext* pFilterContext;
246 OUString sDataType;
247 OUString sConditionValue;
248 OUString sOperator;
249 sal_Int32 nField;
250 bool bIsCaseSensitive;
252 public:
254 ScXMLDPConditionContext( ScXMLImport& rImport, sal_Int32 nElement,
255 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList,
256 ScXMLDPFilterContext* pTempFilterContext);
258 virtual ~ScXMLDPConditionContext() override;
260 static void getOperatorXML(
261 std::u16string_view sTempOperator, ScQueryOp& aFilterOperator, utl::SearchParam::SearchType& rSearchType);
262 virtual void SAL_CALL endFastElement( sal_Int32 nElement ) override;
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */