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 #include "xmlfilti.hxx"
21 #include "xmlimprt.hxx"
22 #include "xmldrani.hxx"
23 #include "xmldpimp.hxx"
24 #include <rangeutl.hxx>
25 #include <queryentry.hxx>
26 #include <document.hxx>
28 #include <o3tl/safeint.hxx>
29 #include <sax/tools/converter.hxx>
30 #include <svl/sharedstringpool.hxx>
31 #include <xmloff/xmltoken.hxx>
32 #include <xmloff/xmlnamespace.hxx>
34 using namespace com::sun::star
;
35 using namespace xmloff::token
;
37 using ::com::sun::star::uno::Reference
;
39 ScXMLFilterContext::ConnStackItem::ConnStackItem(bool bOr
) : mbOr(bOr
), mnCondCount(0) {}
41 ScXMLFilterContext::ScXMLFilterContext( ScXMLImport
& rImport
,
42 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
44 ScXMLDatabaseRangeContext
* pTempDatabaseRangeContext
) :
45 ScXMLImportContext( rImport
),
47 pDatabaseRangeContext(pTempDatabaseRangeContext
),
48 bSkipDuplicates(false),
49 bCopyOutputData(false),
50 bConditionSourceRange(false)
52 ScDocument
* pDoc(GetScImport().GetDocument());
55 if ( !rAttrList
.is() )
58 for (auto &aIter
: *rAttrList
)
60 switch (aIter
.getToken())
62 case XML_ELEMENT( TABLE
, XML_TARGET_RANGE_ADDRESS
):
66 if (ScRangeStringConverter::GetRangeFromString( aScRange
, aIter
.toString(), *pDoc
, ::formula::FormulaGrammar::CONV_OOO
, nOffset
))
68 aOutputPosition
= aScRange
.aStart
;
69 bCopyOutputData
= true;
73 case XML_ELEMENT( TABLE
, XML_CONDITION_SOURCE_RANGE_ADDRESS
):
76 if (ScRangeStringConverter::GetRangeFromString( aConditionSourceRangeAddress
, aIter
.toString(), *pDoc
, ::formula::FormulaGrammar::CONV_OOO
, nOffset
) )
77 bConditionSourceRange
= true;
80 case XML_ELEMENT( TABLE
, XML_CONDITION_SOURCE
):
82 // not supported by StarOffice
85 case XML_ELEMENT( TABLE
, XML_DISPLAY_DUPLICATES
):
87 bSkipDuplicates
= !IsXMLToken(aIter
, XML_TRUE
);
94 ScXMLFilterContext::~ScXMLFilterContext()
98 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLFilterContext::createFastChildContext(
99 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
101 SvXMLImportContext
*pContext(nullptr);
102 sax_fastparser::FastAttributeList
*pAttribList
=
103 &sax_fastparser::castToFastAttributeList( xAttrList
);
107 case XML_ELEMENT( TABLE
, XML_FILTER_AND
):
109 pContext
= new ScXMLAndContext(
110 GetScImport(), mrQueryParam
, this);
113 case XML_ELEMENT( TABLE
, XML_FILTER_OR
):
115 pContext
= new ScXMLOrContext(
116 GetScImport(), mrQueryParam
, this);
119 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
121 pContext
= new ScXMLConditionContext(
122 GetScImport(), nElement
, pAttribList
, mrQueryParam
, this);
130 void SAL_CALL
ScXMLFilterContext::endFastElement( sal_Int32
/*nElement*/ )
132 mrQueryParam
.bInplace
= !bCopyOutputData
;
133 mrQueryParam
.bDuplicate
= !bSkipDuplicates
;
137 mrQueryParam
.nDestCol
= aOutputPosition
.Col();
138 mrQueryParam
.nDestRow
= aOutputPosition
.Row();
139 mrQueryParam
.nDestTab
= aOutputPosition
.Tab();
142 if (bConditionSourceRange
)
143 pDatabaseRangeContext
->SetFilterConditionSourceRangeAddress(aConditionSourceRangeAddress
);
146 void ScXMLFilterContext::OpenConnection(bool b
)
148 maConnStack
.emplace_back(b
);
151 void ScXMLFilterContext::CloseConnection()
153 maConnStack
.pop_back();
156 bool ScXMLFilterContext::GetConnection()
158 // For condition items in each stack, the first one gets the connection of
159 // the last stack, while the rest of them get that of the current stack.
161 if (maConnStack
.empty())
162 // This should never happen.
165 ConnStackItem
& rItem
= maConnStack
.back();
166 if (rItem
.mnCondCount
)
167 // secondary item gets the current connection.
170 // The next condition of this stack will get the current connection.
173 if (maConnStack
.size() < 2)
174 // There is no last stack. Likely the first condition in the first
175 // stack whose connection is not used. Default in
176 // ScQueryEntry::eConnect is SC_AND, so return false (AND instead of
177 // OR) here. Otherwise, when saving the document again, we'd write a
179 // <table:filter-or><table:filter-and>...</table:filter-and></table:filter-or>
180 // for two conditions connected with AND.
183 std::vector
<ConnStackItem
>::reverse_iterator itr
= maConnStack
.rbegin();
185 return itr
->mbOr
; // connection of the last stack.
188 ScXMLAndContext::ScXMLAndContext( ScXMLImport
& rImport
,
189 ScQueryParam
& rParam
,
190 ScXMLFilterContext
* pTempFilterContext
) :
191 ScXMLImportContext( rImport
),
192 mrQueryParam(rParam
),
193 pFilterContext(pTempFilterContext
)
195 pFilterContext
->OpenConnection(false);
198 ScXMLAndContext::~ScXMLAndContext()
202 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLAndContext::createFastChildContext(
203 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
205 SvXMLImportContext
*pContext(nullptr);
206 sax_fastparser::FastAttributeList
*pAttribList
=
207 &sax_fastparser::castToFastAttributeList( xAttrList
);
211 case XML_ELEMENT( TABLE
, XML_FILTER_OR
):
213 // not supported in StarOffice
216 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
218 pContext
= new ScXMLConditionContext(
219 GetScImport(), nElement
, pAttribList
, mrQueryParam
, pFilterContext
);
227 void SAL_CALL
ScXMLAndContext::endFastElement( sal_Int32
/*nElement*/ )
229 pFilterContext
->CloseConnection();
232 ScXMLOrContext::ScXMLOrContext( ScXMLImport
& rImport
,
233 ScQueryParam
& rParam
,
234 ScXMLFilterContext
* pTempFilterContext
) :
235 ScXMLImportContext( rImport
),
236 mrQueryParam(rParam
),
237 pFilterContext(pTempFilterContext
)
239 pFilterContext
->OpenConnection(true);
242 ScXMLOrContext::~ScXMLOrContext()
246 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLOrContext::createFastChildContext(
247 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
249 SvXMLImportContext
*pContext(nullptr);
250 sax_fastparser::FastAttributeList
*pAttribList
=
251 &sax_fastparser::castToFastAttributeList( xAttrList
);
255 case XML_ELEMENT( TABLE
, XML_FILTER_AND
):
257 pContext
= new ScXMLAndContext(
258 GetScImport(), mrQueryParam
, pFilterContext
);
261 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
263 pContext
= new ScXMLConditionContext(
264 GetScImport(), nElement
, pAttribList
, mrQueryParam
, pFilterContext
);
272 void SAL_CALL
ScXMLOrContext::endFastElement( sal_Int32
/*nElement*/ )
274 pFilterContext
->CloseConnection();
277 ScXMLConditionContext::ScXMLConditionContext(
278 ScXMLImport
& rImport
, sal_Int32
/*nElement*/,
279 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
280 ScQueryParam
& rParam
,
281 ScXMLFilterContext
* pTempFilterContext
) :
282 ScXMLImportContext( rImport
),
283 mrQueryParam(rParam
),
284 pFilterContext(pTempFilterContext
),
285 sDataType(GetXMLToken(XML_TEXT
)),
287 bIsCaseSensitive(false)
290 if ( !rAttrList
.is() )
293 for (auto &aIter
: *rAttrList
)
295 switch (aIter
.getToken())
297 case XML_ELEMENT( TABLE
, XML_FIELD_NUMBER
):
299 nField
= aIter
.toInt32();
302 case XML_ELEMENT( TABLE
, XML_CASE_SENSITIVE
):
304 bIsCaseSensitive
= IsXMLToken(aIter
, XML_TRUE
);
307 case XML_ELEMENT( TABLE
, XML_DATA_TYPE
):
308 case XML_ELEMENT( LO_EXT
, XML_DATA_TYPE
):
310 sDataType
= aIter
.toString();
313 case XML_ELEMENT( TABLE
, XML_VALUE
):
315 sConditionValue
= aIter
.toString();
318 case XML_ELEMENT( TABLE
, XML_OPERATOR
):
320 sOperator
= aIter
.toString();
327 ScXMLConditionContext::~ScXMLConditionContext()
331 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLConditionContext::createFastChildContext(
332 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
334 SvXMLImportContext
*pContext
= nullptr;
335 sax_fastparser::FastAttributeList
*pAttribList
=
336 &sax_fastparser::castToFastAttributeList( xAttrList
);
340 case XML_ELEMENT( TABLE
, XML_FILTER_SET_ITEM
):
342 pContext
= new ScXMLSetItemContext(
343 GetScImport(), nElement
, pAttribList
, *this);
351 void ScXMLConditionContext::GetOperator(
352 std::u16string_view aOpStr
, ScQueryParam
& rParam
, ScQueryEntry
& rEntry
)
354 rParam
.eSearchType
= utl::SearchParam::SearchType::Normal
;
355 if (IsXMLToken(aOpStr
, XML_MATCH
))
357 rParam
.eSearchType
= utl::SearchParam::SearchType::Regexp
;
358 rEntry
.eOp
= SC_EQUAL
;
360 else if (IsXMLToken(aOpStr
, XML_NOMATCH
))
362 rParam
.eSearchType
= utl::SearchParam::SearchType::Regexp
;
363 rEntry
.eOp
= SC_NOT_EQUAL
;
365 else if (aOpStr
== u
"=")
366 rEntry
.eOp
= SC_EQUAL
;
367 else if (aOpStr
== u
"!=")
368 rEntry
.eOp
= SC_NOT_EQUAL
;
369 else if (IsXMLToken(aOpStr
, XML_BOTTOM_PERCENT
))
370 rEntry
.eOp
= SC_BOTPERC
;
371 else if (IsXMLToken(aOpStr
, XML_BOTTOM_VALUES
))
372 rEntry
.eOp
= SC_BOTVAL
;
373 else if (IsXMLToken(aOpStr
, XML_TOKEN_EMPTY
))
374 rEntry
.SetQueryByEmpty();
375 else if (aOpStr
== u
">")
376 rEntry
.eOp
= SC_GREATER
;
377 else if (aOpStr
== u
">=")
378 rEntry
.eOp
= SC_GREATER_EQUAL
;
379 else if (aOpStr
== u
"<")
380 rEntry
.eOp
= SC_LESS
;
381 else if (aOpStr
== u
"<=")
382 rEntry
.eOp
= SC_LESS_EQUAL
;
383 else if (IsXMLToken(aOpStr
, XML_NOEMPTY
))
384 rEntry
.SetQueryByNonEmpty();
385 else if (IsXMLToken(aOpStr
, XML_TOP_PERCENT
))
386 rEntry
.eOp
= SC_TOPPERC
;
387 else if (IsXMLToken(aOpStr
, XML_TOP_VALUES
))
388 rEntry
.eOp
= SC_TOPVAL
;
389 else if (IsXMLToken(aOpStr
, XML_CONTAINS
))
390 rEntry
.eOp
= SC_CONTAINS
;
391 else if (IsXMLToken(aOpStr
, XML_DOES_NOT_CONTAIN
))
392 rEntry
.eOp
= SC_DOES_NOT_CONTAIN
;
393 else if (IsXMLToken(aOpStr
, XML_BEGINS_WITH
))
394 rEntry
.eOp
= SC_BEGINS_WITH
;
395 else if (IsXMLToken(aOpStr
, XML_DOES_NOT_BEGIN_WITH
))
396 rEntry
.eOp
= SC_DOES_NOT_BEGIN_WITH
;
397 else if (IsXMLToken(aOpStr
, XML_ENDS_WITH
))
398 rEntry
.eOp
= SC_ENDS_WITH
;
399 else if (IsXMLToken(aOpStr
, XML_DOES_NOT_END_WITH
))
400 rEntry
.eOp
= SC_DOES_NOT_END_WITH
;
403 void ScXMLConditionContext::AddSetItem(const ScQueryEntry::Item
& rItem
)
405 maQueryItems
.push_back(rItem
);
408 void SAL_CALL
ScXMLConditionContext::endFastElement( sal_Int32
/*nElement*/ )
410 ScQueryEntry
& rEntry
= mrQueryParam
.AppendEntry();
412 // We currently don't support per-condition case sensitivity.
413 mrQueryParam
.bCaseSens
= bIsCaseSensitive
;
415 rEntry
.bDoQuery
= true;
416 rEntry
.eConnect
= pFilterContext
->GetConnection() ? SC_OR
: SC_AND
;
418 GetOperator(sOperator
, mrQueryParam
, rEntry
);
419 SCCOLROW nStartPos
= mrQueryParam
.bByRow
? mrQueryParam
.nCol1
: mrQueryParam
.nRow1
;
420 rEntry
.nField
= o3tl::saturating_add(nField
, nStartPos
);
422 if (maQueryItems
.empty())
424 ScQueryEntry::Item
& rItem
= rEntry
.GetQueryItem();
425 if (IsXMLToken(sOperator
, XML_TOKEN_EMPTY
))
427 if (IsXMLToken(sDataType
, XML_NUMBER
))
429 rItem
.mfVal
= sConditionValue
.toDouble();
430 rItem
.meType
= ScQueryEntry::ByValue
;
432 else if (IsXMLToken(sDataType
, XML_TEXT_COLOR
)
433 || IsXMLToken(sDataType
, XML_BACKGROUND_COLOR
))
435 rItem
.meType
= IsXMLToken(sDataType
, XML_TEXT_COLOR
) ? ScQueryEntry::ByTextColor
436 : ScQueryEntry::ByBackgroundColor
;
437 if (IsXMLToken(sConditionValue
, XML_TRANSPARENT
)
438 || IsXMLToken(sConditionValue
, XML_WINDOW_FONT_COLOR
))
439 rItem
.maColor
= COL_AUTO
;
441 sax::Converter::convertColor(rItem
.maColor
, sConditionValue
);
445 svl::SharedStringPool
& rPool
= GetScImport().GetDocument()->GetSharedStringPool();
446 rItem
.maString
= rPool
.intern(sConditionValue
);
447 rItem
.meType
= ScQueryEntry::ByString
;
451 rEntry
.GetQueryItems().swap(maQueryItems
);
454 ScXMLSetItemContext::ScXMLSetItemContext(
455 ScXMLImport
& rImport
, sal_Int32
/*nElement*/,
456 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
, ScXMLConditionContext
& rParent
) :
457 ScXMLImportContext(rImport
)
459 if ( !rAttrList
.is() )
462 for (auto &aIter
: *rAttrList
)
464 switch (aIter
.getToken())
466 case XML_ELEMENT( TABLE
, XML_VALUE
):
468 svl::SharedStringPool
& rPool
= GetScImport().GetDocument()->GetSharedStringPool();
469 ScQueryEntry::Item aItem
;
470 aItem
.maString
= rPool
.intern(aIter
.toString());
471 aItem
.meType
= ScQueryEntry::ByString
;
473 rParent
.AddSetItem(aItem
);
480 ScXMLSetItemContext::~ScXMLSetItemContext()
484 ScXMLDPFilterContext::ScXMLDPFilterContext( ScXMLImport
& rImport
,
485 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
486 ScXMLDataPilotTableContext
* pTempDataPilotTableContext
) :
487 ScXMLImportContext( rImport
),
488 pDataPilotTable(pTempDataPilotTableContext
),
489 eSearchType(utl::SearchParam::SearchType::Normal
),
490 nFilterFieldCount(0),
491 bSkipDuplicates(false),
492 bIsCaseSensitive(false),
494 bNextConnectionOr(true)
496 if ( !rAttrList
.is() )
499 for (auto &aIter
: *rAttrList
)
501 switch (aIter
.getToken())
503 case XML_ELEMENT( TABLE
, XML_TARGET_RANGE_ADDRESS
):
508 case XML_ELEMENT( TABLE
, XML_CONDITION_SOURCE_RANGE_ADDRESS
):
513 case XML_ELEMENT( TABLE
, XML_CONDITION_SOURCE
):
515 // not supported by StarOffice
518 case XML_ELEMENT( TABLE
, XML_DISPLAY_DUPLICATES
):
520 bSkipDuplicates
= !IsXMLToken(aIter
, XML_TRUE
);
527 ScXMLDPFilterContext::~ScXMLDPFilterContext()
531 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLDPFilterContext::createFastChildContext(
532 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
534 SvXMLImportContext
*pContext(nullptr);
535 sax_fastparser::FastAttributeList
*pAttribList
=
536 &sax_fastparser::castToFastAttributeList( xAttrList
);
540 case XML_ELEMENT( TABLE
, XML_FILTER_AND
):
542 pContext
= new ScXMLDPAndContext( GetScImport(), this);
545 case XML_ELEMENT( TABLE
, XML_FILTER_OR
):
547 pContext
= new ScXMLDPOrContext( GetScImport(), this);
550 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
552 pContext
= new ScXMLDPConditionContext( GetScImport(), nElement
, pAttribList
, this);
560 void SAL_CALL
ScXMLDPFilterContext::endFastElement( sal_Int32
/*nElement*/ )
562 aFilterFields
.eSearchType
= eSearchType
;
563 aFilterFields
.bCaseSens
= bIsCaseSensitive
;
564 aFilterFields
.bDuplicate
= !bSkipDuplicates
;
566 pDataPilotTable
->SetSourceQueryParam(aFilterFields
);
569 void ScXMLDPFilterContext::AddFilterField (const ScQueryEntry
& aFilterField
)
571 aFilterFields
.Resize(nFilterFieldCount
+ 1);
572 ScQueryEntry
& rEntry(aFilterFields
.GetEntry(nFilterFieldCount
));
573 rEntry
= aFilterField
;
574 rEntry
.bDoQuery
= true;
578 ScXMLDPAndContext::ScXMLDPAndContext( ScXMLImport
& rImport
,
579 ScXMLDPFilterContext
* pTempFilterContext
) :
580 ScXMLImportContext( rImport
)
582 pFilterContext
= pTempFilterContext
;
583 pFilterContext
->OpenConnection(false);
586 ScXMLDPAndContext::~ScXMLDPAndContext()
590 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLDPAndContext::createFastChildContext(
591 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
593 SvXMLImportContext
*pContext(nullptr);
594 sax_fastparser::FastAttributeList
*pAttribList
=
595 &sax_fastparser::castToFastAttributeList( xAttrList
);
599 case XML_ELEMENT( TABLE
, XML_FILTER_OR
):
601 // not supported in StarOffice
604 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
606 pContext
= new ScXMLDPConditionContext( GetScImport(), nElement
, pAttribList
, pFilterContext
);
614 void SAL_CALL
ScXMLDPAndContext::endFastElement( sal_Int32
/*nElement*/ )
616 pFilterContext
->CloseConnection();
619 ScXMLDPOrContext::ScXMLDPOrContext( ScXMLImport
& rImport
,
620 ScXMLDPFilterContext
* pTempFilterContext
) :
621 ScXMLImportContext( rImport
),
622 pFilterContext(pTempFilterContext
)
624 pFilterContext
->OpenConnection(true);
627 ScXMLDPOrContext::~ScXMLDPOrContext()
631 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLDPOrContext::createFastChildContext(
632 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
634 SvXMLImportContext
*pContext(nullptr);
635 sax_fastparser::FastAttributeList
*pAttribList
=
636 &sax_fastparser::castToFastAttributeList( xAttrList
);
640 case XML_ELEMENT( TABLE
, XML_FILTER_AND
):
642 pContext
= new ScXMLDPAndContext( GetScImport(), pFilterContext
);
645 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
647 pContext
= new ScXMLDPConditionContext( GetScImport(), nElement
, pAttribList
, pFilterContext
);
655 void SAL_CALL
ScXMLDPOrContext::endFastElement( sal_Int32
/*nElement*/ )
657 pFilterContext
->CloseConnection();
660 ScXMLDPConditionContext::ScXMLDPConditionContext( ScXMLImport
& rImport
,
661 sal_Int32
/*nElement*/,
662 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
663 ScXMLDPFilterContext
* pTempFilterContext
) :
664 ScXMLImportContext( rImport
),
665 pFilterContext(pTempFilterContext
),
666 sDataType(GetXMLToken(XML_TEXT
)),
668 bIsCaseSensitive(false)
671 if ( !rAttrList
.is() )
674 for (auto &aIter
: *rAttrList
)
676 switch (aIter
.getToken())
678 case XML_ELEMENT( TABLE
, XML_FIELD_NUMBER
):
680 nField
= aIter
.toInt32();
683 case XML_ELEMENT( TABLE
, XML_CASE_SENSITIVE
):
685 bIsCaseSensitive
= IsXMLToken(aIter
, XML_TRUE
);
688 case XML_ELEMENT( TABLE
, XML_DATA_TYPE
):
690 sDataType
= aIter
.toString();
693 case XML_ELEMENT( TABLE
, XML_VALUE
):
695 sConditionValue
= aIter
.toString();
698 case XML_ELEMENT( TABLE
, XML_OPERATOR
):
700 sOperator
= aIter
.toString();
707 ScXMLDPConditionContext::~ScXMLDPConditionContext()
711 void ScXMLDPConditionContext::getOperatorXML(
712 std::u16string_view sTempOperator
, ScQueryOp
& aFilterOperator
, utl::SearchParam::SearchType
& rSearchType
)
714 rSearchType
= utl::SearchParam::SearchType::Normal
;
715 if (IsXMLToken(sTempOperator
, XML_MATCH
))
717 rSearchType
= utl::SearchParam::SearchType::Regexp
;
718 aFilterOperator
= SC_EQUAL
;
720 else if (IsXMLToken(sTempOperator
, XML_NOMATCH
))
722 rSearchType
= utl::SearchParam::SearchType::Regexp
;
723 aFilterOperator
= SC_NOT_EQUAL
;
725 else if (sTempOperator
== u
"=")
726 aFilterOperator
= SC_EQUAL
;
727 else if (sTempOperator
== u
"!=")
728 aFilterOperator
= SC_NOT_EQUAL
;
729 else if (IsXMLToken(sTempOperator
, XML_BOTTOM_PERCENT
))
730 aFilterOperator
= SC_BOTPERC
;
731 else if (IsXMLToken(sTempOperator
, XML_BOTTOM_VALUES
))
732 aFilterOperator
= SC_BOTVAL
;
733 else if (sTempOperator
== u
">")
734 aFilterOperator
= SC_GREATER
;
735 else if (sTempOperator
== u
">=")
736 aFilterOperator
= SC_GREATER_EQUAL
;
737 else if (sTempOperator
== u
"<")
738 aFilterOperator
= SC_LESS
;
739 else if (sTempOperator
== u
"<=")
740 aFilterOperator
= SC_LESS_EQUAL
;
741 else if (IsXMLToken(sTempOperator
, XML_TOP_PERCENT
))
742 aFilterOperator
= SC_TOPPERC
;
743 else if (IsXMLToken(sTempOperator
, XML_TOP_VALUES
))
744 aFilterOperator
= SC_TOPVAL
;
747 void SAL_CALL
ScXMLDPConditionContext::endFastElement( sal_Int32
/*nElement*/ )
749 ScQueryEntry aFilterField
;
750 aFilterField
.nField
= nField
;
751 if (pFilterContext
->GetConnection())
752 aFilterField
.eConnect
= SC_OR
;
754 aFilterField
.eConnect
= SC_AND
;
755 pFilterContext
->SetIsCaseSensitive(bIsCaseSensitive
);
756 if (IsXMLToken(sOperator
, XML_TOKEN_EMPTY
))
757 aFilterField
.SetQueryByEmpty();
758 else if (IsXMLToken(sOperator
, XML_NOEMPTY
))
759 aFilterField
.SetQueryByNonEmpty();
762 utl::SearchParam::SearchType eSearchType
= utl::SearchParam::SearchType::Normal
;
763 getOperatorXML(sOperator
, aFilterField
.eOp
, eSearchType
);
764 pFilterContext
->SetSearchType(eSearchType
);
765 ScQueryEntry::Item
& rItem
= aFilterField
.GetQueryItem();
766 svl::SharedStringPool
& rPool
= GetScImport().GetDocument()->GetSharedStringPool();
768 if (IsXMLToken(sDataType
, XML_NUMBER
))
770 rItem
.mfVal
= sConditionValue
.toDouble();
771 rItem
.maString
= rPool
.intern(sConditionValue
);
772 rItem
.meType
= ScQueryEntry::ByValue
;
776 rItem
.maString
= rPool
.intern(sConditionValue
);
777 rItem
.meType
= ScQueryEntry::ByString
;
781 pFilterContext
->AddFilterField(aFilterField
);
784 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */