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 // The body of this file is only used when PresenterWindowManager defines 32*cdf0e10cSrcweir // the preprocessor symbol ENABLE_PANE_RESIZING, which by default is not the 33*cdf0e10cSrcweir // case. 34*cdf0e10cSrcweir #ifdef ENABLE_PANE_RESIZING 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include "PresenterPaneBorderManager.hxx" 37*cdf0e10cSrcweir #include "PresenterController.hxx" 38*cdf0e10cSrcweir #include "PresenterPaintManager.hxx" 39*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/awt/SystemPointer.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/awt/WindowDescriptor.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/awt/WindowClass.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow2.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp> 47*cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx> 48*cdf0e10cSrcweir #include <osl/mutex.hxx> 49*cdf0e10cSrcweir #include <boost/weak_ptr.hpp> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir using namespace ::com::sun::star; 52*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 53*cdf0e10cSrcweir using ::rtl::OUString; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir namespace sdext { namespace presenter { 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir //===== Service =============================================================== 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir OUString PresenterPaneBorderManager::getImplementationName_static (void) 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir return OUString::createFromAscii("com.sun.star.comp.Draw.PresenterPaneBorderManager"); 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir Sequence<OUString> PresenterPaneBorderManager::getSupportedServiceNames_static (void) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir static const ::rtl::OUString sServiceName( 71*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("com.sun.star.drawing.PresenterPaneBorderManager")); 72*cdf0e10cSrcweir return Sequence<rtl::OUString>(&sServiceName, 1); 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir Reference<XInterface> PresenterPaneBorderManager::Create (const Reference<uno::XComponentContext>& rxContext) 79*cdf0e10cSrcweir SAL_THROW((css::uno::Exception)) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir return Reference<XInterface>(static_cast<XWeak*>( 82*cdf0e10cSrcweir new PresenterPaneBorderManager(rxContext, NULL))); 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir //===== PresenterPaneBorderManager ============================================ 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir PresenterPaneBorderManager::PresenterPaneBorderManager ( 91*cdf0e10cSrcweir const Reference<XComponentContext>& rxContext, 92*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController) 93*cdf0e10cSrcweir : PresenterPaneBorderManagerInterfaceBase(m_aMutex), 94*cdf0e10cSrcweir mpPresenterController(rpPresenterController), 95*cdf0e10cSrcweir mxComponentContext(rxContext), 96*cdf0e10cSrcweir mxPresenterHelper(), 97*cdf0e10cSrcweir maWindowList(), 98*cdf0e10cSrcweir mnPointerType(), 99*cdf0e10cSrcweir maDragAnchor(), 100*cdf0e10cSrcweir meDragType(Outside), 101*cdf0e10cSrcweir mxOuterDragWindow(), 102*cdf0e10cSrcweir mxInnerDragWindow(), 103*cdf0e10cSrcweir mxPointer() 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir Reference<lang::XMultiComponentFactory> xFactory (rxContext->getServiceManager()); 106*cdf0e10cSrcweir if (xFactory.is()) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir mxPointer = Reference<awt::XPointer>( 109*cdf0e10cSrcweir xFactory->createInstanceWithContext( 110*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.awt.Pointer"), 111*cdf0e10cSrcweir rxContext), 112*cdf0e10cSrcweir UNO_QUERY_THROW); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir mxPresenterHelper = Reference<drawing::XPresenterHelper>( 115*cdf0e10cSrcweir xFactory->createInstanceWithContext( 116*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.comp.Draw.PresenterHelper"), 117*cdf0e10cSrcweir rxContext), 118*cdf0e10cSrcweir UNO_QUERY_THROW); 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir PresenterPaneBorderManager::~PresenterPaneBorderManager (void) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir void PresenterPaneBorderManager::disposing (void) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir WindowList::const_iterator iDescriptor; 135*cdf0e10cSrcweir for (iDescriptor=maWindowList.begin(); iDescriptor!=maWindowList.end(); ++iDescriptor) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir iDescriptor->first->removeMouseListener(this); 138*cdf0e10cSrcweir iDescriptor->first->removeMouseMotionListener(this); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir maWindowList.clear(); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir namespace { 147*cdf0e10cSrcweir const static sal_Int32 mnOutside = 0; 148*cdf0e10cSrcweir const static sal_Int32 mnLeft = 0x01; 149*cdf0e10cSrcweir const static sal_Int32 mnHorizontalCenter = 0x02; 150*cdf0e10cSrcweir const static sal_Int32 mnRight = 0x04; 151*cdf0e10cSrcweir const static sal_Int32 mnTop = 0x10; 152*cdf0e10cSrcweir const static sal_Int32 mnVerticalCenter = 0x20; 153*cdf0e10cSrcweir const static sal_Int32 mnBottom = 0x40; 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir PresenterPaneBorderManager::BorderElement 157*cdf0e10cSrcweir PresenterPaneBorderManager::ClassifyBorderElementUnderMouse ( 158*cdf0e10cSrcweir const Reference<awt::XWindow>& rxOuterWindow, 159*cdf0e10cSrcweir const Reference<awt::XWindow>& rxInnerWindow, 160*cdf0e10cSrcweir const awt::Point aPosition) const 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir OSL_ASSERT(rxOuterWindow.is()); 163*cdf0e10cSrcweir OSL_ASSERT(rxInnerWindow.is()); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir awt::Rectangle aOuterBox (rxOuterWindow->getPosSize()); 166*cdf0e10cSrcweir const awt::Rectangle aInnerBox (rxInnerWindow->getPosSize()); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir // Coordinates of the pointer position are given in the window 169*cdf0e10cSrcweir // coordinate system. Therefore the upper left corner of the outer box 170*cdf0e10cSrcweir // is the origin. 171*cdf0e10cSrcweir aOuterBox.X = 0; 172*cdf0e10cSrcweir aOuterBox.Y = 0; 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir sal_Int32 nCode = 0; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir // Add horizontal classification to nCode. 177*cdf0e10cSrcweir if (aPosition.X < aInnerBox.X) 178*cdf0e10cSrcweir if (aPosition.X < aOuterBox.X) 179*cdf0e10cSrcweir nCode = mnOutside; 180*cdf0e10cSrcweir else 181*cdf0e10cSrcweir nCode = mnLeft; 182*cdf0e10cSrcweir else if (aPosition.X >= aInnerBox.X+aInnerBox.Width) 183*cdf0e10cSrcweir if (aPosition.X >= aOuterBox.X+aOuterBox.Width) 184*cdf0e10cSrcweir nCode = mnOutside; 185*cdf0e10cSrcweir else 186*cdf0e10cSrcweir nCode = mnRight; 187*cdf0e10cSrcweir else 188*cdf0e10cSrcweir nCode = mnHorizontalCenter; 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir // Add vertical classification to nCode. 191*cdf0e10cSrcweir if (aPosition.Y < aInnerBox.Y) 192*cdf0e10cSrcweir if (aPosition.Y < aOuterBox.Y) 193*cdf0e10cSrcweir nCode |= mnOutside; 194*cdf0e10cSrcweir else 195*cdf0e10cSrcweir nCode |= mnTop; 196*cdf0e10cSrcweir else if (aPosition.Y >= aInnerBox.Y+aInnerBox.Height) 197*cdf0e10cSrcweir if (aPosition.Y >= aOuterBox.Y+aOuterBox.Height) 198*cdf0e10cSrcweir nCode |= mnOutside; 199*cdf0e10cSrcweir else 200*cdf0e10cSrcweir nCode |= mnBottom; 201*cdf0e10cSrcweir else 202*cdf0e10cSrcweir nCode |= mnVerticalCenter; 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir // Translate bits in nCode into BorderElement value. 205*cdf0e10cSrcweir switch (nCode) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir case mnOutside | mnOutside: 208*cdf0e10cSrcweir case mnOutside | mnLeft: 209*cdf0e10cSrcweir case mnOutside | mnRight: 210*cdf0e10cSrcweir case mnOutside | mnHorizontalCenter: 211*cdf0e10cSrcweir case mnTop | mnOutside: 212*cdf0e10cSrcweir case mnBottom | mnOutside: 213*cdf0e10cSrcweir case mnVerticalCenter | mnOutside: 214*cdf0e10cSrcweir default: 215*cdf0e10cSrcweir return Outside; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir case mnVerticalCenter | mnHorizontalCenter: 218*cdf0e10cSrcweir return Content; 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir case mnTop | mnLeft: 221*cdf0e10cSrcweir return TopLeft; 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir case mnTop | mnRight: 224*cdf0e10cSrcweir return TopRight; 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir case mnTop | mnHorizontalCenter: 227*cdf0e10cSrcweir return Top; 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir case mnBottom | mnLeft: 230*cdf0e10cSrcweir return BottomLeft; 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir case mnBottom | mnRight: 233*cdf0e10cSrcweir return BottomRight; 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir case mnBottom | mnHorizontalCenter: 236*cdf0e10cSrcweir return Bottom; 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir case mnVerticalCenter | mnLeft: 239*cdf0e10cSrcweir return Left; 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir case mnVerticalCenter | mnRight: 242*cdf0e10cSrcweir return Right; 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir //----- XInitialization ------------------------------------------------------- 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir void SAL_CALL PresenterPaneBorderManager::initialize (const Sequence<Any>& rArguments) 252*cdf0e10cSrcweir throw (Exception, RuntimeException) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir ThrowIfDisposed(); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir if (rArguments.getLength()%2 == 1 && mxComponentContext.is()) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir try 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir mxParentWindow = Reference<awt::XWindow>(rArguments[0], UNO_QUERY_THROW); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir // Get the outer and inner windows from the argument list and 263*cdf0e10cSrcweir // build a window list of it. 264*cdf0e10cSrcweir for (sal_Int32 nIndex=1; nIndex<rArguments.getLength(); nIndex+=2) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir Reference<awt::XWindow> xOuterWindow (rArguments[nIndex], UNO_QUERY_THROW); 267*cdf0e10cSrcweir Reference<awt::XWindow> xInnerWindow (rArguments[nIndex+1], UNO_QUERY_THROW); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir maWindowList.push_back(WindowDescriptor(xOuterWindow,xInnerWindow)); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir xOuterWindow->addMouseListener(this); 272*cdf0e10cSrcweir xOuterWindow->addMouseMotionListener(this); 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir catch (RuntimeException&) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir PresenterPaneBorderManager::disposing(); 278*cdf0e10cSrcweir throw; 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir else 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir throw RuntimeException( 284*cdf0e10cSrcweir OUString::createFromAscii("PresenterPane: invalid number of arguments"), 285*cdf0e10cSrcweir static_cast<XWeak*>(this)); 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir //----- XMouseListener -------------------------------------------------------- 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir void SAL_CALL PresenterPaneBorderManager::mousePressed (const css::awt::MouseEvent& rEvent) 295*cdf0e10cSrcweir throw (css::uno::RuntimeException) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir ThrowIfDisposed(); 298*cdf0e10cSrcweir ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir // Find window descriptor of the window that has been clicked. 301*cdf0e10cSrcweir WindowList::const_iterator iDescriptor; 302*cdf0e10cSrcweir for (iDescriptor=maWindowList.begin(); iDescriptor!=maWindowList.end(); ++iDescriptor) 303*cdf0e10cSrcweir if (iDescriptor->first == rEvent.Source) 304*cdf0e10cSrcweir break; 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir if (iDescriptor != maWindowList.end()) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir // Prepare dragging. 309*cdf0e10cSrcweir mxOuterDragWindow = iDescriptor->first; 310*cdf0e10cSrcweir mxInnerDragWindow = iDescriptor->second; 311*cdf0e10cSrcweir OSL_ASSERT(mxOuterDragWindow.is() && mxInnerDragWindow.is()); 312*cdf0e10cSrcweir const awt::Rectangle aOuterBox (mxOuterDragWindow->getPosSize()); 313*cdf0e10cSrcweir maDragAnchor.X = rEvent.X + aOuterBox.X; 314*cdf0e10cSrcweir maDragAnchor.Y = rEvent.Y + aOuterBox.Y; 315*cdf0e10cSrcweir meDragType = ClassifyBorderElementUnderMouse( 316*cdf0e10cSrcweir mxOuterDragWindow, 317*cdf0e10cSrcweir mxInnerDragWindow, 318*cdf0e10cSrcweir awt::Point(rEvent.X, rEvent.Y)); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir void SAL_CALL PresenterPaneBorderManager::mouseReleased (const css::awt::MouseEvent& rEvent) 326*cdf0e10cSrcweir throw (css::uno::RuntimeException) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir (void)rEvent; 329*cdf0e10cSrcweir ThrowIfDisposed(); 330*cdf0e10cSrcweir ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir ReleaseMouse(mxOuterDragWindow); 333*cdf0e10cSrcweir meDragType = PresenterPaneBorderManager::Outside; 334*cdf0e10cSrcweir mxOuterDragWindow = NULL; 335*cdf0e10cSrcweir mxInnerDragWindow = NULL; 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir void SAL_CALL PresenterPaneBorderManager::mouseEntered (const css::awt::MouseEvent& rEvent) 342*cdf0e10cSrcweir throw (css::uno::RuntimeException) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir (void)rEvent; 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir void SAL_CALL PresenterPaneBorderManager::mouseExited (const css::awt::MouseEvent& rEvent) 351*cdf0e10cSrcweir throw (css::uno::RuntimeException) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir (void)rEvent; 354*cdf0e10cSrcweir ThrowIfDisposed(); 355*cdf0e10cSrcweir ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir ReleaseMouse(mxOuterDragWindow); 358*cdf0e10cSrcweir meDragType = PresenterPaneBorderManager::Outside; 359*cdf0e10cSrcweir mxOuterDragWindow = NULL; 360*cdf0e10cSrcweir mxInnerDragWindow = NULL; 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir //----- XMouseMotionListener -------------------------------------------------- 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir void SAL_CALL PresenterPaneBorderManager::mouseMoved (const css::awt::MouseEvent& rEvent) 369*cdf0e10cSrcweir throw (css::uno::RuntimeException) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir ThrowIfDisposed(); 372*cdf0e10cSrcweir ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir WindowList::const_iterator iDescriptor; 375*cdf0e10cSrcweir for (iDescriptor=maWindowList.begin(); iDescriptor!=maWindowList.end(); ++iDescriptor) 376*cdf0e10cSrcweir if (iDescriptor->first == rEvent.Source) 377*cdf0e10cSrcweir break; 378*cdf0e10cSrcweir if (iDescriptor != maWindowList.end()) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir // Choose pointer shape according to position in the window border. 381*cdf0e10cSrcweir switch (ClassifyBorderElementUnderMouse( 382*cdf0e10cSrcweir iDescriptor->first, 383*cdf0e10cSrcweir iDescriptor->second, 384*cdf0e10cSrcweir awt::Point(rEvent.X,rEvent.Y))) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir case PresenterPaneBorderManager::Top: 387*cdf0e10cSrcweir mnPointerType = awt::SystemPointer::MOVE; 388*cdf0e10cSrcweir break; 389*cdf0e10cSrcweir case PresenterPaneBorderManager::TopLeft: 390*cdf0e10cSrcweir mnPointerType = awt::SystemPointer::WINDOW_NWSIZE; 391*cdf0e10cSrcweir break; 392*cdf0e10cSrcweir case PresenterPaneBorderManager::TopRight: 393*cdf0e10cSrcweir mnPointerType = awt::SystemPointer::WINDOW_NESIZE; 394*cdf0e10cSrcweir break; 395*cdf0e10cSrcweir case PresenterPaneBorderManager::Left: 396*cdf0e10cSrcweir mnPointerType = awt::SystemPointer::WINDOW_WSIZE; 397*cdf0e10cSrcweir break; 398*cdf0e10cSrcweir case PresenterPaneBorderManager::Right: 399*cdf0e10cSrcweir mnPointerType = awt::SystemPointer::WINDOW_ESIZE; 400*cdf0e10cSrcweir break; 401*cdf0e10cSrcweir case PresenterPaneBorderManager::BottomLeft: 402*cdf0e10cSrcweir mnPointerType = awt::SystemPointer::WINDOW_SWSIZE; 403*cdf0e10cSrcweir break; 404*cdf0e10cSrcweir case PresenterPaneBorderManager::BottomRight: 405*cdf0e10cSrcweir mnPointerType = awt::SystemPointer::WINDOW_SESIZE; 406*cdf0e10cSrcweir break; 407*cdf0e10cSrcweir case PresenterPaneBorderManager::Bottom: 408*cdf0e10cSrcweir mnPointerType = awt::SystemPointer::WINDOW_SSIZE; 409*cdf0e10cSrcweir break; 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir case PresenterPaneBorderManager::Content: 412*cdf0e10cSrcweir case PresenterPaneBorderManager::Outside: 413*cdf0e10cSrcweir default: 414*cdf0e10cSrcweir mnPointerType = awt::SystemPointer::ARROW; 415*cdf0e10cSrcweir break; 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir // Make the pointer shape visible. 419*cdf0e10cSrcweir Reference<awt::XWindowPeer> xPeer (iDescriptor->first, UNO_QUERY); 420*cdf0e10cSrcweir if (xPeer.is()) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir if (mxPointer.is()) 423*cdf0e10cSrcweir mxPointer->setType(mnPointerType); 424*cdf0e10cSrcweir xPeer->setPointer(mxPointer); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir void SAL_CALL PresenterPaneBorderManager::mouseDragged (const css::awt::MouseEvent& rEvent) 433*cdf0e10cSrcweir throw (css::uno::RuntimeException) 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir ThrowIfDisposed(); 436*cdf0e10cSrcweir ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir if ( ! mxOuterDragWindow.is()) 439*cdf0e10cSrcweir return; 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir CaptureMouse(mxOuterDragWindow); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir const awt::Rectangle aOldBox (mxOuterDragWindow->getPosSize()); 444*cdf0e10cSrcweir const sal_Int32 nX = rEvent.X + aOldBox.X; 445*cdf0e10cSrcweir const sal_Int32 nY = rEvent.Y + aOldBox.Y; 446*cdf0e10cSrcweir const sal_Int32 nDiffX = nX - maDragAnchor.X; 447*cdf0e10cSrcweir const sal_Int32 nDiffY = nY - maDragAnchor.Y; 448*cdf0e10cSrcweir maDragAnchor.X = nX; 449*cdf0e10cSrcweir maDragAnchor.Y = nY; 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir const sal_Int32 nOldRight = aOldBox.X + aOldBox.Width; 452*cdf0e10cSrcweir const sal_Int32 nOldBottom = aOldBox.Y + aOldBox.Height; 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir awt::Rectangle aBox (aOldBox); 455*cdf0e10cSrcweir sal_Int32 nRight = aBox.X + aBox.Width; 456*cdf0e10cSrcweir sal_Int32 nBottom = aBox.Y + aBox.Height; 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir // Update position and/or size according to initial pointer position 459*cdf0e10cSrcweir // inside the window border. 460*cdf0e10cSrcweir switch (meDragType) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir case PresenterPaneBorderManager::Top: 463*cdf0e10cSrcweir aBox.X += nDiffX; aBox.Y += nDiffY; 464*cdf0e10cSrcweir nRight += nDiffX; nBottom += nDiffY; 465*cdf0e10cSrcweir break; 466*cdf0e10cSrcweir case PresenterPaneBorderManager::TopLeft: 467*cdf0e10cSrcweir aBox.X += nDiffX; aBox.Y += nDiffY; 468*cdf0e10cSrcweir break; 469*cdf0e10cSrcweir case PresenterPaneBorderManager::TopRight: 470*cdf0e10cSrcweir nRight += nDiffX; aBox.Y += nDiffY; 471*cdf0e10cSrcweir break; 472*cdf0e10cSrcweir case PresenterPaneBorderManager::Left: 473*cdf0e10cSrcweir aBox.X += nDiffX; 474*cdf0e10cSrcweir break; 475*cdf0e10cSrcweir case PresenterPaneBorderManager::Right: 476*cdf0e10cSrcweir nRight += nDiffX; 477*cdf0e10cSrcweir break; 478*cdf0e10cSrcweir case PresenterPaneBorderManager::BottomLeft: 479*cdf0e10cSrcweir aBox.X += nDiffX; nBottom += nDiffY; 480*cdf0e10cSrcweir break; 481*cdf0e10cSrcweir case PresenterPaneBorderManager::BottomRight: 482*cdf0e10cSrcweir nRight += nDiffX; nBottom += nDiffY; 483*cdf0e10cSrcweir break; 484*cdf0e10cSrcweir case PresenterPaneBorderManager::Bottom: 485*cdf0e10cSrcweir nBottom += nDiffY; 486*cdf0e10cSrcweir break; 487*cdf0e10cSrcweir default: break; 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir aBox.Width = nRight - aBox.X; 491*cdf0e10cSrcweir aBox.Height = nBottom - aBox.Y; 492*cdf0e10cSrcweir if (aBox.Width > 20 493*cdf0e10cSrcweir && aBox.Height > 20) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir // Set position and/or size of the border window to the new values. 496*cdf0e10cSrcweir sal_Int16 nFlags (0); 497*cdf0e10cSrcweir if (aBox.X != aOldBox.X) 498*cdf0e10cSrcweir nFlags |= awt::PosSize::X; 499*cdf0e10cSrcweir if (aBox.Y != aOldBox.Y) 500*cdf0e10cSrcweir nFlags |= awt::PosSize::Y; 501*cdf0e10cSrcweir if (aBox.Width != aOldBox.Width) 502*cdf0e10cSrcweir nFlags |= awt::PosSize::WIDTH; 503*cdf0e10cSrcweir if (aBox.Height != aOldBox.Height) 504*cdf0e10cSrcweir nFlags |= awt::PosSize::HEIGHT; 505*cdf0e10cSrcweir mxOuterDragWindow->setPosSize(aBox.X, aBox.Y, aBox.Width, aBox.Height, nFlags); 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir // Invalidate that is or was covered by the border window before and 508*cdf0e10cSrcweir // after the move/resize. 509*cdf0e10cSrcweir if (mpPresenterController.get() != NULL) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir const sal_Int32 nLeft = ::std::min(aOldBox.X,aBox.X); 512*cdf0e10cSrcweir const sal_Int32 nTop = ::std::min(aOldBox.Y,aBox.Y); 513*cdf0e10cSrcweir const sal_Int32 nWidth = ::std::max(nOldRight,nRight) - nLeft; 514*cdf0e10cSrcweir const sal_Int32 nHeight = ::std::max(nOldBottom,nBottom) - nTop; 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir OSL_ASSERT(mpPresenterController->GetPaintManager().get()!=NULL); 517*cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate( 518*cdf0e10cSrcweir mxParentWindow, 519*cdf0e10cSrcweir ::awt::Rectangle(nLeft,nTop,nWidth-1,nHeight-1)); 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir //----- lang::XEventListener -------------------------------------------------- 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir void SAL_CALL PresenterPaneBorderManager::disposing (const lang::EventObject& rEvent) 530*cdf0e10cSrcweir throw (RuntimeException) 531*cdf0e10cSrcweir { 532*cdf0e10cSrcweir WindowList::iterator iDescriptor; 533*cdf0e10cSrcweir for (iDescriptor=maWindowList.begin(); iDescriptor!=maWindowList.end(); ++iDescriptor) 534*cdf0e10cSrcweir if (iDescriptor->first == rEvent.Source) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir maWindowList.erase(iDescriptor); 537*cdf0e10cSrcweir break; 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir //----------------------------------------------------------------------------- 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir void PresenterPaneBorderManager::CaptureMouse (const Reference<awt::XWindow>& rxWindow) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir if (mxPresenterHelper.is()) 550*cdf0e10cSrcweir mxPresenterHelper->captureMouse(rxWindow); 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir void PresenterPaneBorderManager::ReleaseMouse (const Reference<awt::XWindow>& rxWindow) 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir if (mxPresenterHelper.is()) 559*cdf0e10cSrcweir mxPresenterHelper->releaseMouse(rxWindow); 560*cdf0e10cSrcweir } 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir void PresenterPaneBorderManager::ThrowIfDisposed (void) 566*cdf0e10cSrcweir throw (::com::sun::star::lang::DisposedException) 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir if (rBHelper.bDisposed || rBHelper.bInDispose) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir throw lang::DisposedException ( 571*cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 572*cdf0e10cSrcweir "PresenterPaneBorderManager object has already been disposed")), 573*cdf0e10cSrcweir static_cast<uno::XWeak*>(this)); 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir } } // end of namespace ::sd::presenter 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir #endif // ENABLE_PANE_RESIZING 583