1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 SD_DRAW_CONTROLLER_HXX
21 #define SD_DRAW_CONTROLLER_HXX
23 #include "ViewShell.hxx"
25 #include <osl/mutex.hxx>
26 #include <cppuhelper/propshlp.hxx>
27 #include <sfx2/sfxbasecontroller.hxx>
28 #include <com/sun/star/view/XSelectionSupplier.hpp>
29 #include <com/sun/star/view/XFormLayerAccess.hpp>
30 #include <com/sun/star/drawing/XDrawSubController.hpp>
31 #include <com/sun/star/drawing/XDrawView.hpp>
32 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
33 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
34 #include <com/sun/star/drawing/framework/ModuleController.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/lang/DisposedException.hpp>
37 #include <comphelper/uno3.hxx>
38 #include <cppuhelper/implbase7.hxx>
39 #include <tools/weakbase.hxx>
42 #include <boost/scoped_ptr.hpp>
46 typedef ::cppu::ImplInheritanceHelper7
<
48 ::com::sun::star::view::XSelectionSupplier
,
49 ::com::sun::star::lang::XServiceInfo
,
50 ::com::sun::star::drawing::XDrawView
,
51 ::com::sun::star::view::XSelectionChangeListener
,
52 ::com::sun::star::view::XFormLayerAccess
,
53 ::com::sun::star::drawing::framework::XControllerManager
,
54 ::com::sun::star::lang::XUnoTunnel
55 > DrawControllerInterfaceBase
;
57 class BroadcastHelperOwner
60 BroadcastHelperOwner (::osl::Mutex
& rMutex
) : maBroadcastHelper(rMutex
) {};
61 ::cppu::OBroadcastHelper maBroadcastHelper
;
64 class DrawSubController
;
69 /** The DrawController is the UNO controller for Impress and Draw. It
70 relies objects that implement the DrawSubController interface for view
71 specific behaviour. The life time of the DrawController is roughly that
72 of ViewShellBase but note that the DrawController can (in the case of a
73 reload) outlive the ViewShellBase.
75 The implementation of the XControllerManager interface is not yet in its
79 : public DrawControllerInterfaceBase
,
80 private BroadcastHelperOwner
,
81 public ::cppu::OPropertySetHelper
85 PROPERTY_WORKAREA
= 0,
86 PROPERTY_SUB_CONTROLLER
= 1,
87 PROPERTY_CURRENTPAGE
= 2,
88 PROPERTY_MASTERPAGEMODE
= 3,
89 PROPERTY_LAYERMODE
= 4,
90 PROPERTY_ACTIVE_LAYER
= 5,
91 PROPERTY_ZOOMTYPE
= 6,
92 PROPERTY_ZOOMVALUE
= 7,
93 PROPERTY_VIEWOFFSET
= 8,
94 PROPERTY_DRAWVIEWMODE
= 9
97 /** Create a new DrawController object for the given ViewShellBase.
99 DrawController (ViewShellBase
& rBase
) throw();
101 virtual ~DrawController (void) throw();
103 /** Replace the currently used sub controller with the given one. This
104 new sub controller is used from now on for the view (that is the
105 main view shell to be precise) specific tasks. Call this method
106 with a suitable sub controller whenever the view shell in the center
108 @param pSubController
109 The ViewShell specific sub controller or NULL when (temporarily
110 while switching to another one) there is no ViewShell displayed
113 void SetSubController (
114 const css::uno::Reference
<css::drawing::XDrawSubController
>& rxSubController
);
116 /** Call this method when the VisArea has changed.
118 void FireVisAreaChanged (const Rectangle
& rVisArea
) throw();
120 /** Call this method when the selection has changed.
122 void FireSelectionChangeListener (void) throw();
124 /** Call this method when the edit mode has changed.
126 void FireChangeEditMode (bool bMasterPageMode
) throw();
128 /** Call this method when the layer mode has changed.
130 void FireChangeLayerMode (bool bLayerMode
) throw();
132 /** Call this method when there is a new current page.
134 void FireSwitchCurrentPage (SdPage
* pCurrentPage
) throw();
136 /** Broadcast a sidebar context change that is caused by a view
139 void BroadcastContextChange (void) const;
141 /** Return a pointer to the ViewShellBase object that the DrawController
144 The returned pointer is <NULL/> after a call to
145 ReleaseViewShellBase().
147 ViewShellBase
* GetViewShellBase (void);
149 /** This method is typically called from the destructor of ViewShellBase
150 to tell the DrawController that it and its members must not access
151 the ViewShellBase anymore.
152 After this call the DrawController is semi-disposed.
154 void ReleaseViewShellBase (void);
156 static const ::com::sun::star::uno::Sequence
<sal_Int8
>& getUnoTunnelId (void);
159 DECLARE_XTYPEPROVIDER()
162 virtual void SAL_CALL
dispose() throw( ::com::sun::star::uno::RuntimeException
);
163 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
164 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
167 virtual ::sal_Bool SAL_CALL
suspend( ::sal_Bool Suspend
) throw (::com::sun::star::uno::RuntimeException
);
170 virtual OUString SAL_CALL
getImplementationName() throw(::com::sun::star::uno::RuntimeException
);
171 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
172 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
);
174 // XSelectionSupplier
175 virtual sal_Bool SAL_CALL
select( const ::com::sun::star::uno::Any
& aSelection
) throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
176 virtual ::com::sun::star::uno::Any SAL_CALL
getSelection( ) throw(::com::sun::star::uno::RuntimeException
);
177 virtual void SAL_CALL
addSelectionChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::view::XSelectionChangeListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
178 virtual void SAL_CALL
removeSelectionChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::view::XSelectionChangeListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
181 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
184 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::form::runtime::XFormController
> SAL_CALL
getFormController( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>& Form
) throw (::com::sun::star::uno::RuntimeException
);
185 virtual ::sal_Bool SAL_CALL
isFormDesignMode( ) throw (::com::sun::star::uno::RuntimeException
);
186 virtual void SAL_CALL
setFormDesignMode( ::sal_Bool DesignMode
) throw (::com::sun::star::uno::RuntimeException
);
189 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
);
192 virtual void SAL_CALL
194 const ::com::sun::star::uno::Reference
<
195 ::com::sun::star::drawing::XDrawPage
>& xPage
)
196 throw(::com::sun::star::uno::RuntimeException
);
198 virtual ::com::sun::star::uno::Reference
<
199 ::com::sun::star::drawing::XDrawPage
> SAL_CALL
200 getCurrentPage (void)
201 throw(::com::sun::star::uno::RuntimeException
);
204 // lang::XEventListener
205 virtual void SAL_CALL
206 disposing (const ::com::sun::star::lang::EventObject
& rEventObject
)
207 throw (::com::sun::star::uno::RuntimeException
);
210 // view::XSelectionChangeListener
211 virtual void SAL_CALL
212 selectionChanged (const ::com::sun::star::lang::EventObject
& rEvent
)
213 throw (::com::sun::star::uno::RuntimeException
);
216 // XControllerManager
218 virtual css::uno::Reference
<css::drawing::framework::XConfigurationController
> SAL_CALL
219 getConfigurationController (void)
220 throw (::com::sun::star::uno::RuntimeException
);
222 virtual css::uno::Reference
<css::drawing::framework::XModuleController
> SAL_CALL
223 getModuleController (void)
224 throw (::com::sun::star::uno::RuntimeException
);
229 virtual sal_Int64 SAL_CALL
getSomething (const com::sun::star::uno::Sequence
<sal_Int8
>& rId
)
230 throw (com::sun::star::uno::RuntimeException
);
233 /** This method must return the name to index table. This table
234 contains all property names and types of this object.
236 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
238 virtual void FillPropertyTable (
239 ::std::vector
< ::com::sun::star::beans::Property
>& rProperties
);
242 * The same as getFastProperyValue, but return the value through
243 * rValue and nHandle is always valid.
245 virtual void SAL_CALL
getFastPropertyValue(
246 ::com::sun::star::uno::Any
& rValue
,
247 sal_Int32 nHandle
) const;
249 /** Convert the value rValue and return the result in rConvertedValue and the
250 old value in rOldValue.
251 After this call the vetoable listeners are notified.
253 @param rConvertedValue
254 The converted value. Only set if return is true.
256 The old value. Only set if return is true.
258 The handle of the proberty.
260 <TRUE/> if the value is converted successfully.
261 @throws IllegalArgumentException
263 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
264 ::com::sun::star::uno::Any
& rConvertedValue
,
265 ::com::sun::star::uno::Any
& rOldValue
,
267 const ::com::sun::star::uno::Any
& rValue
)
268 throw (::com::sun::star::lang::IllegalArgumentException
);
270 /** The same as setFastProperyValue, but no exception is thrown and nHandle
271 is always valid. You must not broadcast the changes in this method.
273 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
275 const ::com::sun::star::uno::Any
& rValue
)
276 throw (::com::sun::star::uno::Exception
);
278 /** When the called object has been disposed already this method throws
279 a Disposed exception and does not return.
281 void ThrowIfDisposed (void) const
282 throw (::com::sun::star::lang::DisposedException
);
284 using cppu::OPropertySetHelper::disposing
;
285 using cppu::OPropertySetHelper::getFastPropertyValue
;
288 const ::com::sun::star::uno::Type m_aSelectionTypeIdentifier
;
290 /** This pointer to the ViewShellBase can be NULL (after a call to
291 ReleaseViewShellBase()).
293 ViewShellBase
* mpBase
;
295 Rectangle maLastVisArea
;
296 ::tools::WeakReference
<SdrPage
> mpCurrentPage
;
297 bool mbMasterPageMode
;
300 /** This flag indicates whether the called DrawController is being
301 disposed or already has been disposed.
305 ::std::auto_ptr
< ::cppu::IPropertyArrayHelper
> mpPropertyArrayHelper
;
307 /** The current sub controller. May be NULL.
309 css::uno::Reference
<css::drawing::XDrawSubController
> mxSubController
;
312 css::drawing::framework::XConfigurationController
> mxConfigurationController
;
314 css::drawing::framework::XModuleController
> mxModuleController
;
316 /** Send an event to all relevant property listeners that a
317 property has changed its value. The fire() method of the
318 OPropertySetHelper is wrapped by this method to handle
319 exceptions thrown by called listeners.
321 void FirePropertyChange (
323 const ::com::sun::star::uno::Any
& rNewValue
,
324 const ::com::sun::star::uno::Any
& rOldValue
);
326 void ProvideFrameworkControllers (void);
327 void DisposeFrameworkControllers (void);
330 } // end of namespace sd
334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */