LCOV - code coverage report
Current view: top level - sc/source/filter/xml - xmlfilti.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 23 25 92.0 %
Date: 2014-04-11 Functions: 12 13 92.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef SC_XMLFILTI_HXX
      21             : #define SC_XMLFILTI_HXX
      22             : 
      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>
      30             : 
      31             : #include "xmldrani.hxx"
      32             : #include "xmldpimp.hxx"
      33             : #include "queryentry.hxx"
      34             : 
      35             : #include <stack>
      36             : #include <vector>
      37             : 
      38             : class ScXMLImport;
      39             : struct ScQueryParam;
      40             : 
      41             : class ScXMLFilterContext : public SvXMLImportContext
      42             : {
      43             :     struct ConnStackItem
      44             :     {
      45             :         bool mbOr;
      46             :         int  mnCondCount;
      47             :         ConnStackItem(bool bOr);
      48             :     };
      49             :     ScQueryParam& mrQueryParam;
      50             :     ScXMLDatabaseRangeContext* pDatabaseRangeContext;
      51             : 
      52             :     com::sun::star::table::CellAddress aOutputPosition;
      53             :     com::sun::star::table::CellRangeAddress aConditionSourceRangeAddress;
      54             :     bool        bSkipDuplicates;
      55             :     bool        bCopyOutputData;
      56             :     bool        bConditionSourceRange;
      57             :     std::vector<ConnStackItem> maConnStack;
      58             : 
      59             :     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
      60          16 :     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
      61             : 
      62             : public:
      63             : 
      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,
      68             :                         ScQueryParam& rParam,
      69             :                         ScXMLDatabaseRangeContext* pTempDatabaseRangeContext);
      70             : 
      71             :     virtual ~ScXMLFilterContext();
      72             : 
      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;
      77             : 
      78             :     virtual void EndElement() SAL_OVERRIDE;
      79             : 
      80             :     void OpenConnection(bool b);
      81             :     void CloseConnection();
      82             :     bool GetConnection();
      83             : };
      84             : 
      85             : class ScXMLAndContext : public SvXMLImportContext
      86             : {
      87             :     ScQueryParam& mrQueryParam;
      88             :     ScXMLFilterContext* pFilterContext;
      89             : 
      90             :     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
      91           2 :     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
      92             : 
      93             : public:
      94             : 
      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,
      99             :                      ScQueryParam& rParam,
     100             :                      ScXMLFilterContext* pTempFilterContext);
     101             : 
     102             :     virtual ~ScXMLAndContext();
     103             : 
     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;
     108             : 
     109             :     virtual void EndElement() SAL_OVERRIDE;
     110             : };
     111             : 
     112             : class ScXMLOrContext : public SvXMLImportContext
     113             : {
     114             :     ScQueryParam& mrQueryParam;
     115             :     ScXMLFilterContext* pFilterContext;
     116             : 
     117             :     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     118           8 :     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
     119             : 
     120             : public:
     121             : 
     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);
     128             : 
     129             :     virtual ~ScXMLOrContext();
     130             : 
     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;
     135             : 
     136             :     virtual void EndElement() SAL_OVERRIDE;
     137             : };
     138             : 
     139             : class ScXMLConditionContext : public SvXMLImportContext
     140             : {
     141             :     ScQueryParam& mrQueryParam;
     142             :     ScXMLFilterContext* pFilterContext;
     143             : 
     144             :     ScQueryEntry::QueryItemsType maQueryItems;
     145             :     OUString sDataType;
     146             :     OUString sConditionValue;
     147             :     OUString sOperator;
     148             :     sal_Int32   nField;
     149             :     bool        bIsCaseSensitive;
     150             : 
     151             :     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     152          38 :     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
     153             : 
     154             : public:
     155             : 
     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);
     162             : 
     163             :     virtual ~ScXMLConditionContext();
     164             : 
     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;
     169             : 
     170             :     virtual void EndElement() SAL_OVERRIDE;
     171             : 
     172             :     void GetOperator(const OUString& aOpStr, ScQueryParam& rParam, ScQueryEntry& rEntry) const;
     173             :     void AddSetItem(const ScQueryEntry::Item& rItem);
     174             : };
     175             : 
     176             : class ScXMLSetItemContext : public SvXMLImportContext
     177             : {
     178             :     const ScXMLImport& GetScImport() const;
     179             :     ScXMLImport& GetScImport();
     180             : public:
     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);
     186             : 
     187             :     virtual ~ScXMLSetItemContext();
     188             : 
     189             :     virtual SvXMLImportContext *CreateChildContext(
     190             :         sal_uInt16 nPrefix,
     191             :         const OUString& rLocalName,
     192             :         const ::com::sun::star::uno::Reference<
     193             :             ::com::sun::star::xml::sax::XAttributeList>& xAttrList) SAL_OVERRIDE;
     194             : 
     195             :     virtual void EndElement() SAL_OVERRIDE;
     196             : };
     197             : 
     198             : // Datapilot (Core)
     199             : 
     200             : class ScXMLDPFilterContext : public SvXMLImportContext
     201             : {
     202             :     ScXMLDataPilotTableContext* pDataPilotTable;
     203             : 
     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;
     216             : 
     217             :     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     218           5 :     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
     219             : 
     220             : public:
     221             : 
     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);
     227             : 
     228             :     virtual ~ScXMLDPFilterContext();
     229             : 
     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;
     234             : 
     235             :     virtual void EndElement() SAL_OVERRIDE;
     236             : 
     237           2 :     void SetIsCaseSensitive(const bool bTemp) { bIsCaseSensitive = bTemp; }
     238           2 :     void SetUseRegularExpressions(const bool bTemp) { if (!bUseRegularExpressions) bUseRegularExpressions = bTemp;}
     239             : 
     240           1 :     void OpenConnection(const bool bVal)
     241             :     {
     242           1 :         bool bTemp = bConnectionOr;
     243           1 :         bConnectionOr = bNextConnectionOr;
     244           1 :         bNextConnectionOr = bVal;
     245           1 :         aConnectionOrStack.push(bTemp);
     246           1 :     }
     247             : 
     248           1 :     void CloseConnection()
     249             :     {
     250             :         bool bTemp;
     251           1 :         if (aConnectionOrStack.empty())
     252           0 :             bTemp = false;
     253             :         else
     254             :         {
     255           1 :             bTemp = aConnectionOrStack.top();
     256           1 :             aConnectionOrStack.pop();
     257             :         }
     258           1 :         bConnectionOr = bTemp;
     259           1 :         bNextConnectionOr = bTemp;
     260           1 :     }
     261             : 
     262           2 :     bool GetConnection() { bool bTemp = bConnectionOr; bConnectionOr = bNextConnectionOr; return bTemp; }
     263             :     void AddFilterField (const ScQueryEntry& aFilterField);
     264             : };
     265             : 
     266             : class ScXMLDPAndContext : public SvXMLImportContext
     267             : {
     268             :     ScXMLDPFilterContext* pFilterContext;
     269             : 
     270             :     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     271           4 :     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
     272             : 
     273             : public:
     274             : 
     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);
     280             : 
     281             :     virtual ~ScXMLDPAndContext();
     282             : 
     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;
     287             : 
     288             :     virtual void EndElement() SAL_OVERRIDE;
     289             : };
     290             : 
     291             : class ScXMLDPOrContext : public SvXMLImportContext
     292             : {
     293             :     ScXMLDPFilterContext* pFilterContext;
     294             : 
     295             :     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     296           0 :     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
     297             : 
     298             : public:
     299             : 
     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);
     305             : 
     306             :     virtual ~ScXMLDPOrContext();
     307             : 
     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;
     312             : 
     313             :     virtual void EndElement() SAL_OVERRIDE;
     314             : };
     315             : 
     316             : class ScXMLDPConditionContext : public SvXMLImportContext
     317             : {
     318             :     ScXMLDPFilterContext* pFilterContext;
     319             : 
     320             :     OUString sDataType;
     321             :     OUString sConditionValue;
     322             :     OUString sOperator;
     323             :     sal_Int32   nField;
     324             :     bool        bIsCaseSensitive;
     325             : 
     326             :     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     327          12 :     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
     328             : 
     329             : public:
     330             : 
     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);
     336             : 
     337             :     virtual ~ScXMLDPConditionContext();
     338             : 
     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;
     343             : 
     344             :     void getOperatorXML(
     345             :         const OUString& sTempOperator, ScQueryOp& aFilterOperator, bool& bUseRegularExpressions) const;
     346             :     virtual void EndElement() SAL_OVERRIDE;
     347             : };
     348             : 
     349             : #endif
     350             : 
     351             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10