1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sdext.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "PresenterScreen.hxx" 32*cdf0e10cSrcweir #include "PresenterConfigurationAccess.hxx" 33*cdf0e10cSrcweir #include "PresenterController.hxx" 34*cdf0e10cSrcweir #include "PresenterFrameworkObserver.hxx" 35*cdf0e10cSrcweir #include "PresenterHelper.hxx" 36*cdf0e10cSrcweir #include "PresenterPaneContainer.hxx" 37*cdf0e10cSrcweir #include "PresenterPaneFactory.hxx" 38*cdf0e10cSrcweir #include "PresenterViewFactory.hxx" 39*cdf0e10cSrcweir #include "PresenterWindowManager.hxx" 40*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/Configuration.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ResourceId.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/presentation/XSlideShow.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentation2.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentationSupplier.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/document/XEventBroadcaster.hpp> 50*cdf0e10cSrcweir #include <boost/bind.hpp> 51*cdf0e10cSrcweir #include <tools/debug.hxx> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp> 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir using namespace ::com::sun::star; 56*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 57*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 58*cdf0e10cSrcweir using namespace ::com::sun::star::presentation; 59*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework; 60*cdf0e10cSrcweir using ::rtl::OUString; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #define A2S(s) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))) 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir namespace sdext { namespace presenter { 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir namespace { 67*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1 < 68*cdf0e10cSrcweir css::document::XEventListener 69*cdf0e10cSrcweir > PresenterScreenListenerInterfaceBase; 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir /** One instance of a PresenterScreenListener is registered per Impress 72*cdf0e10cSrcweir document and waits for the full screen slide show to start and to 73*cdf0e10cSrcweir end. 74*cdf0e10cSrcweir */ 75*cdf0e10cSrcweir class PresenterScreenListener 76*cdf0e10cSrcweir : private ::boost::noncopyable, 77*cdf0e10cSrcweir private ::cppu::BaseMutex, 78*cdf0e10cSrcweir public PresenterScreenListenerInterfaceBase 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir public: 81*cdf0e10cSrcweir PresenterScreenListener ( 82*cdf0e10cSrcweir const css::uno::Reference<css::uno::XComponentContext>& rxContext, 83*cdf0e10cSrcweir const css::uno::Reference<css::frame::XModel2>& rxModel); 84*cdf0e10cSrcweir virtual ~PresenterScreenListener (void); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir void Initialize (void); 87*cdf0e10cSrcweir virtual void SAL_CALL disposing (void); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir // document::XEventListener 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) throw (css::uno::RuntimeException); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir // XEventListener 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir virtual void SAL_CALL disposing ( const css::lang::EventObject& rEvent) throw (css::uno::RuntimeException); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir private: 98*cdf0e10cSrcweir css::uno::Reference<css::frame::XModel2 > mxModel; 99*cdf0e10cSrcweir css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 100*cdf0e10cSrcweir rtl::Reference<PresenterScreen> mpPresenterScreen; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException); 103*cdf0e10cSrcweir }; 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir //----- Service --------------------------------------------------------------- 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir OUString PresenterScreenJob::getImplementationName_static (void) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir return A2S("com.sun.star.comp.Draw.framework.PresenterScreenJob"); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir Sequence<OUString> PresenterScreenJob::getSupportedServiceNames_static (void) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir static const ::rtl::OUString sServiceName( 120*cdf0e10cSrcweir A2S("com.sun.star.drawing.framework.PresenterScreenJob")); 121*cdf0e10cSrcweir return Sequence<rtl::OUString>(&sServiceName, 1); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir Reference<XInterface> PresenterScreenJob::Create (const Reference<uno::XComponentContext>& rxContext) 128*cdf0e10cSrcweir SAL_THROW((css::uno::Exception)) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir return Reference<XInterface>(static_cast<XWeak*>(new PresenterScreenJob(rxContext))); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir //===== PresenterScreenJob ==================================================== 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir PresenterScreenJob::PresenterScreenJob (const Reference<XComponentContext>& rxContext) 139*cdf0e10cSrcweir : PresenterScreenJobInterfaceBase(m_aMutex), 140*cdf0e10cSrcweir mxComponentContext(rxContext) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir PresenterScreenJob::~PresenterScreenJob (void) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir void SAL_CALL PresenterScreenJob::disposing (void) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir mxComponentContext = NULL; 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir //----- XJob ----------------------------------------------------------- 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir Any SAL_CALL PresenterScreenJob::execute( 165*cdf0e10cSrcweir const Sequence< beans::NamedValue >& Arguments ) 166*cdf0e10cSrcweir throw (lang::IllegalArgumentException, Exception, RuntimeException) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir Sequence< beans::NamedValue > lEnv; 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir sal_Int32 i = 0; 171*cdf0e10cSrcweir sal_Int32 c = Arguments.getLength(); 172*cdf0e10cSrcweir const beans::NamedValue* p = Arguments.getConstArray(); 173*cdf0e10cSrcweir for (i=0; i<c; ++i) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir if (p[i].Name.equalsAscii("Environment")) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir p[i].Value >>= lEnv; 178*cdf0e10cSrcweir break; 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir Reference<frame::XModel2> xModel; 183*cdf0e10cSrcweir c = lEnv.getLength(); 184*cdf0e10cSrcweir p = lEnv.getConstArray(); 185*cdf0e10cSrcweir for (i=0; i<c; ++i) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir if (p[i].Name.equalsAscii("Model")) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir p[i].Value >>= xModel; 190*cdf0e10cSrcweir break; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir Reference< XServiceInfo > xInfo( xModel, UNO_QUERY ); 195*cdf0e10cSrcweir if( xInfo.is() && xInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) ) ) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir // Create a new listener that waits for the full screen presentation 198*cdf0e10cSrcweir // to start and to end. It takes care of its own lifetime. 199*cdf0e10cSrcweir ::rtl::Reference<PresenterScreenListener> pListener ( 200*cdf0e10cSrcweir new PresenterScreenListener(mxComponentContext, xModel)); 201*cdf0e10cSrcweir pListener->Initialize(); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir return Any(); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir //===== PresenterScreenListener =============================================== 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir namespace { 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir PresenterScreenListener::PresenterScreenListener ( 215*cdf0e10cSrcweir const css::uno::Reference<css::uno::XComponentContext>& rxContext, 216*cdf0e10cSrcweir const css::uno::Reference<css::frame::XModel2>& rxModel) 217*cdf0e10cSrcweir : PresenterScreenListenerInterfaceBase(m_aMutex), 218*cdf0e10cSrcweir mxModel(rxModel), 219*cdf0e10cSrcweir mxComponentContext(rxContext), 220*cdf0e10cSrcweir mpPresenterScreen() 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir void PresenterScreenListener::Initialize (void) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir Reference< document::XEventListener > xDocListener( 230*cdf0e10cSrcweir static_cast< document::XEventListener* >(this), UNO_QUERY); 231*cdf0e10cSrcweir Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY ); 232*cdf0e10cSrcweir if( xDocBroadcaster.is() ) 233*cdf0e10cSrcweir xDocBroadcaster->addEventListener(xDocListener); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir PresenterScreenListener::~PresenterScreenListener (void) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir void SAL_CALL PresenterScreenListener::disposing (void) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir Reference< document::XEventBroadcaster > xDocBroadcaster( mxModel, UNO_QUERY ); 249*cdf0e10cSrcweir if( xDocBroadcaster.is() ) 250*cdf0e10cSrcweir xDocBroadcaster->removeEventListener( 251*cdf0e10cSrcweir Reference<document::XEventListener>( 252*cdf0e10cSrcweir static_cast<document::XEventListener*>(this), UNO_QUERY)); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir if (mpPresenterScreen.is()) 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir mpPresenterScreen->RequestShutdownPresenterScreen(); 257*cdf0e10cSrcweir mpPresenterScreen = NULL; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir // document::XEventListener 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir void SAL_CALL PresenterScreenListener::notifyEvent( const css::document::EventObject& Event ) throw (css::uno::RuntimeException) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir ThrowIfDisposed(); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir if( Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnStartPresentation" ) ) ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir mpPresenterScreen = new PresenterScreen(mxComponentContext, mxModel); 273*cdf0e10cSrcweir mpPresenterScreen->InitializePresenterScreen(); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir else if( Event.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnEndPresentation" ) ) ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir if (mpPresenterScreen.is()) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir mpPresenterScreen->RequestShutdownPresenterScreen(); 280*cdf0e10cSrcweir mpPresenterScreen = NULL; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir // XEventListener 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir void SAL_CALL PresenterScreenListener::disposing (const css::lang::EventObject& rEvent) 291*cdf0e10cSrcweir throw (css::uno::RuntimeException) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir (void)rEvent; 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir if (mpPresenterScreen.is()) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir mpPresenterScreen->RequestShutdownPresenterScreen(); 298*cdf0e10cSrcweir mpPresenterScreen = NULL; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir void PresenterScreenListener::ThrowIfDisposed (void) const throw ( 306*cdf0e10cSrcweir ::com::sun::star::lang::DisposedException) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir if (rBHelper.bDisposed || rBHelper.bInDispose) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir throw lang::DisposedException ( 311*cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM( 312*cdf0e10cSrcweir "PresenterScreenListener object has already been disposed")), 313*cdf0e10cSrcweir const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this))); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir } // end of anonymous namespace 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir //===== PresenterScreen ======================================================= 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir PresenterScreen::PresenterScreen ( 325*cdf0e10cSrcweir const Reference<XComponentContext>& rxContext, 326*cdf0e10cSrcweir const css::uno::Reference<css::frame::XModel2>& rxModel) 327*cdf0e10cSrcweir : PresenterScreenInterfaceBase(m_aMutex), 328*cdf0e10cSrcweir mxModel(rxModel), 329*cdf0e10cSrcweir mxController(), 330*cdf0e10cSrcweir mxConfigurationControllerWeak(), 331*cdf0e10cSrcweir mxContextWeak(rxContext), 332*cdf0e10cSrcweir mxSlideShowControllerWeak(), 333*cdf0e10cSrcweir mpPresenterController(), 334*cdf0e10cSrcweir mxSlideShowViewId(), 335*cdf0e10cSrcweir mxSavedConfiguration(), 336*cdf0e10cSrcweir mpPaneContainer(), 337*cdf0e10cSrcweir mnComponentIndex(0), 338*cdf0e10cSrcweir mxPaneFactory(), 339*cdf0e10cSrcweir mxViewFactory(), 340*cdf0e10cSrcweir maViewDescriptors() 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir PresenterScreen::~PresenterScreen (void) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir void SAL_CALL PresenterScreen::disposing (void) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir Reference<XConfigurationController> xCC (mxConfigurationControllerWeak); 357*cdf0e10cSrcweir if (xCC.is() && mxSavedConfiguration.is()) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir xCC->restoreConfiguration(mxSavedConfiguration); 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir mxConfigurationControllerWeak = Reference<XConfigurationController>(NULL); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY); 364*cdf0e10cSrcweir if (xViewFactoryComponent.is()) 365*cdf0e10cSrcweir xViewFactoryComponent->dispose(); 366*cdf0e10cSrcweir Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY); 367*cdf0e10cSrcweir if (xPaneFactoryComponent.is()) 368*cdf0e10cSrcweir xPaneFactoryComponent->dispose(); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir mxModel = NULL; 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir //----- XEventListener -------------------------------------------------------- 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir void SAL_CALL PresenterScreen::disposing (const lang::EventObject& /*rEvent*/) 379*cdf0e10cSrcweir throw (RuntimeException) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir mxSlideShowControllerWeak = WeakReference<presentation::XSlideShowController>(); 382*cdf0e10cSrcweir RequestShutdownPresenterScreen(); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir //----------------------------------------------------------------------------- 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir void PresenterScreen::InitializePresenterScreen (void) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir try 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir Reference<XComponentContext> xContext (mxContextWeak); 395*cdf0e10cSrcweir mpPaneContainer = 396*cdf0e10cSrcweir new PresenterPaneContainer(Reference<XComponentContext>(xContext)); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir Reference<XPresentationSupplier> xPS ( mxModel, UNO_QUERY_THROW); 399*cdf0e10cSrcweir Reference<XPresentation2> xPresentation(xPS->getPresentation(), UNO_QUERY_THROW); 400*cdf0e10cSrcweir Reference<presentation::XSlideShowController> xSlideShowController( xPresentation->getController() ); 401*cdf0e10cSrcweir mxSlideShowControllerWeak = xSlideShowController; 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir if( !xSlideShowController.is() || !xSlideShowController->isFullScreen() ) 404*cdf0e10cSrcweir return; 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir // find first controller that is not the current controller (the one with the slideshow 407*cdf0e10cSrcweir mxController = mxModel->getCurrentController(); 408*cdf0e10cSrcweir Reference< container::XEnumeration > xEnum( mxModel->getControllers() ); 409*cdf0e10cSrcweir if( xEnum.is() ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir while( xEnum->hasMoreElements() ) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir Reference< frame::XController > xC( xEnum->nextElement(), UNO_QUERY ); 414*cdf0e10cSrcweir if( xC.is() && (xC != mxController) ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir mxController = xC; 417*cdf0e10cSrcweir break; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir // Get the XController from the first argument. 422*cdf0e10cSrcweir Reference<XControllerManager> xCM(mxController, UNO_QUERY_THROW); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir Reference<XConfigurationController> xCC( xCM->getConfigurationController()); 425*cdf0e10cSrcweir mxConfigurationControllerWeak = xCC; 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir Reference<drawing::framework::XResourceId> xMainPaneId( 428*cdf0e10cSrcweir GetMainPaneId(xPresentation)); 429*cdf0e10cSrcweir // An empty reference means that the presenter screen can 430*cdf0e10cSrcweir // not or must not be displayed. 431*cdf0e10cSrcweir if ( ! xMainPaneId.is()) 432*cdf0e10cSrcweir return; 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir if (xCC.is() && xContext.is()) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir // Store the current configuration so that we can restore it when 437*cdf0e10cSrcweir // the presenter view is deactivated. 438*cdf0e10cSrcweir mxSavedConfiguration = xCC->getRequestedConfiguration(); 439*cdf0e10cSrcweir xCC->lock(); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir try 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir // At the moment the presenter controller is displayed in its 444*cdf0e10cSrcweir // own full screen window that is controlled by the same 445*cdf0e10cSrcweir // configuration controller as the Impress document from 446*cdf0e10cSrcweir // which the presentation was started. Therefore the main 447*cdf0e10cSrcweir // pane is actived additionally to the already existing 448*cdf0e10cSrcweir // panes and does not replace them. 449*cdf0e10cSrcweir xCC->requestResourceActivation( 450*cdf0e10cSrcweir xMainPaneId, 451*cdf0e10cSrcweir ResourceActivationMode_ADD); 452*cdf0e10cSrcweir SetupConfiguration(xContext, xMainPaneId); 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir mpPresenterController = new PresenterController( 455*cdf0e10cSrcweir xContext, 456*cdf0e10cSrcweir mxController, 457*cdf0e10cSrcweir xSlideShowController, 458*cdf0e10cSrcweir mpPaneContainer, 459*cdf0e10cSrcweir xMainPaneId); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir // Create pane and view factories and integrate them into the 462*cdf0e10cSrcweir // drawing framework. 463*cdf0e10cSrcweir SetupPaneFactory(xContext); 464*cdf0e10cSrcweir SetupViewFactory(xContext); 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir mpPresenterController->GetWindowManager()->RestoreViewMode(); 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir catch (RuntimeException&) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir xCC->restoreConfiguration(mxSavedConfiguration); 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir xCC->unlock(); 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir catch (Exception&) 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir sal_Int32 PresenterScreen::GetScreenNumber ( 484*cdf0e10cSrcweir const Reference<presentation::XPresentation2>& rxPresentation) const 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir // Determine the screen on which the full screen presentation is being 487*cdf0e10cSrcweir // displayed. 488*cdf0e10cSrcweir sal_Int32 nScreenNumber (0); 489*cdf0e10cSrcweir sal_Int32 nScreenCount (1); 490*cdf0e10cSrcweir try 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir Reference<beans::XPropertySet> xProperties (rxPresentation, UNO_QUERY); 493*cdf0e10cSrcweir if ( ! xProperties.is()) 494*cdf0e10cSrcweir return -1; 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir sal_Int32 nDisplayNumber (-1); 497*cdf0e10cSrcweir if ( ! (xProperties->getPropertyValue(A2S("Display")) >>= nDisplayNumber)) 498*cdf0e10cSrcweir return -1; 499*cdf0e10cSrcweir if (nDisplayNumber == -1) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir // The special value -1 indicates that the slide show 502*cdf0e10cSrcweir // spans all available displays. That leaves no room for 503*cdf0e10cSrcweir // the presenter screen. 504*cdf0e10cSrcweir return -1; 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir Reference<XComponentContext> xContext (mxContextWeak); 508*cdf0e10cSrcweir if ( ! xContext.is()) 509*cdf0e10cSrcweir return -1; 510*cdf0e10cSrcweir Reference<lang::XMultiComponentFactory> xFactory ( 511*cdf0e10cSrcweir xContext->getServiceManager(), UNO_QUERY); 512*cdf0e10cSrcweir if ( ! xFactory.is()) 513*cdf0e10cSrcweir return -1; 514*cdf0e10cSrcweir Reference<beans::XPropertySet> xDisplayProperties ( 515*cdf0e10cSrcweir xFactory->createInstanceWithContext(A2S("com.sun.star.awt.DisplayAccess"),xContext), 516*cdf0e10cSrcweir UNO_QUERY); 517*cdf0e10cSrcweir if ( ! xDisplayProperties.is()) 518*cdf0e10cSrcweir return -1; 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir if (nDisplayNumber > 0) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir nScreenNumber = nDisplayNumber - 1; 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir else if (nDisplayNumber == 0) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir // A display number value of 0 indicates the primary screen. 527*cdf0e10cSrcweir // Instantiate the DisplayAccess service to find out which 528*cdf0e10cSrcweir // screen number that is. 529*cdf0e10cSrcweir if (nDisplayNumber <= 0 && xDisplayProperties.is()) 530*cdf0e10cSrcweir xDisplayProperties->getPropertyValue(A2S("DefaultDisplay")) >>= nScreenNumber; 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir // We still have to determine the number of screens to decide 534*cdf0e10cSrcweir // whether the presenter screen may be shown at all. 535*cdf0e10cSrcweir Reference<container::XIndexAccess> xIndexAccess (xDisplayProperties, UNO_QUERY); 536*cdf0e10cSrcweir if ( ! xIndexAccess.is()) 537*cdf0e10cSrcweir return -1; 538*cdf0e10cSrcweir nScreenCount = xIndexAccess->getCount(); 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir if (nScreenCount < 2 || nDisplayNumber > nScreenCount) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir // There is either only one screen or the full screen 543*cdf0e10cSrcweir // presentation spans all available screens. The presenter 544*cdf0e10cSrcweir // screen is shown only when a special flag in the configuration 545*cdf0e10cSrcweir // is set. 546*cdf0e10cSrcweir PresenterConfigurationAccess aConfiguration ( 547*cdf0e10cSrcweir xContext, 548*cdf0e10cSrcweir OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"), 549*cdf0e10cSrcweir PresenterConfigurationAccess::READ_ONLY); 550*cdf0e10cSrcweir bool bStartAlways (false); 551*cdf0e10cSrcweir if (aConfiguration.GetConfigurationNode( 552*cdf0e10cSrcweir OUString::createFromAscii("Presenter/StartAlways")) >>= bStartAlways) 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir if (bStartAlways) 555*cdf0e10cSrcweir return nScreenNumber; 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir return -1; 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir catch (beans::UnknownPropertyException&) 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir OSL_ASSERT(false); 563*cdf0e10cSrcweir // For some reason we can not access the screen number. Use 564*cdf0e10cSrcweir // the default instead. 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir return nScreenNumber; 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir Reference<drawing::framework::XResourceId> PresenterScreen::GetMainPaneId ( 574*cdf0e10cSrcweir const Reference<presentation::XPresentation2>& rxPresentation) const 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir // A negative value means that the presentation spans all available 577*cdf0e10cSrcweir // displays. That leaves no room for the presenter. 578*cdf0e10cSrcweir const sal_Int32 nScreenNumber(GetScreenNumber(rxPresentation)); 579*cdf0e10cSrcweir if (nScreenNumber < 0) 580*cdf0e10cSrcweir return NULL; 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir // Setup the resource id of the full screen background pane so that 583*cdf0e10cSrcweir // it is displayed on another screen than the presentation. 584*cdf0e10cSrcweir sal_Int32 nPresenterScreenNumber (1); 585*cdf0e10cSrcweir switch (nScreenNumber) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir case 0: 588*cdf0e10cSrcweir nPresenterScreenNumber = 1; 589*cdf0e10cSrcweir break; 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir case 1: 592*cdf0e10cSrcweir nPresenterScreenNumber = 0; 593*cdf0e10cSrcweir break; 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir default: 596*cdf0e10cSrcweir // When the full screen presentation is displayed on a screen 597*cdf0e10cSrcweir // other than 0 or 1 then place the presenter on the first 598*cdf0e10cSrcweir // available screen. 599*cdf0e10cSrcweir nPresenterScreenNumber = 0; 600*cdf0e10cSrcweir break; 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir return ResourceId::create( 604*cdf0e10cSrcweir Reference<XComponentContext>(mxContextWeak), 605*cdf0e10cSrcweir PresenterHelper::msFullScreenPaneURL 606*cdf0e10cSrcweir +A2S("?FullScreen=true&ScreenNumber=") 607*cdf0e10cSrcweir + OUString::valueOf(nPresenterScreenNumber)); 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir void PresenterScreen::RequestShutdownPresenterScreen (void) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir // Restore the configuration that was active before the presenter screen 616*cdf0e10cSrcweir // has been activated. Now, that the presenter screen is displayed in 617*cdf0e10cSrcweir // its own top level window this probably not necessary, but one never knows. 618*cdf0e10cSrcweir Reference<XConfigurationController> xCC (mxConfigurationControllerWeak); 619*cdf0e10cSrcweir if (xCC.is() && mxSavedConfiguration.is()) 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir xCC->restoreConfiguration(mxSavedConfiguration); 622*cdf0e10cSrcweir mxSavedConfiguration = NULL; 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir if (xCC.is()) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir // The actual restoration of the configuration takes place 628*cdf0e10cSrcweir // asynchronously. The view and pane factories can only by disposed 629*cdf0e10cSrcweir // after that. Therefore, set up a listener and wait for the 630*cdf0e10cSrcweir // restoration. 631*cdf0e10cSrcweir rtl::Reference<PresenterScreen> pSelf (this); 632*cdf0e10cSrcweir PresenterFrameworkObserver::RunOnUpdateEnd( 633*cdf0e10cSrcweir xCC, 634*cdf0e10cSrcweir ::boost::bind(&PresenterScreen::ShutdownPresenterScreen, pSelf)); 635*cdf0e10cSrcweir xCC->update(); 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir void PresenterScreen::ShutdownPresenterScreen (void) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir Reference<lang::XComponent> xViewFactoryComponent (mxViewFactory, UNO_QUERY); 645*cdf0e10cSrcweir if (xViewFactoryComponent.is()) 646*cdf0e10cSrcweir xViewFactoryComponent->dispose(); 647*cdf0e10cSrcweir mxViewFactory = NULL; 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir Reference<lang::XComponent> xPaneFactoryComponent (mxPaneFactory, UNO_QUERY); 650*cdf0e10cSrcweir if (xPaneFactoryComponent.is()) 651*cdf0e10cSrcweir xPaneFactoryComponent->dispose(); 652*cdf0e10cSrcweir mxPaneFactory = NULL; 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir if (mpPresenterController.get() != NULL) 655*cdf0e10cSrcweir { 656*cdf0e10cSrcweir mpPresenterController->dispose(); 657*cdf0e10cSrcweir mpPresenterController = rtl::Reference<PresenterController>(); 658*cdf0e10cSrcweir } 659*cdf0e10cSrcweir mpPaneContainer = new PresenterPaneContainer(Reference<XComponentContext>(mxContextWeak)); 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir void PresenterScreen::SetupPaneFactory (const Reference<XComponentContext>& rxContext) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir try 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir if ( ! mxPaneFactory.is()) 670*cdf0e10cSrcweir mxPaneFactory = PresenterPaneFactory::Create( 671*cdf0e10cSrcweir rxContext, 672*cdf0e10cSrcweir mxController, 673*cdf0e10cSrcweir mpPresenterController); 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir catch (RuntimeException&) 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir OSL_ASSERT(false); 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir void PresenterScreen::SetupViewFactory (const Reference<XComponentContext>& rxContext) 685*cdf0e10cSrcweir { 686*cdf0e10cSrcweir try 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir if ( ! mxViewFactory.is()) 689*cdf0e10cSrcweir mxViewFactory = PresenterViewFactory::Create( 690*cdf0e10cSrcweir rxContext, 691*cdf0e10cSrcweir mxController, 692*cdf0e10cSrcweir mpPresenterController); 693*cdf0e10cSrcweir } 694*cdf0e10cSrcweir catch (RuntimeException&) 695*cdf0e10cSrcweir { 696*cdf0e10cSrcweir OSL_ASSERT(false); 697*cdf0e10cSrcweir } 698*cdf0e10cSrcweir } 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir void PresenterScreen::SetupConfiguration ( 704*cdf0e10cSrcweir const Reference<XComponentContext>& rxContext, 705*cdf0e10cSrcweir const Reference<XResourceId>& rxAnchorId) 706*cdf0e10cSrcweir { 707*cdf0e10cSrcweir try 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir PresenterConfigurationAccess aConfiguration ( 710*cdf0e10cSrcweir rxContext, 711*cdf0e10cSrcweir OUString::createFromAscii("org.openoffice.Office.extension.PresenterScreen"), 712*cdf0e10cSrcweir PresenterConfigurationAccess::READ_ONLY); 713*cdf0e10cSrcweir maViewDescriptors.clear(); 714*cdf0e10cSrcweir ProcessViewDescriptions(aConfiguration); 715*cdf0e10cSrcweir OUString sLayoutName (OUString::createFromAscii("DefaultLayout")); 716*cdf0e10cSrcweir aConfiguration.GetConfigurationNode( 717*cdf0e10cSrcweir OUString::createFromAscii("Presenter/CurrentLayout")) >>= sLayoutName; 718*cdf0e10cSrcweir ProcessLayout(aConfiguration, sLayoutName, rxContext, rxAnchorId); 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir catch (RuntimeException&) 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir } 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir void PresenterScreen::ProcessLayout ( 729*cdf0e10cSrcweir PresenterConfigurationAccess& rConfiguration, 730*cdf0e10cSrcweir const OUString& rsLayoutName, 731*cdf0e10cSrcweir const Reference<XComponentContext>& rxContext, 732*cdf0e10cSrcweir const Reference<XResourceId>& rxAnchorId) 733*cdf0e10cSrcweir { 734*cdf0e10cSrcweir try 735*cdf0e10cSrcweir { 736*cdf0e10cSrcweir Reference<container::XHierarchicalNameAccess> xLayoutNode ( 737*cdf0e10cSrcweir rConfiguration.GetConfigurationNode( 738*cdf0e10cSrcweir OUString::createFromAscii("Presenter/Layouts/")+rsLayoutName), 739*cdf0e10cSrcweir UNO_QUERY_THROW); 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir // Read the parent layout first, if one is referenced. 742*cdf0e10cSrcweir OUString sParentLayout; 743*cdf0e10cSrcweir rConfiguration.GetConfigurationNode( 744*cdf0e10cSrcweir xLayoutNode, 745*cdf0e10cSrcweir OUString::createFromAscii("ParentLayout")) >>= sParentLayout; 746*cdf0e10cSrcweir if (sParentLayout.getLength() > 0) 747*cdf0e10cSrcweir { 748*cdf0e10cSrcweir // Prevent infinite recursion. 749*cdf0e10cSrcweir if (rsLayoutName != sParentLayout) 750*cdf0e10cSrcweir ProcessLayout(rConfiguration, sParentLayout, rxContext, rxAnchorId); 751*cdf0e10cSrcweir } 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir // Process the actual layout list. 754*cdf0e10cSrcweir Reference<container::XNameAccess> xList ( 755*cdf0e10cSrcweir rConfiguration.GetConfigurationNode( 756*cdf0e10cSrcweir xLayoutNode, 757*cdf0e10cSrcweir OUString::createFromAscii("Layout")), 758*cdf0e10cSrcweir UNO_QUERY_THROW); 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir ::std::vector<rtl::OUString> aProperties (6); 761*cdf0e10cSrcweir aProperties[0] = OUString::createFromAscii("PaneURL"); 762*cdf0e10cSrcweir aProperties[1] = OUString::createFromAscii("ViewURL"); 763*cdf0e10cSrcweir aProperties[2] = OUString::createFromAscii("RelativeX"); 764*cdf0e10cSrcweir aProperties[3] = OUString::createFromAscii("RelativeY"); 765*cdf0e10cSrcweir aProperties[4] = OUString::createFromAscii("RelativeWidth"); 766*cdf0e10cSrcweir aProperties[5] = OUString::createFromAscii("RelativeHeight"); 767*cdf0e10cSrcweir mnComponentIndex = 1; 768*cdf0e10cSrcweir PresenterConfigurationAccess::ForAll( 769*cdf0e10cSrcweir xList, 770*cdf0e10cSrcweir aProperties, 771*cdf0e10cSrcweir ::boost::bind(&PresenterScreen::ProcessComponent, this, 772*cdf0e10cSrcweir _1, 773*cdf0e10cSrcweir _2, 774*cdf0e10cSrcweir rxContext, 775*cdf0e10cSrcweir rxAnchorId)); 776*cdf0e10cSrcweir } 777*cdf0e10cSrcweir catch (RuntimeException&) 778*cdf0e10cSrcweir { 779*cdf0e10cSrcweir } 780*cdf0e10cSrcweir } 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir void PresenterScreen::ProcessViewDescriptions ( 786*cdf0e10cSrcweir PresenterConfigurationAccess& rConfiguration) 787*cdf0e10cSrcweir { 788*cdf0e10cSrcweir try 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir Reference<container::XNameAccess> xViewDescriptionsNode ( 791*cdf0e10cSrcweir rConfiguration.GetConfigurationNode(A2S("Presenter/Views")), 792*cdf0e10cSrcweir UNO_QUERY_THROW); 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir ::std::vector<rtl::OUString> aProperties (4); 795*cdf0e10cSrcweir aProperties[0] = OUString::createFromAscii("ViewURL"); 796*cdf0e10cSrcweir aProperties[1] = OUString::createFromAscii("Title"); 797*cdf0e10cSrcweir aProperties[2] = OUString::createFromAscii("AccessibleTitle"); 798*cdf0e10cSrcweir aProperties[3] = OUString::createFromAscii("IsOpaque"); 799*cdf0e10cSrcweir mnComponentIndex = 1; 800*cdf0e10cSrcweir PresenterConfigurationAccess::ForAll( 801*cdf0e10cSrcweir xViewDescriptionsNode, 802*cdf0e10cSrcweir aProperties, 803*cdf0e10cSrcweir ::boost::bind(&PresenterScreen::ProcessViewDescription, this, _1, _2)); 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir catch (RuntimeException&) 806*cdf0e10cSrcweir { 807*cdf0e10cSrcweir OSL_ASSERT(false); 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir } 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir void PresenterScreen::ProcessComponent ( 815*cdf0e10cSrcweir const OUString& rsKey, 816*cdf0e10cSrcweir const ::std::vector<Any>& rValues, 817*cdf0e10cSrcweir const Reference<XComponentContext>& rxContext, 818*cdf0e10cSrcweir const Reference<XResourceId>& rxAnchorId) 819*cdf0e10cSrcweir { 820*cdf0e10cSrcweir (void)rsKey; 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir if (rValues.size() != 6) 823*cdf0e10cSrcweir return; 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir try 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir OUString sPaneURL; 828*cdf0e10cSrcweir OUString sViewURL; 829*cdf0e10cSrcweir double nX = 0; 830*cdf0e10cSrcweir double nY = 0; 831*cdf0e10cSrcweir double nWidth = 0; 832*cdf0e10cSrcweir double nHeight = 0; 833*cdf0e10cSrcweir rValues[0] >>= sPaneURL; 834*cdf0e10cSrcweir rValues[1] >>= sViewURL; 835*cdf0e10cSrcweir rValues[2] >>= nX; 836*cdf0e10cSrcweir rValues[3] >>= nY; 837*cdf0e10cSrcweir rValues[4] >>= nWidth; 838*cdf0e10cSrcweir rValues[5] >>= nHeight; 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir if (nX>=0 && nY>=0 && nWidth>0 && nHeight>0) 841*cdf0e10cSrcweir { 842*cdf0e10cSrcweir SetupView( 843*cdf0e10cSrcweir rxContext, 844*cdf0e10cSrcweir rxAnchorId, 845*cdf0e10cSrcweir sPaneURL, 846*cdf0e10cSrcweir sViewURL, 847*cdf0e10cSrcweir PresenterPaneContainer::ViewInitializationFunction(), 848*cdf0e10cSrcweir nX, 849*cdf0e10cSrcweir nY, 850*cdf0e10cSrcweir nX+nWidth, 851*cdf0e10cSrcweir nY+nHeight); 852*cdf0e10cSrcweir } 853*cdf0e10cSrcweir } 854*cdf0e10cSrcweir catch (Exception& e) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir (void)e; 857*cdf0e10cSrcweir OSL_ASSERT(false); 858*cdf0e10cSrcweir } 859*cdf0e10cSrcweir } 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir void PresenterScreen::ProcessViewDescription ( 865*cdf0e10cSrcweir const OUString& rsKey, 866*cdf0e10cSrcweir const ::std::vector<Any>& rValues) 867*cdf0e10cSrcweir { 868*cdf0e10cSrcweir (void)rsKey; 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir if (rValues.size() != 4) 871*cdf0e10cSrcweir return; 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir try 874*cdf0e10cSrcweir { 875*cdf0e10cSrcweir ViewDescriptor aViewDescriptor; 876*cdf0e10cSrcweir OUString sViewURL; 877*cdf0e10cSrcweir rValues[0] >>= sViewURL; 878*cdf0e10cSrcweir rValues[1] >>= aViewDescriptor.msTitle; 879*cdf0e10cSrcweir rValues[2] >>= aViewDescriptor.msAccessibleTitle; 880*cdf0e10cSrcweir rValues[3] >>= aViewDescriptor.mbIsOpaque; 881*cdf0e10cSrcweir if (aViewDescriptor.msAccessibleTitle.getLength()==0) 882*cdf0e10cSrcweir aViewDescriptor.msAccessibleTitle = aViewDescriptor.msTitle; 883*cdf0e10cSrcweir maViewDescriptors[sViewURL] = aViewDescriptor; 884*cdf0e10cSrcweir } 885*cdf0e10cSrcweir catch (Exception&) 886*cdf0e10cSrcweir { 887*cdf0e10cSrcweir OSL_ASSERT(false); 888*cdf0e10cSrcweir } 889*cdf0e10cSrcweir } 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir void PresenterScreen::SetupView( 895*cdf0e10cSrcweir const Reference<XComponentContext>& rxContext, 896*cdf0e10cSrcweir const Reference<XResourceId>& rxAnchorId, 897*cdf0e10cSrcweir const OUString& rsPaneURL, 898*cdf0e10cSrcweir const OUString& rsViewURL, 899*cdf0e10cSrcweir const PresenterPaneContainer::ViewInitializationFunction& rViewInitialization, 900*cdf0e10cSrcweir const double nLeft, 901*cdf0e10cSrcweir const double nTop, 902*cdf0e10cSrcweir const double nRight, 903*cdf0e10cSrcweir const double nBottom) 904*cdf0e10cSrcweir { 905*cdf0e10cSrcweir Reference<XConfigurationController> xCC (mxConfigurationControllerWeak); 906*cdf0e10cSrcweir if (xCC.is()) 907*cdf0e10cSrcweir { 908*cdf0e10cSrcweir Reference<XResourceId> xPaneId (ResourceId::createWithAnchor(rxContext,rsPaneURL,rxAnchorId)); 909*cdf0e10cSrcweir // Look up the view descriptor. 910*cdf0e10cSrcweir ViewDescriptor aViewDescriptor; 911*cdf0e10cSrcweir ViewDescriptorContainer::const_iterator iDescriptor (maViewDescriptors.find(rsViewURL)); 912*cdf0e10cSrcweir if (iDescriptor != maViewDescriptors.end()) 913*cdf0e10cSrcweir aViewDescriptor = iDescriptor->second; 914*cdf0e10cSrcweir 915*cdf0e10cSrcweir // Prepare the pane. 916*cdf0e10cSrcweir OSL_ASSERT(mpPaneContainer.get() != NULL); 917*cdf0e10cSrcweir mpPaneContainer->PreparePane( 918*cdf0e10cSrcweir xPaneId, 919*cdf0e10cSrcweir rsViewURL, 920*cdf0e10cSrcweir aViewDescriptor.msTitle, 921*cdf0e10cSrcweir aViewDescriptor.msAccessibleTitle, 922*cdf0e10cSrcweir aViewDescriptor.mbIsOpaque, 923*cdf0e10cSrcweir rViewInitialization, 924*cdf0e10cSrcweir nLeft, 925*cdf0e10cSrcweir nTop, 926*cdf0e10cSrcweir nRight, 927*cdf0e10cSrcweir nBottom); 928*cdf0e10cSrcweir } 929*cdf0e10cSrcweir } 930*cdf0e10cSrcweir 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir } } // end of namespace ::sdext::presenter 935