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 <svl/sharedstringpool.hxx>
30 #include <xmloff/xmltoken.hxx>
31 #include <xmloff/xmlnmspe.hxx>
33 using namespace com::sun::star
;
34 using namespace xmloff::token
;
36 using ::com::sun::star::uno::Reference
;
37 using ::com::sun::star::xml::sax::XAttributeList
;
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());
56 for (auto &aIter
: *rAttrList
)
58 switch (aIter
.getToken())
60 case XML_ELEMENT( TABLE
, XML_TARGET_RANGE_ADDRESS
):
64 if (ScRangeStringConverter::GetRangeFromString( aScRange
, aIter
.toString(), pDoc
, ::formula::FormulaGrammar::CONV_OOO
, nOffset
))
66 aOutputPosition
= aScRange
.aStart
;
67 bCopyOutputData
= true;
71 case XML_ELEMENT( TABLE
, XML_CONDITION_SOURCE_RANGE_ADDRESS
):
74 if (ScRangeStringConverter::GetRangeFromString( aConditionSourceRangeAddress
, aIter
.toString(), pDoc
, ::formula::FormulaGrammar::CONV_OOO
, nOffset
) )
75 bConditionSourceRange
= true;
78 case XML_ELEMENT( TABLE
, XML_CONDITION_SOURCE
):
80 // not supported by StarOffice
83 case XML_ELEMENT( TABLE
, XML_DISPLAY_DUPLICATES
):
85 bSkipDuplicates
= !IsXMLToken(aIter
, XML_TRUE
);
93 ScXMLFilterContext::~ScXMLFilterContext()
97 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLFilterContext::createFastChildContext(
98 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
100 SvXMLImportContext
*pContext(nullptr);
101 sax_fastparser::FastAttributeList
*pAttribList
=
102 sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList
);
106 case XML_ELEMENT( TABLE
, XML_FILTER_AND
):
108 pContext
= new ScXMLAndContext(
109 GetScImport(), mrQueryParam
, this);
112 case XML_ELEMENT( TABLE
, XML_FILTER_OR
):
114 pContext
= new ScXMLOrContext(
115 GetScImport(), mrQueryParam
, this);
118 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
120 pContext
= new ScXMLConditionContext(
121 GetScImport(), nElement
, pAttribList
, mrQueryParam
, this);
127 pContext
= new SvXMLImportContext( GetImport() );
132 void SAL_CALL
ScXMLFilterContext::endFastElement( sal_Int32
/*nElement*/ )
134 mrQueryParam
.bInplace
= !bCopyOutputData
;
135 mrQueryParam
.bDuplicate
= !bSkipDuplicates
;
139 mrQueryParam
.nDestCol
= aOutputPosition
.Col();
140 mrQueryParam
.nDestRow
= aOutputPosition
.Row();
141 mrQueryParam
.nDestTab
= aOutputPosition
.Tab();
144 if (bConditionSourceRange
)
145 pDatabaseRangeContext
->SetFilterConditionSourceRangeAddress(aConditionSourceRangeAddress
);
148 void ScXMLFilterContext::OpenConnection(bool b
)
150 maConnStack
.emplace_back(b
);
153 void ScXMLFilterContext::CloseConnection()
155 maConnStack
.pop_back();
158 bool ScXMLFilterContext::GetConnection()
160 // For condition items in each stack, the first one gets the connection of
161 // the last stack, while the rest of them get that of the current stack.
163 if (maConnStack
.empty())
164 // This should never happen.
167 ConnStackItem
& rItem
= maConnStack
.back();
168 if (rItem
.mnCondCount
)
169 // secondary item gets the current connection.
172 // The next condition of this stack will get the current connection.
175 if (maConnStack
.size() < 2)
176 // There is no last stack. Likely the first condition in the first
177 // stack whose connection is not used. Default in
178 // ScQueryEntry::eConnect is SC_AND, so return false (AND instead of
179 // OR) here. Otherwise, when saving the document again, we'd write a
181 // <table:filter-or><table:filter-and>...</table:filter-and></table:filter-or>
182 // for two conditions connected with AND.
185 std::vector
<ConnStackItem
>::reverse_iterator itr
= maConnStack
.rbegin();
187 return itr
->mbOr
; // connection of the last stack.
190 ScXMLAndContext::ScXMLAndContext( ScXMLImport
& rImport
,
191 ScQueryParam
& rParam
,
192 ScXMLFilterContext
* pTempFilterContext
) :
193 ScXMLImportContext( rImport
),
194 mrQueryParam(rParam
),
195 pFilterContext(pTempFilterContext
)
197 pFilterContext
->OpenConnection(false);
200 ScXMLAndContext::~ScXMLAndContext()
204 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLAndContext::createFastChildContext(
205 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
207 SvXMLImportContext
*pContext(nullptr);
208 sax_fastparser::FastAttributeList
*pAttribList
=
209 sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList
);
213 case XML_ELEMENT( TABLE
, XML_FILTER_OR
):
215 // not supported in StarOffice
218 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
220 pContext
= new ScXMLConditionContext(
221 GetScImport(), nElement
, pAttribList
, mrQueryParam
, pFilterContext
);
227 pContext
= new SvXMLImportContext( GetImport() );
232 void SAL_CALL
ScXMLAndContext::endFastElement( sal_Int32
/*nElement*/ )
234 pFilterContext
->CloseConnection();
237 ScXMLOrContext::ScXMLOrContext( ScXMLImport
& rImport
,
238 ScQueryParam
& rParam
,
239 ScXMLFilterContext
* pTempFilterContext
) :
240 ScXMLImportContext( rImport
),
241 mrQueryParam(rParam
),
242 pFilterContext(pTempFilterContext
)
244 pFilterContext
->OpenConnection(true);
247 ScXMLOrContext::~ScXMLOrContext()
251 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLOrContext::createFastChildContext(
252 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
254 SvXMLImportContext
*pContext(nullptr);
255 sax_fastparser::FastAttributeList
*pAttribList
=
256 sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList
);
260 case XML_ELEMENT( TABLE
, XML_FILTER_AND
):
262 pContext
= new ScXMLAndContext(
263 GetScImport(), mrQueryParam
, pFilterContext
);
266 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
268 pContext
= new ScXMLConditionContext(
269 GetScImport(), nElement
, pAttribList
, mrQueryParam
, pFilterContext
);
275 pContext
= new SvXMLImportContext( GetImport() );
280 void SAL_CALL
ScXMLOrContext::endFastElement( sal_Int32
/*nElement*/ )
282 pFilterContext
->CloseConnection();
285 ScXMLConditionContext::ScXMLConditionContext(
286 ScXMLImport
& rImport
, sal_Int32
/*nElement*/,
287 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
288 ScQueryParam
& rParam
,
289 ScXMLFilterContext
* pTempFilterContext
) :
290 ScXMLImportContext( rImport
),
291 mrQueryParam(rParam
),
292 pFilterContext(pTempFilterContext
),
294 bIsCaseSensitive(false)
296 sDataType
= GetXMLToken(XML_TEXT
);
298 if ( rAttrList
.is() )
300 for (auto &aIter
: *rAttrList
)
302 switch (aIter
.getToken())
304 case XML_ELEMENT( TABLE
, XML_FIELD_NUMBER
):
306 nField
= aIter
.toInt32();
309 case XML_ELEMENT( TABLE
, XML_CASE_SENSITIVE
):
311 bIsCaseSensitive
= IsXMLToken(aIter
, XML_TRUE
);
314 case XML_ELEMENT( TABLE
, XML_DATA_TYPE
):
316 sDataType
= aIter
.toString();
319 case XML_ELEMENT( TABLE
, XML_VALUE
):
321 sConditionValue
= aIter
.toString();
324 case XML_ELEMENT( TABLE
, XML_OPERATOR
):
326 sOperator
= aIter
.toString();
334 ScXMLConditionContext::~ScXMLConditionContext()
338 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLConditionContext::createFastChildContext(
339 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
341 SvXMLImportContext
*pContext
= nullptr;
342 sax_fastparser::FastAttributeList
*pAttribList
=
343 sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList
);
347 case XML_ELEMENT( TABLE
, XML_FILTER_SET_ITEM
):
349 pContext
= new ScXMLSetItemContext(
350 GetScImport(), nElement
, pAttribList
, *this);
356 pContext
= new SvXMLImportContext( GetImport() );
361 void ScXMLConditionContext::GetOperator(
362 const OUString
& aOpStr
, ScQueryParam
& rParam
, ScQueryEntry
& rEntry
)
364 rParam
.eSearchType
= utl::SearchParam::SearchType::Normal
;
365 if (IsXMLToken(aOpStr
, XML_MATCH
))
367 rParam
.eSearchType
= utl::SearchParam::SearchType::Regexp
;
368 rEntry
.eOp
= SC_EQUAL
;
370 else if (IsXMLToken(aOpStr
, XML_NOMATCH
))
372 rParam
.eSearchType
= utl::SearchParam::SearchType::Regexp
;
373 rEntry
.eOp
= SC_NOT_EQUAL
;
375 else if (aOpStr
== "=")
376 rEntry
.eOp
= SC_EQUAL
;
377 else if (aOpStr
== "!=")
378 rEntry
.eOp
= SC_NOT_EQUAL
;
379 else if (IsXMLToken(aOpStr
, XML_BOTTOM_PERCENT
))
380 rEntry
.eOp
= SC_BOTPERC
;
381 else if (IsXMLToken(aOpStr
, XML_BOTTOM_VALUES
))
382 rEntry
.eOp
= SC_BOTVAL
;
383 else if (IsXMLToken(aOpStr
, XML_EMPTY
))
384 rEntry
.SetQueryByEmpty();
385 else if (aOpStr
== ">")
386 rEntry
.eOp
= SC_GREATER
;
387 else if (aOpStr
== ">=")
388 rEntry
.eOp
= SC_GREATER_EQUAL
;
389 else if (aOpStr
== "<")
390 rEntry
.eOp
= SC_LESS
;
391 else if (aOpStr
== "<=")
392 rEntry
.eOp
= SC_LESS_EQUAL
;
393 else if (IsXMLToken(aOpStr
, XML_NOEMPTY
))
394 rEntry
.SetQueryByNonEmpty();
395 else if (IsXMLToken(aOpStr
, XML_TOP_PERCENT
))
396 rEntry
.eOp
= SC_TOPPERC
;
397 else if (IsXMLToken(aOpStr
, XML_TOP_VALUES
))
398 rEntry
.eOp
= SC_TOPVAL
;
399 else if (IsXMLToken(aOpStr
, XML_CONTAINS
))
400 rEntry
.eOp
= SC_CONTAINS
;
401 else if (IsXMLToken(aOpStr
, XML_DOES_NOT_CONTAIN
))
402 rEntry
.eOp
= SC_DOES_NOT_CONTAIN
;
403 else if (IsXMLToken(aOpStr
, XML_BEGINS_WITH
))
404 rEntry
.eOp
= SC_BEGINS_WITH
;
405 else if (IsXMLToken(aOpStr
, XML_DOES_NOT_BEGIN_WITH
))
406 rEntry
.eOp
= SC_DOES_NOT_BEGIN_WITH
;
407 else if (IsXMLToken(aOpStr
, XML_ENDS_WITH
))
408 rEntry
.eOp
= SC_ENDS_WITH
;
409 else if (IsXMLToken(aOpStr
, XML_DOES_NOT_END_WITH
))
410 rEntry
.eOp
= SC_DOES_NOT_END_WITH
;
413 void ScXMLConditionContext::AddSetItem(const ScQueryEntry::Item
& rItem
)
415 maQueryItems
.push_back(rItem
);
418 void SAL_CALL
ScXMLConditionContext::endFastElement( sal_Int32
/*nElement*/ )
420 ScQueryEntry
& rEntry
= mrQueryParam
.AppendEntry();
422 // We currently don't support per-condition case sensitivity.
423 mrQueryParam
.bCaseSens
= bIsCaseSensitive
;
425 rEntry
.bDoQuery
= true;
426 rEntry
.eConnect
= pFilterContext
->GetConnection() ? SC_OR
: SC_AND
;
428 GetOperator(sOperator
, mrQueryParam
, rEntry
);
429 SCCOLROW nStartPos
= mrQueryParam
.bByRow
? mrQueryParam
.nCol1
: mrQueryParam
.nRow1
;
430 rEntry
.nField
= o3tl::saturating_add(nField
, nStartPos
);
432 if (maQueryItems
.empty())
434 ScQueryEntry::Item
& rItem
= rEntry
.GetQueryItem();
435 if (IsXMLToken(sDataType
, XML_NUMBER
))
437 rItem
.mfVal
= sConditionValue
.toDouble();
438 rItem
.meType
= ScQueryEntry::ByValue
;
442 svl::SharedStringPool
& rPool
= GetScImport().GetDocument()->GetSharedStringPool();
443 rItem
.maString
= rPool
.intern(sConditionValue
);
444 rItem
.meType
= ScQueryEntry::ByString
;
448 rEntry
.GetQueryItems().swap(maQueryItems
);
451 ScXMLSetItemContext::ScXMLSetItemContext(
452 ScXMLImport
& rImport
, sal_Int32
/*nElement*/,
453 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
, ScXMLConditionContext
& rParent
) :
454 ScXMLImportContext(rImport
)
456 if ( rAttrList
.is() )
458 for (auto &aIter
: *rAttrList
)
460 switch (aIter
.getToken())
462 case XML_ELEMENT( TABLE
, XML_VALUE
):
464 svl::SharedStringPool
& rPool
= GetScImport().GetDocument()->GetSharedStringPool();
465 ScQueryEntry::Item aItem
;
466 aItem
.maString
= rPool
.intern(aIter
.toString());
467 aItem
.meType
= ScQueryEntry::ByString
;
469 rParent
.AddSetItem(aItem
);
477 ScXMLSetItemContext::~ScXMLSetItemContext()
481 ScXMLDPFilterContext::ScXMLDPFilterContext( ScXMLImport
& rImport
,
482 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
483 ScXMLDataPilotTableContext
* pTempDataPilotTableContext
) :
484 ScXMLImportContext( rImport
),
485 pDataPilotTable(pTempDataPilotTableContext
),
487 eSearchType(utl::SearchParam::SearchType::Normal
),
488 nFilterFieldCount(0),
489 bSkipDuplicates(false),
490 bIsCaseSensitive(false),
492 bNextConnectionOr(true)
494 if ( rAttrList
.is() )
496 for (auto &aIter
: *rAttrList
)
498 switch (aIter
.getToken())
500 case XML_ELEMENT( TABLE
, XML_TARGET_RANGE_ADDRESS
):
505 case XML_ELEMENT( TABLE
, XML_CONDITION_SOURCE_RANGE_ADDRESS
):
510 case XML_ELEMENT( TABLE
, XML_CONDITION_SOURCE
):
512 // not supported by StarOffice
515 case XML_ELEMENT( TABLE
, XML_DISPLAY_DUPLICATES
):
517 bSkipDuplicates
= !IsXMLToken(aIter
, XML_TRUE
);
525 ScXMLDPFilterContext::~ScXMLDPFilterContext()
529 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLDPFilterContext::createFastChildContext(
530 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
532 SvXMLImportContext
*pContext(nullptr);
533 sax_fastparser::FastAttributeList
*pAttribList
=
534 sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList
);
538 case XML_ELEMENT( TABLE
, XML_FILTER_AND
):
540 pContext
= new ScXMLDPAndContext( GetScImport(), this);
543 case XML_ELEMENT( TABLE
, XML_FILTER_OR
):
545 pContext
= new ScXMLDPOrContext( GetScImport(), this);
548 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
550 pContext
= new ScXMLDPConditionContext( GetScImport(), nElement
, pAttribList
, this);
556 pContext
= new SvXMLImportContext( GetImport() );
561 void SAL_CALL
ScXMLDPFilterContext::endFastElement( sal_Int32
/*nElement*/ )
563 aFilterFields
.eSearchType
= eSearchType
;
564 aFilterFields
.bCaseSens
= bIsCaseSensitive
;
565 aFilterFields
.bDuplicate
= !bSkipDuplicates
;
567 pDataPilotTable
->SetSourceQueryParam(aFilterFields
);
570 void ScXMLDPFilterContext::AddFilterField (const ScQueryEntry
& aFilterField
)
572 aFilterFields
.Resize(nFilterFieldCount
+ 1);
573 ScQueryEntry
& rEntry(aFilterFields
.GetEntry(nFilterFieldCount
));
574 rEntry
= aFilterField
;
575 rEntry
.bDoQuery
= true;
579 ScXMLDPAndContext::ScXMLDPAndContext( ScXMLImport
& rImport
,
580 ScXMLDPFilterContext
* pTempFilterContext
) :
581 ScXMLImportContext( rImport
)
583 pFilterContext
= pTempFilterContext
;
584 pFilterContext
->OpenConnection(false);
587 ScXMLDPAndContext::~ScXMLDPAndContext()
591 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLDPAndContext::createFastChildContext(
592 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
594 SvXMLImportContext
*pContext(nullptr);
595 sax_fastparser::FastAttributeList
*pAttribList
=
596 sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList
);
600 case XML_ELEMENT( TABLE
, XML_FILTER_OR
):
602 // not supported in StarOffice
605 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
607 pContext
= new ScXMLDPConditionContext( GetScImport(), nElement
, pAttribList
, pFilterContext
);
613 pContext
= new SvXMLImportContext( GetImport() );
618 void SAL_CALL
ScXMLDPAndContext::endFastElement( sal_Int32
/*nElement*/ )
620 pFilterContext
->CloseConnection();
623 ScXMLDPOrContext::ScXMLDPOrContext( ScXMLImport
& rImport
,
624 ScXMLDPFilterContext
* pTempFilterContext
) :
625 ScXMLImportContext( rImport
),
626 pFilterContext(pTempFilterContext
)
628 pFilterContext
->OpenConnection(true);
631 ScXMLDPOrContext::~ScXMLDPOrContext()
635 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLDPOrContext::createFastChildContext(
636 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
638 SvXMLImportContext
*pContext(nullptr);
639 sax_fastparser::FastAttributeList
*pAttribList
=
640 sax_fastparser::FastAttributeList::castToFastAttributeList( xAttrList
);
644 case XML_ELEMENT( TABLE
, XML_FILTER_AND
):
646 pContext
= new ScXMLDPAndContext( GetScImport(), pFilterContext
);
649 case XML_ELEMENT( TABLE
, XML_FILTER_CONDITION
):
651 pContext
= new ScXMLDPConditionContext( GetScImport(), nElement
, pAttribList
, pFilterContext
);
657 pContext
= new SvXMLImportContext( GetImport() );
662 void SAL_CALL
ScXMLDPOrContext::endFastElement( sal_Int32
/*nElement*/ )
664 pFilterContext
->CloseConnection();
667 ScXMLDPConditionContext::ScXMLDPConditionContext( ScXMLImport
& rImport
,
668 sal_Int32
/*nElement*/,
669 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
,
670 ScXMLDPFilterContext
* pTempFilterContext
) :
671 ScXMLImportContext( rImport
),
672 pFilterContext(pTempFilterContext
),
673 sDataType(GetXMLToken(XML_TEXT
)),
675 bIsCaseSensitive(false)
678 if ( rAttrList
.is() )
680 for (auto &aIter
: *rAttrList
)
682 switch (aIter
.getToken())
684 case XML_ELEMENT( TABLE
, XML_FIELD_NUMBER
):
686 nField
= aIter
.toInt32();
689 case XML_ELEMENT( TABLE
, XML_CASE_SENSITIVE
):
691 bIsCaseSensitive
= IsXMLToken(aIter
, XML_TRUE
);
694 case XML_ELEMENT( TABLE
, XML_DATA_TYPE
):
696 sDataType
= aIter
.toString();
699 case XML_ELEMENT( TABLE
, XML_VALUE
):
701 sConditionValue
= aIter
.toString();
704 case XML_ELEMENT( TABLE
, XML_OPERATOR
):
706 sOperator
= aIter
.toString();
714 ScXMLDPConditionContext::~ScXMLDPConditionContext()
718 void ScXMLDPConditionContext::getOperatorXML(
719 const OUString
& sTempOperator
, ScQueryOp
& aFilterOperator
, utl::SearchParam::SearchType
& rSearchType
)
721 rSearchType
= utl::SearchParam::SearchType::Normal
;
722 if (IsXMLToken(sTempOperator
, XML_MATCH
))
724 rSearchType
= utl::SearchParam::SearchType::Regexp
;
725 aFilterOperator
= SC_EQUAL
;
727 else if (IsXMLToken(sTempOperator
, XML_NOMATCH
))
729 rSearchType
= utl::SearchParam::SearchType::Regexp
;
730 aFilterOperator
= SC_NOT_EQUAL
;
732 else if (sTempOperator
== "=")
733 aFilterOperator
= SC_EQUAL
;
734 else if (sTempOperator
== "!=")
735 aFilterOperator
= SC_NOT_EQUAL
;
736 else if (IsXMLToken(sTempOperator
, XML_BOTTOM_PERCENT
))
737 aFilterOperator
= SC_BOTPERC
;
738 else if (IsXMLToken(sTempOperator
, XML_BOTTOM_VALUES
))
739 aFilterOperator
= SC_BOTVAL
;
740 else if (sTempOperator
== ">")
741 aFilterOperator
= SC_GREATER
;
742 else if (sTempOperator
== ">=")
743 aFilterOperator
= SC_GREATER_EQUAL
;
744 else if (sTempOperator
== "<")
745 aFilterOperator
= SC_LESS
;
746 else if (sTempOperator
== "<=")
747 aFilterOperator
= SC_LESS_EQUAL
;
748 else if (IsXMLToken(sTempOperator
, XML_TOP_PERCENT
))
749 aFilterOperator
= SC_TOPPERC
;
750 else if (IsXMLToken(sTempOperator
, XML_TOP_VALUES
))
751 aFilterOperator
= SC_TOPVAL
;
754 void SAL_CALL
ScXMLDPConditionContext::endFastElement( sal_Int32
/*nElement*/ )
756 ScQueryEntry aFilterField
;
757 if (pFilterContext
->GetConnection())
758 aFilterField
.eConnect
= SC_OR
;
760 aFilterField
.eConnect
= SC_AND
;
761 pFilterContext
->SetIsCaseSensitive(bIsCaseSensitive
);
762 if (IsXMLToken(sOperator
, XML_EMPTY
))
763 aFilterField
.SetQueryByEmpty();
764 else if (IsXMLToken(sOperator
, XML_NOEMPTY
))
765 aFilterField
.SetQueryByNonEmpty();
768 utl::SearchParam::SearchType eSearchType
= utl::SearchParam::SearchType::Normal
;
769 getOperatorXML(sOperator
, aFilterField
.eOp
, eSearchType
);
770 pFilterContext
->SetSearchType(eSearchType
);
771 aFilterField
.nField
= nField
;
772 ScQueryEntry::Item
& rItem
= aFilterField
.GetQueryItem();
773 svl::SharedStringPool
& rPool
= GetScImport().GetDocument()->GetSharedStringPool();
775 if (IsXMLToken(sDataType
, XML_NUMBER
))
777 rItem
.mfVal
= sConditionValue
.toDouble();
778 rItem
.maString
= rPool
.intern(sConditionValue
);
779 rItem
.meType
= ScQueryEntry::ByValue
;
783 rItem
.maString
= rPool
.intern(sConditionValue
);
784 rItem
.meType
= ScQueryEntry::ByString
;
788 pFilterContext
->AddFilterField(aFilterField
);
791 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */