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 INCLUDED_FORMS_SOURCE_COMPONENT_FILTER_HXX
21 : #define INCLUDED_FORMS_SOURCE_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 <cppuhelper/implbase4.hxx>
36 : #include <connectivity/sqlparse.hxx>
37 : #include <svx/ParseContext.hxx>
38 :
39 : #include <boost/unordered_map.hpp>
40 :
41 :
42 : namespace frm
43 : {
44 :
45 :
46 :
47 : // OFilterControl
48 :
49 : typedef ::cppu::ImplHelper5 < ::com::sun::star::awt::XTextComponent
50 : , ::com::sun::star::awt::XFocusListener
51 : , ::com::sun::star::awt::XItemListener
52 : , ::com::sun::star::form::XBoundComponent
53 : , ::com::sun::star::lang::XInitialization
54 : > OFilterControl_BASE;
55 :
56 0 : class OFilterControl :public UnoControl
57 : ,public OFilterControl_BASE
58 : ,public ::svxform::OParseContextClient
59 : {
60 : TextListenerMultiplexer m_aTextListeners;
61 :
62 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
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< OUString, OUString, OUStringHash > MapString2String;
70 : MapString2String m_aDisplayItemToValueItem;
71 :
72 : 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 : void implInitFilterList();
81 : void initControlModel(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xControlModel);
82 :
83 : public:
84 : OFilterControl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB );
85 :
86 0 : DECLARE_UNO3_AGG_DEFAULTS(OFilterControl,OWeakAggObject)
87 : ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
88 :
89 : virtual OUString GetComponentServiceName() SAL_OVERRIDE;
90 : 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, std::exception ) SAL_OVERRIDE;
91 :
92 : // ::com::sun::star::lang::XComponent
93 : virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
94 :
95 : // ::com::sun::star::awt::XTextComponent
96 : virtual void SAL_CALL addTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
97 : virtual void SAL_CALL removeTextListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener > & l ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
98 : virtual void SAL_CALL setText( const OUString& aText ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
99 : virtual void SAL_CALL insertText( const ::com::sun::star::awt::Selection& rSel, const OUString& aText ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
100 : virtual OUString SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
101 : virtual OUString SAL_CALL getSelectedText() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
102 : virtual void SAL_CALL setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
103 : virtual ::com::sun::star::awt::Selection SAL_CALL getSelection() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
104 : virtual sal_Bool SAL_CALL isEditable() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
105 : virtual void SAL_CALL setEditable( sal_Bool bEditable ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
106 : virtual void SAL_CALL setMaxTextLen( sal_Int16 nLength ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
107 : virtual sal_Int16 SAL_CALL getMaxTextLen() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
108 :
109 : // ::com::sun::star::form::XBoundComponent
110 0 : virtual void SAL_CALL addUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener > & /*l*/) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE {}
111 0 : virtual void SAL_CALL removeUpdateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XUpdateListener > & /*l*/) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE {}
112 : virtual sal_Bool SAL_CALL commit() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
113 :
114 : // ::com::sun::star::lang::XEventListener
115 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
116 :
117 : // ::com::sun::star::awt::XFocusListener
118 : virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
119 : virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
120 :
121 : // ::com::sun::star::awt::XItemListener
122 : virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
123 :
124 : // ::com::sun::star::util::XInitialization
125 : 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, std::exception) SAL_OVERRIDE;
126 :
127 : // XServiceInfo
128 : virtual OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
130 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 :
132 : // com::sun::star::lang::XServiceInfo - static version
133 : static OUString SAL_CALL getImplementationName_Static();
134 : static ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_Static();
135 : 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 );
136 :
137 : protected:
138 : virtual void PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc ) SAL_OVERRIDE;
139 : virtual void ImplSetPeerProperty( const OUString& rPropName, const ::com::sun::star::uno::Any& rVal ) SAL_OVERRIDE;
140 :
141 : sal_Bool ensureInitialized( );
142 :
143 : void displayException( const ::com::sun::star::sdb::SQLContext& _rExcept );
144 : };
145 :
146 : } // namespace frm
147 :
148 :
149 : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_FILTER_HXX
150 :
151 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|