Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_FPICKER_SOURCE_OFFICE_COMMONPICKER_HXX
21 : #define INCLUDED_FPICKER_SOURCE_OFFICE_COMMONPICKER_HXX
22 :
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>
36 :
37 : class SvtFileDialog;
38 : namespace vcl { class Window; }
39 : struct ImplSVEvent;
40 :
41 : namespace svt
42 : {
43 :
44 :
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
52 : */
53 : class OCommonPicker
54 : :public ::comphelper::OBaseMutex
55 : ,public OCommonPicker_Base
56 : ,public ::comphelper::OPropertyContainer
57 : ,public ::comphelper::OPropertyArrayUsageHelper< OCommonPicker >
58 : {
59 : private:
60 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
61 :
62 : // <properties>
63 : OUString m_sHelpURL;
64 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xWindow;
65 : // </properties>
66 :
67 : SvtFileDialog* m_pDlg;
68 : ImplSVEvent * m_nCancelEvent;
69 : bool m_bExecuting;
70 :
71 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xDialogParent;
72 :
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;
75 :
76 : protected:
77 : OUString m_aTitle;
78 : OUString m_aDisplayDirectory;
79 :
80 : protected:
81 0 : inline SvtFileDialog* getDialog() { return m_pDlg; }
82 :
83 0 : inline const ::cppu::OBroadcastHelper& GetBroadcastHelper() const { return OCommonPicker_Base::rBHelper; }
84 4 : inline ::cppu::OBroadcastHelper& GetBroadcastHelper() { return OCommonPicker_Base::rBHelper; }
85 :
86 : public:
87 : OCommonPicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory );
88 :
89 : protected:
90 : virtual ~OCommonPicker();
91 :
92 : // overridables
93 :
94 : // will be called with locked SolarMutex
95 : virtual SvtFileDialog* implCreateDialog( vcl::Window* _pParent ) = 0;
96 : virtual sal_Int16 implExecutePicker( ) = 0;
97 : // do NOT override XExecutableDialog::execute! We need to do some stuff there ourself ...
98 :
99 : protected:
100 :
101 : // disambiguate XInterface
102 :
103 : DECLARE_XINTERFACE( )
104 :
105 :
106 : // disambiguate XTypeProvider
107 :
108 : DECLARE_XTYPEPROVIDER( )
109 :
110 :
111 : // ComponentHelper/XComponent
112 :
113 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
114 :
115 :
116 : // XEventListner
117 :
118 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 :
120 :
121 : // property set related methods
122 :
123 :
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, std::exception) SAL_OVERRIDE;
126 : // OPropertySetHelper pure methods
127 : virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
128 : // OPropertyArrayUsageHelper pure methods
129 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
130 :
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, std::exception) SAL_OVERRIDE;
134 :
135 :
136 : // XExecutableDialog functions
137 :
138 : virtual void SAL_CALL setTitle( const OUString& _rTitle ) throw( ::com::sun::star::uno::RuntimeException, std::exception );
139 : virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException, std::exception );
140 :
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
146 :
147 :
148 : // XControlInformation functions
149 :
150 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedControls( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
151 : virtual sal_Bool SAL_CALL isControlSupported( const OUString& aControlName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
153 : virtual sal_Bool SAL_CALL isControlPropertySupported( const OUString& aControlName, const OUString& aControlProperty ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
154 :
155 :
156 : // XCancellable functions
157 :
158 : virtual void SAL_CALL cancel( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 :
160 :
161 : // XInitialization functions
162 :
163 :
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, std::exception ) SAL_OVERRIDE;
165 :
166 :
167 : // misc
168 :
169 : void checkAlive() const;
170 :
171 : void prepareDialog();
172 :
173 : protected:
174 : bool createPicker();
175 :
176 : /** handle a single argument from the XInitialization::initialize method
177 :
178 : @return <TRUE/> if the argument could be handled
179 : */
180 : virtual bool implHandleInitializationArgument(
181 : const OUString& _rName,
182 : const ::com::sun::star::uno::Any& _rValue
183 : );
184 :
185 : private:
186 : void stopWindowListening();
187 :
188 : DECL_LINK( OnCancelPicker, void* );
189 : };
190 :
191 : } // namespace svt
192 :
193 :
194 : #endif // INCLUDED_FPICKER_SOURCE_OFFICE_COMMONPICKER_HXX
195 :
196 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|