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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_XML_XMLFILTI_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_XML_XMLFILTI_HXX
23 #include <xmloff/xmlictxt.hxx>
24 #include <xmloff/xmlimp.hxx>
25 #include <com/sun/star/table/CellAddress.hpp>
26 #include <com/sun/star/table/CellRangeAddress.hpp>
27 #include <com/sun/star/sheet/FilterOperator.hpp>
28 #include <com/sun/star/sheet/FilterOperator2.hpp>
29 #include <com/sun/star/sheet/TableFilterField2.hpp>
31 #include "xmldrani.hxx"
32 #include "xmldpimp.hxx"
33 #include "queryentry.hxx"
41 class ScXMLFilterContext
: public SvXMLImportContext
47 ConnStackItem(bool bOr
);
49 ScQueryParam
& mrQueryParam
;
50 ScXMLDatabaseRangeContext
* pDatabaseRangeContext
;
52 com::sun::star::table::CellAddress aOutputPosition
;
53 com::sun::star::table::CellRangeAddress aConditionSourceRangeAddress
;
56 bool bConditionSourceRange
;
57 std::vector
<ConnStackItem
> maConnStack
;
59 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
60 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
64 ScXMLFilterContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
65 const OUString
& rLName
,
66 const ::com::sun::star::uno::Reference
<
67 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
69 ScXMLDatabaseRangeContext
* pTempDatabaseRangeContext
);
71 virtual ~ScXMLFilterContext();
73 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
74 const OUString
& rLocalName
,
75 const ::com::sun::star::uno::Reference
<
76 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
78 virtual void EndElement() SAL_OVERRIDE
;
80 void OpenConnection(bool b
);
81 void CloseConnection();
85 class ScXMLAndContext
: public SvXMLImportContext
87 ScQueryParam
& mrQueryParam
;
88 ScXMLFilterContext
* pFilterContext
;
90 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
91 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
95 ScXMLAndContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
96 const OUString
& rLName
,
97 const ::com::sun::star::uno::Reference
<
98 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
100 ScXMLFilterContext
* pTempFilterContext
);
102 virtual ~ScXMLAndContext();
104 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
105 const OUString
& rLocalName
,
106 const ::com::sun::star::uno::Reference
<
107 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
109 virtual void EndElement() SAL_OVERRIDE
;
112 class ScXMLOrContext
: public SvXMLImportContext
114 ScQueryParam
& mrQueryParam
;
115 ScXMLFilterContext
* pFilterContext
;
117 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
118 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
122 ScXMLOrContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
123 const OUString
& rLName
,
124 const ::com::sun::star::uno::Reference
<
125 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
126 ScQueryParam
& rParam
,
127 ScXMLFilterContext
* pTempFilterContext
);
129 virtual ~ScXMLOrContext();
131 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
132 const OUString
& rLocalName
,
133 const ::com::sun::star::uno::Reference
<
134 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
136 virtual void EndElement() SAL_OVERRIDE
;
139 class ScXMLConditionContext
: public SvXMLImportContext
141 ScQueryParam
& mrQueryParam
;
142 ScXMLFilterContext
* pFilterContext
;
144 ScQueryEntry::QueryItemsType maQueryItems
;
146 OUString sConditionValue
;
149 bool bIsCaseSensitive
;
151 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
152 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
156 ScXMLConditionContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
157 const OUString
& rLName
,
158 const ::com::sun::star::uno::Reference
<
159 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
160 ScQueryParam
& rParam
,
161 ScXMLFilterContext
* pTempFilterContext
);
163 virtual ~ScXMLConditionContext();
165 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
166 const OUString
& rLocalName
,
167 const ::com::sun::star::uno::Reference
<
168 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
170 virtual void EndElement() SAL_OVERRIDE
;
172 static void GetOperator(const OUString
& aOpStr
, ScQueryParam
& rParam
, ScQueryEntry
& rEntry
);
173 void AddSetItem(const ScQueryEntry::Item
& rItem
);
176 class ScXMLSetItemContext
: public SvXMLImportContext
178 const ScXMLImport
& GetScImport() const;
179 ScXMLImport
& GetScImport();
181 ScXMLSetItemContext(ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
182 const OUString
& rLName
,
183 const ::com::sun::star::uno::Reference
<
184 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
185 ScXMLConditionContext
& rParent
);
187 virtual ~ScXMLSetItemContext();
189 virtual SvXMLImportContext
*CreateChildContext(
191 const OUString
& rLocalName
,
192 const ::com::sun::star::uno::Reference
<
193 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
195 virtual void EndElement() SAL_OVERRIDE
;
200 class ScXMLDPFilterContext
: public SvXMLImportContext
202 ScXMLDataPilotTableContext
* pDataPilotTable
;
204 ScQueryParam aFilterFields
;
205 ScAddress aOutputPosition
;
206 ScRange aConditionSourceRangeAddress
;
207 sal_uInt8 nFilterFieldCount
;
208 bool bSkipDuplicates
:1;
209 bool bCopyOutputData
:1;
210 bool bUseRegularExpressions
:1;
211 bool bIsCaseSensitive
:1;
212 bool bConnectionOr
:1;
213 bool bNextConnectionOr
:1;
214 bool bConditionSourceRange
:1;
215 ::std::stack
<bool> aConnectionOrStack
;
217 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
218 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
222 ScXMLDPFilterContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
223 const OUString
& rLName
,
224 const ::com::sun::star::uno::Reference
<
225 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
226 ScXMLDataPilotTableContext
* pTempDataPilotTableContext
);
228 virtual ~ScXMLDPFilterContext();
230 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
231 const OUString
& rLocalName
,
232 const ::com::sun::star::uno::Reference
<
233 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
235 virtual void EndElement() SAL_OVERRIDE
;
237 void SetIsCaseSensitive(const bool bTemp
) { bIsCaseSensitive
= bTemp
; }
238 void SetUseRegularExpressions(const bool bTemp
) { if (!bUseRegularExpressions
) bUseRegularExpressions
= bTemp
;}
240 void OpenConnection(const bool bVal
)
242 bool bTemp
= bConnectionOr
;
243 bConnectionOr
= bNextConnectionOr
;
244 bNextConnectionOr
= bVal
;
245 aConnectionOrStack
.push(bTemp
);
248 void CloseConnection()
251 if (aConnectionOrStack
.empty())
255 bTemp
= aConnectionOrStack
.top();
256 aConnectionOrStack
.pop();
258 bConnectionOr
= bTemp
;
259 bNextConnectionOr
= bTemp
;
262 bool GetConnection() { bool bTemp
= bConnectionOr
; bConnectionOr
= bNextConnectionOr
; return bTemp
; }
263 void AddFilterField (const ScQueryEntry
& aFilterField
);
266 class ScXMLDPAndContext
: public SvXMLImportContext
268 ScXMLDPFilterContext
* pFilterContext
;
270 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
271 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
275 ScXMLDPAndContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
276 const OUString
& rLName
,
277 const ::com::sun::star::uno::Reference
<
278 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
279 ScXMLDPFilterContext
* pTempFilterContext
);
281 virtual ~ScXMLDPAndContext();
283 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
284 const OUString
& rLocalName
,
285 const ::com::sun::star::uno::Reference
<
286 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
288 virtual void EndElement() SAL_OVERRIDE
;
291 class ScXMLDPOrContext
: public SvXMLImportContext
293 ScXMLDPFilterContext
* pFilterContext
;
295 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
296 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
300 ScXMLDPOrContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
301 const OUString
& rLName
,
302 const ::com::sun::star::uno::Reference
<
303 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
304 ScXMLDPFilterContext
* pTempFilterContext
);
306 virtual ~ScXMLDPOrContext();
308 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
309 const OUString
& rLocalName
,
310 const ::com::sun::star::uno::Reference
<
311 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
313 virtual void EndElement() SAL_OVERRIDE
;
316 class ScXMLDPConditionContext
: public SvXMLImportContext
318 ScXMLDPFilterContext
* pFilterContext
;
321 OUString sConditionValue
;
324 bool bIsCaseSensitive
;
326 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
327 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
331 ScXMLDPConditionContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
332 const OUString
& rLName
,
333 const ::com::sun::star::uno::Reference
<
334 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
335 ScXMLDPFilterContext
* pTempFilterContext
);
337 virtual ~ScXMLDPConditionContext();
339 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
340 const OUString
& rLocalName
,
341 const ::com::sun::star::uno::Reference
<
342 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
344 static void getOperatorXML(
345 const OUString
& sTempOperator
, ScQueryOp
& aFilterOperator
, bool& bUseRegularExpressions
);
346 virtual void EndElement() SAL_OVERRIDE
;
351 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */