15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
105b190011SAndrew Rist  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
125b190011SAndrew Rist  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
195b190011SAndrew Rist  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "DrawController.hxx"
28cdf0e10cSrcweir #include "DrawDocShell.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "DrawSubController.hxx"
31cdf0e10cSrcweir #include "sdpage.hxx"
32cdf0e10cSrcweir #include "ViewShellBase.hxx"
33cdf0e10cSrcweir #include "ViewShellManager.hxx"
34cdf0e10cSrcweir #include "FormShellManager.hxx"
35cdf0e10cSrcweir #include "Window.hxx"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <comphelper/anytostring.hxx>
38cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
39cdf0e10cSrcweir #include <comphelper/sequence.hxx>
40cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
41cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx>
42cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
45cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ConfigurationController.hpp>
46cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ModuleController.hpp>
47cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include "slideshow.hxx"
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include <svx/fmshell.hxx>
52cdf0e10cSrcweir #include <vos/mutex.hxx>
53cdf0e10cSrcweir #include <vcl/svapp.hxx>
5465be1ea2SAndre Fischer #include <sfx2/sidebar/EnumContext.hxx>
5565be1ea2SAndre Fischer #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
5665be1ea2SAndre Fischer 
57cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
58cdf0e10cSrcweir 
59cdf0e10cSrcweir using namespace ::std;
60cdf0e10cSrcweir using ::rtl::OUString;
61cdf0e10cSrcweir using namespace ::cppu;
62cdf0e10cSrcweir using namespace ::vos;
63cdf0e10cSrcweir using namespace ::com::sun::star;
64cdf0e10cSrcweir using namespace ::com::sun::star::uno;
65cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
6665be1ea2SAndre Fischer using ::sfx2::sidebar::EnumContext;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir namespace {
69cdf0e10cSrcweir static const ::com::sun::star::uno::Type saComponentTypeIdentifier (
70cdf0e10cSrcweir     ::getCppuType( (Reference<lang::XEventListener > *)0 ));
71cdf0e10cSrcweir static const ::com::sun::star::uno::Type saSelectionTypeIdentifier (
72cdf0e10cSrcweir     ::getCppuType( (Reference<view::XSelectionChangeListener > *)0 ));
73cdf0e10cSrcweir 
74cdf0e10cSrcweir } // end of anonymous namespace
75cdf0e10cSrcweir 
76cdf0e10cSrcweir namespace sd {
77cdf0e10cSrcweir 
DrawController(ViewShellBase & rBase)78cdf0e10cSrcweir DrawController::DrawController (ViewShellBase& rBase) throw()
79cdf0e10cSrcweir     : DrawControllerInterfaceBase(&rBase),
80cdf0e10cSrcweir       BroadcastHelperOwner(SfxBaseController::m_aMutex),
81cdf0e10cSrcweir       OPropertySetHelper( static_cast<OBroadcastHelperVar<
82cdf0e10cSrcweir           OMultiTypeInterfaceContainerHelper,
83cdf0e10cSrcweir           OMultiTypeInterfaceContainerHelper::keyType>& >(
84cdf0e10cSrcweir               BroadcastHelperOwner::maBroadcastHelper)),
85cdf0e10cSrcweir       mpBase(&rBase),
86cdf0e10cSrcweir       maLastVisArea(),
87cdf0e10cSrcweir       mpCurrentPage(NULL),
88cdf0e10cSrcweir       mbMasterPageMode(false),
89cdf0e10cSrcweir       mbLayerMode(false),
90cdf0e10cSrcweir       mbDisposing(false),
91cdf0e10cSrcweir       mpPropertyArrayHelper(NULL),
92cdf0e10cSrcweir       mxSubController(),
93cdf0e10cSrcweir       mxConfigurationController(),
94cdf0e10cSrcweir       mxModuleController()
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     ProvideFrameworkControllers();
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 
~DrawController(void)102cdf0e10cSrcweir DrawController::~DrawController (void) throw()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 
SetSubController(const Reference<drawing::XDrawSubController> & rxSubController)109cdf0e10cSrcweir void DrawController::SetSubController (
110cdf0e10cSrcweir     const Reference<drawing::XDrawSubController>& rxSubController)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir     // Update the internal state.
113cdf0e10cSrcweir     mxSubController = rxSubController;
114cdf0e10cSrcweir     mpPropertyArrayHelper.reset();
115cdf0e10cSrcweir     maLastVisArea = Rectangle();
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     // Inform listeners about the changed state.
118cdf0e10cSrcweir     FireSelectionChangeListener();
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir // XInterface
125cdf0e10cSrcweir 
126cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2(
127cdf0e10cSrcweir     DrawController,
128cdf0e10cSrcweir     DrawControllerInterfaceBase,
129cdf0e10cSrcweir     OPropertySetHelper);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 
132cdf0e10cSrcweir // XTypeProvider
133cdf0e10cSrcweir 
getTypes(void)134cdf0e10cSrcweir Sequence<Type> SAL_CALL DrawController::getTypes (void)
135cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir     ThrowIfDisposed();
138cdf0e10cSrcweir     // OPropertySetHelper does not provide getTypes, so we have to
139cdf0e10cSrcweir     // implement this method manually and list its three interfaces.
140cdf0e10cSrcweir     OTypeCollection aTypeCollection (
141cdf0e10cSrcweir         ::getCppuType (( const Reference<beans::XMultiPropertySet>*)NULL),
142cdf0e10cSrcweir         ::getCppuType (( const Reference<beans::XFastPropertySet>*)NULL),
143cdf0e10cSrcweir         ::getCppuType (( const Reference<beans::XPropertySet>*)NULL));
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     return ::comphelper::concatSequences(
146cdf0e10cSrcweir         SfxBaseController::getTypes(),
147cdf0e10cSrcweir         aTypeCollection.getTypes(),
148cdf0e10cSrcweir         DrawControllerInterfaceBase::getTypes());
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir IMPLEMENT_GET_IMPLEMENTATION_ID(DrawController);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 
155cdf0e10cSrcweir // XComponent
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
dispose(void)158cdf0e10cSrcweir void SAL_CALL DrawController::dispose (void)
159cdf0e10cSrcweir 	throw( RuntimeException )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir 	if( !mbDisposing )
162cdf0e10cSrcweir 	{
163cdf0e10cSrcweir 		OGuard aGuard( Application::GetSolarMutex() );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 		if( !mbDisposing )
166cdf0e10cSrcweir 		{
167cdf0e10cSrcweir 			mbDisposing = true;
168cdf0e10cSrcweir 
169cdf0e10cSrcweir             boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
170cdf0e10cSrcweir             if ( pViewShell )
171cdf0e10cSrcweir             {
172cdf0e10cSrcweir                 pViewShell->DeactivateCurrentFunction();
173cdf0e10cSrcweir                 DrawDocShell* pDocShell = pViewShell->GetDocSh();
174cdf0e10cSrcweir                 if ( pDocShell != NULL )
175cdf0e10cSrcweir                     pDocShell->SetDocShellFunction(0);
176cdf0e10cSrcweir             }
177cdf0e10cSrcweir             pViewShell.reset();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir             // When the controller has not been detached from its view
180cdf0e10cSrcweir             // shell, i.e. mpViewShell is not NULL, then tell PaneManager
181cdf0e10cSrcweir             // and ViewShellManager to clear the shell stack.
182cdf0e10cSrcweir             if (mxSubController.is() && mpBase!=NULL)
183cdf0e10cSrcweir             {
184cdf0e10cSrcweir                 mpBase->DisconnectAllClients();
185cdf0e10cSrcweir                 mpBase->GetViewShellManager()->Shutdown();
186cdf0e10cSrcweir             }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir             OPropertySetHelper::disposing();
189cdf0e10cSrcweir 
190cdf0e10cSrcweir             DisposeFrameworkControllers();
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 			SfxBaseController::dispose();
193cdf0e10cSrcweir 		}
194cdf0e10cSrcweir 	}
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 
addEventListener(const Reference<lang::XEventListener> & xListener)200cdf0e10cSrcweir void SAL_CALL DrawController::addEventListener(
201cdf0e10cSrcweir     const Reference<lang::XEventListener >& xListener)
202cdf0e10cSrcweir     throw (RuntimeException)
203cdf0e10cSrcweir {
204cdf0e10cSrcweir     ThrowIfDisposed();
205cdf0e10cSrcweir 	SfxBaseController::addEventListener( xListener );
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 
removeEventListener(const Reference<lang::XEventListener> & aListener)211cdf0e10cSrcweir void SAL_CALL DrawController::removeEventListener (
212cdf0e10cSrcweir     const Reference<lang::XEventListener >& aListener)
213cdf0e10cSrcweir     throw (RuntimeException)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir 	if(!rBHelper.bDisposed && !rBHelper.bInDispose && !mbDisposing)
216cdf0e10cSrcweir 		SfxBaseController::removeEventListener( aListener );
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir // XController
suspend(::sal_Bool Suspend)220cdf0e10cSrcweir ::sal_Bool SAL_CALL DrawController::suspend( ::sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir 	if( Suspend )
223cdf0e10cSrcweir 	{
224cdf0e10cSrcweir 		ViewShellBase* pViewShellBase = GetViewShellBase();
225cdf0e10cSrcweir 		if( pViewShellBase )
226cdf0e10cSrcweir 		{
227cdf0e10cSrcweir 			// do not allow suspend if a slideshow needs this controller!
228cdf0e10cSrcweir 			rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pViewShellBase ) );
229cdf0e10cSrcweir 			if( xSlideShow.is() && xSlideShow->dependsOn(pViewShellBase) )
230cdf0e10cSrcweir 				return sal_False;
231cdf0e10cSrcweir 		}
232cdf0e10cSrcweir 	}
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 	return SfxBaseController::suspend( Suspend );
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 
238cdf0e10cSrcweir // XServiceInfo
239cdf0e10cSrcweir 
getImplementationName()240cdf0e10cSrcweir OUString SAL_CALL DrawController::getImplementationName(  ) throw(RuntimeException)
241cdf0e10cSrcweir {
242cdf0e10cSrcweir     // Do not throw an excepetion at the moment.  This leads to a crash
243cdf0e10cSrcweir     // under Solaris on relead.  See issue i70929 for details.
244cdf0e10cSrcweir     //    ThrowIfDisposed();
245cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "DrawController" ) );
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 
250cdf0e10cSrcweir static OUString ssServiceName (OUString::createFromAscii(
251cdf0e10cSrcweir     "com.sun.star.drawing.DrawingDocumentDrawView"));
252cdf0e10cSrcweir 
supportsService(const OUString & rsServiceName)253cdf0e10cSrcweir sal_Bool SAL_CALL DrawController::supportsService (
254cdf0e10cSrcweir     const OUString& rsServiceName)
255cdf0e10cSrcweir     throw(RuntimeException)
256cdf0e10cSrcweir {
257cdf0e10cSrcweir     // Do not throw an excepetion at the moment.  This leads to a crash
258cdf0e10cSrcweir     // under Solaris on relead.  See issue i70929 for details.
259cdf0e10cSrcweir     //    ThrowIfDisposed();
260cdf0e10cSrcweir     return rsServiceName.equals(ssServiceName);
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 
getSupportedServiceNames(void)266cdf0e10cSrcweir Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames (void)
267cdf0e10cSrcweir     throw(RuntimeException)
268cdf0e10cSrcweir {
269cdf0e10cSrcweir     ThrowIfDisposed();
270cdf0e10cSrcweir 	Sequence<OUString> aSupportedServices (1);
271cdf0e10cSrcweir 	OUString* pServices = aSupportedServices.getArray();
272cdf0e10cSrcweir     pServices[0] = ssServiceName;
273cdf0e10cSrcweir 	return aSupportedServices;
274cdf0e10cSrcweir }
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 
279cdf0e10cSrcweir //------ XSelectionSupplier --------------------------------------------
280cdf0e10cSrcweir 
select(const Any & aSelection)281cdf0e10cSrcweir sal_Bool SAL_CALL DrawController::select (const Any& aSelection)
282cdf0e10cSrcweir 	throw(lang::IllegalArgumentException, RuntimeException)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir     ThrowIfDisposed();
285cdf0e10cSrcweir 	::vos::OGuard aGuard (Application::GetSolarMutex());
286cdf0e10cSrcweir 
287cdf0e10cSrcweir     if (mxSubController.is())
288cdf0e10cSrcweir         return mxSubController->select(aSelection);
289cdf0e10cSrcweir     else
290cdf0e10cSrcweir         return false;
291cdf0e10cSrcweir }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 
getSelection()296cdf0e10cSrcweir Any SAL_CALL DrawController::getSelection()
297cdf0e10cSrcweir 	throw(RuntimeException)
298cdf0e10cSrcweir {
299cdf0e10cSrcweir     ThrowIfDisposed();
300cdf0e10cSrcweir 	::vos::OGuard aGuard (Application::GetSolarMutex());
301cdf0e10cSrcweir 
302cdf0e10cSrcweir     if (mxSubController.is())
303cdf0e10cSrcweir         return mxSubController->getSelection();
304cdf0e10cSrcweir     else
305cdf0e10cSrcweir         return Any();
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 
addSelectionChangeListener(const Reference<view::XSelectionChangeListener> & xListener)311cdf0e10cSrcweir void SAL_CALL DrawController::addSelectionChangeListener(
312cdf0e10cSrcweir     const Reference< view::XSelectionChangeListener >& xListener)
313cdf0e10cSrcweir 	throw(RuntimeException)
314cdf0e10cSrcweir {
315cdf0e10cSrcweir 	if( mbDisposing )
316cdf0e10cSrcweir 		throw lang::DisposedException();
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     BroadcastHelperOwner::maBroadcastHelper.addListener (saSelectionTypeIdentifier, xListener);
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 
removeSelectionChangeListener(const Reference<view::XSelectionChangeListener> & xListener)324cdf0e10cSrcweir void SAL_CALL DrawController::removeSelectionChangeListener(
325cdf0e10cSrcweir     const Reference< view::XSelectionChangeListener >& xListener )
326cdf0e10cSrcweir     throw(RuntimeException)
327cdf0e10cSrcweir {
328cdf0e10cSrcweir     if (rBHelper.bDisposed)
329cdf0e10cSrcweir         throw lang::DisposedException();
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 	BroadcastHelperOwner::maBroadcastHelper.removeListener (saSelectionTypeIdentifier, xListener);
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 
338cdf0e10cSrcweir //=====  lang::XEventListener  ================================================
339cdf0e10cSrcweir 
340cdf0e10cSrcweir void SAL_CALL
disposing(const lang::EventObject &)341cdf0e10cSrcweir     DrawController::disposing (const lang::EventObject& )
342cdf0e10cSrcweir     throw (uno::RuntimeException)
343cdf0e10cSrcweir {
344cdf0e10cSrcweir }
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 
349cdf0e10cSrcweir //=====  view::XSelectionChangeListener  ======================================
350cdf0e10cSrcweir 
351cdf0e10cSrcweir void  SAL_CALL
selectionChanged(const lang::EventObject & rEvent)352cdf0e10cSrcweir     DrawController::selectionChanged (const lang::EventObject& rEvent)
353cdf0e10cSrcweir         throw (uno::RuntimeException)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir     ThrowIfDisposed();
356cdf0e10cSrcweir     // Have to forward the event to our selection change listeners.
357cdf0e10cSrcweir 	OInterfaceContainerHelper* pListeners = BroadcastHelperOwner::maBroadcastHelper.getContainer(
358cdf0e10cSrcweir         ::getCppuType((Reference<view::XSelectionChangeListener>*)0));
359cdf0e10cSrcweir 	if (pListeners)
360cdf0e10cSrcweir 	{
361cdf0e10cSrcweir 		// Re-send the event to all of our listeners.
362cdf0e10cSrcweir 		OInterfaceIteratorHelper aIterator (*pListeners);
363cdf0e10cSrcweir 		while (aIterator.hasMoreElements())
364cdf0e10cSrcweir 		{
365cdf0e10cSrcweir             try
366cdf0e10cSrcweir             {
367cdf0e10cSrcweir                 view::XSelectionChangeListener* pListener =
368cdf0e10cSrcweir                     static_cast<view::XSelectionChangeListener*>(
369cdf0e10cSrcweir                         aIterator.next());
370cdf0e10cSrcweir                 if (pListener != NULL)
371cdf0e10cSrcweir                     pListener->selectionChanged (rEvent);
372cdf0e10cSrcweir             }
373cdf0e10cSrcweir             catch (RuntimeException aException)
374cdf0e10cSrcweir             {
375cdf0e10cSrcweir             }
376cdf0e10cSrcweir 		}
377cdf0e10cSrcweir 	}
378cdf0e10cSrcweir }
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 
383cdf0e10cSrcweir // XDrawView
384cdf0e10cSrcweir 
setCurrentPage(const Reference<drawing::XDrawPage> & xPage)385cdf0e10cSrcweir void SAL_CALL DrawController::setCurrentPage( const Reference< drawing::XDrawPage >& xPage )
386cdf0e10cSrcweir 	throw(RuntimeException)
387cdf0e10cSrcweir {
388cdf0e10cSrcweir     ThrowIfDisposed();
389cdf0e10cSrcweir     ::vos::OGuard aGuard (Application::GetSolarMutex());
390cdf0e10cSrcweir 
391cdf0e10cSrcweir     if (mxSubController.is())
392cdf0e10cSrcweir         mxSubController->setCurrentPage(xPage);
393cdf0e10cSrcweir }
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 
getCurrentPage(void)398cdf0e10cSrcweir Reference< drawing::XDrawPage > SAL_CALL DrawController::getCurrentPage (void)
399cdf0e10cSrcweir 	throw(RuntimeException)
400cdf0e10cSrcweir {
401cdf0e10cSrcweir     ThrowIfDisposed();
402cdf0e10cSrcweir 	::vos::OGuard aGuard( Application::GetSolarMutex() );
403cdf0e10cSrcweir     Reference<drawing::XDrawPage> xPage;
404cdf0e10cSrcweir 
405cdf0e10cSrcweir     // Get current page from sub controller.
406cdf0e10cSrcweir     if (mxSubController.is())
407cdf0e10cSrcweir         xPage = mxSubController->getCurrentPage();
408cdf0e10cSrcweir 
409cdf0e10cSrcweir     // When there is not yet a sub controller (during initialization) then fall back
410cdf0e10cSrcweir     // to the current page in mpCurrentPage.
411cdf0e10cSrcweir     if ( ! xPage.is() && mpCurrentPage.is())
412cdf0e10cSrcweir         xPage = Reference<drawing::XDrawPage>(mpCurrentPage->getUnoPage(), UNO_QUERY);
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 	return xPage;
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 
FireVisAreaChanged(const Rectangle & rVisArea)420cdf0e10cSrcweir void DrawController::FireVisAreaChanged (const Rectangle& rVisArea) throw()
421cdf0e10cSrcweir {
422cdf0e10cSrcweir 	if( maLastVisArea != rVisArea )
423cdf0e10cSrcweir 	{
424cdf0e10cSrcweir 		Any aNewValue;
425cdf0e10cSrcweir 		aNewValue <<= awt::Rectangle(
426cdf0e10cSrcweir             rVisArea.Left(),
427cdf0e10cSrcweir             rVisArea.Top(),
428cdf0e10cSrcweir             rVisArea.GetWidth(),
429cdf0e10cSrcweir             rVisArea.GetHeight() );
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 		Any aOldValue;
432cdf0e10cSrcweir 		aOldValue <<= awt::Rectangle(
433cdf0e10cSrcweir             maLastVisArea.Left(),
434cdf0e10cSrcweir             maLastVisArea.Top(),
435cdf0e10cSrcweir             maLastVisArea.GetWidth(),
436cdf0e10cSrcweir             maLastVisArea.GetHeight() );
437cdf0e10cSrcweir 
438cdf0e10cSrcweir         FirePropertyChange (PROPERTY_WORKAREA, aNewValue, aOldValue);
439cdf0e10cSrcweir 
440cdf0e10cSrcweir 		maLastVisArea = rVisArea;
441cdf0e10cSrcweir 	}
442cdf0e10cSrcweir }
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 
FireSelectionChangeListener()447cdf0e10cSrcweir void DrawController::FireSelectionChangeListener() throw()
448cdf0e10cSrcweir {
449cdf0e10cSrcweir 	OInterfaceContainerHelper * pLC = BroadcastHelperOwner::maBroadcastHelper.getContainer(
450cdf0e10cSrcweir         saSelectionTypeIdentifier);
451cdf0e10cSrcweir 	if( pLC )
452cdf0e10cSrcweir 	{
453cdf0e10cSrcweir 		Reference< XInterface > xSource( (XWeak*)this );
454cdf0e10cSrcweir 		const lang::EventObject aEvent( xSource );
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 		// Ueber alle Listener iterieren und Events senden
457cdf0e10cSrcweir 		OInterfaceIteratorHelper aIt( *pLC);
458cdf0e10cSrcweir 		while( aIt.hasMoreElements() )
459cdf0e10cSrcweir 		{
460cdf0e10cSrcweir             try
461cdf0e10cSrcweir             {
462cdf0e10cSrcweir                 view::XSelectionChangeListener * pL =
463cdf0e10cSrcweir                     static_cast<view::XSelectionChangeListener*>(aIt.next());
464cdf0e10cSrcweir                 if (pL != NULL)
465cdf0e10cSrcweir                     pL->selectionChanged( aEvent );
466cdf0e10cSrcweir             }
467cdf0e10cSrcweir             catch (RuntimeException aException)
468cdf0e10cSrcweir             {
469cdf0e10cSrcweir             }
470cdf0e10cSrcweir 		}
471cdf0e10cSrcweir 	}
472cdf0e10cSrcweir }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 
FireChangeEditMode(bool bMasterPageMode)477cdf0e10cSrcweir void DrawController::FireChangeEditMode (bool bMasterPageMode) throw()
478cdf0e10cSrcweir {
479cdf0e10cSrcweir 	if (bMasterPageMode != mbMasterPageMode )
480cdf0e10cSrcweir 	{
481cdf0e10cSrcweir         FirePropertyChange(
482cdf0e10cSrcweir             PROPERTY_MASTERPAGEMODE,
483cdf0e10cSrcweir             makeAny(bMasterPageMode),
484cdf0e10cSrcweir             makeAny(mbMasterPageMode));
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 		mbMasterPageMode = bMasterPageMode;
487cdf0e10cSrcweir 	}
488cdf0e10cSrcweir }
489cdf0e10cSrcweir 
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 
492cdf0e10cSrcweir 
FireChangeLayerMode(bool bLayerMode)493cdf0e10cSrcweir void DrawController::FireChangeLayerMode (bool bLayerMode) throw()
494cdf0e10cSrcweir {
495cdf0e10cSrcweir 	if (bLayerMode != mbLayerMode)
496cdf0e10cSrcweir 	{
497cdf0e10cSrcweir         FirePropertyChange(
498cdf0e10cSrcweir             PROPERTY_LAYERMODE,
499cdf0e10cSrcweir             makeAny(bLayerMode),
500cdf0e10cSrcweir             makeAny(mbLayerMode));
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 		mbLayerMode = bLayerMode;
503cdf0e10cSrcweir 	}
504cdf0e10cSrcweir }
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 
FireSwitchCurrentPage(SdPage * pNewCurrentPage)509cdf0e10cSrcweir void DrawController::FireSwitchCurrentPage (SdPage* pNewCurrentPage) throw()
510cdf0e10cSrcweir {
511cdf0e10cSrcweir     SdrPage* pCurrentPage  = mpCurrentPage.get();
512cdf0e10cSrcweir     if (pNewCurrentPage != pCurrentPage)
513cdf0e10cSrcweir     {
514cdf0e10cSrcweir         try
515cdf0e10cSrcweir         {
516cdf0e10cSrcweir             Any aNewValue (
517cdf0e10cSrcweir                 makeAny(Reference<drawing::XDrawPage>(pNewCurrentPage->getUnoPage(), UNO_QUERY)));
518cdf0e10cSrcweir 
519cdf0e10cSrcweir             Any aOldValue;
520cdf0e10cSrcweir             if (pCurrentPage != NULL)
521cdf0e10cSrcweir             {
522cdf0e10cSrcweir                 Reference<drawing::XDrawPage> xOldPage (pCurrentPage->getUnoPage(), UNO_QUERY);
523cdf0e10cSrcweir                 aOldValue <<= xOldPage;
524cdf0e10cSrcweir             }
525cdf0e10cSrcweir 
526cdf0e10cSrcweir             FirePropertyChange(PROPERTY_CURRENTPAGE, aNewValue, aOldValue);
527cdf0e10cSrcweir 
528cdf0e10cSrcweir             mpCurrentPage.reset(pNewCurrentPage);
529cdf0e10cSrcweir         }
530cdf0e10cSrcweir         catch( uno::Exception& e )
531cdf0e10cSrcweir         {
532cdf0e10cSrcweir             (void)e;
533cdf0e10cSrcweir             DBG_ERROR(
534cdf0e10cSrcweir                 (::rtl::OString("sd::SdUnoDrawView::FireSwitchCurrentPage(), "
535cdf0e10cSrcweir                     "exception caught: ") +
536cdf0e10cSrcweir                     ::rtl::OUStringToOString(
537cdf0e10cSrcweir                         comphelper::anyToString( cppu::getCaughtException() ),
538cdf0e10cSrcweir                         RTL_TEXTENCODING_UTF8 )).getStr() );
539cdf0e10cSrcweir         }
540cdf0e10cSrcweir     }
541cdf0e10cSrcweir }
NotifyAccUpdate()5420deba7fbSSteve Yin void DrawController::NotifyAccUpdate()
5430deba7fbSSteve Yin {
5440deba7fbSSteve Yin 	sal_Int32 nHandle = PROPERTY_UPDATEACC;
5450deba7fbSSteve Yin 	Any aNewValue, aOldValue;
5460deba7fbSSteve Yin 	fire (&nHandle, &aNewValue, &aOldValue, 1, sal_False);
5470deba7fbSSteve Yin }
5480deba7fbSSteve Yin 
fireChangeLayer(::com::sun::star::uno::Reference<::com::sun::star::drawing::XLayer> * pCurrentLayer)5490deba7fbSSteve Yin void DrawController::fireChangeLayer( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer>* pCurrentLayer ) throw()
5500deba7fbSSteve Yin {
5510deba7fbSSteve Yin 	if( pCurrentLayer != mpCurrentLayer )
5520deba7fbSSteve Yin 	{
5530deba7fbSSteve Yin 		sal_Int32 nHandle = PROPERTY_ACTIVE_LAYER;
5540deba7fbSSteve Yin 
5550deba7fbSSteve Yin 		Any aNewValue (makeAny( *pCurrentLayer) );
5560deba7fbSSteve Yin 
5570deba7fbSSteve Yin 		Any aOldValue ;
558cdf0e10cSrcweir 
5590deba7fbSSteve Yin 		fire (&nHandle, &aNewValue, &aOldValue, 1, sal_False);
5600deba7fbSSteve Yin 
5610deba7fbSSteve Yin 		mpCurrentLayer = pCurrentLayer;
5620deba7fbSSteve Yin 	}
5630deba7fbSSteve Yin }
564cdf0e10cSrcweir 
5650deba7fbSSteve Yin // This method is only called in slide show and outline view
5660deba7fbSSteve Yin //void DrawController::fireSwitchCurrentPage(String pageName ) throw()
fireSwitchCurrentPage(sal_Int32 pageIndex)5670deba7fbSSteve Yin void DrawController::fireSwitchCurrentPage(sal_Int32 pageIndex ) throw()
5680deba7fbSSteve Yin {
5690deba7fbSSteve Yin 		Any aNewValue;
5700deba7fbSSteve Yin 		Any aOldValue;
5710deba7fbSSteve Yin 		//OUString aPageName(  pageName );
5720deba7fbSSteve Yin 		//aNewValue <<= aPageName ;
5730deba7fbSSteve Yin 		aNewValue <<= pageIndex;
574cdf0e10cSrcweir 
5750deba7fbSSteve Yin 		// Use new property to handle page change event
5760deba7fbSSteve Yin 		sal_Int32 nHandles = PROPERTY_PAGE_CHANGE;
5770deba7fbSSteve Yin 		fire( &nHandles, &aNewValue, &aOldValue, 1, sal_False );
5780deba7fbSSteve Yin }
579cdf0e10cSrcweir 
FirePropertyChange(sal_Int32 nHandle,const Any & rNewValue,const Any & rOldValue)580cdf0e10cSrcweir void DrawController::FirePropertyChange (
581cdf0e10cSrcweir     sal_Int32 nHandle,
582cdf0e10cSrcweir     const Any& rNewValue,
583cdf0e10cSrcweir     const Any& rOldValue)
584cdf0e10cSrcweir {
585cdf0e10cSrcweir     try
586cdf0e10cSrcweir     {
587cdf0e10cSrcweir         fire (&nHandle, &rNewValue, &rOldValue, 1, sal_False);
588cdf0e10cSrcweir     }
589cdf0e10cSrcweir     catch (RuntimeException aException)
590cdf0e10cSrcweir     {
591cdf0e10cSrcweir         // Ignore this exception.  Exceptions should be handled in the
592cdf0e10cSrcweir         // fire() function so that all listeners are called.  This is
593cdf0e10cSrcweir         // not the case at the moment, so we simply ignore the
594cdf0e10cSrcweir         // exception.
595cdf0e10cSrcweir     }
596cdf0e10cSrcweir 
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 
601cdf0e10cSrcweir 
BroadcastContextChange(void) const60265be1ea2SAndre Fischer void DrawController::BroadcastContextChange (void) const
60365be1ea2SAndre Fischer {
60465be1ea2SAndre Fischer     ::boost::shared_ptr<ViewShell> pViewShell (mpBase->GetMainViewShell());
60565be1ea2SAndre Fischer     if ( ! pViewShell)
60665be1ea2SAndre Fischer         return;
60765be1ea2SAndre Fischer 
60865be1ea2SAndre Fischer     EnumContext::Context eContext (EnumContext::Context_Unknown);
60965be1ea2SAndre Fischer     switch (pViewShell->GetShellType())
61065be1ea2SAndre Fischer     {
61165be1ea2SAndre Fischer         case ViewShell::ST_IMPRESS:
61265be1ea2SAndre Fischer         case ViewShell::ST_DRAW:
61365be1ea2SAndre Fischer             if (mbMasterPageMode)
61465be1ea2SAndre Fischer                 eContext = EnumContext::Context_MasterPage;
61565be1ea2SAndre Fischer             else
61665be1ea2SAndre Fischer                 eContext = EnumContext::Context_DrawPage;
61765be1ea2SAndre Fischer             break;
61865be1ea2SAndre Fischer 
61965be1ea2SAndre Fischer         case ViewShell::ST_NOTES:
62065be1ea2SAndre Fischer             eContext = EnumContext::Context_NotesPage;
62165be1ea2SAndre Fischer             break;
62265be1ea2SAndre Fischer 
62365be1ea2SAndre Fischer         case ViewShell::ST_HANDOUT:
62465be1ea2SAndre Fischer             eContext = EnumContext::Context_HandoutPage;
62565be1ea2SAndre Fischer             break;
62665be1ea2SAndre Fischer 
62765be1ea2SAndre Fischer         case ViewShell::ST_OUTLINE:
62865be1ea2SAndre Fischer             eContext = EnumContext::Context_OutlineText;
62965be1ea2SAndre Fischer             break;
63065be1ea2SAndre Fischer 
63165be1ea2SAndre Fischer         case ViewShell::ST_SLIDE_SORTER:
63265be1ea2SAndre Fischer             eContext = EnumContext::Context_SlidesorterPage;
63365be1ea2SAndre Fischer             break;
63465be1ea2SAndre Fischer 
63565be1ea2SAndre Fischer         case ViewShell::ST_PRESENTATION:
63665be1ea2SAndre Fischer         case ViewShell::ST_NONE:
637ebf088bfSAndre Fischer         default:
63865be1ea2SAndre Fischer             eContext = EnumContext::Context_Empty;
63965be1ea2SAndre Fischer             break;
64065be1ea2SAndre Fischer     }
64165be1ea2SAndre Fischer 
64265be1ea2SAndre Fischer     ContextChangeEventMultiplexer::NotifyContextChange(mpBase, eContext);
64365be1ea2SAndre Fischer }
64465be1ea2SAndre Fischer 
64565be1ea2SAndre Fischer 
64665be1ea2SAndre Fischer 
64765be1ea2SAndre Fischer 
GetViewShellBase(void)648cdf0e10cSrcweir ViewShellBase* DrawController::GetViewShellBase (void)
649cdf0e10cSrcweir {
650cdf0e10cSrcweir     return mpBase;
651cdf0e10cSrcweir }
652cdf0e10cSrcweir 
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 
655cdf0e10cSrcweir 
ReleaseViewShellBase(void)656cdf0e10cSrcweir void DrawController::ReleaseViewShellBase (void)
657cdf0e10cSrcweir {
658cdf0e10cSrcweir     DisposeFrameworkControllers();
659cdf0e10cSrcweir     mpBase = NULL;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 
665cdf0e10cSrcweir //===== XControllerManager ==============================================================
666cdf0e10cSrcweir 
667cdf0e10cSrcweir Reference<XConfigurationController> SAL_CALL
getConfigurationController(void)668cdf0e10cSrcweir     DrawController::getConfigurationController (void)
669cdf0e10cSrcweir     throw (RuntimeException)
670cdf0e10cSrcweir {
671cdf0e10cSrcweir     ThrowIfDisposed();
672cdf0e10cSrcweir 
673cdf0e10cSrcweir     return mxConfigurationController;
674cdf0e10cSrcweir }
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 
679cdf0e10cSrcweir Reference<XModuleController> SAL_CALL
getModuleController(void)680cdf0e10cSrcweir     DrawController::getModuleController (void)
681cdf0e10cSrcweir     throw (RuntimeException)
682cdf0e10cSrcweir {
683cdf0e10cSrcweir     ThrowIfDisposed();
684cdf0e10cSrcweir 
685cdf0e10cSrcweir     return mxModuleController;
686cdf0e10cSrcweir }
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 
689cdf0e10cSrcweir 
690cdf0e10cSrcweir 
691cdf0e10cSrcweir //===== XUnoTunnel ============================================================
692cdf0e10cSrcweir 
getUnoTunnelId(void)693cdf0e10cSrcweir const Sequence<sal_Int8>& DrawController::getUnoTunnelId (void)
694cdf0e10cSrcweir {
695cdf0e10cSrcweir 	static ::com::sun::star::uno::Sequence<sal_Int8>* pSequence = NULL;
696cdf0e10cSrcweir 	if (pSequence == NULL)
697cdf0e10cSrcweir 	{
698cdf0e10cSrcweir 		::osl::Guard< ::osl::Mutex > aGuard (::osl::Mutex::getGlobalMutex());
699cdf0e10cSrcweir 		if (pSequence == NULL)
700cdf0e10cSrcweir 		{
701cdf0e10cSrcweir 			static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16);
702cdf0e10cSrcweir 			rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True);
703cdf0e10cSrcweir 			pSequence = &aSequence;
704cdf0e10cSrcweir 		}
705cdf0e10cSrcweir 	}
706cdf0e10cSrcweir 	return *pSequence;
707cdf0e10cSrcweir }
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 
getSomething(const Sequence<sal_Int8> & rId)712cdf0e10cSrcweir sal_Int64 SAL_CALL DrawController::getSomething (const Sequence<sal_Int8>& rId)
713cdf0e10cSrcweir     throw (RuntimeException)
714cdf0e10cSrcweir {
715cdf0e10cSrcweir     sal_Int64 nResult = 0;
716cdf0e10cSrcweir 
717cdf0e10cSrcweir     if (rId.getLength() == 16
718cdf0e10cSrcweir         && rtl_compareMemory(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
719cdf0e10cSrcweir 	{
720cdf0e10cSrcweir 		nResult = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
721cdf0e10cSrcweir 	}
722cdf0e10cSrcweir 
723cdf0e10cSrcweir     return nResult;
724cdf0e10cSrcweir }
725cdf0e10cSrcweir 
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 
729cdf0e10cSrcweir //===== Properties ============================================================
730cdf0e10cSrcweir 
FillPropertyTable(::std::vector<beans::Property> & rProperties)731cdf0e10cSrcweir void DrawController::FillPropertyTable (
732cdf0e10cSrcweir     ::std::vector<beans::Property>& rProperties)
733cdf0e10cSrcweir {
734cdf0e10cSrcweir     rProperties.push_back(
735cdf0e10cSrcweir         beans::Property(
736cdf0e10cSrcweir             OUString( RTL_CONSTASCII_USTRINGPARAM("VisibleArea") ),
737cdf0e10cSrcweir             PROPERTY_WORKAREA,
738cdf0e10cSrcweir             ::getCppuType((const ::com::sun::star::awt::Rectangle*)0),
739cdf0e10cSrcweir             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY));
740cdf0e10cSrcweir     rProperties.push_back(
741cdf0e10cSrcweir         beans::Property(
742cdf0e10cSrcweir             OUString( RTL_CONSTASCII_USTRINGPARAM("SubController") ),
743cdf0e10cSrcweir             PROPERTY_SUB_CONTROLLER,
744cdf0e10cSrcweir             ::getCppuType((const Reference<drawing::XDrawSubController>*)0),
745cdf0e10cSrcweir             beans::PropertyAttribute::BOUND));
746cdf0e10cSrcweir     rProperties.push_back(
747cdf0e10cSrcweir         beans::Property(
748cdf0e10cSrcweir             OUString( RTL_CONSTASCII_USTRINGPARAM("CurrentPage") ),
749cdf0e10cSrcweir             PROPERTY_CURRENTPAGE,
750cdf0e10cSrcweir             ::getCppuType((const Reference< drawing::XDrawPage > *)0),
751cdf0e10cSrcweir             beans::PropertyAttribute::BOUND ));
752cdf0e10cSrcweir     rProperties.push_back(
753cdf0e10cSrcweir         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("IsLayerMode") ),
754cdf0e10cSrcweir             PROPERTY_LAYERMODE,
755cdf0e10cSrcweir             ::getCppuBooleanType(),
756cdf0e10cSrcweir             beans::PropertyAttribute::BOUND ));
757cdf0e10cSrcweir     rProperties.push_back(
758cdf0e10cSrcweir         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("IsMasterPageMode") ),
759cdf0e10cSrcweir             PROPERTY_MASTERPAGEMODE,
760cdf0e10cSrcweir             ::getCppuBooleanType(),
761cdf0e10cSrcweir             beans::PropertyAttribute::BOUND ));
762cdf0e10cSrcweir     rProperties.push_back(
763cdf0e10cSrcweir         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ActiveLayer") ),
764cdf0e10cSrcweir             PROPERTY_ACTIVE_LAYER,
765*84e214b4SJürgen Schmidt             ::getCppuType((const Reference< drawing::XLayer > *)0),
766cdf0e10cSrcweir             beans::PropertyAttribute::BOUND ));
767cdf0e10cSrcweir     rProperties.push_back(
768cdf0e10cSrcweir         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomValue") ),
769cdf0e10cSrcweir 			PROPERTY_ZOOMVALUE,
770cdf0e10cSrcweir             ::getCppuType((const sal_Int16*)0),
771cdf0e10cSrcweir             beans::PropertyAttribute::BOUND ));
772cdf0e10cSrcweir     rProperties.push_back(
773cdf0e10cSrcweir         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomType") ),
774cdf0e10cSrcweir 			PROPERTY_ZOOMTYPE,
775cdf0e10cSrcweir             ::getCppuType((const sal_Int16*)0),
776cdf0e10cSrcweir             beans::PropertyAttribute::BOUND ));
777cdf0e10cSrcweir     rProperties.push_back(
778cdf0e10cSrcweir         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ViewOffset") ),
779cdf0e10cSrcweir 			PROPERTY_VIEWOFFSET,
780cdf0e10cSrcweir             ::getCppuType((const ::com::sun::star::awt::Point*)0),
781cdf0e10cSrcweir             beans::PropertyAttribute::BOUND ));
782cdf0e10cSrcweir     rProperties.push_back(
783cdf0e10cSrcweir         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("DrawViewMode") ),
784cdf0e10cSrcweir 			PROPERTY_DRAWVIEWMODE,
785cdf0e10cSrcweir             ::getCppuType((const ::com::sun::star::awt::Point*)0),
786cdf0e10cSrcweir             beans::PropertyAttribute::BOUND|beans::PropertyAttribute::READONLY|beans::PropertyAttribute::MAYBEVOID ));
7870deba7fbSSteve Yin 	// add new property to update current page's acc information
7880deba7fbSSteve Yin     rProperties.push_back(
7890deba7fbSSteve Yin         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("UpdateAcc") ),
7900deba7fbSSteve Yin 			PROPERTY_UPDATEACC,
7910deba7fbSSteve Yin             ::getCppuType((const sal_Int16*)0),
7920deba7fbSSteve Yin             beans::PropertyAttribute::BOUND ));
7930deba7fbSSteve Yin 	rProperties.push_back(
7940deba7fbSSteve Yin         beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("PageChange") ),
7950deba7fbSSteve Yin 			PROPERTY_PAGE_CHANGE,
7960deba7fbSSteve Yin             ::getCppuType((const sal_Int16*)0),
7970deba7fbSSteve Yin             beans::PropertyAttribute::BOUND ));
798cdf0e10cSrcweir }
799cdf0e10cSrcweir 
800cdf0e10cSrcweir 
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 
getInfoHelper()803cdf0e10cSrcweir IPropertyArrayHelper & DrawController::getInfoHelper()
804cdf0e10cSrcweir {
805cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
806cdf0e10cSrcweir 
807cdf0e10cSrcweir     if (mpPropertyArrayHelper.get() == NULL)
808cdf0e10cSrcweir     {
809cdf0e10cSrcweir         ::std::vector<beans::Property> aProperties;
810cdf0e10cSrcweir         FillPropertyTable (aProperties);
811cdf0e10cSrcweir         Sequence<beans::Property> aPropertySequence (aProperties.size());
812cdf0e10cSrcweir         for (unsigned int i=0; i<aProperties.size(); i++)
813cdf0e10cSrcweir             aPropertySequence[i] = aProperties[i];
814cdf0e10cSrcweir         mpPropertyArrayHelper.reset(new OPropertyArrayHelper(aPropertySequence, sal_False));
815cdf0e10cSrcweir     }
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 	return *mpPropertyArrayHelper.get();
818cdf0e10cSrcweir }
819cdf0e10cSrcweir 
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 
822cdf0e10cSrcweir 
getPropertySetInfo()823cdf0e10cSrcweir Reference < beans::XPropertySetInfo >  DrawController::getPropertySetInfo()
824cdf0e10cSrcweir 		throw ( ::com::sun::star::uno::RuntimeException)
825cdf0e10cSrcweir {
826cdf0e10cSrcweir 	::vos::OGuard aGuard( Application::GetSolarMutex() );
827cdf0e10cSrcweir 
828cdf0e10cSrcweir 	static Reference < beans::XPropertySetInfo >  xInfo( createPropertySetInfo( getInfoHelper() ) );
829cdf0e10cSrcweir 	return xInfo;
830cdf0e10cSrcweir }
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 
getFormController(const uno::Reference<form::XForm> & Form)833cdf0e10cSrcweir uno::Reference< form::runtime::XFormController > SAL_CALL DrawController::getFormController( const uno::Reference< form::XForm >& Form ) throw (uno::RuntimeException)
834cdf0e10cSrcweir {
835cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
836cdf0e10cSrcweir 
837cdf0e10cSrcweir     FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
838cdf0e10cSrcweir     SdrView* pSdrView = mpBase->GetDrawView();
839cdf0e10cSrcweir     ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
840cdf0e10cSrcweir     ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL;
841cdf0e10cSrcweir 
842cdf0e10cSrcweir     uno::Reference< form::runtime::XFormController > xController( NULL );
843cdf0e10cSrcweir     if ( pFormShell && pSdrView && pWindow )
844cdf0e10cSrcweir         xController = pFormShell->GetFormController( Form, *pSdrView, *pWindow );
845cdf0e10cSrcweir     return xController;
846cdf0e10cSrcweir }
847cdf0e10cSrcweir 
isFormDesignMode()848cdf0e10cSrcweir ::sal_Bool SAL_CALL DrawController::isFormDesignMode(  ) throw (uno::RuntimeException)
849cdf0e10cSrcweir {
850cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
851cdf0e10cSrcweir 
852cdf0e10cSrcweir     sal_Bool bIsDesignMode = sal_True;
853cdf0e10cSrcweir 
854cdf0e10cSrcweir     FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
855cdf0e10cSrcweir     if ( pFormShell )
856cdf0e10cSrcweir         bIsDesignMode = pFormShell->IsDesignMode();
857cdf0e10cSrcweir 
858cdf0e10cSrcweir     return bIsDesignMode;
859cdf0e10cSrcweir }
860cdf0e10cSrcweir 
setFormDesignMode(::sal_Bool _DesignMode)861cdf0e10cSrcweir void SAL_CALL DrawController::setFormDesignMode( ::sal_Bool _DesignMode ) throw (uno::RuntimeException)
862cdf0e10cSrcweir {
863cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
864cdf0e10cSrcweir 
865cdf0e10cSrcweir     FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
866cdf0e10cSrcweir     if ( pFormShell )
867cdf0e10cSrcweir         pFormShell->SetDesignMode( _DesignMode );
868cdf0e10cSrcweir }
869cdf0e10cSrcweir 
getControl(const uno::Reference<awt::XControlModel> & xModel)870cdf0e10cSrcweir uno::Reference< awt::XControl > SAL_CALL DrawController::getControl( const uno::Reference< awt::XControlModel >& xModel ) throw (container::NoSuchElementException, uno::RuntimeException)
871cdf0e10cSrcweir {
872cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
873cdf0e10cSrcweir 
874cdf0e10cSrcweir     FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
875cdf0e10cSrcweir     SdrView* pSdrView = mpBase->GetDrawView();
876cdf0e10cSrcweir     ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
877cdf0e10cSrcweir     ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL;
878cdf0e10cSrcweir 
879cdf0e10cSrcweir     uno::Reference< awt::XControl > xControl( NULL );
880cdf0e10cSrcweir     if ( pFormShell && pSdrView && pWindow )
881cdf0e10cSrcweir         pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xControl );
882cdf0e10cSrcweir     return xControl;
883cdf0e10cSrcweir }
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 
convertFastPropertyValue(Any & rConvertedValue,Any & rOldValue,sal_Int32 nHandle,const Any & rValue)888cdf0e10cSrcweir sal_Bool DrawController::convertFastPropertyValue (
889cdf0e10cSrcweir     Any & rConvertedValue,
890cdf0e10cSrcweir 	Any & rOldValue,
891cdf0e10cSrcweir 	sal_Int32 nHandle,
892cdf0e10cSrcweir 	const Any& rValue)
893cdf0e10cSrcweir     throw ( com::sun::star::lang::IllegalArgumentException)
894cdf0e10cSrcweir {
895cdf0e10cSrcweir     sal_Bool bResult = sal_False;
896cdf0e10cSrcweir 
897cdf0e10cSrcweir     if (nHandle == PROPERTY_SUB_CONTROLLER)
898cdf0e10cSrcweir     {
899cdf0e10cSrcweir         rOldValue <<= mxSubController;
900cdf0e10cSrcweir         rConvertedValue <<= Reference<drawing::XDrawSubController>(rValue, UNO_QUERY);
901cdf0e10cSrcweir         bResult = (rOldValue != rConvertedValue);
902cdf0e10cSrcweir     }
903cdf0e10cSrcweir     else if (mxSubController.is())
904cdf0e10cSrcweir     {
905cdf0e10cSrcweir         rConvertedValue = rValue;
906cdf0e10cSrcweir         try
907cdf0e10cSrcweir         {
908cdf0e10cSrcweir             rOldValue = mxSubController->getFastPropertyValue(nHandle);
909cdf0e10cSrcweir             bResult = (rOldValue != rConvertedValue);
910cdf0e10cSrcweir         }
911cdf0e10cSrcweir         catch(beans::UnknownPropertyException aException)
912cdf0e10cSrcweir         {
913cdf0e10cSrcweir             // The prperty is unknown and thus an illegal argument to this method.
914cdf0e10cSrcweir             throw com::sun::star::lang::IllegalArgumentException();
915cdf0e10cSrcweir         }
916cdf0e10cSrcweir     }
917cdf0e10cSrcweir 
918cdf0e10cSrcweir     return bResult;
919cdf0e10cSrcweir }
920cdf0e10cSrcweir 
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 
923cdf0e10cSrcweir 
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any & rValue)924cdf0e10cSrcweir void DrawController::setFastPropertyValue_NoBroadcast (
925cdf0e10cSrcweir 	sal_Int32 nHandle,
926cdf0e10cSrcweir 	const Any& rValue)
927cdf0e10cSrcweir     throw ( com::sun::star::uno::Exception)
928cdf0e10cSrcweir {
929cdf0e10cSrcweir     OGuard aGuard( Application::GetSolarMutex() );
930cdf0e10cSrcweir     if (nHandle == PROPERTY_SUB_CONTROLLER)
931cdf0e10cSrcweir         SetSubController(Reference<drawing::XDrawSubController>(rValue, UNO_QUERY));
932cdf0e10cSrcweir     else if (mxSubController.is())
933cdf0e10cSrcweir         mxSubController->setFastPropertyValue(nHandle, rValue);
934cdf0e10cSrcweir }
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 
937cdf0e10cSrcweir 
938cdf0e10cSrcweir 
getFastPropertyValue(Any & rRet,sal_Int32 nHandle) const939cdf0e10cSrcweir void DrawController::getFastPropertyValue (
940cdf0e10cSrcweir     Any & rRet,
941cdf0e10cSrcweir     sal_Int32 nHandle ) const
942cdf0e10cSrcweir {
943cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
944cdf0e10cSrcweir 
945cdf0e10cSrcweir 	switch( nHandle )
946cdf0e10cSrcweir 	{
947cdf0e10cSrcweir 		case PROPERTY_WORKAREA:
948cdf0e10cSrcweir 			rRet <<= awt::Rectangle(
949cdf0e10cSrcweir                 maLastVisArea.Left(),
950cdf0e10cSrcweir                 maLastVisArea.Top(),
951cdf0e10cSrcweir                 maLastVisArea.GetWidth(),
952cdf0e10cSrcweir                 maLastVisArea.GetHeight());
953cdf0e10cSrcweir 			break;
954cdf0e10cSrcweir 
955cdf0e10cSrcweir         case PROPERTY_SUB_CONTROLLER:
956cdf0e10cSrcweir             rRet <<= mxSubController;
957cdf0e10cSrcweir             break;
958cdf0e10cSrcweir 
959cdf0e10cSrcweir         default:
960cdf0e10cSrcweir             if (mxSubController.is())
961cdf0e10cSrcweir                 rRet = mxSubController->getFastPropertyValue(nHandle);
962cdf0e10cSrcweir             break;
963cdf0e10cSrcweir     }
964cdf0e10cSrcweir }
965cdf0e10cSrcweir 
966cdf0e10cSrcweir 
967cdf0e10cSrcweir 
968cdf0e10cSrcweir 
969cdf0e10cSrcweir //-----------------------------------------------------------------------------
970cdf0e10cSrcweir 
ProvideFrameworkControllers(void)971cdf0e10cSrcweir void DrawController::ProvideFrameworkControllers (void)
972cdf0e10cSrcweir {
973cdf0e10cSrcweir 	::vos::OGuard aGuard (Application::GetSolarMutex());
974cdf0e10cSrcweir     try
975cdf0e10cSrcweir     {
976cdf0e10cSrcweir         Reference<XController> xController (this);
977cdf0e10cSrcweir         const Reference<XComponentContext> xContext (
978cdf0e10cSrcweir             ::comphelper::getProcessComponentContext() );
979cdf0e10cSrcweir         mxConfigurationController = ConfigurationController::create(
980cdf0e10cSrcweir             xContext,
981cdf0e10cSrcweir             xController);
982cdf0e10cSrcweir         mxModuleController = ModuleController::create(
983cdf0e10cSrcweir             xContext,
984cdf0e10cSrcweir             xController);
985cdf0e10cSrcweir     }
986cdf0e10cSrcweir     catch (RuntimeException&)
987cdf0e10cSrcweir     {
988cdf0e10cSrcweir         mxConfigurationController = NULL;
989cdf0e10cSrcweir         mxModuleController = NULL;
990cdf0e10cSrcweir     }
991cdf0e10cSrcweir }
992cdf0e10cSrcweir 
993cdf0e10cSrcweir 
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 
DisposeFrameworkControllers(void)996cdf0e10cSrcweir void DrawController::DisposeFrameworkControllers (void)
997cdf0e10cSrcweir {
998cdf0e10cSrcweir     Reference<XComponent> xComponent (mxModuleController, UNO_QUERY);
999cdf0e10cSrcweir     if (xComponent.is())
1000cdf0e10cSrcweir         xComponent->dispose();
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir     xComponent = Reference<XComponent>(mxConfigurationController, UNO_QUERY);
1003cdf0e10cSrcweir     if (xComponent.is())
1004cdf0e10cSrcweir         xComponent->dispose();
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 
ThrowIfDisposed(void) const1010cdf0e10cSrcweir void DrawController::ThrowIfDisposed (void) const
1011cdf0e10cSrcweir     throw (::com::sun::star::lang::DisposedException)
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose || mbDisposing)
1014cdf0e10cSrcweir 	{
1015cdf0e10cSrcweir         OSL_TRACE ("Calling disposed DrawController object. Throwing exception:");
1016cdf0e10cSrcweir         throw lang::DisposedException (
1017cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM(
1018cdf0e10cSrcweir                 "DrawController object has already been disposed")),
1019cdf0e10cSrcweir             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
1020cdf0e10cSrcweir     }
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir } // end of namespace sd
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir 
1030