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 INCLUDED_SD_SOURCE_UI_INC_DRAWCONTROLLER_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_DRAWCONTROLLER_HXX
23 #include <cppuhelper/propshlp.hxx>
24 #include <sfx2/sfxbasecontroller.hxx>
25 #include <com/sun/star/view/XSelectionSupplier.hpp>
26 #include <com/sun/star/view/XFormLayerAccess.hpp>
27 #include <com/sun/star/drawing/XDrawView.hpp>
28 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <comphelper/uno3.hxx>
32 #include <cppuhelper/implbase.hxx>
33 #include <tools/weakbase.h>
34 #include <tools/gen.hxx>
38 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ class XDrawSubController
; } } } }
39 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ namespace framework
{ class XConfigurationController
; } } } } }
40 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ namespace framework
{ class XModuleController
; } } } } }
41 namespace com
{ namespace sun
{ namespace star
{ namespace drawing
{ class XLayer
; } } } }
42 namespace osl
{ class Mutex
; }
48 typedef ::cppu::ImplInheritanceHelper
<
50 css::view::XSelectionSupplier
,
51 css::lang::XServiceInfo
,
52 css::drawing::XDrawView
,
53 css::view::XSelectionChangeListener
,
54 css::view::XFormLayerAccess
,
55 css::drawing::framework::XControllerManager
,
57 > DrawControllerInterfaceBase
;
59 class BroadcastHelperOwner
62 explicit BroadcastHelperOwner (::osl::Mutex
& rMutex
) : maBroadcastHelper(rMutex
) {};
63 ::cppu::OBroadcastHelper maBroadcastHelper
;
68 /** The DrawController is the UNO controller for Impress and Draw. It
69 relies objects that implement the DrawSubController interface for view
70 specific behaviour. The life time of the DrawController is roughly that
71 of ViewShellBase but note that the DrawController can (in the case of a
72 reload) outlive the ViewShellBase.
74 The implementation of the XControllerManager interface is not yet in its
77 class DrawController final
78 : public DrawControllerInterfaceBase
,
79 private BroadcastHelperOwner
,
80 public ::cppu::OPropertySetHelper
84 PROPERTY_WORKAREA
= 0,
85 PROPERTY_SUB_CONTROLLER
= 1,
86 PROPERTY_CURRENTPAGE
= 2,
87 PROPERTY_MASTERPAGEMODE
= 3,
88 PROPERTY_LAYERMODE
= 4,
89 PROPERTY_ACTIVE_LAYER
= 5,
90 PROPERTY_ZOOMTYPE
= 6,
91 PROPERTY_ZOOMVALUE
= 7,
92 PROPERTY_VIEWOFFSET
= 8,
93 PROPERTY_DRAWVIEWMODE
= 9
94 ,PROPERTY_UPDATEACC
= 10
95 ,PROPERTY_PAGE_CHANGE
= 11
98 /** Create a new DrawController object for the given ViewShellBase.
100 explicit DrawController (ViewShellBase
& rBase
) throw();
102 virtual ~DrawController() throw() override
;
104 /** Replace the currently used sub controller with the given one. This
105 new sub controller is used from now on for the view (that is the
106 main view shell to be precise) specific tasks. Call this method
107 with a suitable sub controller whenever the view shell in the center
109 @param pSubController
110 The ViewShell specific sub controller or NULL when (temporarily
111 while switching to another one) there is no ViewShell displayed
114 void SetSubController (
115 const css::uno::Reference
<css::drawing::XDrawSubController
>& rxSubController
);
117 /** Call this method when the VisArea has changed.
119 void FireVisAreaChanged (const ::tools::Rectangle
& rVisArea
) throw();
121 /** Call this method when the selection has changed.
123 void FireSelectionChangeListener() throw();
125 /** Call this method when the edit mode has changed.
127 void FireChangeEditMode (bool bMasterPageMode
) throw();
129 /** Call this method when the layer mode has changed.
131 void FireChangeLayerMode (bool bLayerMode
) throw();
133 /** Call this method when there is a new current page.
135 void FireSwitchCurrentPage (SdPage
* pCurrentPage
) throw();
137 /** Broadcast a sidebar context change that is caused by a view
140 void BroadcastContextChange() const;
141 void NotifyAccUpdate();
142 void fireChangeLayer( css::uno::Reference
< css::drawing::XLayer
>* pCurrentLayer
) throw();
143 // change the parameter to int
144 //void fireSwitchCurrentPage( String pageName) throw();
145 void fireSwitchCurrentPage( sal_Int32 pageIndex
) throw();
146 bool IsDisposing() const { return mbDisposing
; }
148 /** Return a pointer to the ViewShellBase object that the DrawController
151 The returned pointer is <NULL/> after a call to
152 ReleaseViewShellBase().
154 ViewShellBase
* GetViewShellBase() { return mpBase
;}
156 /** This method is typically called from the destructor of ViewShellBase
157 to tell the DrawController that it and its members must not access
158 the ViewShellBase anymore.
159 After this call the DrawController is semi-disposed.
161 void ReleaseViewShellBase();
163 static const css::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
166 DECLARE_XTYPEPROVIDER()
169 virtual void SAL_CALL
dispose() override
;
170 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
171 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
174 virtual sal_Bool SAL_CALL
suspend( sal_Bool Suspend
) override
;
177 virtual OUString SAL_CALL
getImplementationName() override
;
178 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
179 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
181 // XSelectionSupplier
182 virtual sal_Bool SAL_CALL
select( const css::uno::Any
& aSelection
) override
;
183 virtual css::uno::Any SAL_CALL
getSelection( ) override
;
184 virtual void SAL_CALL
addSelectionChangeListener( const css::uno::Reference
< css::view::XSelectionChangeListener
>& xListener
) override
;
185 virtual void SAL_CALL
removeSelectionChangeListener( const css::uno::Reference
< css::view::XSelectionChangeListener
>& xListener
) override
;
188 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
191 virtual css::uno::Reference
< css::form::runtime::XFormController
> SAL_CALL
getFormController( const css::uno::Reference
< css::form::XForm
>& Form
) override
;
192 virtual sal_Bool SAL_CALL
isFormDesignMode( ) override
;
193 virtual void SAL_CALL
setFormDesignMode( sal_Bool DesignMode
) override
;
196 virtual css::uno::Reference
< css::awt::XControl
> SAL_CALL
getControl( const css::uno::Reference
< css::awt::XControlModel
>& xModel
) override
;
199 virtual void SAL_CALL
201 const css::uno::Reference
<
202 css::drawing::XDrawPage
>& xPage
) override
;
204 virtual css::uno::Reference
<
205 css::drawing::XDrawPage
> SAL_CALL
206 getCurrentPage() override
;
208 // lang::XEventListener
209 virtual void SAL_CALL
210 disposing (const css::lang::EventObject
& rEventObject
) override
;
212 // view::XSelectionChangeListener
213 virtual void SAL_CALL
214 selectionChanged (const css::lang::EventObject
& rEvent
) override
;
216 // XControllerManager
218 virtual css::uno::Reference
<css::drawing::framework::XConfigurationController
> SAL_CALL
219 getConfigurationController() override
;
221 virtual css::uno::Reference
<css::drawing::framework::XModuleController
> SAL_CALL
222 getModuleController() override
;
226 virtual sal_Int64 SAL_CALL
getSomething (const css::uno::Sequence
<sal_Int8
>& rId
) override
;
229 /** This method must return the name to index table. This table
230 contains all property names and types of this object.
232 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
234 static void FillPropertyTable (
235 ::std::vector
< css::beans::Property
>& rProperties
);
238 * The same as getFastProperyValue, but return the value through
239 * rValue and nHandle is always valid.
241 virtual void SAL_CALL
getFastPropertyValue(
242 css::uno::Any
& rValue
,
243 sal_Int32 nHandle
) const override
;
245 /** Convert the value rValue and return the result in rConvertedValue and the
246 old value in rOldValue.
247 After this call the vetoable listeners are notified.
249 @param rConvertedValue
250 The converted value. Only set if return is true.
252 The old value. Only set if return is true.
254 The handle of the proberty.
256 <TRUE/> if the value is converted successfully.
257 @throws IllegalArgumentException
259 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
260 css::uno::Any
& rConvertedValue
,
261 css::uno::Any
& rOldValue
,
263 const css::uno::Any
& rValue
) override
;
265 /** The same as setFastProperyValue, but no exception is thrown and nHandle
266 is always valid. You must not broadcast the changes in this method.
268 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
270 const css::uno::Any
& rValue
) override
;
272 /** When the called object has been disposed already this method throws
273 a Disposed exception and does not return.
275 @throws css::lang::DisposedException
277 void ThrowIfDisposed() const;
279 using cppu::OPropertySetHelper::disposing
;
280 using cppu::OPropertySetHelper::getFastPropertyValue
;
282 css::uno::Reference
< css::drawing::XLayer
>* mpCurrentLayer
;
284 const css::uno::Type m_aSelectionTypeIdentifier
;
286 /** This pointer to the ViewShellBase can be NULL (after a call to
287 ReleaseViewShellBase()).
289 ViewShellBase
* mpBase
;
291 ::tools::Rectangle maLastVisArea
;
292 ::tools::WeakReference
<SdPage
> mpCurrentPage
;
293 bool mbMasterPageMode
;
296 /** This flag indicates whether the called DrawController is being
297 disposed or already has been disposed.
301 ::std::unique_ptr
< ::cppu::IPropertyArrayHelper
> mpPropertyArrayHelper
;
303 /** The current sub controller. May be NULL.
305 css::uno::Reference
<css::drawing::XDrawSubController
> mxSubController
;
308 css::drawing::framework::XConfigurationController
> mxConfigurationController
;
310 css::drawing::framework::XModuleController
> mxModuleController
;
312 /** Send an event to all relevant property listeners that a
313 property has changed its value. The fire() method of the
314 OPropertySetHelper is wrapped by this method to handle
315 exceptions thrown by called listeners.
317 void FirePropertyChange (
319 const css::uno::Any
& rNewValue
,
320 const css::uno::Any
& rOldValue
);
322 void ProvideFrameworkControllers();
323 void DisposeFrameworkControllers();
326 } // end of namespace sd
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */