bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / inc / DrawController.hxx
blob8486a14e63cf4f2eea1f22243777fb4fe415b83e
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 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>
35 #include <memory>
36 #include <vector>
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; }
44 class SdPage;
46 namespace sd {
48 typedef ::cppu::ImplInheritanceHelper <
49 SfxBaseController,
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,
56 css::lang::XUnoTunnel
57 > DrawControllerInterfaceBase;
59 class BroadcastHelperOwner
61 public:
62 explicit BroadcastHelperOwner (::osl::Mutex& rMutex) : maBroadcastHelper(rMutex) {};
63 ::cppu::OBroadcastHelper maBroadcastHelper;
66 class ViewShellBase;
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
75 final form.
77 class DrawController final
78 : public DrawControllerInterfaceBase,
79 private BroadcastHelperOwner,
80 public ::cppu::OPropertySetHelper
82 public:
83 enum PropertyHandle {
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
108 pane is exchanged.
109 @param pSubController
110 The ViewShell specific sub controller or NULL when (temporarily
111 while switching to another one) there is no ViewShell displayed
112 in the center pane.
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
138 switch.
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
149 is connected to.
150 @return
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();
165 DECLARE_XINTERFACE()
166 DECLARE_XTYPEPROVIDER()
168 // XComponent
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;
173 // XController
174 virtual sal_Bool SAL_CALL suspend( sal_Bool Suspend ) override;
176 // XServiceInfo
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;
187 // XPropertySet
188 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
190 // XFormLayerAccess
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;
195 // XControlAccess
196 virtual css::uno::Reference< css::awt::XControl > SAL_CALL getControl( const css::uno::Reference< css::awt::XControlModel >& xModel ) override;
198 // XDrawView
199 virtual void SAL_CALL
200 setCurrentPage (
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;
224 // XUnoTunnel
226 virtual sal_Int64 SAL_CALL getSomething (const css::uno::Sequence<sal_Int8>& rId) override;
228 private:
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.
251 @param rOldValue
252 The old value. Only set if return is true.
253 @param nHandle
254 The handle of the proberty.
255 @return
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,
262 sal_Int32 nHandle,
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(
269 sal_Int32 nHandle,
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;
294 bool mbLayerMode;
296 /** This flag indicates whether the called DrawController is being
297 disposed or already has been disposed.
299 bool mbDisposing;
301 ::std::unique_ptr< ::cppu::IPropertyArrayHelper> mpPropertyArrayHelper;
303 /** The current sub controller. May be NULL.
305 css::uno::Reference<css::drawing::XDrawSubController> mxSubController;
307 css::uno::Reference<
308 css::drawing::framework::XConfigurationController> mxConfigurationController;
309 css::uno::Reference<
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 (
318 sal_Int32 nHandle,
319 const css::uno::Any& rNewValue,
320 const css::uno::Any& rOldValue);
322 void ProvideFrameworkControllers();
323 void DisposeFrameworkControllers();
326 } // end of namespace sd
328 #endif
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */