1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_FORMS_SOURCE_COMPONENT_FILTER_HXX
21 #define INCLUDED_FORMS_SOURCE_COMPONENT_FILTER_HXX
23 #include <config_features.h>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/lang/XInitialization.hpp>
28 #include <com/sun/star/form/XBoundComponent.hpp>
29 #include <com/sun/star/util/XNumberFormatter.hpp>
30 #include <com/sun/star/awt/XTextComponent.hpp>
31 #include <com/sun/star/sdb/SQLContext.hpp>
32 #include <toolkit/controls/unocontrol.hxx>
34 #include <toolkit/helper/listenermultiplexer.hxx>
35 #include <cppuhelper/implbase5.hxx>
36 #include <comphelper/uno3.hxx>
37 #include <cppuhelper/implbase4.hxx>
38 #include <connectivity/sqlparse.hxx>
39 #include <svx/ParseContext.hxx>
41 #include <unordered_map>
51 typedef ::cppu::ImplHelper5
< ::com::sun::star::awt::XTextComponent
52 , ::com::sun::star::awt::XFocusListener
53 , ::com::sun::star::awt::XItemListener
54 , ::com::sun::star::form::XBoundComponent
55 , ::com::sun::star::lang::XInitialization
56 > OFilterControl_BASE
;
58 class OFilterControl
:public UnoControl
59 ,public OFilterControl_BASE
60 ,public ::svxform::OParseContextClient
62 TextListenerMultiplexer m_aTextListeners
;
64 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
65 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> m_xField
;
66 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatter
> m_xFormatter
;
67 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> m_xConnection
;
68 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
> m_xMetaData
;
69 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xMessageParent
;
71 typedef std::unordered_map
< OUString
, OUString
, OUStringHash
> MapString2String
;
72 MapString2String m_aDisplayItemToValueItem
;
75 #if HAVE_FEATURE_DBCONNECTIVITY
76 ::connectivity::OSQLParser m_aParser
;
78 sal_Int16 m_nControlClass
; // which kind of control do we use?
79 bool m_bFilterList
: 1;
80 bool m_bMultiLine
: 1;
81 bool m_bFilterListFilled
: 1;
84 void implInitFilterList();
85 void initControlModel(::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xControlModel
);
88 OFilterControl( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxORB
);
90 DECLARE_UNO3_AGG_DEFAULTS(OFilterControl
,OWeakAggObject
)
91 ::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
;
93 virtual OUString
GetComponentServiceName() SAL_OVERRIDE
;
94 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
;
96 // ::com::sun::star::lang::XComponent
97 virtual void SAL_CALL
dispose() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
99 // ::com::sun::star::awt::XTextComponent
100 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
;
101 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
;
102 virtual void SAL_CALL
setText( const OUString
& aText
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
103 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
;
104 virtual OUString SAL_CALL
getText() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
105 virtual OUString SAL_CALL
getSelectedText() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
106 virtual void SAL_CALL
setSelection( const ::com::sun::star::awt::Selection
& aSelection
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
107 virtual ::com::sun::star::awt::Selection SAL_CALL
getSelection() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
108 virtual sal_Bool SAL_CALL
isEditable() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
109 virtual void SAL_CALL
setEditable( sal_Bool bEditable
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
110 virtual void SAL_CALL
setMaxTextLen( sal_Int16 nLength
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
111 virtual sal_Int16 SAL_CALL
getMaxTextLen() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
113 // ::com::sun::star::form::XBoundComponent
114 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
{}
115 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
{}
116 virtual sal_Bool SAL_CALL
commit() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
118 // ::com::sun::star::lang::XEventListener
119 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
121 // ::com::sun::star::awt::XFocusListener
122 virtual void SAL_CALL
focusGained(const ::com::sun::star::awt::FocusEvent
& e
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
123 virtual void SAL_CALL
focusLost(const ::com::sun::star::awt::FocusEvent
& e
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
125 // ::com::sun::star::awt::XItemListener
126 virtual void SAL_CALL
itemStateChanged(const ::com::sun::star::awt::ItemEvent
& rEvent
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
128 // ::com::sun::star::util::XInitialization
129 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
;
132 virtual OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
133 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
134 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
136 // com::sun::star::lang::XServiceInfo - static version
137 static OUString SAL_CALL
getImplementationName_Static();
138 static ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames_Static();
141 virtual void PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor
& rDesc
) SAL_OVERRIDE
;
142 virtual void ImplSetPeerProperty( const OUString
& rPropName
, const ::com::sun::star::uno::Any
& rVal
) SAL_OVERRIDE
;
144 bool ensureInitialized( );
146 void displayException( const ::com::sun::star::sdb::SQLContext
& _rExcept
);
152 #endif // INCLUDED_FORMS_SOURCE_COMPONENT_FILTER_HXX
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */