1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SC_XMLFILTI_HXX 25 #define SC_XMLFILTI_HXX 26 27 #include <xmloff/xmlictxt.hxx> 28 #include <xmloff/xmlimp.hxx> 29 #include <com/sun/star/table/CellAddress.hpp> 30 #include <com/sun/star/table/CellRangeAddress.hpp> 31 #include <com/sun/star/sheet/FilterOperator.hpp> 32 #include <com/sun/star/sheet/FilterOperator2.hpp> 33 #include <com/sun/star/sheet/TableFilterField2.hpp> 34 #include <tools/stack.hxx> 35 36 #include "xmldrani.hxx" 37 #include "xmldpimp.hxx" 38 39 class ScXMLImport; 40 41 class ScXMLFilterContext : public SvXMLImportContext 42 { 43 ScXMLDatabaseRangeContext* pDatabaseRangeContext; 44 45 com::sun::star::uno::Sequence <com::sun::star::sheet::TableFilterField2> aFilterFields; 46 com::sun::star::table::CellAddress aOutputPosition; 47 com::sun::star::table::CellRangeAddress aConditionSourceRangeAddress; 48 sal_Int16 nUserListIndex; 49 sal_Bool bSkipDuplicates; 50 sal_Bool bCopyOutputData; 51 sal_Bool bUseRegularExpressions; 52 sal_Bool bIsCaseSensitive; 53 sal_Bool bEnabledUserList; 54 sal_Bool bConnectionOr; 55 sal_Bool bNextConnectionOr; 56 sal_Bool bConditionSourceRange; 57 Stack aConnectionOrStack; 58 GetScImport() const59 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()60 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 61 62 public: 63 64 ScXMLFilterContext( ScXMLImport& rImport, sal_uInt16 nPrfx, 65 const ::rtl::OUString& rLName, 66 const ::com::sun::star::uno::Reference< 67 ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 68 ScXMLDatabaseRangeContext* pTempDatabaseRangeContext); 69 70 virtual ~ScXMLFilterContext(); 71 72 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 73 const ::rtl::OUString& rLocalName, 74 const ::com::sun::star::uno::Reference< 75 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 76 77 virtual void EndElement(); 78 SetIsCaseSensitive(const sal_Bool bTemp)79 void SetIsCaseSensitive(const sal_Bool bTemp) { bIsCaseSensitive = bTemp; } SetUseRegularExpressions(const sal_Bool bTemp)80 void SetUseRegularExpressions(const sal_Bool bTemp) { if (!bUseRegularExpressions) bUseRegularExpressions = bTemp;} OpenConnection(const sal_Bool bTemp)81 void OpenConnection(const sal_Bool bTemp) { sal_Bool* pTemp = new sal_Bool; *pTemp = bConnectionOr; 82 bConnectionOr = bNextConnectionOr; bNextConnectionOr = bTemp; 83 aConnectionOrStack.Push(pTemp);} CloseConnection()84 void CloseConnection() { sal_Bool* pTemp = static_cast <sal_Bool*> (aConnectionOrStack.Pop()); bConnectionOr = *pTemp; bNextConnectionOr = *pTemp; delete pTemp;} GetConnection()85 sal_Bool GetConnection() { sal_Bool bTemp = bConnectionOr; bConnectionOr = bNextConnectionOr; return bTemp; } AddFilterField(const com::sun::star::sheet::TableFilterField2 aFilterField)86 void AddFilterField(const com::sun::star::sheet::TableFilterField2 aFilterField) { aFilterFields.realloc(aFilterFields.getLength() + 1); 87 aFilterFields[aFilterFields.getLength() - 1] = aFilterField; } 88 }; 89 90 class ScXMLAndContext : public SvXMLImportContext 91 { 92 ScXMLFilterContext* pFilterContext; 93 GetScImport() const94 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()95 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 96 97 public: 98 99 ScXMLAndContext( ScXMLImport& rImport, sal_uInt16 nPrfx, 100 const ::rtl::OUString& rLName, 101 const ::com::sun::star::uno::Reference< 102 ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 103 ScXMLFilterContext* pTempFilterContext); 104 105 virtual ~ScXMLAndContext(); 106 107 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 108 const ::rtl::OUString& rLocalName, 109 const ::com::sun::star::uno::Reference< 110 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 111 112 virtual void EndElement(); 113 }; 114 115 class ScXMLOrContext : public SvXMLImportContext 116 { 117 ScXMLFilterContext* pFilterContext; 118 GetScImport() const119 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()120 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 121 122 public: 123 124 ScXMLOrContext( ScXMLImport& rImport, sal_uInt16 nPrfx, 125 const ::rtl::OUString& rLName, 126 const ::com::sun::star::uno::Reference< 127 ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 128 ScXMLFilterContext* pTempFilterContext); 129 130 virtual ~ScXMLOrContext(); 131 132 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 133 const ::rtl::OUString& rLocalName, 134 const ::com::sun::star::uno::Reference< 135 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 136 137 virtual void EndElement(); 138 }; 139 140 class ScXMLConditionContext : public SvXMLImportContext 141 { 142 ScXMLFilterContext* pFilterContext; 143 144 rtl::OUString sDataType; 145 rtl::OUString sConditionValue; 146 rtl::OUString sOperator; 147 sal_Int32 nField; 148 sal_Bool bIsCaseSensitive; 149 GetScImport() const150 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()151 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 152 153 public: 154 155 ScXMLConditionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, 156 const ::rtl::OUString& rLName, 157 const ::com::sun::star::uno::Reference< 158 ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 159 ScXMLFilterContext* pTempFilterContext); 160 161 virtual ~ScXMLConditionContext(); 162 163 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 164 const ::rtl::OUString& rLocalName, 165 const ::com::sun::star::uno::Reference< 166 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 167 168 void getOperatorXML(const rtl::OUString sTempOperator, sal_Int32& aFilterOperator, sal_Bool& bUseRegularExpressions) const; 169 virtual void EndElement(); 170 }; 171 172 // Datapilot (Core) 173 174 class ScXMLDPFilterContext : public SvXMLImportContext 175 { 176 ScXMLDataPilotTableContext* pDataPilotTable; 177 178 ScQueryParam aFilterFields; 179 ScAddress aOutputPosition; 180 ScRange aConditionSourceRangeAddress; 181 sal_uInt8 nFilterFieldCount; 182 sal_Int16 nUserListIndex; 183 sal_Bool bSkipDuplicates; 184 sal_Bool bCopyOutputData; 185 sal_Bool bUseRegularExpressions; 186 sal_Bool bIsCaseSensitive; 187 sal_Bool bEnabledUserList; 188 sal_Bool bConnectionOr; 189 sal_Bool bNextConnectionOr; 190 sal_Bool bConditionSourceRange; 191 Stack aConnectionOrStack; 192 GetScImport() const193 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()194 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 195 196 public: 197 198 ScXMLDPFilterContext( ScXMLImport& rImport, sal_uInt16 nPrfx, 199 const ::rtl::OUString& rLName, 200 const ::com::sun::star::uno::Reference< 201 ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 202 ScXMLDataPilotTableContext* pTempDataPilotTableContext); 203 204 virtual ~ScXMLDPFilterContext(); 205 206 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 207 const ::rtl::OUString& rLocalName, 208 const ::com::sun::star::uno::Reference< 209 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 210 211 virtual void EndElement(); 212 SetIsCaseSensitive(const sal_Bool bTemp)213 void SetIsCaseSensitive(const sal_Bool bTemp) { bIsCaseSensitive = bTemp; } SetUseRegularExpressions(const sal_Bool bTemp)214 void SetUseRegularExpressions(const sal_Bool bTemp) { if (!bUseRegularExpressions) bUseRegularExpressions = bTemp;} OpenConnection(const sal_Bool bTemp)215 void OpenConnection(const sal_Bool bTemp) { sal_Bool* pTemp = new sal_Bool; *pTemp = bConnectionOr; 216 bConnectionOr = bNextConnectionOr; bNextConnectionOr = bTemp; 217 aConnectionOrStack.Push(pTemp);} CloseConnection()218 void CloseConnection() { sal_Bool* pTemp = static_cast <sal_Bool*> (aConnectionOrStack.Pop()); bConnectionOr = *pTemp; bNextConnectionOr = *pTemp; delete pTemp;} GetConnection()219 sal_Bool GetConnection() { sal_Bool bTemp = bConnectionOr; bConnectionOr = bNextConnectionOr; return bTemp; } 220 void AddFilterField (const ScQueryEntry& aFilterField); 221 }; 222 223 class ScXMLDPAndContext : public SvXMLImportContext 224 { 225 ScXMLDPFilterContext* pFilterContext; 226 GetScImport() const227 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()228 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 229 230 public: 231 232 ScXMLDPAndContext( ScXMLImport& rImport, sal_uInt16 nPrfx, 233 const ::rtl::OUString& rLName, 234 const ::com::sun::star::uno::Reference< 235 ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 236 ScXMLDPFilterContext* pTempFilterContext); 237 238 virtual ~ScXMLDPAndContext(); 239 240 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 241 const ::rtl::OUString& rLocalName, 242 const ::com::sun::star::uno::Reference< 243 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 244 245 virtual void EndElement(); 246 }; 247 248 class ScXMLDPOrContext : public SvXMLImportContext 249 { 250 ScXMLDPFilterContext* pFilterContext; 251 GetScImport() const252 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()253 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 254 255 public: 256 257 ScXMLDPOrContext( ScXMLImport& rImport, sal_uInt16 nPrfx, 258 const ::rtl::OUString& rLName, 259 const ::com::sun::star::uno::Reference< 260 ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 261 ScXMLDPFilterContext* pTempFilterContext); 262 263 virtual ~ScXMLDPOrContext(); 264 265 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 266 const ::rtl::OUString& rLocalName, 267 const ::com::sun::star::uno::Reference< 268 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 269 270 virtual void EndElement(); 271 }; 272 273 class ScXMLDPConditionContext : public SvXMLImportContext 274 { 275 ScXMLDPFilterContext* pFilterContext; 276 277 rtl::OUString sDataType; 278 rtl::OUString sConditionValue; 279 rtl::OUString sOperator; 280 sal_Int32 nField; 281 sal_Bool bIsCaseSensitive; 282 GetScImport() const283 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()284 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 285 286 public: 287 288 ScXMLDPConditionContext( ScXMLImport& rImport, sal_uInt16 nPrfx, 289 const ::rtl::OUString& rLName, 290 const ::com::sun::star::uno::Reference< 291 ::com::sun::star::xml::sax::XAttributeList>& xAttrList, 292 ScXMLDPFilterContext* pTempFilterContext); 293 294 virtual ~ScXMLDPConditionContext(); 295 296 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 297 const ::rtl::OUString& rLocalName, 298 const ::com::sun::star::uno::Reference< 299 ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); 300 301 void getOperatorXML(const rtl::OUString sTempOperator, ScQueryOp& aFilterOperator, sal_Bool& bUseRegularExpressions, 302 double& dVal) const; 303 virtual void EndElement(); 304 }; 305 306 #endif 307