1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SDEXT_PRESENTER_PRESENTER_PANE_BORDER_MANAGER_HXX 29 #define SDEXT_PRESENTER_PRESENTER_PANE_BORDER_MANAGER_HXX 30 31 // The body of this file is only used when PresenterWindowManager defines 32 // the preprocessor symbol ENABLE_PANE_RESIZING, which by default is not the 33 // case. 34 #ifdef ENABLE_PANE_RESIZING 35 36 #include <cppuhelper/basemutex.hxx> 37 #include <cppuhelper/compbase3.hxx> 38 #include <com/sun/star/awt/Point.hpp> 39 #include <com/sun/star/awt/Size.hpp> 40 #include <com/sun/star/awt/XGraphics.hpp> 41 #include <com/sun/star/awt/XMouseListener.hpp> 42 #include <com/sun/star/awt/XMouseMotionListener.hpp> 43 #include <com/sun/star/awt/XPointer.hpp> 44 #include <com/sun/star/awt/XWindowListener.hpp> 45 #include <com/sun/star/container/XChild.hpp> 46 #include <com/sun/star/drawing/XPresenterHelper.hpp> 47 #include <com/sun/star/drawing/framework/XPane.hpp> 48 #include <com/sun/star/lang/XInitialization.hpp> 49 #include <com/sun/star/uno/XComponentContext.hpp> 50 #include <com/sun/star/rendering/XCanvas.hpp> 51 #include <rtl/ref.hxx> 52 #include <tools/svborder.hxx> 53 #include <boost/noncopyable.hpp> 54 #include <boost/shared_ptr.hpp> 55 56 namespace css = ::com::sun::star; 57 58 59 namespace sdext { namespace presenter { 60 61 class PresenterController; 62 63 namespace { 64 typedef ::cppu::WeakComponentImplHelper3 < 65 css::lang::XInitialization, 66 css::awt::XMouseListener, 67 css::awt::XMouseMotionListener 68 > PresenterPaneBorderManagerInterfaceBase; 69 } 70 71 72 /** Manage the interactive moving and resizing of panes. 73 */ 74 class PresenterPaneBorderManager 75 : private ::boost::noncopyable, 76 protected ::cppu::BaseMutex, 77 public PresenterPaneBorderManagerInterfaceBase 78 { 79 public: 80 PresenterPaneBorderManager ( 81 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 82 const ::rtl::Reference<PresenterController>& rpPresenterController); 83 virtual ~PresenterPaneBorderManager (void); 84 85 virtual void SAL_CALL disposing (void); 86 87 88 static ::rtl::OUString getImplementationName_static (void); 89 static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static (void); 90 static css::uno::Reference<css::uno::XInterface> Create( 91 const css::uno::Reference<css::uno::XComponentContext>& rxContext) 92 SAL_THROW((css::uno::Exception)); 93 94 95 // XInitialization 96 97 virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments) 98 throw (css::uno::Exception, css::uno::RuntimeException); 99 100 101 // XMouseListener 102 103 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) 104 throw (css::uno::RuntimeException); 105 106 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) 107 throw (css::uno::RuntimeException); 108 109 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) 110 throw (css::uno::RuntimeException); 111 112 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) 113 throw (css::uno::RuntimeException); 114 115 116 // XMouseMotionListener 117 118 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent) 119 throw (css::uno::RuntimeException); 120 121 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent) 122 throw (css::uno::RuntimeException); 123 124 125 // lang::XEventListener 126 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) 127 throw (css::uno::RuntimeException); 128 129 130 private: 131 enum BorderElement { Top, TopLeft, TopRight, Left, Right, BottomLeft, BottomRight, Bottom, 132 Content, Outside }; 133 134 ::rtl::Reference<PresenterController> mpPresenterController; 135 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 136 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper; 137 /** The parent window is stored so that it can be invalidated when one 138 of its children is resized or moved. It is assumed to be the parent 139 window of all outer windows stored in maWindowList. 140 */ 141 css::uno::Reference<css::awt::XWindow> mxParentWindow; 142 typedef ::std::pair<css::uno::Reference<css::awt::XWindow>, 143 css::uno::Reference<css::awt::XWindow> > WindowDescriptor; 144 typedef ::std::vector<WindowDescriptor> WindowList; 145 WindowList maWindowList; 146 147 sal_Int32 mnPointerType; 148 css::awt::Point maDragAnchor; 149 BorderElement meDragType; 150 css::uno::Reference<css::awt::XWindow> mxOuterDragWindow; 151 css::uno::Reference<css::awt::XWindow> mxInnerDragWindow; 152 css::uno::Reference<css::awt::XPointer> mxPointer; 153 154 BorderElement ClassifyBorderElementUnderMouse ( 155 const css::uno::Reference<css::awt::XWindow>& rxOuterDragWindow, 156 const css::uno::Reference<css::awt::XWindow>& rxInnerDragWindow, 157 const css::awt::Point aPosition) const; 158 void CreateWindows (const css::uno::Reference<css::awt::XWindow>& rxParentWindow); 159 void CaptureMouse (const css::uno::Reference<css::awt::XWindow>& rxWindow); 160 void ReleaseMouse (const css::uno::Reference<css::awt::XWindow>& rxWindow); 161 162 /** This method throws a DisposedException when the object has already been 163 disposed. 164 */ 165 void ThrowIfDisposed (void) 166 throw (css::lang::DisposedException); 167 }; 168 169 } } // end of namespace ::sd::presenter 170 171 #endif // ENABLE_PANE_RESIZING 172 173 #endif 174 175