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