update dev300-m58
[ooovba.git] / fpicker / source / office / commonpicker.hxx
blob6dc6e41a75065b1f2406976cc6ef21c05e25450f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: commonpicker.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SVTOOLS_COMMONPICKER_HXX
32 #define SVTOOLS_COMMONPICKER_HXX
34 #include <cppuhelper/compbase5.hxx>
35 #include <com/sun/star/ui/dialogs/XControlInformation.hpp>
36 #include <com/sun/star/ui/dialogs/XControlAccess.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/lang/DisposedException.hpp>
39 #include <com/sun/star/awt/XWindow.hpp>
40 #include <com/sun/star/util/XCancellable.hpp>
41 #include <com/sun/star/lang/XInitialization.hpp>
42 #include <comphelper/broadcasthelper.hxx>
43 #include <comphelper/propertycontainer.hxx>
44 #include <comphelper/proparrhlp.hxx>
45 #include <comphelper/uno3.hxx>
46 #include <tools/link.hxx>
48 class SvtFileDialog;
49 class Window;
51 namespace comphelper
53 class OWeakEventListenerAdapter;
56 //.........................................................................
57 namespace svt
59 //.........................................................................
61 typedef ::cppu::WeakComponentImplHelper5 < ::com::sun::star::ui::dialogs::XControlAccess
62 , ::com::sun::star::ui::dialogs::XControlInformation
63 , ::com::sun::star::lang::XEventListener
64 , ::com::sun::star::util::XCancellable
65 , ::com::sun::star::lang::XInitialization
66 > OCommonPicker_Base;
67 /** implements common functionality for the 2 UNO picker components
69 class OCommonPicker
70 :public ::comphelper::OBaseMutex
71 ,public OCommonPicker_Base
72 ,public ::comphelper::OPropertyContainer
73 ,public ::comphelper::OPropertyArrayUsageHelper< OCommonPicker >
75 private:
76 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
78 // <properties>
79 ::rtl::OUString m_sHelpURL;
80 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xWindow;
81 // </properties>
83 SvtFileDialog* m_pDlg;
84 sal_uInt32 m_nCancelEvent;
85 sal_Bool m_bExecuting;
87 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xDialogParent;
89 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xWindowListenerAdapter;
90 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xParentListenerAdapter;
92 protected:
93 ::rtl::OUString m_aTitle;
94 ::rtl::OUString m_aDisplayDirectory;
96 protected:
97 inline SvtFileDialog* getDialog() { return m_pDlg; }
99 inline const ::cppu::OBroadcastHelper& GetBroadcastHelper() const { return OCommonPicker_Base::rBHelper; }
100 inline ::cppu::OBroadcastHelper& GetBroadcastHelper() { return OCommonPicker_Base::rBHelper; }
102 public:
103 OCommonPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory );
105 protected:
106 virtual ~OCommonPicker();
108 // overridables
110 // will be called with locked SolarMutex
111 virtual SvtFileDialog* implCreateDialog( Window* _pParent ) = 0;
112 virtual sal_Int16 implExecutePicker( ) = 0;
113 // do NOT override XExecutableDialog::execute! We need to do some stuff there ourself ...
115 protected:
116 //------------------------------------------------------------------------------------
117 // disambiguate XInterface
118 //------------------------------------------------------------------------------------
119 DECLARE_XINTERFACE( )
121 //------------------------------------------------------------------------------------
122 // disambiguate XTypeProvider
123 //------------------------------------------------------------------------------------
124 DECLARE_XTYPEPROVIDER( )
126 //------------------------------------------------------------------------------------
127 // ComponentHelper/XComponent
128 //------------------------------------------------------------------------------------
129 virtual void SAL_CALL disposing();
131 //------------------------------------------------------------------------------------
132 // XEventListner
133 //------------------------------------------------------------------------------------
134 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
136 //------------------------------------------------------------------------------------
137 // property set related methods
138 //------------------------------------------------------------------------------------
140 // XPropertySet pure methods
141 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
142 // OPropertySetHelper pure methods
143 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
144 // OPropertyArrayUsageHelper pure methods
145 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
147 // OPropertySetHelper overridden methods
148 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
149 sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception);
151 //------------------------------------------------------------------------------------
152 // XExecutableDialog functions
153 //------------------------------------------------------------------------------------
154 virtual void SAL_CALL setTitle( const ::rtl::OUString& _rTitle ) throw( ::com::sun::star::uno::RuntimeException );
155 virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException );
157 //------------------------------------------------------------------------------------
158 // XControlAccess functions
159 //------------------------------------------------------------------------------------
160 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);
161 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);
163 //------------------------------------------------------------------------------------
164 // XControlInformation functions
165 //------------------------------------------------------------------------------------
166 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedControls( ) throw (::com::sun::star::uno::RuntimeException);
167 virtual sal_Bool SAL_CALL isControlSupported( const ::rtl::OUString& aControlName ) throw (::com::sun::star::uno::RuntimeException);
168 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);
169 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);
171 //------------------------------------------------------------------------------------
172 // XCancellable functions
173 //------------------------------------------------------------------------------------
174 virtual void SAL_CALL cancel( ) throw (::com::sun::star::uno::RuntimeException);
176 //------------------------------------------------------------------------------------
177 // XInitialization functions
178 //------------------------------------------------------------------------------------
180 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 );
182 //------------------------------------------------------------------------------------
183 // misc
184 //------------------------------------------------------------------------------------
185 void checkAlive() const SAL_THROW( (::com::sun::star::lang::DisposedException) );
187 void prepareDialog();
189 protected:
190 sal_Bool createPicker();
192 /** handle a single argument from the XInitialization::initialize method
194 @return <TRUE/> if the argument could be handled
196 virtual sal_Bool implHandleInitializationArgument(
197 const ::rtl::OUString& _rName,
198 const ::com::sun::star::uno::Any& _rValue
200 SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) );
202 private:
203 void stopWindowListening();
205 DECL_LINK( OnCancelPicker, void* );
207 //.........................................................................
208 } // namespace svt
209 //.........................................................................
211 #endif // SVTOOLS_COMMONPICKER_HXX