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 SAL_THROW((css::uno::Exception)); 89 90 91 // XInitialization 92 93 virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments) 94 throw (css::uno::Exception, css::uno::RuntimeException); 95 96 97 // XMouseListener 98 99 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) 100 throw (css::uno::RuntimeException); 101 102 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) 103 throw (css::uno::RuntimeException); 104 105 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) 106 throw (css::uno::RuntimeException); 107 108 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) 109 throw (css::uno::RuntimeException); 110 111 112 // XMouseMotionListener 113 114 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent) 115 throw (css::uno::RuntimeException); 116 117 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent) 118 throw (css::uno::RuntimeException); 119 120 121 // lang::XEventListener 122 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) 123 throw (css::uno::RuntimeException); 124 125 126 private: 127 enum BorderElement { Top, TopLeft, TopRight, Left, Right, BottomLeft, BottomRight, Bottom, 128 Content, Outside }; 129 130 ::rtl::Reference<PresenterController> mpPresenterController; 131 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 132 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper; 133 /** The parent window is stored so that it can be invalidated when one 134 of its children is resized or moved. It is assumed to be the parent 135 window of all outer windows stored in maWindowList. 136 */ 137 css::uno::Reference<css::awt::XWindow> mxParentWindow; 138 typedef ::std::pair<css::uno::Reference<css::awt::XWindow>, 139 css::uno::Reference<css::awt::XWindow> > WindowDescriptor; 140 typedef ::std::vector<WindowDescriptor> WindowList; 141 WindowList maWindowList; 142 143 sal_Int32 mnPointerType; 144 css::awt::Point maDragAnchor; 145 BorderElement meDragType; 146 css::uno::Reference<css::awt::XWindow> mxOuterDragWindow; 147 css::uno::Reference<css::awt::XWindow> mxInnerDragWindow; 148 css::uno::Reference<css::awt::XPointer> mxPointer; 149 150 BorderElement ClassifyBorderElementUnderMouse ( 151 const css::uno::Reference<css::awt::XWindow>& rxOuterDragWindow, 152 const css::uno::Reference<css::awt::XWindow>& rxInnerDragWindow, 153 const css::awt::Point aPosition) const; 154 void CreateWindows (const css::uno::Reference<css::awt::XWindow>& rxParentWindow); 155 void CaptureMouse (const css::uno::Reference<css::awt::XWindow>& rxWindow); 156 void ReleaseMouse (const css::uno::Reference<css::awt::XWindow>& rxWindow); 157 158 /** This method throws a DisposedException when the object has already been 159 disposed. 160 */ 161 void ThrowIfDisposed (void) 162 throw (css::lang::DisposedException); 163 }; 164 165 } } // end of namespace ::sd::presenter 166 167 #endif // ENABLE_PANE_RESIZING 168 169 #endif 170 171