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 "PresenterPane.hxx" 32*cdf0e10cSrcweir #include "PresenterController.hxx" 33*cdf0e10cSrcweir #include "PresenterPaintManager.hxx" 34*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/drawing/CanvasFeature.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp> 38*cdf0e10cSrcweir #include <osl/mutex.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir using namespace ::com::sun::star; 41*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 42*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework; 43*cdf0e10cSrcweir using ::rtl::OUString; 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir namespace sdext { namespace presenter { 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir //===== PresenterPane ========================================================= 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir PresenterPane::PresenterPane ( 50*cdf0e10cSrcweir const Reference<XComponentContext>& rxContext, 51*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController) 52*cdf0e10cSrcweir : PresenterPaneBase(rxContext, rpPresenterController), 53*cdf0e10cSrcweir maBoundingBox() 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir Reference<lang::XMultiComponentFactory> xFactory ( 56*cdf0e10cSrcweir mxComponentContext->getServiceManager(), UNO_QUERY_THROW); 57*cdf0e10cSrcweir mxPresenterHelper = Reference<drawing::XPresenterHelper>( 58*cdf0e10cSrcweir xFactory->createInstanceWithContext( 59*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.comp.Draw.PresenterHelper"), 60*cdf0e10cSrcweir mxComponentContext), 61*cdf0e10cSrcweir UNO_QUERY_THROW); 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir PresenterPane::~PresenterPane (void) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir //----- XPane ----------------------------------------------------------------- 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir Reference<awt::XWindow> SAL_CALL PresenterPane::getWindow (void) 77*cdf0e10cSrcweir throw (RuntimeException) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir ThrowIfDisposed(); 80*cdf0e10cSrcweir return mxContentWindow; 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir Reference<rendering::XCanvas> SAL_CALL PresenterPane::getCanvas (void) 87*cdf0e10cSrcweir throw (RuntimeException) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir ThrowIfDisposed(); 90*cdf0e10cSrcweir return mxContentCanvas; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir //----- XWindowListener ------------------------------------------------------- 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir void SAL_CALL PresenterPane::windowResized (const awt::WindowEvent& rEvent) 99*cdf0e10cSrcweir throw (RuntimeException) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir (void)rEvent; 102*cdf0e10cSrcweir PresenterPaneBase::windowResized(rEvent); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir Invalidate(maBoundingBox); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir LayoutContextWindow(); 107*cdf0e10cSrcweir ToTop(); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir UpdateBoundingBox(); 110*cdf0e10cSrcweir Invalidate(maBoundingBox); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir void SAL_CALL PresenterPane::windowMoved (const awt::WindowEvent& rEvent) 118*cdf0e10cSrcweir throw (RuntimeException) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir (void)rEvent; 121*cdf0e10cSrcweir PresenterPaneBase::windowMoved(rEvent); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir Invalidate(maBoundingBox); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir ToTop(); 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir UpdateBoundingBox(); 128*cdf0e10cSrcweir Invalidate(maBoundingBox); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir void SAL_CALL PresenterPane::windowShown (const lang::EventObject& rEvent) 135*cdf0e10cSrcweir throw (RuntimeException) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir (void)rEvent; 138*cdf0e10cSrcweir PresenterPaneBase::windowShown(rEvent); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir ToTop(); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir if (mxContentWindow.is()) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir LayoutContextWindow(); 145*cdf0e10cSrcweir mxContentWindow->setVisible(sal_True); 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir UpdateBoundingBox(); 149*cdf0e10cSrcweir Invalidate(maBoundingBox); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir void SAL_CALL PresenterPane::windowHidden (const lang::EventObject& rEvent) 156*cdf0e10cSrcweir throw (RuntimeException) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir (void)rEvent; 159*cdf0e10cSrcweir PresenterPaneBase::windowHidden(rEvent); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir if (mxContentWindow.is()) 162*cdf0e10cSrcweir mxContentWindow->setVisible(sal_False); 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir //----- XPaintListener -------------------------------------------------------- 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir void SAL_CALL PresenterPane::windowPaint (const awt::PaintEvent& rEvent) 171*cdf0e10cSrcweir throw (RuntimeException) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir (void)rEvent; 174*cdf0e10cSrcweir ThrowIfDisposed(); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir PaintBorder(rEvent.UpdateRect); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir //----------------------------------------------------------------------------- 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir void PresenterPane::CreateCanvases ( 186*cdf0e10cSrcweir const Reference<awt::XWindow>& rxParentWindow, 187*cdf0e10cSrcweir const Reference<rendering::XSpriteCanvas>& rxParentCanvas) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir if ( ! mxPresenterHelper.is()) 190*cdf0e10cSrcweir return; 191*cdf0e10cSrcweir if ( ! rxParentWindow.is()) 192*cdf0e10cSrcweir return; 193*cdf0e10cSrcweir if ( ! rxParentCanvas.is()) 194*cdf0e10cSrcweir return; 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir mxBorderCanvas = mxPresenterHelper->createSharedCanvas( 197*cdf0e10cSrcweir rxParentCanvas, 198*cdf0e10cSrcweir rxParentWindow, 199*cdf0e10cSrcweir Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY), 200*cdf0e10cSrcweir rxParentWindow, 201*cdf0e10cSrcweir mxBorderWindow); 202*cdf0e10cSrcweir mxContentCanvas = mxPresenterHelper->createSharedCanvas( 203*cdf0e10cSrcweir rxParentCanvas, 204*cdf0e10cSrcweir rxParentWindow, 205*cdf0e10cSrcweir Reference<rendering::XCanvas>(rxParentCanvas, UNO_QUERY), 206*cdf0e10cSrcweir rxParentWindow, 207*cdf0e10cSrcweir mxContentWindow); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir PaintBorder(mxBorderWindow->getPosSize()); 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir void PresenterPane::Invalidate (const css::awt::Rectangle& rRepaintBox) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir // Invalidate the parent window to be able to invalidate an area outside 218*cdf0e10cSrcweir // the current window area. 219*cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate(mxParentWindow, rRepaintBox); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir void PresenterPane::UpdateBoundingBox (void) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir if (mxBorderWindow.is() && IsVisible()) 228*cdf0e10cSrcweir maBoundingBox = mxBorderWindow->getPosSize(); 229*cdf0e10cSrcweir else 230*cdf0e10cSrcweir maBoundingBox = awt::Rectangle(); 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir } } // end of namespace ::sd::presenter 235