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 DBAUI_QUERYFILTER_HXX
25 #define DBAUI_QUERYFILTER_HXX
26 
27 #ifndef _DIALOG_HXX //autogen
28 #include <vcl/dialog.hxx>
29 #endif
30 
31 #ifndef _LSTBOX_HXX //autogen
32 #include <vcl/lstbox.hxx>
33 #endif
34 
35 #ifndef _EDIT_HXX //autogen
36 #include <vcl/edit.hxx>
37 #endif
38 
39 #ifndef _FIXED_HXX //autogen
40 #include <vcl/fixed.hxx>
41 #endif
42 
43 #ifndef _BUTTON_HXX //autogen
44 #include <vcl/button.hxx>
45 #endif
46 #ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
47 #include <connectivity/sqliterator.hxx>
48 #endif
49 
50 #ifndef CONNECTIVITY_PREDICATEINPUT_HXX
51 #include <connectivity/predicateinput.hxx>
52 #endif
53 #ifndef SVX_QUERYDESIGNCONTEXT_HXX
54 #include "svx/ParseContext.hxx"
55 #endif
56 
57 namespace rtl
58 {
59 	class OUString;
60 }
61 namespace com
62 {
63 	namespace sun
64 	{
65 		namespace star
66 		{
67 			namespace sdb
68 			{
69 				class XSingleSelectQueryComposer;
70 			}
71 			namespace sdbc
72 			{
73 				class XConnection;
74 				class XDatabaseMetaData;
75 			}
76 			namespace container
77 			{
78 				class XNameAccess;
79 			}
80 			namespace beans
81 			{
82 				struct PropertyValue;
83 			}
84 		}
85 	}
86 }
87 //==================================================================
88 // DlgFilterCrit
89 //==================================================================
90 namespace dbaui
91 {
92 	class DlgFilterCrit	:public ModalDialog
93 						,public ::svxform::OParseContextClient
94 	{
95 	private:
96 		ListBox			aLB_WHEREFIELD1;
97 		ListBox			aLB_WHERECOMP1;
98 		Edit			aET_WHEREVALUE1;
99 		ListBox			aLB_WHERECOND2;
100 		ListBox			aLB_WHEREFIELD2;
101 		ListBox			aLB_WHERECOMP2;
102 		Edit			aET_WHEREVALUE2;
103 		ListBox			aLB_WHERECOND3;
104 		ListBox			aLB_WHEREFIELD3;
105 		ListBox			aLB_WHERECOMP3;
106 		Edit			aET_WHEREVALUE3;
107 		FixedText		aFT_WHEREFIELD;
108 		FixedText		aFT_WHERECOMP;
109 		FixedText		aFT_WHEREVALUE;
110 		FixedText		aFT_WHEREOPER;
111         FixedLine       aFL_FIELDS;
112 		OKButton		aBT_OK;
113 		CancelButton	aBT_CANCEL;
114 		HelpButton		aBT_HELP;
115 		String			aSTR_NOENTRY;
116 		String			aSTR_COMPARE_OPERATORS;
117 
118 		::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer>	m_xQueryComposer;
119 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>		m_xColumns;
120 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>			m_xConnection;
121 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>	m_xMetaData;
122 
123 		::dbtools::OPredicateInputController	m_aPredicateInput;
124 
125 		void			SelectField( ListBox& rBox, const String& rField );
126 		DECL_LINK( ListSelectHdl, ListBox * );
127 		DECL_LINK( ListSelectCompHdl, ListBox * );
128 
129 		void			SetLine( sal_uInt16 nIdx,const ::com::sun::star::beans::PropertyValue& _rItem,sal_Bool _bOr );
130 		void			EnableLines();
131 		sal_Int32		GetOSQLPredicateType( const String& _rSelectedPredicate ) const;
132 		sal_uInt16			GetSelectionPos(sal_Int32 eType,const ListBox& rListBox) const;
133 		sal_Bool 		getCondition(const ListBox& _rField,const ListBox& _rComp,const Edit& _rValue,::com::sun::star::beans::PropertyValue& _rFilter) const;
134 		void			fillLines(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& _aValues);
135 
136 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getMatchingColumn( const Edit& _rValueInput ) const;
137 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getColumn( const ::rtl::OUString& _rFieldName ) const;
138 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getQueryColumn( const ::rtl::OUString& _rFieldName ) const;
139 
140 	public:
141 		DlgFilterCrit(	Window * pParent,
142 						const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
143 						const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection,
144 						const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer>& _rxComposer,
145 						const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxCols
146 					);
147 		~DlgFilterCrit();
148 
149         void            BuildWherePart();
150 
151 	protected:
152 		DECL_LINK( PredicateLoseFocus, Edit* );
153 	};
154 
155 }
156 
157 #endif // DBAUI_QUERYFILTER_HXX
158 
159 
160