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>
50 class OWeakEventListenerAdapter
;
53 //.........................................................................
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
64 /** implements common functionality for the 2 UNO picker components
67 :public ::comphelper::OBaseMutex
68 ,public OCommonPicker_Base
69 ,public ::comphelper::OPropertyContainer
70 ,public ::comphelper::OPropertyArrayUsageHelper
< OCommonPicker
>
73 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xORB
;
76 ::rtl::OUString m_sHelpURL
;
77 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xWindow
;
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
;
90 ::rtl::OUString m_aTitle
;
91 ::rtl::OUString m_aDisplayDirectory
;
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
; }
100 OCommonPicker( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxFactory
);
103 virtual ~OCommonPicker();
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 ...
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 //------------------------------------------------------------------------------------
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 //------------------------------------------------------------------------------------
181 //------------------------------------------------------------------------------------
182 void checkAlive() const SAL_THROW( (::com::sun::star::lang::DisposedException
) );
184 void prepareDialog();
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
) );
200 void stopWindowListening();
202 DECL_LINK( OnCancelPicker
, void* );
204 //.........................................................................
206 //.........................................................................
208 #endif // SVTOOLS_COMMONPICKER_HXX