xref: /trunk/main/forms/source/component/Filter.hxx (revision cdf0e10c)
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 FORMS_COMPONENT_FILTER_HXX
29 #define FORMS_COMPONENT_FILTER_HXX
30 
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/lang/XInitialization.hpp>
34 #include <com/sun/star/form/XBoundComponent.hpp>
35 #include <com/sun/star/util/XNumberFormatter.hpp>
36 #include <com/sun/star/awt/XTextComponent.hpp>
37 #include <com/sun/star/sdb/SQLContext.hpp>
38 #include <toolkit/controls/unocontrol.hxx>
39 
40 #include <toolkit/helper/listenermultiplexer.hxx>
41 #include <cppuhelper/implbase5.hxx>
42 #include <comphelper/uno3.hxx>
43 #include <comphelper/componentcontext.hxx>
44 #include <cppuhelper/implbase4.hxx>
45 #include <connectivity/sqlparse.hxx>
46 #include <svx/ParseContext.hxx>
47 
48 #include <hash_map>
49 
50 //.........................................................................
51 namespace frm
52 {
53 //.........................................................................
54 
55 	//=====================================================================
56 	// OFilterControl
57 	//=====================================================================
58 	typedef ::cppu::ImplHelper5	<	::com::sun::star::awt::XTextComponent
59 								,	::com::sun::star::awt::XFocusListener
60 								,	::com::sun::star::awt::XItemListener
61 								,	::com::sun::star::form::XBoundComponent
62 								,	::com::sun::star::lang::XInitialization
63 								>	OFilterControl_BASE;
64 
65 	class OFilterControl	:public UnoControl
66 							,public OFilterControl_BASE
67 							,public ::svxform::OParseContextClient
68 	{
69 		TextListenerMultiplexer		m_aTextListeners;
70 
71 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 				m_xField;
72 		::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > 			m_xFormatter;
73 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > 			    m_xConnection;
74 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > 			m_xMetaData;
75 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >						m_xMessageParent;
76 
77         typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > MapString2String;
78         MapString2String                m_aDisplayItemToValueItem;
79 
80 		::rtl::OUString					m_aText;
81 		::connectivity::OSQLParser		m_aParser;
82 		sal_Int16						m_nControlClass;		// which kind of control do we use?
83 		sal_Bool						m_bFilterList : 1;
84 		sal_Bool						m_bMultiLine : 1;
85 		sal_Bool						m_bFilterListFilled : 1;
86 
87 	private:
88 //		OFilterControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
89 
90 		void implInitFilterList();
91 
92 	public:
93 		OFilterControl(	const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
94 
95 		DECLARE_UNO3_AGG_DEFAULTS(OFilterControl,OWeakAggObject);
96 		::com::sun::star::uno::Any	SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
97 
98 		virtual ::rtl::OUString	GetComponentServiceName();
99 		virtual void SAL_CALL	createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > & rxToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >  & rParentPeer ) throw( ::com::sun::star::uno::RuntimeException );
100 
101 	// ::com::sun::star::lang::XComponent
102 		virtual void SAL_CALL	dispose(void) throw( ::com::sun::star::uno::RuntimeException );
103 
104 	// ::com::sun::star::awt::XTextComponent
105 		virtual void			SAL_CALL addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
106 		virtual void			SAL_CALL removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
107 		virtual void			SAL_CALL setText( const ::rtl::OUString& aText ) throw( ::com::sun::star::uno::RuntimeException );
108 		virtual void			SAL_CALL insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw( ::com::sun::star::uno::RuntimeException );
109 		virtual ::rtl::OUString	SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException );
110 		virtual ::rtl::OUString	SAL_CALL getSelectedText() throw( ::com::sun::star::uno::RuntimeException );
111 		virtual void			SAL_CALL setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw( ::com::sun::star::uno::RuntimeException );
112 		virtual ::com::sun::star::awt::Selection SAL_CALL getSelection() throw( ::com::sun::star::uno::RuntimeException );
113 		virtual sal_Bool		SAL_CALL isEditable() throw( ::com::sun::star::uno::RuntimeException );
114 		virtual void			SAL_CALL setEditable( sal_Bool bEditable ) throw( ::com::sun::star::uno::RuntimeException );
115 		virtual void			SAL_CALL setMaxTextLen( sal_Int16 nLength ) throw( ::com::sun::star::uno::RuntimeException );
116 		virtual sal_Int16		SAL_CALL getMaxTextLen() throw( ::com::sun::star::uno::RuntimeException );
117 
118 	// ::com::sun::star::form::XBoundComponent
119 		virtual void			SAL_CALL addUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener > & /*l*/) throw( ::com::sun::star::uno::RuntimeException ) {}
120 		virtual void			SAL_CALL removeUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener > & /*l*/) throw( ::com::sun::star::uno::RuntimeException ) {}
121 		virtual sal_Bool		SAL_CALL commit() throw( ::com::sun::star::uno::RuntimeException );
122 
123 	// ::com::sun::star::lang::XEventListener
124 		virtual void			SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
125 
126 	// ::com::sun::star::awt::XFocusListener
127 		virtual void			SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException );
128         virtual void			SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException );
129 
130 	// ::com::sun::star::awt::XItemListener
131 		virtual void			SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
132 
133 	// ::com::sun::star::util::XInitialization
134 		virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
135 
136 		// XServiceInfo
137 		virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
138 		virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
139 		virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
140 
141 		// com::sun::star::lang::XServiceInfo - static version
142 		static	::rtl::OUString	SAL_CALL getImplementationName_Static();
143 		static	::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static();
144 		static	::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory );
145 
146 	protected:
147 		virtual void PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc );
148 		virtual void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rVal );
149 
150 		sal_Bool ensureInitialized( );
151 
152 		void displayException( const ::com::sun::star::sdb::SQLContext& _rExcept );
153 	};
154 //.........................................................................
155 }	// namespace frm
156 //.........................................................................
157 
158 #endif // FORMS_COMPONENT_FILTER_HXX
159