xref: /AOO41X/main/sd/source/ui/inc/DrawController.hxx (revision c45d927ae478a6b27be268f8970f881a09d05b3f)
1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c45d927aSAndrew Rist  * distributed with this work for additional information
6*c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c45d927aSAndrew Rist  * specific language governing permissions and limitations
18*c45d927aSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*c45d927aSAndrew Rist  *************************************************************/
21*c45d927aSAndrew Rist 
22*c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SD_DRAW_CONTROLLER_HXX
25cdf0e10cSrcweir #define SD_DRAW_CONTROLLER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "ViewShell.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <osl/mutex.hxx>
30cdf0e10cSrcweir #include <cppuhelper/propshlp.hxx>
31cdf0e10cSrcweir #include <sfx2/sfxbasecontroller.hxx>
32cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp>
33cdf0e10cSrcweir #include <com/sun/star/view/XFormLayerAccess.hpp>
34cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawSubController.hpp>
35cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp>
36cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
37cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp>
38cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ModuleController.hpp>
39cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
40cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
41cdf0e10cSrcweir #include <comphelper/uno3.hxx>
42cdf0e10cSrcweir #include <cppuhelper/implbase7.hxx>
43cdf0e10cSrcweir #include <tools/weakbase.hxx>
44cdf0e10cSrcweir #include <memory>
45cdf0e10cSrcweir #include <vector>
46cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir class SfxViewShell;
49cdf0e10cSrcweir class SdXImpressDocument;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir namespace css = ::com::sun::star;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir namespace sd {
54cdf0e10cSrcweir 
55cdf0e10cSrcweir typedef ::cppu::ImplInheritanceHelper7 <
56cdf0e10cSrcweir     SfxBaseController,
57cdf0e10cSrcweir     ::com::sun::star::view::XSelectionSupplier,
58cdf0e10cSrcweir     ::com::sun::star::lang::XServiceInfo,
59cdf0e10cSrcweir     ::com::sun::star::drawing::XDrawView,
60cdf0e10cSrcweir     ::com::sun::star::view::XSelectionChangeListener,
61cdf0e10cSrcweir     ::com::sun::star::view::XFormLayerAccess,
62cdf0e10cSrcweir     ::com::sun::star::drawing::framework::XControllerManager,
63cdf0e10cSrcweir     ::com::sun::star::lang::XUnoTunnel
64cdf0e10cSrcweir     > DrawControllerInterfaceBase;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir class BroadcastHelperOwner
67cdf0e10cSrcweir {
68cdf0e10cSrcweir public:
69cdf0e10cSrcweir     BroadcastHelperOwner (::osl::Mutex& rMutex) : maBroadcastHelper(rMutex) {};
70cdf0e10cSrcweir     ::cppu::OBroadcastHelper maBroadcastHelper;
71cdf0e10cSrcweir };
72cdf0e10cSrcweir 
73cdf0e10cSrcweir class DrawSubController;
74cdf0e10cSrcweir class ViewShellBase;
75cdf0e10cSrcweir class ViewShell;
76cdf0e10cSrcweir class View;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 
79cdf0e10cSrcweir /** The DrawController is the UNO controller for Impress and Draw.  It
80cdf0e10cSrcweir     relies objects that implement the DrawSubController interface for view
81cdf0e10cSrcweir     specific behaviour.  The life time of the DrawController is roughly that
82cdf0e10cSrcweir     of ViewShellBase but note that the DrawController can (in the case of a
83cdf0e10cSrcweir     reload) outlive the ViewShellBase.
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     The implementation of the XControllerManager interface is not yet in its
86cdf0e10cSrcweir     final form.
87cdf0e10cSrcweir */
88cdf0e10cSrcweir class DrawController
89cdf0e10cSrcweir     : public DrawControllerInterfaceBase,
90cdf0e10cSrcweir       private BroadcastHelperOwner,
91cdf0e10cSrcweir       public ::cppu::OPropertySetHelper
92cdf0e10cSrcweir {
93cdf0e10cSrcweir public:
94cdf0e10cSrcweir     enum PropertyHandle {
95cdf0e10cSrcweir         PROPERTY_WORKAREA = 0,
96cdf0e10cSrcweir         PROPERTY_SUB_CONTROLLER = 1,
97cdf0e10cSrcweir         PROPERTY_CURRENTPAGE = 2,
98cdf0e10cSrcweir         PROPERTY_MASTERPAGEMODE = 3,
99cdf0e10cSrcweir         PROPERTY_LAYERMODE = 4,
100cdf0e10cSrcweir         PROPERTY_ACTIVE_LAYER = 5,
101cdf0e10cSrcweir         PROPERTY_ZOOMTYPE = 6,
102cdf0e10cSrcweir         PROPERTY_ZOOMVALUE = 7,
103cdf0e10cSrcweir         PROPERTY_VIEWOFFSET = 8,
104cdf0e10cSrcweir 		PROPERTY_DRAWVIEWMODE = 9
105cdf0e10cSrcweir     };
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     /** Create a new DrawController object for the given ViewShellBase.
108cdf0e10cSrcweir     */
109cdf0e10cSrcweir 	DrawController (ViewShellBase& rBase) throw();
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	virtual ~DrawController (void) throw();
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     /** Replace the currently used sub controller with the given one.  This
114cdf0e10cSrcweir         new sub controller is used from now on for the view (that is the
115cdf0e10cSrcweir         main view shell to be precise) specific tasks.  Call this method
116cdf0e10cSrcweir         with a suitable sub controller whenever the view shell in the center
117cdf0e10cSrcweir         pane is exchanged.
118cdf0e10cSrcweir         @param pSubController
119cdf0e10cSrcweir             The ViewShell specific sub controller or NULL when (temporarily
120cdf0e10cSrcweir             while switching to another one) there is no ViewShell displayed
121cdf0e10cSrcweir             in the center pane.
122cdf0e10cSrcweir     */
123cdf0e10cSrcweir     void SetSubController (
124cdf0e10cSrcweir         const css::uno::Reference<css::drawing::XDrawSubController>& rxSubController);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     /** Call this method when the VisArea has changed.
127cdf0e10cSrcweir     */
128cdf0e10cSrcweir     void FireVisAreaChanged (const Rectangle& rVisArea) throw();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     /** Call this method when the selection has changed.
131cdf0e10cSrcweir     */
132cdf0e10cSrcweir 	void FireSelectionChangeListener (void) throw();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     /** Call this method when the edit mode has changed.
135cdf0e10cSrcweir     */
136cdf0e10cSrcweir     void FireChangeEditMode (bool bMasterPageMode) throw();
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     /** Call this method when the layer mode has changed.
139cdf0e10cSrcweir     */
140cdf0e10cSrcweir 	void FireChangeLayerMode (bool bLayerMode) throw();
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     /** Call this method when there is a new current page.
143cdf0e10cSrcweir     */
144cdf0e10cSrcweir 	void FireSwitchCurrentPage (SdPage* pCurrentPage) throw();
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     /** Return a pointer to the ViewShellBase object that the DrawController
147cdf0e10cSrcweir         is connected to.
148cdf0e10cSrcweir         @return
149cdf0e10cSrcweir             The returned pointer is <NULL/> after a call to
150cdf0e10cSrcweir             ReleaseViewShellBase().
151cdf0e10cSrcweir     */
152cdf0e10cSrcweir     ViewShellBase* GetViewShellBase (void);
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     /** This method is typically called from the destructor of ViewShellBase
155cdf0e10cSrcweir         to tell the DrawController that it and its members must not access
156cdf0e10cSrcweir         the ViewShellBase anymore.
157cdf0e10cSrcweir         After this call the DrawController is semi-disposed.
158cdf0e10cSrcweir     */
159cdf0e10cSrcweir     void ReleaseViewShellBase (void);
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     DECLARE_XINTERFACE()
164cdf0e10cSrcweir 	DECLARE_XTYPEPROVIDER()
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	// XComponent
167cdf0e10cSrcweir 	virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
168cdf0e10cSrcweir     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
169cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	// XController
172cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL suspend( ::sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException);
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	// XServiceInfo
175cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
176cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
177cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	// XSelectionSupplier
180cdf0e10cSrcweir     virtual sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& aSelection ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
181cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL getSelection(  ) throw(::com::sun::star::uno::RuntimeException);
182cdf0e10cSrcweir     virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
183cdf0e10cSrcweir     virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	// XPropertySet
186cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     // XFormLayerAccess
189cdf0e10cSrcweir     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);
190cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL isFormDesignMode(  ) throw (::com::sun::star::uno::RuntimeException);
191cdf0e10cSrcweir     virtual void SAL_CALL setFormDesignMode( ::sal_Bool DesignMode ) throw (::com::sun::star::uno::RuntimeException);
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     // XControlAccess
194cdf0e10cSrcweir     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);
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	// XDrawView
197cdf0e10cSrcweir     virtual void SAL_CALL
198cdf0e10cSrcweir         setCurrentPage (
199cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
200cdf0e10cSrcweir             ::com::sun::star::drawing::XDrawPage >& xPage)
201cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
204cdf0e10cSrcweir         ::com::sun::star::drawing::XDrawPage > SAL_CALL
205cdf0e10cSrcweir         getCurrentPage (void)
206cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     // lang::XEventListener
210cdf0e10cSrcweir     virtual void SAL_CALL
211cdf0e10cSrcweir         disposing (const ::com::sun::star::lang::EventObject& rEventObject)
212cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     // view::XSelectionChangeListener
216cdf0e10cSrcweir     virtual void  SAL_CALL
217cdf0e10cSrcweir         selectionChanged (const ::com::sun::star::lang::EventObject& rEvent)
218cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     // XControllerManager
222cdf0e10cSrcweir 
223cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::framework::XConfigurationController> SAL_CALL
224cdf0e10cSrcweir         getConfigurationController (void)
225cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     virtual css::uno::Reference<css::drawing::framework::XModuleController> SAL_CALL
228cdf0e10cSrcweir         getModuleController (void)
229cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     // XUnoTunnel
233cdf0e10cSrcweir 
234cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId)
235cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
236cdf0e10cSrcweir 
237cdf0e10cSrcweir protected:
238cdf0e10cSrcweir 	/** This method must return the name to index table. This table
239cdf0e10cSrcweir 	    contains all property names and types of this object.
240cdf0e10cSrcweir 	 */
241cdf0e10cSrcweir 	virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
242cdf0e10cSrcweir 
243cdf0e10cSrcweir     virtual void FillPropertyTable (
244cdf0e10cSrcweir         ::std::vector< ::com::sun::star::beans::Property>& rProperties);
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 	/**
247cdf0e10cSrcweir 	 * The same as getFastProperyValue, but return the value through
248cdf0e10cSrcweir 	 * rValue and nHandle is always valid.
249cdf0e10cSrcweir 	 */
250cdf0e10cSrcweir 	virtual void SAL_CALL getFastPropertyValue(
251cdf0e10cSrcweir 		::com::sun::star::uno::Any& rValue,
252cdf0e10cSrcweir 		sal_Int32 nHandle ) const;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	/** Convert the value rValue and return the result in rConvertedValue and the
255cdf0e10cSrcweir         old value in rOldValue.
256cdf0e10cSrcweir         After this call the vetoable listeners are notified.
257cdf0e10cSrcweir 
258cdf0e10cSrcweir         @param rConvertedValue
259cdf0e10cSrcweir             The converted value. Only set if return is true.
260cdf0e10cSrcweir         @param rOldValue
261cdf0e10cSrcweir             The old value. Only set if return is true.
262cdf0e10cSrcweir         @param nHandle
263cdf0e10cSrcweir             The handle of the proberty.
264cdf0e10cSrcweir         @return
265cdf0e10cSrcweir             <TRUE/> if the value is converted successfully.
266cdf0e10cSrcweir         @throws IllegalArgumentException
267cdf0e10cSrcweir 	 */
268cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL convertFastPropertyValue(
269cdf0e10cSrcweir 		::com::sun::star::uno::Any & rConvertedValue,
270cdf0e10cSrcweir 		::com::sun::star::uno::Any & rOldValue,
271cdf0e10cSrcweir 		sal_Int32 nHandle,
272cdf0e10cSrcweir 		const ::com::sun::star::uno::Any& rValue )
273cdf0e10cSrcweir 		throw (::com::sun::star::lang::IllegalArgumentException);
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	/** The same as setFastProperyValue, but no exception is thrown and nHandle
276cdf0e10cSrcweir         is always valid. You must not broadcast the changes in this method.
277cdf0e10cSrcweir 	 */
278cdf0e10cSrcweir 	virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
279cdf0e10cSrcweir 		sal_Int32 nHandle,
280cdf0e10cSrcweir 		const ::com::sun::star::uno::Any& rValue )
281cdf0e10cSrcweir 		throw (::com::sun::star::uno::Exception);
282cdf0e10cSrcweir 
283cdf0e10cSrcweir     /** When the called object has been disposed already this method throws
284cdf0e10cSrcweir         a Disposed exception and does not return.
285cdf0e10cSrcweir     */
286cdf0e10cSrcweir     void ThrowIfDisposed (void) const
287cdf0e10cSrcweir         throw (::com::sun::star::lang::DisposedException);
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	using cppu::OPropertySetHelper::disposing;
290cdf0e10cSrcweir 	using cppu::OPropertySetHelper::getFastPropertyValue;
291cdf0e10cSrcweir 
292cdf0e10cSrcweir private:
293cdf0e10cSrcweir     /** This pointer to the ViewShellBase can be NULL (after a call to
294cdf0e10cSrcweir         ReleaseViewShellBase()).
295cdf0e10cSrcweir     */
296cdf0e10cSrcweir     ViewShellBase* mpBase;
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 	Rectangle maLastVisArea;
299cdf0e10cSrcweir     ::tools::WeakReference<SdrPage> mpCurrentPage;
300cdf0e10cSrcweir 	bool mbMasterPageMode;
301cdf0e10cSrcweir 	bool mbLayerMode;
302cdf0e10cSrcweir 
303cdf0e10cSrcweir     /** This flag indicates whether the called DrawController is being
304cdf0e10cSrcweir         disposed or already has been disposed.
305cdf0e10cSrcweir     */
306cdf0e10cSrcweir     bool mbDisposing;
307cdf0e10cSrcweir 
308cdf0e10cSrcweir     ::std::auto_ptr< ::cppu::IPropertyArrayHelper> mpPropertyArrayHelper;
309cdf0e10cSrcweir 
310cdf0e10cSrcweir     /** The current sub controller.  May be NULL.
311cdf0e10cSrcweir     */
312cdf0e10cSrcweir     css::uno::Reference<css::drawing::XDrawSubController> mxSubController;
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     css::uno::Reference<
315cdf0e10cSrcweir         css::drawing::framework::XConfigurationController> mxConfigurationController;
316cdf0e10cSrcweir     css::uno::Reference<
317cdf0e10cSrcweir         css::drawing::framework::XModuleController> mxModuleController;
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     /** Send an event to all relevant property listeners that a
320cdf0e10cSrcweir         property has changed its value.  The fire() method of the
321cdf0e10cSrcweir         OPropertySetHelper is wrapped by this method to handle
322cdf0e10cSrcweir         exceptions thrown by called listeners.
323cdf0e10cSrcweir     */
324cdf0e10cSrcweir     void FirePropertyChange (
325cdf0e10cSrcweir         sal_Int32 nHandle,
326cdf0e10cSrcweir         const ::com::sun::star::uno::Any& rNewValue,
327cdf0e10cSrcweir         const ::com::sun::star::uno::Any& rOldValue);
328cdf0e10cSrcweir 
329cdf0e10cSrcweir     void ProvideFrameworkControllers (void);
330cdf0e10cSrcweir     void DisposeFrameworkControllers (void);
331cdf0e10cSrcweir };
332cdf0e10cSrcweir 
333cdf0e10cSrcweir } // end of namespace sd
334cdf0e10cSrcweir 
335cdf0e10cSrcweir #endif
336