1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _CONNECTIVITY_KAB_CONDITION_HXX_
29 #define _CONNECTIVITY_KAB_CONDITION_HXX_
30 
31 #ifndef _COMPHELPER_TYPES_H_
32 #include <comphelper/types.hxx>
33 #endif
34 #include <shell/kde_headers.h>
35 #include <connectivity/dbexception.hxx>
36 
37 namespace connectivity
38 {
39 	namespace kab
40 	{
41 // -----------------------------------------------------------------------------
42 class KabCondition
43 {
44 	public:
45 		virtual ~KabCondition();
46 		virtual sal_Bool isAlwaysTrue() const = 0;
47 		virtual sal_Bool isAlwaysFalse() const = 0;
48 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const = 0;
49 };
50 // -----------------------------------------------------------------------------
51 class KabConditionConstant : public KabCondition
52 {
53 	protected:
54 		sal_Bool m_bValue;
55 
56 	public:
57 		KabConditionConstant(const sal_Bool bValue);
58 		virtual sal_Bool isAlwaysTrue() const;
59 		virtual sal_Bool isAlwaysFalse() const;
60 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
61 };
62 // -----------------------------------------------------------------------------
63 class KabConditionColumn : public KabCondition
64 {
65 	protected:
66 		sal_Int32 m_nFieldNumber;
67 
68 		QString value(const ::KABC::Addressee &aAddressee) const;
69 
70 	public:
71 		KabConditionColumn(
72 			const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
73 		virtual sal_Bool isAlwaysTrue() const;
74 		virtual sal_Bool isAlwaysFalse() const;
75 };
76 // -----------------------------------------------------------------------------
77 class KabConditionNull : public KabConditionColumn
78 {
79 	public:
80 		KabConditionNull(
81 			const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
82 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
83 };
84 // -----------------------------------------------------------------------------
85 class KabConditionNotNull : public KabConditionColumn
86 {
87 	public:
88 		KabConditionNotNull(
89 			const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
90 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
91 };
92 // -----------------------------------------------------------------------------
93 class KabConditionCompare : public KabConditionColumn
94 {
95 	protected:
96 		const ::rtl::OUString m_sMatchString;
97 
98 	public:
99 		KabConditionCompare(
100 			const ::rtl::OUString &sColumnName,
101 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
102 };
103 // -----------------------------------------------------------------------------
104 class KabConditionEqual : public KabConditionCompare
105 {
106 	public:
107 		KabConditionEqual(
108 			const ::rtl::OUString &sColumnName,
109 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
110 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
111 };
112 // -----------------------------------------------------------------------------
113 class KabConditionDifferent : public KabConditionCompare
114 {
115 	public:
116 		KabConditionDifferent(
117 			const ::rtl::OUString &sColumnName,
118 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
119 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
120 };
121 // -----------------------------------------------------------------------------
122 class KabConditionSimilar : public KabConditionCompare
123 {
124 	public:
125 		KabConditionSimilar(
126 			const ::rtl::OUString &sColumnName,
127 			const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
128 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
129 };
130 // -----------------------------------------------------------------------------
131 class KabConditionBoolean : public KabCondition
132 {
133 	protected:
134 		KabCondition *m_pLeft, *m_pRight;
135 
136 	public:
137 		KabConditionBoolean(KabCondition *pLeft, KabCondition *pRight);
138 		virtual ~KabConditionBoolean();
139 };
140 // -----------------------------------------------------------------------------
141 class KabConditionOr : public KabConditionBoolean
142 {
143 	public:
144 		KabConditionOr(KabCondition *pLeft, KabCondition *pRight);
145 		virtual sal_Bool isAlwaysTrue() const;
146 		virtual sal_Bool isAlwaysFalse() const;
147 		virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
148 };
149 // -----------------------------------------------------------------------------
150 class KabConditionAnd : public KabConditionBoolean
151 {
152 	public:
153 		KabConditionAnd(KabCondition *pLeft, KabCondition *pRight);
154 		virtual sal_Bool isAlwaysTrue() const;
155 		virtual sal_Bool isAlwaysFalse() const;
156 		virtual sal_Bool eval(const ::KABC::Addressee &addressee) const;
157 };
158 // -----------------------------------------------------------------------------
159 	}
160 }
161 
162 #endif // _CONNECTIVITY_KAB_CONDITION_HXX_
163