merged tag ooo/DEV300_m102
[LibreOffice.git] / fpicker / source / office / commonpicker.hxx
blob2531f5e7f4c559f4b3de08aafdcec336d1af34c3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef SVTOOLS_COMMONPICKER_HXX
29 #define SVTOOLS_COMMONPICKER_HXX
31 #include <cppuhelper/compbase5.hxx>
32 #include <com/sun/star/ui/dialogs/XControlInformation.hpp>
33 #include <com/sun/star/ui/dialogs/XControlAccess.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include <com/sun/star/awt/XWindow.hpp>
37 #include <com/sun/star/util/XCancellable.hpp>
38 #include <com/sun/star/lang/XInitialization.hpp>
39 #include <comphelper/broadcasthelper.hxx>
40 #include <comphelper/propertycontainer.hxx>
41 #include <comphelper/proparrhlp.hxx>
42 #include <comphelper/uno3.hxx>
43 #include <tools/link.hxx>
45 class SvtFileDialog;
46 class Window;
48 namespace comphelper
50 class OWeakEventListenerAdapter;
53 //.........................................................................
54 namespace svt
56 //.........................................................................
58 typedef ::cppu::WeakComponentImplHelper5 < ::com::sun::star::ui::dialogs::XControlAccess
59 , ::com::sun::star::ui::dialogs::XControlInformation
60 , ::com::sun::star::lang::XEventListener
61 , ::com::sun::star::util::XCancellable
62 , ::com::sun::star::lang::XInitialization
63 > OCommonPicker_Base;
64 /** implements common functionality for the 2 UNO picker components
66 class OCommonPicker
67 :public ::comphelper::OBaseMutex
68 ,public OCommonPicker_Base
69 ,public ::comphelper::OPropertyContainer
70 ,public ::comphelper::OPropertyArrayUsageHelper< OCommonPicker >
72 private:
73 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
75 // <properties>
76 ::rtl::OUString m_sHelpURL;
77 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xWindow;
78 // </properties>
80 SvtFileDialog* m_pDlg;
81 sal_uInt32 m_nCancelEvent;
82 sal_Bool m_bExecuting;
84 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xDialogParent;
86 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xWindowListenerAdapter;
87 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xParentListenerAdapter;
89 protected:
90 ::rtl::OUString m_aTitle;
91 ::rtl::OUString m_aDisplayDirectory;
93 protected:
94 inline SvtFileDialog* getDialog() { return m_pDlg; }
96 inline const ::cppu::OBroadcastHelper& GetBroadcastHelper() const { return OCommonPicker_Base::rBHelper; }
97 inline ::cppu::OBroadcastHelper& GetBroadcastHelper() { return OCommonPicker_Base::rBHelper; }
99 public:
100 OCommonPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory );
102 protected:
103 virtual ~OCommonPicker();
105 // overridables
107 // will be called with locked SolarMutex
108 virtual SvtFileDialog* implCreateDialog( Window* _pParent ) = 0;
109 virtual sal_Int16 implExecutePicker( ) = 0;
110 // do NOT override XExecutableDialog::execute! We need to do some stuff there ourself ...
112 protected:
113 //------------------------------------------------------------------------------------
114 // disambiguate XInterface
115 //------------------------------------------------------------------------------------
116 DECLARE_XINTERFACE( )
118 //------------------------------------------------------------------------------------
119 // disambiguate XTypeProvider
120 //------------------------------------------------------------------------------------
121 DECLARE_XTYPEPROVIDER( )
123 //------------------------------------------------------------------------------------
124 // ComponentHelper/XComponent
125 //------------------------------------------------------------------------------------
126 virtual void SAL_CALL disposing();
128 //------------------------------------------------------------------------------------
129 // XEventListner
130 //------------------------------------------------------------------------------------
131 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
133 //------------------------------------------------------------------------------------
134 // property set related methods
135 //------------------------------------------------------------------------------------
137 // XPropertySet pure methods
138 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
139 // OPropertySetHelper pure methods
140 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
141 // OPropertyArrayUsageHelper pure methods
142 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
144 // OPropertySetHelper overridden methods
145 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
146 sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception);
148 //------------------------------------------------------------------------------------
149 // XExecutableDialog functions
150 //------------------------------------------------------------------------------------
151 virtual void SAL_CALL setTitle( const ::rtl::OUString& _rTitle ) throw( ::com::sun::star::uno::RuntimeException );
152 virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException );
154 //------------------------------------------------------------------------------------
155 // XControlAccess functions
156 //------------------------------------------------------------------------------------
157 virtual void SAL_CALL setControlProperty( const ::rtl::OUString& aControlName, const ::rtl::OUString& aControlProperty, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
158 virtual ::com::sun::star::uno::Any SAL_CALL getControlProperty( const ::rtl::OUString& aControlName, const ::rtl::OUString& aControlProperty ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
160 //------------------------------------------------------------------------------------
161 // XControlInformation functions
162 //------------------------------------------------------------------------------------
163 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedControls( ) throw (::com::sun::star::uno::RuntimeException);
164 virtual sal_Bool SAL_CALL isControlSupported( const ::rtl::OUString& aControlName ) throw (::com::sun::star::uno::RuntimeException);
165 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedControlProperties( const ::rtl::OUString& aControlName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
166 virtual sal_Bool SAL_CALL isControlPropertySupported( const ::rtl::OUString& aControlName, const ::rtl::OUString& aControlProperty ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
168 //------------------------------------------------------------------------------------
169 // XCancellable functions
170 //------------------------------------------------------------------------------------
171 virtual void SAL_CALL cancel( ) throw (::com::sun::star::uno::RuntimeException);
173 //------------------------------------------------------------------------------------
174 // XInitialization functions
175 //------------------------------------------------------------------------------------
177 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 );
179 //------------------------------------------------------------------------------------
180 // misc
181 //------------------------------------------------------------------------------------
182 void checkAlive() const SAL_THROW( (::com::sun::star::lang::DisposedException) );
184 void prepareDialog();
186 protected:
187 sal_Bool createPicker();
189 /** handle a single argument from the XInitialization::initialize method
191 @return <TRUE/> if the argument could be handled
193 virtual sal_Bool implHandleInitializationArgument(
194 const ::rtl::OUString& _rName,
195 const ::com::sun::star::uno::Any& _rValue
197 SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) );
199 private:
200 void stopWindowListening();
202 DECL_LINK( OnCancelPicker, void* );
204 //.........................................................................
205 } // namespace svt
206 //.........................................................................
208 #endif // SVTOOLS_COMMONPICKER_HXX