Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_XMLFILTI_HXX
30 : : #define SC_XMLFILTI_HXX
31 : :
32 : : #include <xmloff/xmlictxt.hxx>
33 : : #include <xmloff/xmlimp.hxx>
34 : : #include <com/sun/star/table/CellAddress.hpp>
35 : : #include <com/sun/star/table/CellRangeAddress.hpp>
36 : : #include <com/sun/star/sheet/FilterOperator.hpp>
37 : : #include <com/sun/star/sheet/FilterOperator2.hpp>
38 : : #include <com/sun/star/sheet/TableFilterField2.hpp>
39 : :
40 : : #include "xmldrani.hxx"
41 : : #include "xmldpimp.hxx"
42 : : #include "queryentry.hxx"
43 : :
44 : : #include <vector>
45 : :
46 : : class ScXMLImport;
47 : : struct ScQueryParam;
48 : :
49 : : class ScXMLFilterContext : public SvXMLImportContext
50 : : {
51 : : struct ConnStackItem
52 : : {
53 : : bool mbOr;
54 : : int mnCondCount;
55 : : ConnStackItem(bool bOr);
56 : : };
57 : : ScQueryParam& mrQueryParam;
58 : : ScXMLDatabaseRangeContext* pDatabaseRangeContext;
59 : :
60 : : com::sun::star::table::CellAddress aOutputPosition;
61 : : com::sun::star::table::CellRangeAddress aConditionSourceRangeAddress;
62 : : sal_Int16 nUserListIndex;
63 : : bool bSkipDuplicates;
64 : : bool bCopyOutputData;
65 : : bool bEnabledUserList;
66 : : bool bConditionSourceRange;
67 : : std::vector<ConnStackItem> maConnStack;
68 : :
69 : : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
70 : 36 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
71 : :
72 : : public:
73 : :
74 : : ScXMLFilterContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
75 : : const ::rtl::OUString& rLName,
76 : : const ::com::sun::star::uno::Reference<
77 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
78 : : ScQueryParam& rParam,
79 : : ScXMLDatabaseRangeContext* pTempDatabaseRangeContext);
80 : :
81 : : virtual ~ScXMLFilterContext();
82 : :
83 : : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
84 : : const ::rtl::OUString& rLocalName,
85 : : const ::com::sun::star::uno::Reference<
86 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
87 : :
88 : : virtual void EndElement();
89 : :
90 : : void OpenConnection(bool b);
91 : : void CloseConnection();
92 : : bool GetConnection();
93 : : };
94 : :
95 : : class ScXMLAndContext : public SvXMLImportContext
96 : : {
97 : : ScQueryParam& mrQueryParam;
98 : : ScXMLFilterContext* pFilterContext;
99 : :
100 : : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
101 : 4 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
102 : :
103 : : public:
104 : :
105 : : ScXMLAndContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
106 : : const ::rtl::OUString& rLName,
107 : : const ::com::sun::star::uno::Reference<
108 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
109 : : ScQueryParam& rParam,
110 : : ScXMLFilterContext* pTempFilterContext);
111 : :
112 : : virtual ~ScXMLAndContext();
113 : :
114 : : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
115 : : const ::rtl::OUString& rLocalName,
116 : : const ::com::sun::star::uno::Reference<
117 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
118 : :
119 : : virtual void EndElement();
120 : : };
121 : :
122 : : class ScXMLOrContext : public SvXMLImportContext
123 : : {
124 : : ScQueryParam& mrQueryParam;
125 : : ScXMLFilterContext* pFilterContext;
126 : :
127 : : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
128 : 18 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
129 : :
130 : : public:
131 : :
132 : : ScXMLOrContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
133 : : const ::rtl::OUString& rLName,
134 : : const ::com::sun::star::uno::Reference<
135 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
136 : : ScQueryParam& rParam,
137 : : ScXMLFilterContext* pTempFilterContext);
138 : :
139 : : virtual ~ScXMLOrContext();
140 : :
141 : : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
142 : : const ::rtl::OUString& rLocalName,
143 : : const ::com::sun::star::uno::Reference<
144 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
145 : :
146 : : virtual void EndElement();
147 : : };
148 : :
149 : : class ScXMLConditionContext : public SvXMLImportContext
150 : : {
151 : : ScQueryParam& mrQueryParam;
152 : : ScXMLFilterContext* pFilterContext;
153 : :
154 : : ScQueryEntry::QueryItemsType maQueryItems;
155 : : rtl::OUString sDataType;
156 : : rtl::OUString sConditionValue;
157 : : rtl::OUString sOperator;
158 : : sal_Int32 nField;
159 : : bool bIsCaseSensitive;
160 : :
161 : : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
162 : 76 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
163 : :
164 : : public:
165 : :
166 : : ScXMLConditionContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
167 : : const ::rtl::OUString& rLName,
168 : : const ::com::sun::star::uno::Reference<
169 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
170 : : ScQueryParam& rParam,
171 : : ScXMLFilterContext* pTempFilterContext);
172 : :
173 : : virtual ~ScXMLConditionContext();
174 : :
175 : : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
176 : : const ::rtl::OUString& rLocalName,
177 : : const ::com::sun::star::uno::Reference<
178 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
179 : :
180 : : virtual void EndElement();
181 : :
182 : : void GetOperator(const rtl::OUString& aOpStr, ScQueryParam& rParam, ScQueryEntry& rEntry) const;
183 : : void AddSetItem(const ScQueryEntry::Item& rItem);
184 : : };
185 : :
186 : : class ScXMLSetItemContext : public SvXMLImportContext
187 : : {
188 : : const ScXMLImport& GetScImport() const;
189 : : ScXMLImport& GetScImport();
190 : : public:
191 : : ScXMLSetItemContext(ScXMLImport& rImport, sal_uInt16 nPrfx,
192 : : const ::rtl::OUString& rLName,
193 : : const ::com::sun::star::uno::Reference<
194 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
195 : : ScXMLConditionContext& rParent);
196 : :
197 : : virtual ~ScXMLSetItemContext();
198 : :
199 : : virtual SvXMLImportContext *CreateChildContext(
200 : : sal_uInt16 nPrefix,
201 : : const ::rtl::OUString& rLocalName,
202 : : const ::com::sun::star::uno::Reference<
203 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList);
204 : :
205 : : virtual void EndElement();
206 : : };
207 : :
208 : : // Datapilot (Core)
209 : :
210 : : class ScXMLDPFilterContext : public SvXMLImportContext
211 : : {
212 : : ScXMLDataPilotTableContext* pDataPilotTable;
213 : :
214 : : ScQueryParam aFilterFields;
215 : : ScAddress aOutputPosition;
216 : : ScRange aConditionSourceRangeAddress;
217 : : sal_uInt8 nFilterFieldCount;
218 : : sal_Int16 nUserListIndex;
219 : : bool bSkipDuplicates:1;
220 : : bool bCopyOutputData:1;
221 : : bool bUseRegularExpressions:1;
222 : : bool bIsCaseSensitive:1;
223 : : bool bEnabledUserList:1;
224 : : bool bConnectionOr:1;
225 : : bool bNextConnectionOr:1;
226 : : bool bConditionSourceRange:1;
227 : : ::std::stack<bool> aConnectionOrStack;
228 : :
229 : : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
230 : 10 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
231 : :
232 : : public:
233 : :
234 : : ScXMLDPFilterContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
235 : : const ::rtl::OUString& rLName,
236 : : const ::com::sun::star::uno::Reference<
237 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
238 : : ScXMLDataPilotTableContext* pTempDataPilotTableContext);
239 : :
240 : : virtual ~ScXMLDPFilterContext();
241 : :
242 : : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
243 : : const ::rtl::OUString& rLocalName,
244 : : const ::com::sun::star::uno::Reference<
245 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
246 : :
247 : : virtual void EndElement();
248 : :
249 : 4 : void SetIsCaseSensitive(const bool bTemp) { bIsCaseSensitive = bTemp; }
250 [ + - ]: 4 : void SetUseRegularExpressions(const bool bTemp) { if (!bUseRegularExpressions) bUseRegularExpressions = bTemp;}
251 : :
252 : 2 : void OpenConnection(const bool bVal)
253 : : {
254 : 2 : bool bTemp = bConnectionOr;
255 : 2 : bConnectionOr = bNextConnectionOr;
256 : 2 : bNextConnectionOr = bVal;
257 [ + - ]: 2 : aConnectionOrStack.push(bTemp);
258 : 2 : }
259 : :
260 : 2 : void CloseConnection()
261 : : {
262 : : bool bTemp;
263 [ - + ]: 2 : if (aConnectionOrStack.empty())
264 : 0 : bTemp = false;
265 : : else
266 : : {
267 : 2 : bTemp = aConnectionOrStack.top();
268 : 2 : aConnectionOrStack.pop();
269 : : }
270 : 2 : bConnectionOr = bTemp;
271 : 2 : bNextConnectionOr = bTemp;
272 : 2 : }
273 : :
274 : 4 : bool GetConnection() { bool bTemp = bConnectionOr; bConnectionOr = bNextConnectionOr; return bTemp; }
275 : : void AddFilterField (const ScQueryEntry& aFilterField);
276 : : };
277 : :
278 : : class ScXMLDPAndContext : public SvXMLImportContext
279 : : {
280 : : ScXMLDPFilterContext* pFilterContext;
281 : :
282 : : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
283 : 8 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
284 : :
285 : : public:
286 : :
287 : : ScXMLDPAndContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
288 : : const ::rtl::OUString& rLName,
289 : : const ::com::sun::star::uno::Reference<
290 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
291 : : ScXMLDPFilterContext* pTempFilterContext);
292 : :
293 : : virtual ~ScXMLDPAndContext();
294 : :
295 : : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
296 : : const ::rtl::OUString& rLocalName,
297 : : const ::com::sun::star::uno::Reference<
298 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
299 : :
300 : : virtual void EndElement();
301 : : };
302 : :
303 : : class ScXMLDPOrContext : public SvXMLImportContext
304 : : {
305 : : ScXMLDPFilterContext* pFilterContext;
306 : :
307 : : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
308 : 0 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
309 : :
310 : : public:
311 : :
312 : : ScXMLDPOrContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
313 : : const ::rtl::OUString& rLName,
314 : : const ::com::sun::star::uno::Reference<
315 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
316 : : ScXMLDPFilterContext* pTempFilterContext);
317 : :
318 : : virtual ~ScXMLDPOrContext();
319 : :
320 : : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
321 : : const ::rtl::OUString& rLocalName,
322 : : const ::com::sun::star::uno::Reference<
323 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
324 : :
325 : : virtual void EndElement();
326 : : };
327 : :
328 : : class ScXMLDPConditionContext : public SvXMLImportContext
329 : : {
330 : : ScXMLDPFilterContext* pFilterContext;
331 : :
332 : : rtl::OUString sDataType;
333 : : rtl::OUString sConditionValue;
334 : : rtl::OUString sOperator;
335 : : sal_Int32 nField;
336 : : bool bIsCaseSensitive;
337 : :
338 : : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
339 : 20 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
340 : :
341 : : public:
342 : :
343 : : ScXMLDPConditionContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
344 : : const ::rtl::OUString& rLName,
345 : : const ::com::sun::star::uno::Reference<
346 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
347 : : ScXMLDPFilterContext* pTempFilterContext);
348 : :
349 : : virtual ~ScXMLDPConditionContext();
350 : :
351 : : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
352 : : const ::rtl::OUString& rLocalName,
353 : : const ::com::sun::star::uno::Reference<
354 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
355 : :
356 : : void getOperatorXML(
357 : : const rtl::OUString sTempOperator, ScQueryOp& aFilterOperator, bool& bUseRegularExpressions) const;
358 : : virtual void EndElement();
359 : : };
360 : :
361 : : #endif
362 : :
363 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|