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 _CONNECTIVITY_KAB_CONDITION_HXX_
25 #define _CONNECTIVITY_KAB_CONDITION_HXX_
26 
27 #ifndef _COMPHELPER_TYPES_H_
28 #include <comphelper/types.hxx>
29 #endif
30 #include <shell/kde_headers.h>
31 #include <connectivity/dbexception.hxx>
32 
33 namespace connectivity
34 {
35 	namespace kab
36 	{
37 // -----------------------------------------------------------------------------
38 class KabCondition
39 {
40 	public:
41 		virtual ~KabCondition();
42 		virtual sal_Bool isAlwaysTrue() const = 0;
43 		virtual sal_Bool isAlwaysFalse() const = 0;
44 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const = 0;
45 };
46 // -----------------------------------------------------------------------------
47 class KabConditionConstant : public KabCondition
48 {
49 	protected:
50 		sal_Bool m_bValue;
51 
52 	public:
53 		KabConditionConstant(const sal_Bool bValue);
54 		virtual sal_Bool isAlwaysTrue() const;
55 		virtual sal_Bool isAlwaysFalse() const;
56 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
57 };
58 // -----------------------------------------------------------------------------
59 class KabConditionColumn : public KabCondition
60 {
61 	protected:
62 		sal_Int32 m_nFieldNumber;
63 
64 		QString value(const ::KABC::Addressee &aAddressee) const;
65 
66 	public:
67 		KabConditionColumn(
68 			const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
69 		virtual sal_Bool isAlwaysTrue() const;
70 		virtual sal_Bool isAlwaysFalse() const;
71 };
72 // -----------------------------------------------------------------------------
73 class KabConditionNull : public KabConditionColumn
74 {
75 	public:
76 		KabConditionNull(
77 			const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
78 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
79 };
80 // -----------------------------------------------------------------------------
81 class KabConditionNotNull : public KabConditionColumn
82 {
83 	public:
84 		KabConditionNotNull(
85 			const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
86 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
87 };
88 // -----------------------------------------------------------------------------
89 class KabConditionCompare : public KabConditionColumn
90 {
91 	protected:
92 		const ::rtl::OUString m_sMatchString;
93 
94 	public:
95 		KabConditionCompare(
96 			const ::rtl::OUString &sColumnName,
97 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
98 };
99 // -----------------------------------------------------------------------------
100 class KabConditionEqual : public KabConditionCompare
101 {
102 	public:
103 		KabConditionEqual(
104 			const ::rtl::OUString &sColumnName,
105 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
106 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
107 };
108 // -----------------------------------------------------------------------------
109 class KabConditionDifferent : public KabConditionCompare
110 {
111 	public:
112 		KabConditionDifferent(
113 			const ::rtl::OUString &sColumnName,
114 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
115 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
116 };
117 // -----------------------------------------------------------------------------
118 class KabConditionSimilar : public KabConditionCompare
119 {
120 	public:
121 		KabConditionSimilar(
122 			const ::rtl::OUString &sColumnName,
123 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
124 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
125 };
126 // -----------------------------------------------------------------------------
127 class KabConditionBoolean : public KabCondition
128 {
129 	protected:
130 		KabCondition *m_pLeft, *m_pRight;
131 
132 	public:
133 		KabConditionBoolean(KabCondition *pLeft, KabCondition *pRight);
134 		virtual ~KabConditionBoolean();
135 };
136 // -----------------------------------------------------------------------------
137 class KabConditionOr : public KabConditionBoolean
138 {
139 	public:
140 		KabConditionOr(KabCondition *pLeft, KabCondition *pRight);
141 		virtual sal_Bool isAlwaysTrue() const;
142 		virtual sal_Bool isAlwaysFalse() const;
143 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
144 };
145 // -----------------------------------------------------------------------------
146 class KabConditionAnd : public KabConditionBoolean
147 {
148 	public:
149 		KabConditionAnd(KabCondition *pLeft, KabCondition *pRight);
150 		virtual sal_Bool isAlwaysTrue() const;
151 		virtual sal_Bool isAlwaysFalse() const;
152 		virtual sal_Bool eval(const ::KABC::Addressee &addressee) const;
153 };
154 // -----------------------------------------------------------------------------
155 	}
156 }
157 
158 #endif // _CONNECTIVITY_KAB_CONDITION_HXX_
159