Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "DrawController.hxx"
21 : #include "DrawDocShell.hxx"
22 :
23 : #include "DrawSubController.hxx"
24 : #include "sdpage.hxx"
25 : #include "ViewShellBase.hxx"
26 : #include "ViewShellManager.hxx"
27 : #include "FormShellManager.hxx"
28 : #include "Window.hxx"
29 :
30 : #include <comphelper/anytostring.hxx>
31 : #include <comphelper/processfactory.hxx>
32 : #include <comphelper/sequence.hxx>
33 : #include <comphelper/servicehelper.hxx>
34 : #include <cppuhelper/exc_hlp.hxx>
35 : #include <cppuhelper/bootstrap.hxx>
36 : #include <cppuhelper/supportsservice.hxx>
37 :
38 : #include <com/sun/star/beans/PropertyAttribute.hpp>
39 : #include <com/sun/star/drawing/framework/ConfigurationController.hpp>
40 : #include <com/sun/star/drawing/framework/ModuleController.hpp>
41 : #include <com/sun/star/lang/XInitialization.hpp>
42 :
43 : #include "slideshow.hxx"
44 :
45 : #include <svx/fmshell.hxx>
46 : #include <osl/mutex.hxx>
47 : #include <vcl/svapp.hxx>
48 : #include <sfx2/sidebar/EnumContext.hxx>
49 : #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
50 :
51 : #include <boost/shared_ptr.hpp>
52 :
53 : using namespace ::std;
54 : using namespace ::cppu;
55 : using namespace ::com::sun::star;
56 : using namespace ::com::sun::star::uno;
57 : using namespace ::com::sun::star::drawing::framework;
58 : using ::sfx2::sidebar::EnumContext;
59 :
60 : namespace sd {
61 :
62 127 : DrawController::DrawController (ViewShellBase& rBase) throw()
63 : : DrawControllerInterfaceBase(&rBase),
64 : BroadcastHelperOwner(SfxBaseController::m_aMutex),
65 : OPropertySetHelper( static_cast<OBroadcastHelperVar<
66 : OMultiTypeInterfaceContainerHelper,
67 : OMultiTypeInterfaceContainerHelper::keyType>& >(
68 : BroadcastHelperOwner::maBroadcastHelper)),
69 : m_aSelectionTypeIdentifier(
70 127 : cppu::UnoType<view::XSelectionChangeListener>::get()),
71 : mpBase(&rBase),
72 : maLastVisArea(),
73 : mpCurrentPage(NULL),
74 : mbMasterPageMode(false),
75 : mbLayerMode(false),
76 : mbDisposing(false),
77 : mxSubController(),
78 : mxConfigurationController(),
79 254 : mxModuleController()
80 : {
81 127 : ProvideFrameworkControllers();
82 127 : }
83 :
84 168 : DrawController::~DrawController() throw()
85 : {
86 168 : }
87 :
88 266 : void DrawController::SetSubController (
89 : const Reference<drawing::XDrawSubController>& rxSubController)
90 : {
91 : // Update the internal state.
92 266 : mxSubController = rxSubController;
93 266 : mpPropertyArrayHelper.reset();
94 266 : maLastVisArea = Rectangle();
95 :
96 : // Inform listeners about the changed state.
97 266 : FireSelectionChangeListener();
98 266 : }
99 :
100 : // XInterface
101 :
102 272744 : IMPLEMENT_FORWARD_XINTERFACE2(
103 : DrawController,
104 : DrawControllerInterfaceBase,
105 : OPropertySetHelper);
106 :
107 : // XTypeProvider
108 :
109 0 : Sequence<Type> SAL_CALL DrawController::getTypes()
110 : throw (::com::sun::star::uno::RuntimeException, std::exception)
111 : {
112 0 : ThrowIfDisposed();
113 : // OPropertySetHelper does not provide getTypes, so we have to
114 : // implement this method manually and list its three interfaces.
115 : OTypeCollection aTypeCollection (
116 0 : cppu::UnoType<beans::XMultiPropertySet>::get(),
117 0 : cppu::UnoType<beans::XFastPropertySet>::get(),
118 0 : cppu::UnoType<beans::XPropertySet>::get());
119 :
120 : return ::comphelper::concatSequences(
121 : SfxBaseController::getTypes(),
122 : aTypeCollection.getTypes(),
123 0 : DrawControllerInterfaceBase::getTypes());
124 : }
125 :
126 0 : IMPLEMENT_GET_IMPLEMENTATION_ID(DrawController);
127 :
128 : // XComponent
129 :
130 127 : void SAL_CALL DrawController::dispose()
131 : throw( RuntimeException, std::exception )
132 : {
133 127 : if( !mbDisposing )
134 : {
135 127 : SolarMutexGuard aGuard;
136 :
137 127 : if( !mbDisposing )
138 : {
139 127 : mbDisposing = true;
140 :
141 127 : boost::shared_ptr<ViewShell> pViewShell;
142 127 : if (mpBase)
143 127 : pViewShell = mpBase->GetMainViewShell();
144 127 : if ( pViewShell )
145 : {
146 127 : pViewShell->DeactivateCurrentFunction();
147 127 : DrawDocShell* pDocShell = pViewShell->GetDocSh();
148 127 : if ( pDocShell != NULL )
149 127 : pDocShell->SetDocShellFunction(0);
150 : }
151 127 : pViewShell.reset();
152 :
153 : // When the controller has not been detached from its view
154 : // shell, i.e. mpViewShell is not NULL, then tell PaneManager
155 : // and ViewShellManager to clear the shell stack.
156 127 : if (mxSubController.is() && mpBase!=NULL)
157 : {
158 127 : mpBase->DisconnectAllClients();
159 127 : mpBase->GetViewShellManager()->Shutdown();
160 : }
161 :
162 127 : OPropertySetHelper::disposing();
163 :
164 127 : DisposeFrameworkControllers();
165 :
166 127 : SfxBaseController::dispose();
167 127 : }
168 : }
169 127 : }
170 :
171 585 : void SAL_CALL DrawController::addEventListener(
172 : const Reference<lang::XEventListener >& xListener)
173 : throw (RuntimeException, std::exception)
174 : {
175 585 : ThrowIfDisposed();
176 578 : SfxBaseController::addEventListener( xListener );
177 578 : }
178 :
179 451 : void SAL_CALL DrawController::removeEventListener (
180 : const Reference<lang::XEventListener >& aListener)
181 : throw (RuntimeException, std::exception)
182 : {
183 451 : if(!rBHelper.bDisposed && !rBHelper.bInDispose && !mbDisposing)
184 318 : SfxBaseController::removeEventListener( aListener );
185 451 : }
186 :
187 : // XController
188 0 : sal_Bool SAL_CALL DrawController::suspend( sal_Bool Suspend ) throw (::com::sun::star::uno::RuntimeException, std::exception)
189 : {
190 0 : if( Suspend )
191 : {
192 0 : ViewShellBase* pViewShellBase = GetViewShellBase();
193 0 : if( pViewShellBase )
194 : {
195 : // do not allow suspend if a slideshow needs this controller!
196 0 : rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pViewShellBase ) );
197 0 : if( xSlideShow.is() && xSlideShow->dependsOn(pViewShellBase) )
198 0 : return sal_False;
199 : }
200 : }
201 :
202 0 : return SfxBaseController::suspend( Suspend );
203 : }
204 :
205 : // XServiceInfo
206 0 : OUString SAL_CALL DrawController::getImplementationName( ) throw(RuntimeException, std::exception)
207 : {
208 : // Do not throw an excepetion at the moment. This leads to a crash
209 : // under Solaris on relead. See issue i70929 for details.
210 : // ThrowIfDisposed();
211 0 : return OUString("DrawController") ;
212 : }
213 :
214 : static const char ssServiceName[] = "com.sun.star.drawing.DrawingDocumentDrawView";
215 :
216 0 : sal_Bool SAL_CALL DrawController::supportsService (const OUString& rsServiceName)
217 : throw(RuntimeException, std::exception)
218 : {
219 0 : return cppu::supportsService(this, rsServiceName);
220 : }
221 :
222 7 : Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames()
223 : throw(RuntimeException, std::exception)
224 : {
225 7 : ThrowIfDisposed();
226 7 : Sequence<OUString> aSupportedServices (1);
227 7 : OUString* pServices = aSupportedServices.getArray();
228 7 : pServices[0] = ssServiceName;
229 7 : return aSupportedServices;
230 : }
231 :
232 : //------ XSelectionSupplier --------------------------------------------
233 2 : sal_Bool SAL_CALL DrawController::select (const Any& aSelection)
234 : throw(lang::IllegalArgumentException, RuntimeException, std::exception)
235 : {
236 2 : ThrowIfDisposed();
237 2 : SolarMutexGuard aGuard;
238 :
239 2 : if (mxSubController.is())
240 2 : return mxSubController->select(aSelection);
241 : else
242 0 : return false;
243 : }
244 :
245 12 : Any SAL_CALL DrawController::getSelection()
246 : throw(RuntimeException, std::exception)
247 : {
248 12 : ThrowIfDisposed();
249 9 : SolarMutexGuard aGuard;
250 :
251 9 : if (mxSubController.is())
252 9 : return mxSubController->getSelection();
253 : else
254 0 : return Any();
255 : }
256 :
257 390 : void SAL_CALL DrawController::addSelectionChangeListener(
258 : const Reference< view::XSelectionChangeListener >& xListener)
259 : throw(RuntimeException, std::exception)
260 : {
261 390 : if( mbDisposing )
262 0 : throw lang::DisposedException();
263 :
264 390 : BroadcastHelperOwner::maBroadcastHelper.addListener (m_aSelectionTypeIdentifier, xListener);
265 390 : }
266 :
267 390 : void SAL_CALL DrawController::removeSelectionChangeListener(
268 : const Reference< view::XSelectionChangeListener >& xListener )
269 : throw(RuntimeException, std::exception)
270 : {
271 390 : if (rBHelper.bDisposed)
272 0 : throw lang::DisposedException();
273 :
274 390 : BroadcastHelperOwner::maBroadcastHelper.removeListener (m_aSelectionTypeIdentifier, xListener);
275 390 : }
276 :
277 : //===== lang::XEventListener ================================================
278 :
279 : void SAL_CALL
280 0 : DrawController::disposing (const lang::EventObject& )
281 : throw (uno::RuntimeException, std::exception)
282 : {
283 0 : }
284 :
285 : //===== view::XSelectionChangeListener ======================================
286 :
287 : void SAL_CALL
288 0 : DrawController::selectionChanged (const lang::EventObject& rEvent)
289 : throw (uno::RuntimeException, std::exception)
290 : {
291 0 : ThrowIfDisposed();
292 : // Have to forward the event to our selection change listeners.
293 : OInterfaceContainerHelper* pListeners = BroadcastHelperOwner::maBroadcastHelper.getContainer(
294 0 : cppu::UnoType<view::XSelectionChangeListener>::get());
295 0 : if (pListeners)
296 : {
297 : // Re-send the event to all of our listeners.
298 0 : OInterfaceIteratorHelper aIterator (*pListeners);
299 0 : while (aIterator.hasMoreElements())
300 : {
301 : try
302 : {
303 : view::XSelectionChangeListener* pListener =
304 : static_cast<view::XSelectionChangeListener*>(
305 0 : aIterator.next());
306 0 : if (pListener != NULL)
307 0 : pListener->selectionChanged (rEvent);
308 : }
309 0 : catch (const RuntimeException&)
310 : {
311 : }
312 0 : }
313 : }
314 0 : }
315 :
316 : // XDrawView
317 :
318 4 : void SAL_CALL DrawController::setCurrentPage( const Reference< drawing::XDrawPage >& xPage )
319 : throw(RuntimeException, std::exception)
320 : {
321 4 : ThrowIfDisposed();
322 4 : SolarMutexGuard aGuard;
323 :
324 4 : if (mxSubController.is())
325 4 : mxSubController->setCurrentPage(xPage);
326 4 : }
327 :
328 220 : Reference< drawing::XDrawPage > SAL_CALL DrawController::getCurrentPage()
329 : throw(RuntimeException, std::exception)
330 : {
331 220 : ThrowIfDisposed();
332 220 : SolarMutexGuard aGuard;
333 220 : Reference<drawing::XDrawPage> xPage;
334 :
335 : // Get current page from sub controller.
336 220 : if (mxSubController.is())
337 220 : xPage = mxSubController->getCurrentPage();
338 :
339 : // When there is not yet a sub controller (during initialization) then fall back
340 : // to the current page in mpCurrentPage.
341 220 : if ( ! xPage.is() && mpCurrentPage.is())
342 0 : xPage = Reference<drawing::XDrawPage>(mpCurrentPage->getUnoPage(), UNO_QUERY);
343 :
344 220 : return xPage;
345 : }
346 :
347 909 : void DrawController::FireVisAreaChanged (const Rectangle& rVisArea) throw()
348 : {
349 909 : if( maLastVisArea != rVisArea )
350 : {
351 640 : Any aNewValue;
352 3200 : aNewValue <<= awt::Rectangle(
353 640 : rVisArea.Left(),
354 640 : rVisArea.Top(),
355 640 : rVisArea.GetWidth(),
356 1280 : rVisArea.GetHeight() );
357 :
358 1280 : Any aOldValue;
359 3200 : aOldValue <<= awt::Rectangle(
360 640 : maLastVisArea.Left(),
361 640 : maLastVisArea.Top(),
362 640 : maLastVisArea.GetWidth(),
363 1280 : maLastVisArea.GetHeight() );
364 :
365 640 : FirePropertyChange (PROPERTY_WORKAREA, aNewValue, aOldValue);
366 :
367 1280 : maLastVisArea = rVisArea;
368 : }
369 909 : }
370 :
371 421 : void DrawController::FireSelectionChangeListener() throw()
372 : {
373 : OInterfaceContainerHelper * pLC = BroadcastHelperOwner::maBroadcastHelper.getContainer(
374 421 : m_aSelectionTypeIdentifier);
375 421 : if( pLC )
376 : {
377 421 : Reference< XInterface > xSource( static_cast<XWeak*>(this) );
378 842 : const lang::EventObject aEvent( xSource );
379 :
380 : // iterate over all listeners and send events
381 842 : OInterfaceIteratorHelper aIt( *pLC);
382 1453 : while( aIt.hasMoreElements() )
383 : {
384 : try
385 : {
386 : view::XSelectionChangeListener * pL =
387 611 : static_cast<view::XSelectionChangeListener*>(aIt.next());
388 611 : if (pL != NULL)
389 611 : pL->selectionChanged( aEvent );
390 : }
391 3 : catch (const RuntimeException&)
392 : {
393 : }
394 421 : }
395 : }
396 421 : }
397 :
398 411 : void DrawController::FireChangeEditMode (bool bMasterPageMode) throw()
399 : {
400 411 : if (bMasterPageMode != mbMasterPageMode )
401 : {
402 : FirePropertyChange(
403 : PROPERTY_MASTERPAGEMODE,
404 : makeAny(bMasterPageMode),
405 10 : makeAny(mbMasterPageMode));
406 :
407 10 : mbMasterPageMode = bMasterPageMode;
408 : }
409 411 : }
410 :
411 411 : void DrawController::FireChangeLayerMode (bool bLayerMode) throw()
412 : {
413 411 : if (bLayerMode != mbLayerMode)
414 : {
415 : FirePropertyChange(
416 : PROPERTY_LAYERMODE,
417 : makeAny(bLayerMode),
418 128 : makeAny(mbLayerMode));
419 :
420 128 : mbLayerMode = bLayerMode;
421 : }
422 411 : }
423 :
424 150 : void DrawController::FireSwitchCurrentPage (SdPage* pNewCurrentPage) throw()
425 : {
426 150 : SdrPage* pCurrentPage = mpCurrentPage.get();
427 150 : if (pNewCurrentPage != pCurrentPage)
428 : {
429 : try
430 : {
431 : Any aNewValue (
432 150 : makeAny(Reference<drawing::XDrawPage>(pNewCurrentPage->getUnoPage(), UNO_QUERY)));
433 :
434 300 : Any aOldValue;
435 150 : if (pCurrentPage != NULL)
436 : {
437 23 : Reference<drawing::XDrawPage> xOldPage (pCurrentPage->getUnoPage(), UNO_QUERY);
438 23 : aOldValue <<= xOldPage;
439 : }
440 :
441 150 : FirePropertyChange(PROPERTY_CURRENTPAGE, aNewValue, aOldValue);
442 :
443 300 : mpCurrentPage.reset(pNewCurrentPage);
444 : }
445 0 : catch (const uno::Exception&)
446 : {
447 : OSL_FAIL(
448 : OString("sd::SdUnoDrawView::FireSwitchCurrentPage(), exception caught: " +
449 : OUStringToOString(
450 : comphelper::anyToString( cppu::getCaughtException() ),
451 : RTL_TEXTENCODING_UTF8 )).getStr() );
452 : }
453 : }
454 150 : }
455 :
456 0 : void DrawController::NotifyAccUpdate()
457 : {
458 0 : sal_Int32 nHandle = PROPERTY_UPDATEACC;
459 0 : Any aNewValue, aOldValue;
460 0 : fire (&nHandle, &aNewValue, &aOldValue, 1, sal_False);
461 0 : }
462 :
463 0 : void DrawController::fireChangeLayer( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer>* pCurrentLayer ) throw()
464 : {
465 0 : if( pCurrentLayer != mpCurrentLayer )
466 : {
467 0 : sal_Int32 nHandle = PROPERTY_ACTIVE_LAYER;
468 :
469 0 : Any aNewValue (makeAny( *pCurrentLayer) );
470 :
471 0 : Any aOldValue ;
472 :
473 0 : fire (&nHandle, &aNewValue, &aOldValue, 1, sal_False);
474 :
475 0 : mpCurrentLayer = pCurrentLayer;
476 : }
477 0 : }
478 :
479 : // This method is only called in slide show and outline view
480 : //void DrawController::fireSwitchCurrentPage(String pageName ) throw()
481 0 : void DrawController::fireSwitchCurrentPage(sal_Int32 pageIndex ) throw()
482 : {
483 0 : Any aNewValue;
484 0 : Any aOldValue;
485 : //OUString aPageName( pageName );
486 : //aNewValue <<= aPageName ;
487 0 : aNewValue <<= pageIndex;
488 :
489 : // Use new property to handle page change event
490 0 : sal_Int32 nHandles = PROPERTY_PAGE_CHANGE;
491 0 : fire( &nHandles, &aNewValue, &aOldValue, 1, sal_False );
492 0 : }
493 :
494 928 : void DrawController::FirePropertyChange (
495 : sal_Int32 nHandle,
496 : const Any& rNewValue,
497 : const Any& rOldValue)
498 : {
499 : try
500 : {
501 928 : fire (&nHandle, &rNewValue, &rOldValue, 1, sal_False);
502 : }
503 0 : catch (const RuntimeException&)
504 : {
505 : // Ignore this exception. Exceptions should be handled in the
506 : // fire() function so that all listeners are called. This is
507 : // not the case at the moment, so we simply ignore the
508 : // exception.
509 : }
510 :
511 928 : }
512 :
513 411 : void DrawController::BroadcastContextChange() const
514 : {
515 411 : ::boost::shared_ptr<ViewShell> pViewShell (mpBase->GetMainViewShell());
516 411 : if ( ! pViewShell)
517 544 : return;
518 :
519 278 : EnumContext::Context eContext (EnumContext::Context_Unknown);
520 278 : switch (pViewShell->GetShellType())
521 : {
522 : case ViewShell::ST_IMPRESS:
523 : case ViewShell::ST_DRAW:
524 274 : if (mbMasterPageMode)
525 2 : eContext = EnumContext::Context_MasterPage;
526 : else
527 272 : eContext = EnumContext::Context_DrawPage;
528 274 : break;
529 :
530 : case ViewShell::ST_NOTES:
531 3 : eContext = EnumContext::Context_NotesPage;
532 3 : break;
533 :
534 : case ViewShell::ST_HANDOUT:
535 1 : eContext = EnumContext::Context_HandoutPage;
536 1 : break;
537 :
538 : case ViewShell::ST_OUTLINE:
539 0 : eContext = EnumContext::Context_OutlineText;
540 0 : break;
541 :
542 : case ViewShell::ST_SLIDE_SORTER:
543 0 : eContext = EnumContext::Context_SlidesorterPage;
544 0 : break;
545 :
546 : case ViewShell::ST_PRESENTATION:
547 : case ViewShell::ST_NONE:
548 : default:
549 0 : eContext = EnumContext::Context_Empty;
550 0 : break;
551 : }
552 :
553 278 : ContextChangeEventMultiplexer::NotifyContextChange(mpBase, eContext);
554 : }
555 :
556 127 : void DrawController::ReleaseViewShellBase()
557 : {
558 127 : DisposeFrameworkControllers();
559 127 : mpBase = NULL;
560 127 : }
561 :
562 : //===== XControllerManager ==============================================================
563 :
564 : Reference<XConfigurationController> SAL_CALL
565 1864 : DrawController::getConfigurationController()
566 : throw (RuntimeException, std::exception)
567 : {
568 1864 : ThrowIfDisposed();
569 :
570 1864 : return mxConfigurationController;
571 : }
572 :
573 : Reference<XModuleController> SAL_CALL
574 477 : DrawController::getModuleController()
575 : throw (RuntimeException, std::exception)
576 : {
577 477 : ThrowIfDisposed();
578 :
579 477 : return mxModuleController;
580 : }
581 :
582 : //===== XUnoTunnel ============================================================
583 :
584 : namespace
585 : {
586 : class theDrawControllerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theDrawControllerUnoTunnelId> {};
587 : }
588 :
589 1364 : const Sequence<sal_Int8>& DrawController::getUnoTunnelId()
590 : {
591 1364 : return theDrawControllerUnoTunnelId::get().getSeq();
592 : }
593 :
594 682 : sal_Int64 SAL_CALL DrawController::getSomething (const Sequence<sal_Int8>& rId)
595 : throw (RuntimeException, std::exception)
596 : {
597 682 : sal_Int64 nResult = 0;
598 :
599 1364 : if (rId.getLength() == 16
600 682 : && memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
601 : {
602 682 : nResult = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
603 : }
604 :
605 682 : return nResult;
606 : }
607 :
608 : //===== Properties ============================================================
609 :
610 266 : void DrawController::FillPropertyTable (
611 : ::std::vector<beans::Property>& rProperties)
612 : {
613 : rProperties.push_back(
614 : beans::Property("VisibleArea",
615 : PROPERTY_WORKAREA,
616 266 : ::cppu::UnoType< ::com::sun::star::awt::Rectangle>::get(),
617 532 : beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY));
618 : rProperties.push_back(
619 : beans::Property(
620 : "SubController",
621 : PROPERTY_SUB_CONTROLLER,
622 266 : cppu::UnoType<drawing::XDrawSubController>::get(),
623 266 : beans::PropertyAttribute::BOUND));
624 : rProperties.push_back(
625 : beans::Property(
626 : "CurrentPage",
627 : PROPERTY_CURRENTPAGE,
628 266 : cppu::UnoType<drawing::XDrawPage>::get(),
629 266 : beans::PropertyAttribute::BOUND ));
630 : rProperties.push_back(
631 : beans::Property("IsLayerMode",
632 : PROPERTY_LAYERMODE,
633 266 : cppu::UnoType<bool>::get(),
634 266 : beans::PropertyAttribute::BOUND ));
635 : rProperties.push_back(
636 : beans::Property("IsMasterPageMode",
637 : PROPERTY_MASTERPAGEMODE,
638 266 : cppu::UnoType<bool>::get(),
639 266 : beans::PropertyAttribute::BOUND ));
640 : rProperties.push_back(
641 : beans::Property("ActiveLayer",
642 : PROPERTY_ACTIVE_LAYER,
643 266 : cppu::UnoType<drawing::XLayer>::get(),
644 266 : beans::PropertyAttribute::BOUND ));
645 : rProperties.push_back(
646 : beans::Property("ZoomValue",
647 : PROPERTY_ZOOMVALUE,
648 266 : ::cppu::UnoType<sal_Int16>::get(),
649 266 : beans::PropertyAttribute::BOUND ));
650 : rProperties.push_back(
651 : beans::Property("ZoomType",
652 : PROPERTY_ZOOMTYPE,
653 266 : ::cppu::UnoType<sal_Int16>::get(),
654 266 : beans::PropertyAttribute::BOUND ));
655 : rProperties.push_back(
656 : beans::Property("ViewOffset",
657 : PROPERTY_VIEWOFFSET,
658 266 : ::cppu::UnoType< ::com::sun::star::awt::Point>::get(),
659 266 : beans::PropertyAttribute::BOUND ));
660 : rProperties.push_back(
661 : beans::Property("DrawViewMode",
662 : PROPERTY_DRAWVIEWMODE,
663 266 : ::cppu::UnoType< ::com::sun::star::awt::Point>::get(),
664 532 : beans::PropertyAttribute::BOUND|beans::PropertyAttribute::READONLY|beans::PropertyAttribute::MAYBEVOID ));
665 : // add new property to update current page's acc information
666 : rProperties.push_back(
667 : beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("UpdateAcc") ),
668 : PROPERTY_UPDATEACC,
669 266 : ::cppu::UnoType<sal_Int16>::get(),
670 266 : beans::PropertyAttribute::BOUND ));
671 : rProperties.push_back(
672 : beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("PageChange") ),
673 : PROPERTY_PAGE_CHANGE,
674 266 : ::cppu::UnoType<sal_Int16>::get(),
675 266 : beans::PropertyAttribute::BOUND ));
676 266 : }
677 :
678 2214 : IPropertyArrayHelper & DrawController::getInfoHelper()
679 : {
680 2214 : SolarMutexGuard aGuard;
681 :
682 2214 : if (mpPropertyArrayHelper.get() == NULL)
683 : {
684 266 : ::std::vector<beans::Property> aProperties;
685 266 : FillPropertyTable (aProperties);
686 532 : Sequence<beans::Property> aPropertySequence (aProperties.size());
687 3458 : for (size_t i=0; i<aProperties.size(); i++)
688 3192 : aPropertySequence[i] = aProperties[i];
689 532 : mpPropertyArrayHelper.reset(new OPropertyArrayHelper(aPropertySequence, sal_False));
690 : }
691 :
692 2214 : return *mpPropertyArrayHelper.get();
693 : }
694 :
695 390 : Reference < beans::XPropertySetInfo > DrawController::getPropertySetInfo()
696 : throw ( ::com::sun::star::uno::RuntimeException, std::exception)
697 : {
698 390 : SolarMutexGuard aGuard;
699 :
700 390 : static Reference < beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
701 390 : return xInfo;
702 : }
703 :
704 0 : uno::Reference< form::runtime::XFormController > SAL_CALL DrawController::getFormController( const uno::Reference< form::XForm >& Form ) throw (uno::RuntimeException, std::exception)
705 : {
706 0 : SolarMutexGuard aGuard;
707 :
708 0 : FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
709 0 : SdrView* pSdrView = mpBase->GetDrawView();
710 0 : ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
711 0 : ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL;
712 :
713 0 : uno::Reference< form::runtime::XFormController > xController( NULL );
714 0 : if ( pFormShell && pSdrView && pWindow )
715 0 : xController = FmFormShell::GetFormController( Form, *pSdrView, *pWindow );
716 0 : return xController;
717 : }
718 :
719 0 : sal_Bool SAL_CALL DrawController::isFormDesignMode( ) throw (uno::RuntimeException, std::exception)
720 : {
721 0 : SolarMutexGuard aGuard;
722 :
723 0 : bool bIsDesignMode = true;
724 :
725 0 : FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
726 0 : if ( pFormShell )
727 0 : bIsDesignMode = pFormShell->IsDesignMode();
728 :
729 0 : return bIsDesignMode;
730 : }
731 :
732 0 : void SAL_CALL DrawController::setFormDesignMode( sal_Bool _DesignMode ) throw (uno::RuntimeException, std::exception)
733 : {
734 0 : SolarMutexGuard aGuard;
735 :
736 0 : FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
737 0 : if ( pFormShell )
738 0 : pFormShell->SetDesignMode( _DesignMode );
739 0 : }
740 :
741 0 : uno::Reference< awt::XControl > SAL_CALL DrawController::getControl( const uno::Reference< awt::XControlModel >& xModel ) throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
742 : {
743 0 : SolarMutexGuard aGuard;
744 :
745 0 : FmFormShell* pFormShell = mpBase->GetFormShellManager()->GetFormShell();
746 0 : SdrView* pSdrView = mpBase->GetDrawView();
747 0 : ::boost::shared_ptr<ViewShell> pViewShell = mpBase->GetMainViewShell();
748 0 : ::sd::Window* pWindow = pViewShell ? pViewShell->GetActiveWindow() : NULL;
749 :
750 0 : uno::Reference< awt::XControl > xControl( NULL );
751 0 : if ( pFormShell && pSdrView && pWindow )
752 0 : pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xControl );
753 0 : return xControl;
754 : }
755 :
756 0 : sal_Bool DrawController::convertFastPropertyValue (
757 : Any & rConvertedValue,
758 : Any & rOldValue,
759 : sal_Int32 nHandle,
760 : const Any& rValue)
761 : throw ( com::sun::star::lang::IllegalArgumentException)
762 : {
763 0 : bool bResult = false;
764 :
765 0 : if (nHandle == PROPERTY_SUB_CONTROLLER)
766 : {
767 0 : rOldValue <<= mxSubController;
768 0 : rConvertedValue <<= Reference<drawing::XDrawSubController>(rValue, UNO_QUERY);
769 0 : bResult = (rOldValue != rConvertedValue);
770 : }
771 0 : else if (mxSubController.is())
772 : {
773 0 : rConvertedValue = rValue;
774 : try
775 : {
776 0 : rOldValue = mxSubController->getFastPropertyValue(nHandle);
777 0 : bResult = (rOldValue != rConvertedValue);
778 : }
779 0 : catch (const beans::UnknownPropertyException&)
780 : {
781 : // The property is unknown and thus an illegal argument to this method.
782 0 : throw com::sun::star::lang::IllegalArgumentException();
783 : }
784 : }
785 :
786 0 : return bResult;
787 : }
788 :
789 0 : void DrawController::setFastPropertyValue_NoBroadcast (
790 : sal_Int32 nHandle,
791 : const Any& rValue)
792 : throw ( com::sun::star::uno::Exception, std::exception)
793 : {
794 0 : SolarMutexGuard aGuard;
795 0 : if (nHandle == PROPERTY_SUB_CONTROLLER)
796 0 : SetSubController(Reference<drawing::XDrawSubController>(rValue, UNO_QUERY));
797 0 : else if (mxSubController.is())
798 0 : mxSubController->setFastPropertyValue(nHandle, rValue);
799 0 : }
800 :
801 0 : void DrawController::getFastPropertyValue (
802 : Any & rRet,
803 : sal_Int32 nHandle ) const
804 : {
805 0 : SolarMutexGuard aGuard;
806 :
807 0 : switch( nHandle )
808 : {
809 : case PROPERTY_WORKAREA:
810 0 : rRet <<= awt::Rectangle(
811 0 : maLastVisArea.Left(),
812 0 : maLastVisArea.Top(),
813 0 : maLastVisArea.GetWidth(),
814 0 : maLastVisArea.GetHeight());
815 0 : break;
816 :
817 : case PROPERTY_SUB_CONTROLLER:
818 0 : rRet <<= mxSubController;
819 0 : break;
820 :
821 : default:
822 0 : if (mxSubController.is())
823 0 : rRet = mxSubController->getFastPropertyValue(nHandle);
824 0 : break;
825 0 : }
826 0 : }
827 :
828 127 : void DrawController::ProvideFrameworkControllers()
829 : {
830 127 : SolarMutexGuard aGuard;
831 : try
832 : {
833 127 : Reference<XController> xController (this);
834 : const Reference<XComponentContext> xContext (
835 254 : ::comphelper::getProcessComponentContext() );
836 254 : mxConfigurationController = ConfigurationController::create(
837 : xContext,
838 127 : xController);
839 254 : mxModuleController = ModuleController::create(
840 : xContext,
841 254 : xController);
842 : }
843 0 : catch (const RuntimeException&)
844 : {
845 0 : mxConfigurationController = NULL;
846 0 : mxModuleController = NULL;
847 127 : }
848 127 : }
849 :
850 254 : void DrawController::DisposeFrameworkControllers()
851 : {
852 254 : Reference<XComponent> xComponent (mxModuleController, UNO_QUERY);
853 254 : if (xComponent.is())
854 254 : xComponent->dispose();
855 :
856 254 : xComponent = Reference<XComponent>(mxConfigurationController, UNO_QUERY);
857 254 : if (xComponent.is())
858 254 : xComponent->dispose();
859 254 : }
860 :
861 3171 : void DrawController::ThrowIfDisposed() const
862 : throw (::com::sun::star::lang::DisposedException)
863 : {
864 3171 : if (rBHelper.bDisposed || rBHelper.bInDispose || mbDisposing)
865 : {
866 : OSL_TRACE ("Calling disposed DrawController object. Throwing exception:");
867 : throw lang::DisposedException (
868 : "DrawController object has already been disposed",
869 10 : const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
870 : }
871 3161 : }
872 :
873 66 : } // end of namespace sd
874 :
875 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|