1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SDEXT_PRESENTER_PRESENTER_PANE_BORDER_MANAGER_HXX 25 #define SDEXT_PRESENTER_PRESENTER_PANE_BORDER_MANAGER_HXX 26 27 // The body of this file is only used when PresenterWindowManager defines 28 // the preprocessor symbol ENABLE_PANE_RESIZING, which by default is not the 29 // case. 30 #ifdef ENABLE_PANE_RESIZING 31 32 #include <cppuhelper/basemutex.hxx> 33 #include <cppuhelper/compbase3.hxx> 34 #include <com/sun/star/awt/Point.hpp> 35 #include <com/sun/star/awt/Size.hpp> 36 #include <com/sun/star/awt/XGraphics.hpp> 37 #include <com/sun/star/awt/XMouseListener.hpp> 38 #include <com/sun/star/awt/XMouseMotionListener.hpp> 39 #include <com/sun/star/awt/XPointer.hpp> 40 #include <com/sun/star/awt/XWindowListener.hpp> 41 #include <com/sun/star/container/XChild.hpp> 42 #include <com/sun/star/drawing/XPresenterHelper.hpp> 43 #include <com/sun/star/drawing/framework/XPane.hpp> 44 #include <com/sun/star/lang/XInitialization.hpp> 45 #include <com/sun/star/uno/XComponentContext.hpp> 46 #include <com/sun/star/rendering/XCanvas.hpp> 47 #include <rtl/ref.hxx> 48 #include <tools/svborder.hxx> 49 #include <boost/noncopyable.hpp> 50 #include <boost/shared_ptr.hpp> 51 52 namespace css = ::com::sun::star; 53 54 55 namespace sdext { namespace presenter { 56 57 class PresenterController; 58 59 namespace { 60 typedef ::cppu::WeakComponentImplHelper3 < 61 css::lang::XInitialization, 62 css::awt::XMouseListener, 63 css::awt::XMouseMotionListener 64 > PresenterPaneBorderManagerInterfaceBase; 65 } 66 67 68 /** Manage the interactive moving and resizing of panes. 69 */ 70 class PresenterPaneBorderManager 71 : private ::boost::noncopyable, 72 protected ::cppu::BaseMutex, 73 public PresenterPaneBorderManagerInterfaceBase 74 { 75 public: 76 PresenterPaneBorderManager ( 77 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 78 const ::rtl::Reference<PresenterController>& rpPresenterController); 79 virtual ~PresenterPaneBorderManager (void); 80 81 virtual void SAL_CALL disposing (void); 82 83 84 static ::rtl::OUString getImplementationName_static (void); 85 static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static (void); 86 static css::uno::Reference<css::uno::XInterface> Create( 87 const css::uno::Reference<css::uno::XComponentContext>& rxContext); 88 89 90 // XInitialization 91 92 virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments); 93 94 95 // XMouseListener 96 97 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent); 98 99 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent); 100 101 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent); 102 103 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent); 104 105 106 // XMouseMotionListener 107 108 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent); 109 110 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent); 111 112 113 // lang::XEventListener 114 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent); 115 116 117 private: 118 enum BorderElement { Top, TopLeft, TopRight, Left, Right, BottomLeft, BottomRight, Bottom, 119 Content, Outside }; 120 121 ::rtl::Reference<PresenterController> mpPresenterController; 122 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 123 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper; 124 /** The parent window is stored so that it can be invalidated when one 125 of its children is resized or moved. It is assumed to be the parent 126 window of all outer windows stored in maWindowList. 127 */ 128 css::uno::Reference<css::awt::XWindow> mxParentWindow; 129 typedef ::std::pair<css::uno::Reference<css::awt::XWindow>, 130 css::uno::Reference<css::awt::XWindow> > WindowDescriptor; 131 typedef ::std::vector<WindowDescriptor> WindowList; 132 WindowList maWindowList; 133 134 sal_Int32 mnPointerType; 135 css::awt::Point maDragAnchor; 136 BorderElement meDragType; 137 css::uno::Reference<css::awt::XWindow> mxOuterDragWindow; 138 css::uno::Reference<css::awt::XWindow> mxInnerDragWindow; 139 css::uno::Reference<css::awt::XPointer> mxPointer; 140 141 BorderElement ClassifyBorderElementUnderMouse ( 142 const css::uno::Reference<css::awt::XWindow>& rxOuterDragWindow, 143 const css::uno::Reference<css::awt::XWindow>& rxInnerDragWindow, 144 const css::awt::Point aPosition) const; 145 void CreateWindows (const css::uno::Reference<css::awt::XWindow>& rxParentWindow); 146 void CaptureMouse (const css::uno::Reference<css::awt::XWindow>& rxWindow); 147 void ReleaseMouse (const css::uno::Reference<css::awt::XWindow>& rxWindow); 148 149 /** This method throws a DisposedException when the object has already been 150 disposed. 151 */ 152 void ThrowIfDisposed (void); 153 }; 154 155 } } // end of namespace ::sd::presenter 156 157 #endif // ENABLE_PANE_RESIZING 158 159 #endif 160