update credits
[LibreOffice.git] / fpicker / source / office / commonpicker.hxx
blob5008f68055cc402ce5697de284bba686e0a58d77
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 SVTOOLS_COMMONPICKER_HXX
21 #define SVTOOLS_COMMONPICKER_HXX
23 #include <cppuhelper/compbase5.hxx>
24 #include <com/sun/star/ui/dialogs/XControlInformation.hpp>
25 #include <com/sun/star/ui/dialogs/XControlAccess.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/lang/DisposedException.hpp>
28 #include <com/sun/star/awt/XWindow.hpp>
29 #include <com/sun/star/util/XCancellable.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
31 #include <comphelper/broadcasthelper.hxx>
32 #include <comphelper/propertycontainer.hxx>
33 #include <comphelper/proparrhlp.hxx>
34 #include <comphelper/uno3.hxx>
35 #include <tools/link.hxx>
37 class SvtFileDialog;
38 class Window;
40 //.........................................................................
41 namespace svt
43 //.........................................................................
45 typedef ::cppu::WeakComponentImplHelper5 < ::com::sun::star::ui::dialogs::XControlAccess
46 , ::com::sun::star::ui::dialogs::XControlInformation
47 , ::com::sun::star::lang::XEventListener
48 , ::com::sun::star::util::XCancellable
49 , ::com::sun::star::lang::XInitialization
50 > OCommonPicker_Base;
51 /** implements common functionality for the 2 UNO picker components
53 class OCommonPicker
54 :public ::comphelper::OBaseMutex
55 ,public OCommonPicker_Base
56 ,public ::comphelper::OPropertyContainer
57 ,public ::comphelper::OPropertyArrayUsageHelper< OCommonPicker >
59 private:
60 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
62 // <properties>
63 OUString m_sHelpURL;
64 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xWindow;
65 // </properties>
67 SvtFileDialog* m_pDlg;
68 sal_uInt32 m_nCancelEvent;
69 sal_Bool m_bExecuting;
71 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xDialogParent;
73 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xWindowListenerAdapter;
74 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xParentListenerAdapter;
76 protected:
77 OUString m_aTitle;
78 OUString m_aDisplayDirectory;
80 protected:
81 inline SvtFileDialog* getDialog() { return m_pDlg; }
83 inline const ::cppu::OBroadcastHelper& GetBroadcastHelper() const { return OCommonPicker_Base::rBHelper; }
84 inline ::cppu::OBroadcastHelper& GetBroadcastHelper() { return OCommonPicker_Base::rBHelper; }
86 public:
87 OCommonPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory );
89 protected:
90 virtual ~OCommonPicker();
92 // overridables
94 // will be called with locked SolarMutex
95 virtual SvtFileDialog* implCreateDialog( Window* _pParent ) = 0;
96 virtual sal_Int16 implExecutePicker( ) = 0;
97 // do NOT override XExecutableDialog::execute! We need to do some stuff there ourself ...
99 protected:
100 //------------------------------------------------------------------------------------
101 // disambiguate XInterface
102 //------------------------------------------------------------------------------------
103 DECLARE_XINTERFACE( )
105 //------------------------------------------------------------------------------------
106 // disambiguate XTypeProvider
107 //------------------------------------------------------------------------------------
108 DECLARE_XTYPEPROVIDER( )
110 //------------------------------------------------------------------------------------
111 // ComponentHelper/XComponent
112 //------------------------------------------------------------------------------------
113 virtual void SAL_CALL disposing();
115 //------------------------------------------------------------------------------------
116 // XEventListner
117 //------------------------------------------------------------------------------------
118 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
120 //------------------------------------------------------------------------------------
121 // property set related methods
122 //------------------------------------------------------------------------------------
124 // XPropertySet pure methods
125 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
126 // OPropertySetHelper pure methods
127 virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
128 // OPropertyArrayUsageHelper pure methods
129 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
131 // OPropertySetHelper overridden methods
132 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
133 sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception);
135 //------------------------------------------------------------------------------------
136 // XExecutableDialog functions
137 //------------------------------------------------------------------------------------
138 virtual void SAL_CALL setTitle( const OUString& _rTitle ) throw( ::com::sun::star::uno::RuntimeException );
139 virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException );
141 //------------------------------------------------------------------------------------
142 // XControlAccess functions
143 //------------------------------------------------------------------------------------
144 virtual void SAL_CALL setControlProperty( const OUString& aControlName, const OUString& aControlProperty, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
145 virtual ::com::sun::star::uno::Any SAL_CALL getControlProperty( const OUString& aControlName, const OUString& aControlProperty ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
147 //------------------------------------------------------------------------------------
148 // XControlInformation functions
149 //------------------------------------------------------------------------------------
150 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedControls( ) throw (::com::sun::star::uno::RuntimeException);
151 virtual sal_Bool SAL_CALL isControlSupported( const OUString& aControlName ) throw (::com::sun::star::uno::RuntimeException);
152 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedControlProperties( const OUString& aControlName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
153 virtual sal_Bool SAL_CALL isControlPropertySupported( const OUString& aControlName, const OUString& aControlProperty ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
155 //------------------------------------------------------------------------------------
156 // XCancellable functions
157 //------------------------------------------------------------------------------------
158 virtual void SAL_CALL cancel( ) throw (::com::sun::star::uno::RuntimeException);
160 //------------------------------------------------------------------------------------
161 // XInitialization functions
162 //------------------------------------------------------------------------------------
164 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 );
166 //------------------------------------------------------------------------------------
167 // misc
168 //------------------------------------------------------------------------------------
169 void checkAlive() const SAL_THROW( (::com::sun::star::lang::DisposedException) );
171 void prepareDialog();
173 protected:
174 sal_Bool createPicker();
176 /** handle a single argument from the XInitialization::initialize method
178 @return <TRUE/> if the argument could be handled
180 virtual sal_Bool implHandleInitializationArgument(
181 const OUString& _rName,
182 const ::com::sun::star::uno::Any& _rValue
184 SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) );
186 private:
187 void stopWindowListening();
189 DECL_LINK( OnCancelPicker, void* );
191 //.........................................................................
192 } // namespace svt
193 //.........................................................................
195 #endif // SVTOOLS_COMMONPICKER_HXX
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */