1*caf5cd79SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*caf5cd79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*caf5cd79SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*caf5cd79SAndrew Rist * distributed with this work for additional information 6*caf5cd79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*caf5cd79SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*caf5cd79SAndrew Rist * "License"); you may not use this file except in compliance 9*caf5cd79SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*caf5cd79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*caf5cd79SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*caf5cd79SAndrew Rist * software distributed under the License is distributed on an 15*caf5cd79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*caf5cd79SAndrew Rist * KIND, either express or implied. See the License for the 17*caf5cd79SAndrew Rist * specific language governing permissions and limitations 18*caf5cd79SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*caf5cd79SAndrew Rist *************************************************************/ 21*caf5cd79SAndrew Rist 22*caf5cd79SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _CONNECTIVITY_KAB_CONDITION_HXX_ 25cdf0e10cSrcweir #define _CONNECTIVITY_KAB_CONDITION_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_H_ 28cdf0e10cSrcweir #include <comphelper/types.hxx> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #include <shell/kde_headers.h> 31cdf0e10cSrcweir #include <connectivity/dbexception.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace connectivity 34cdf0e10cSrcweir { 35cdf0e10cSrcweir namespace kab 36cdf0e10cSrcweir { 37cdf0e10cSrcweir // ----------------------------------------------------------------------------- 38cdf0e10cSrcweir class KabCondition 39cdf0e10cSrcweir { 40cdf0e10cSrcweir public: 41cdf0e10cSrcweir virtual ~KabCondition(); 42cdf0e10cSrcweir virtual sal_Bool isAlwaysTrue() const = 0; 43cdf0e10cSrcweir virtual sal_Bool isAlwaysFalse() const = 0; 44cdf0e10cSrcweir virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const = 0; 45cdf0e10cSrcweir }; 46cdf0e10cSrcweir // ----------------------------------------------------------------------------- 47cdf0e10cSrcweir class KabConditionConstant : public KabCondition 48cdf0e10cSrcweir { 49cdf0e10cSrcweir protected: 50cdf0e10cSrcweir sal_Bool m_bValue; 51cdf0e10cSrcweir 52cdf0e10cSrcweir public: 53cdf0e10cSrcweir KabConditionConstant(const sal_Bool bValue); 54cdf0e10cSrcweir virtual sal_Bool isAlwaysTrue() const; 55cdf0e10cSrcweir virtual sal_Bool isAlwaysFalse() const; 56cdf0e10cSrcweir virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; 57cdf0e10cSrcweir }; 58cdf0e10cSrcweir // ----------------------------------------------------------------------------- 59cdf0e10cSrcweir class KabConditionColumn : public KabCondition 60cdf0e10cSrcweir { 61cdf0e10cSrcweir protected: 62cdf0e10cSrcweir sal_Int32 m_nFieldNumber; 63cdf0e10cSrcweir 64cdf0e10cSrcweir QString value(const ::KABC::Addressee &aAddressee) const; 65cdf0e10cSrcweir 66cdf0e10cSrcweir public: 67cdf0e10cSrcweir KabConditionColumn( 68cdf0e10cSrcweir const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException); 69cdf0e10cSrcweir virtual sal_Bool isAlwaysTrue() const; 70cdf0e10cSrcweir virtual sal_Bool isAlwaysFalse() const; 71cdf0e10cSrcweir }; 72cdf0e10cSrcweir // ----------------------------------------------------------------------------- 73cdf0e10cSrcweir class KabConditionNull : public KabConditionColumn 74cdf0e10cSrcweir { 75cdf0e10cSrcweir public: 76cdf0e10cSrcweir KabConditionNull( 77cdf0e10cSrcweir const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException); 78cdf0e10cSrcweir virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; 79cdf0e10cSrcweir }; 80cdf0e10cSrcweir // ----------------------------------------------------------------------------- 81cdf0e10cSrcweir class KabConditionNotNull : public KabConditionColumn 82cdf0e10cSrcweir { 83cdf0e10cSrcweir public: 84cdf0e10cSrcweir KabConditionNotNull( 85cdf0e10cSrcweir const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException); 86cdf0e10cSrcweir virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; 87cdf0e10cSrcweir }; 88cdf0e10cSrcweir // ----------------------------------------------------------------------------- 89cdf0e10cSrcweir class KabConditionCompare : public KabConditionColumn 90cdf0e10cSrcweir { 91cdf0e10cSrcweir protected: 92cdf0e10cSrcweir const ::rtl::OUString m_sMatchString; 93cdf0e10cSrcweir 94cdf0e10cSrcweir public: 95cdf0e10cSrcweir KabConditionCompare( 96cdf0e10cSrcweir const ::rtl::OUString &sColumnName, 97cdf0e10cSrcweir const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException); 98cdf0e10cSrcweir }; 99cdf0e10cSrcweir // ----------------------------------------------------------------------------- 100cdf0e10cSrcweir class KabConditionEqual : public KabConditionCompare 101cdf0e10cSrcweir { 102cdf0e10cSrcweir public: 103cdf0e10cSrcweir KabConditionEqual( 104cdf0e10cSrcweir const ::rtl::OUString &sColumnName, 105cdf0e10cSrcweir const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException); 106cdf0e10cSrcweir virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; 107cdf0e10cSrcweir }; 108cdf0e10cSrcweir // ----------------------------------------------------------------------------- 109cdf0e10cSrcweir class KabConditionDifferent : public KabConditionCompare 110cdf0e10cSrcweir { 111cdf0e10cSrcweir public: 112cdf0e10cSrcweir KabConditionDifferent( 113cdf0e10cSrcweir const ::rtl::OUString &sColumnName, 114cdf0e10cSrcweir const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException); 115cdf0e10cSrcweir virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; 116cdf0e10cSrcweir }; 117cdf0e10cSrcweir // ----------------------------------------------------------------------------- 118cdf0e10cSrcweir class KabConditionSimilar : public KabConditionCompare 119cdf0e10cSrcweir { 120cdf0e10cSrcweir public: 121cdf0e10cSrcweir KabConditionSimilar( 122cdf0e10cSrcweir const ::rtl::OUString &sColumnName, 123cdf0e10cSrcweir const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException); 124cdf0e10cSrcweir virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; 125cdf0e10cSrcweir }; 126cdf0e10cSrcweir // ----------------------------------------------------------------------------- 127cdf0e10cSrcweir class KabConditionBoolean : public KabCondition 128cdf0e10cSrcweir { 129cdf0e10cSrcweir protected: 130cdf0e10cSrcweir KabCondition *m_pLeft, *m_pRight; 131cdf0e10cSrcweir 132cdf0e10cSrcweir public: 133cdf0e10cSrcweir KabConditionBoolean(KabCondition *pLeft, KabCondition *pRight); 134cdf0e10cSrcweir virtual ~KabConditionBoolean(); 135cdf0e10cSrcweir }; 136cdf0e10cSrcweir // ----------------------------------------------------------------------------- 137cdf0e10cSrcweir class KabConditionOr : public KabConditionBoolean 138cdf0e10cSrcweir { 139cdf0e10cSrcweir public: 140cdf0e10cSrcweir KabConditionOr(KabCondition *pLeft, KabCondition *pRight); 141cdf0e10cSrcweir virtual sal_Bool isAlwaysTrue() const; 142cdf0e10cSrcweir virtual sal_Bool isAlwaysFalse() const; 143cdf0e10cSrcweir virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; 144cdf0e10cSrcweir }; 145cdf0e10cSrcweir // ----------------------------------------------------------------------------- 146cdf0e10cSrcweir class KabConditionAnd : public KabConditionBoolean 147cdf0e10cSrcweir { 148cdf0e10cSrcweir public: 149cdf0e10cSrcweir KabConditionAnd(KabCondition *pLeft, KabCondition *pRight); 150cdf0e10cSrcweir virtual sal_Bool isAlwaysTrue() const; 151cdf0e10cSrcweir virtual sal_Bool isAlwaysFalse() const; 152cdf0e10cSrcweir virtual sal_Bool eval(const ::KABC::Addressee &addressee) const; 153cdf0e10cSrcweir }; 154cdf0e10cSrcweir // ----------------------------------------------------------------------------- 155cdf0e10cSrcweir } 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir #endif // _CONNECTIVITY_KAB_CONDITION_HXX_ 159