update dev300-m58
[ooovba.git] / sd / source / ui / inc / DrawController.hxx
blob68746781fde30bbc236377f8b9c31a65e885ccc9
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: DrawController.hxx,v $
10 * $Revision: 1.19 $
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 SD_DRAW_CONTROLLER_HXX
32 #define SD_DRAW_CONTROLLER_HXX
34 #include "ViewShell.hxx"
36 #include <osl/mutex.hxx>
37 #include <cppuhelper/propshlp.hxx>
38 #include <sfx2/sfxbasecontroller.hxx>
39 #include <com/sun/star/view/XSelectionSupplier.hpp>
40 #include <com/sun/star/view/XFormLayerAccess.hpp>
41 #include <com/sun/star/drawing/XDrawSubController.hpp>
42 #include <com/sun/star/drawing/XDrawView.hpp>
43 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
44 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
45 #include <com/sun/star/drawing/framework/ModuleController.hpp>
46 #include <com/sun/star/lang/XServiceInfo.hpp>
47 #include <com/sun/star/lang/DisposedException.hpp>
48 #include <comphelper/uno3.hxx>
49 #include <cppuhelper/implbase7.hxx>
50 #include <tools/weakbase.hxx>
51 #include <memory>
52 #include <vector>
53 #include <boost/scoped_ptr.hpp>
55 class SfxViewShell;
56 class SdXImpressDocument;
58 namespace css = ::com::sun::star;
60 namespace sd {
62 typedef ::cppu::ImplInheritanceHelper7 <
63 SfxBaseController,
64 ::com::sun::star::view::XSelectionSupplier,
65 ::com::sun::star::lang::XServiceInfo,
66 ::com::sun::star::drawing::XDrawView,
67 ::com::sun::star::view::XSelectionChangeListener,
68 ::com::sun::star::view::XFormLayerAccess,
69 ::com::sun::star::drawing::framework::XControllerManager,
70 ::com::sun::star::lang::XUnoTunnel
71 > DrawControllerInterfaceBase;
73 class BroadcastHelperOwner
75 public:
76 BroadcastHelperOwner (::osl::Mutex& rMutex) : maBroadcastHelper(rMutex) {};
77 ::cppu::OBroadcastHelper maBroadcastHelper;
80 class DrawSubController;
81 class ViewShellBase;
82 class ViewShell;
83 class View;
86 /** The DrawController is the UNO controller for Impress and Draw. It
87 relies objects that implement the DrawSubController interface for view
88 specific behaviour. The life time of the DrawController is roughly that
89 of ViewShellBase but note that the DrawController can (in the case of a
90 reload) outlive the ViewShellBase.
92 The implementation of the XControllerManager interface is not yet in its
93 final form.
95 class DrawController
96 : public DrawControllerInterfaceBase,
97 private BroadcastHelperOwner,
98 public ::cppu::OPropertySetHelper
100 public:
101 enum PropertyHandle {
102 PROPERTY_WORKAREA = 0,
103 PROPERTY_SUB_CONTROLLER = 1,
104 PROPERTY_CURRENTPAGE = 2,
105 PROPERTY_MASTERPAGEMODE = 3,
106 PROPERTY_LAYERMODE = 4,
107 PROPERTY_ACTIVE_LAYER = 5,
108 PROPERTY_ZOOMTYPE = 6,
109 PROPERTY_ZOOMVALUE = 7,
110 PROPERTY_VIEWOFFSET = 8
113 /** Create a new DrawController object for the given ViewShellBase.
115 DrawController (ViewShellBase& rBase) throw();
117 virtual ~DrawController (void) throw();
119 /** Replace the currently used sub controller with the given one. This
120 new sub controller is used from now on for the view (that is the
121 main view shell to be precise) specific tasks. Call this method
122 with a suitable sub controller whenever the view shell in the center
123 pane is exchanged.
124 @param pSubController
125 The ViewShell specific sub controller or NULL when (temporarily
126 while switching to another one) there is no ViewShell displayed
127 in the center pane.
129 void SetSubController (
130 const css::uno::Reference<css::drawing::XDrawSubController>& rxSubController);
132 ::com::sun::star::awt::Rectangle GetVisArea (void) const;
134 /** Call this method when the VisArea has changed.
136 void FireVisAreaChanged (const Rectangle& rVisArea) throw();
138 /** Call this method when the selection has changed.
140 void FireSelectionChangeListener (void) throw();
142 /** Call this method when the edit mode has changed.
144 void FireChangeEditMode (bool bMasterPageMode) throw();
146 /** Call this method when the layer mode has changed.
148 void FireChangeLayerMode (bool bLayerMode) throw();
150 /** Call this method when there is a new current page.
152 void FireSwitchCurrentPage (SdPage* pCurrentPage) throw();
154 /** Return a pointer to the ViewShellBase object that the DrawController
155 is connected to.
156 @return
157 The returned pointer is <NULL/> after a call to
158 ReleaseViewShellBase().
160 ViewShellBase* GetViewShellBase (void);
162 /** This method is typically called from the destructor of ViewShellBase
163 to tell the DrawController that it and its members must not access
164 the ViewShellBase anymore.
165 After this call the DrawController is semi-disposed.
167 void ReleaseViewShellBase (void);
169 static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
171 DECLARE_XINTERFACE()
172 DECLARE_XTYPEPROVIDER()
174 // XComponent
175 virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
176 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
177 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
179 // XController
180 virtual ::sal_Bool SAL_CALL suspend( ::sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException);
182 // XServiceInfo
183 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
184 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
185 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
187 // XSelectionSupplier
188 virtual sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& aSelection ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
189 virtual ::com::sun::star::uno::Any SAL_CALL getSelection( ) throw(::com::sun::star::uno::RuntimeException);
190 virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
191 virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
193 // XPropertySet
194 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
196 // XFormLayerAccess
197 virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > SAL_CALL getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& Form ) throw (::com::sun::star::uno::RuntimeException);
198 virtual ::sal_Bool SAL_CALL isFormDesignMode( ) throw (::com::sun::star::uno::RuntimeException);
199 virtual void SAL_CALL setFormDesignMode( ::sal_Bool DesignMode ) throw (::com::sun::star::uno::RuntimeException);
201 // XControlAccess
202 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& xModel ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
204 // XDrawView
205 virtual void SAL_CALL
206 setCurrentPage (
207 const ::com::sun::star::uno::Reference<
208 ::com::sun::star::drawing::XDrawPage >& xPage)
209 throw(::com::sun::star::uno::RuntimeException);
211 virtual ::com::sun::star::uno::Reference<
212 ::com::sun::star::drawing::XDrawPage > SAL_CALL
213 getCurrentPage (void)
214 throw(::com::sun::star::uno::RuntimeException);
217 // lang::XEventListener
218 virtual void SAL_CALL
219 disposing (const ::com::sun::star::lang::EventObject& rEventObject)
220 throw (::com::sun::star::uno::RuntimeException);
223 // view::XSelectionChangeListener
224 virtual void SAL_CALL
225 selectionChanged (const ::com::sun::star::lang::EventObject& rEvent)
226 throw (::com::sun::star::uno::RuntimeException);
229 // XControllerManager
231 virtual css::uno::Reference<css::drawing::framework::XConfigurationController> SAL_CALL
232 getConfigurationController (void)
233 throw (::com::sun::star::uno::RuntimeException);
235 virtual css::uno::Reference<css::drawing::framework::XModuleController> SAL_CALL
236 getModuleController (void)
237 throw (::com::sun::star::uno::RuntimeException);
240 // XUnoTunnel
242 virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId)
243 throw (com::sun::star::uno::RuntimeException);
245 protected:
246 /** This method must return the name to index table. This table
247 contains all property names and types of this object.
249 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
251 virtual void FillPropertyTable (
252 ::std::vector< ::com::sun::star::beans::Property>& rProperties);
255 * The same as getFastProperyValue, but return the value through
256 * rValue and nHandle is always valid.
258 virtual void SAL_CALL getFastPropertyValue(
259 ::com::sun::star::uno::Any& rValue,
260 sal_Int32 nHandle ) const;
262 /** Convert the value rValue and return the result in rConvertedValue and the
263 old value in rOldValue.
264 After this call the vetoable listeners are notified.
266 @param rConvertedValue
267 The converted value. Only set if return is true.
268 @param rOldValue
269 The old value. Only set if return is true.
270 @param nHandle
271 The handle of the proberty.
272 @return
273 <TRUE/> if the value is converted successfully.
274 @throws IllegalArgumentException
276 virtual sal_Bool SAL_CALL convertFastPropertyValue(
277 ::com::sun::star::uno::Any & rConvertedValue,
278 ::com::sun::star::uno::Any & rOldValue,
279 sal_Int32 nHandle,
280 const ::com::sun::star::uno::Any& rValue )
281 throw (::com::sun::star::lang::IllegalArgumentException);
283 /** The same as setFastProperyValue, but no exception is thrown and nHandle
284 is always valid. You must not broadcast the changes in this method.
286 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
287 sal_Int32 nHandle,
288 const ::com::sun::star::uno::Any& rValue )
289 throw (::com::sun::star::uno::Exception);
291 /** When the called object has been disposed already this method throws
292 a Disposed exception and does not return.
294 void ThrowIfDisposed (void) const
295 throw (::com::sun::star::lang::DisposedException);
297 using cppu::OPropertySetHelper::disposing;
298 using cppu::OPropertySetHelper::getFastPropertyValue;
300 private:
301 /** This pointer to the ViewShellBase can be NULL (after a call to
302 ReleaseViewShellBase()).
304 ViewShellBase* mpBase;
306 Rectangle maLastVisArea;
307 ::tools::WeakReference<SdrPage> mpCurrentPage;
308 bool mbMasterPageMode;
309 bool mbLayerMode;
311 /** This flag indicates whether the called DrawController is being
312 disposed or already has been disposed.
314 bool mbDisposing;
316 ::std::auto_ptr< ::cppu::IPropertyArrayHelper> mpPropertyArrayHelper;
318 /** The current sub controller. May be NULL.
320 css::uno::Reference<css::drawing::XDrawSubController> mxSubController;
322 css::uno::Reference<
323 css::drawing::framework::XConfigurationController> mxConfigurationController;
324 css::uno::Reference<
325 css::drawing::framework::XModuleController> mxModuleController;
327 /** Send an event to all relevant property listeners that a
328 property has changed its value. The fire() method of the
329 OPropertySetHelper is wrapped by this method to handle
330 exceptions thrown by called listeners.
332 void FirePropertyChange (
333 sal_Int32 nHandle,
334 const ::com::sun::star::uno::Any& rNewValue,
335 const ::com::sun::star::uno::Any& rOldValue);
337 void ProvideFrameworkControllers (void);
338 void DisposeFrameworkControllers (void);
341 } // end of namespace sd
343 #endif