Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef FORMS_COMPONENT_FILTER_HXX
21 : #define FORMS_COMPONENT_FILTER_HXX
22 :
23 : #include <com/sun/star/lang/XServiceInfo.hpp>
24 : #include <com/sun/star/beans/XPropertySet.hpp>
25 : #include <com/sun/star/lang/XInitialization.hpp>
26 : #include <com/sun/star/form/XBoundComponent.hpp>
27 : #include <com/sun/star/util/XNumberFormatter.hpp>
28 : #include <com/sun/star/awt/XTextComponent.hpp>
29 : #include <com/sun/star/sdb/SQLContext.hpp>
30 : #include <toolkit/controls/unocontrol.hxx>
31 :
32 : #include <toolkit/helper/listenermultiplexer.hxx>
33 : #include <cppuhelper/implbase5.hxx>
34 : #include <comphelper/uno3.hxx>
35 : #include <comphelper/componentcontext.hxx>
36 : #include <cppuhelper/implbase4.hxx>
37 : #include <connectivity/sqlparse.hxx>
38 : #include <svx/ParseContext.hxx>
39 :
40 : #include <boost/unordered_map.hpp>
41 :
42 : //.........................................................................
43 : namespace frm
44 : {
45 : //.........................................................................
46 :
47 : //=====================================================================
48 : // OFilterControl
49 : //=====================================================================
50 : typedef ::cppu::ImplHelper5 < ::com::sun::star::awt::XTextComponent
51 : , ::com::sun::star::awt::XFocusListener
52 : , ::com::sun::star::awt::XItemListener
53 : , ::com::sun::star::form::XBoundComponent
54 : , ::com::sun::star::lang::XInitialization
55 : > OFilterControl_BASE;
56 :
57 0 : class OFilterControl :public UnoControl
58 : ,public OFilterControl_BASE
59 : ,public ::svxform::OParseContextClient
60 : {
61 : TextListenerMultiplexer m_aTextListeners;
62 :
63 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xField;
64 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter;
65 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
66 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
67 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xMessageParent;
68 :
69 : typedef ::boost::unordered_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > MapString2String;
70 : MapString2String m_aDisplayItemToValueItem;
71 :
72 : ::rtl::OUString m_aText;
73 : ::connectivity::OSQLParser m_aParser;
74 : sal_Int16 m_nControlClass; // which kind of control do we use?
75 : sal_Bool m_bFilterList : 1;
76 : sal_Bool m_bMultiLine : 1;
77 : sal_Bool m_bFilterListFilled : 1;
78 :
79 : private:
80 : // OFilterControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
81 :
82 : void implInitFilterList();
83 :
84 : public:
85 : OFilterControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
86 :
87 0 : DECLARE_UNO3_AGG_DEFAULTS(OFilterControl,OWeakAggObject);
88 : ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
89 :
90 : virtual ::rtl::OUString GetComponentServiceName();
91 : 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 );
92 :
93 : // ::com::sun::star::lang::XComponent
94 : virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException );
95 :
96 : // ::com::sun::star::awt::XTextComponent
97 : virtual void SAL_CALL addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
98 : virtual void SAL_CALL removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
99 : virtual void SAL_CALL setText( const ::rtl::OUString& aText ) throw( ::com::sun::star::uno::RuntimeException );
100 : virtual void SAL_CALL insertText( const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText ) throw( ::com::sun::star::uno::RuntimeException );
101 : virtual ::rtl::OUString SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException );
102 : virtual ::rtl::OUString SAL_CALL getSelectedText() throw( ::com::sun::star::uno::RuntimeException );
103 : virtual void SAL_CALL setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw( ::com::sun::star::uno::RuntimeException );
104 : virtual ::com::sun::star::awt::Selection SAL_CALL getSelection() throw( ::com::sun::star::uno::RuntimeException );
105 : virtual sal_Bool SAL_CALL isEditable() throw( ::com::sun::star::uno::RuntimeException );
106 : virtual void SAL_CALL setEditable( sal_Bool bEditable ) throw( ::com::sun::star::uno::RuntimeException );
107 : virtual void SAL_CALL setMaxTextLen( sal_Int16 nLength ) throw( ::com::sun::star::uno::RuntimeException );
108 : virtual sal_Int16 SAL_CALL getMaxTextLen() throw( ::com::sun::star::uno::RuntimeException );
109 :
110 : // ::com::sun::star::form::XBoundComponent
111 0 : virtual void SAL_CALL addUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener > & /*l*/) throw( ::com::sun::star::uno::RuntimeException ) {}
112 0 : virtual void SAL_CALL removeUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener > & /*l*/) throw( ::com::sun::star::uno::RuntimeException ) {}
113 : virtual sal_Bool SAL_CALL commit() throw( ::com::sun::star::uno::RuntimeException );
114 :
115 : // ::com::sun::star::lang::XEventListener
116 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
117 :
118 : // ::com::sun::star::awt::XFocusListener
119 : virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException );
120 : virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException );
121 :
122 : // ::com::sun::star::awt::XItemListener
123 : virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
124 :
125 : // ::com::sun::star::util::XInitialization
126 : 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);
127 :
128 : // XServiceInfo
129 : virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
130 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
131 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
132 :
133 : // com::sun::star::lang::XServiceInfo - static version
134 : static ::rtl::OUString SAL_CALL getImplementationName_Static();
135 : static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static();
136 : 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 );
137 :
138 : protected:
139 : virtual void PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc );
140 : virtual void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rVal );
141 :
142 : sal_Bool ensureInitialized( );
143 :
144 : void displayException( const ::com::sun::star::sdb::SQLContext& _rExcept );
145 : };
146 : //.........................................................................
147 : } // namespace frm
148 : //.........................................................................
149 :
150 : #endif // FORMS_COMPONENT_FILTER_HXX
151 :
152 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|