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_SLIDE_SORTER_HXX 25 #define SDEXT_PRESENTER_PRESENTER_SLIDE_SORTER_HXX 26 27 #include "PresenterController.hxx" 28 #include "PresenterPaneContainer.hxx" 29 #include "PresenterViewFactory.hxx" 30 #include <cppuhelper/basemutex.hxx> 31 #include <cppuhelper/compbase8.hxx> 32 #include <com/sun/star/awt/XPaintListener.hpp> 33 #include <com/sun/star/awt/XWindowListener.hpp> 34 #include <com/sun/star/beans/XPropertyChangeListener.hpp> 35 #include <com/sun/star/drawing/XDrawView.hpp> 36 #include <com/sun/star/drawing/XSlidePreviewCache.hpp> 37 #include <com/sun/star/drawing/framework/XView.hpp> 38 #include <com/sun/star/drawing/framework/XResourceId.hpp> 39 #include <com/sun/star/frame/XController.hpp> 40 #include <com/sun/star/geometry/RealRectangle2D.hpp> 41 #include <com/sun/star/rendering/XPolyPolygon2D.hpp> 42 #include <com/sun/star/rendering/XSprite.hpp> 43 #include <com/sun/star/rendering/XSpriteCanvas.hpp> 44 45 namespace css = ::com::sun::star; 46 47 namespace { 48 typedef cppu::WeakComponentImplHelper8< 49 css::drawing::framework::XView, 50 css::awt::XWindowListener, 51 css::awt::XPaintListener, 52 css::beans::XPropertyChangeListener, 53 css::drawing::XSlidePreviewCacheListener, 54 css::awt::XMouseListener, 55 css::awt::XMouseMotionListener, 56 css::drawing::XDrawView 57 > PresenterSlideSorterInterfaceBase; 58 } 59 60 namespace sdext { namespace presenter { 61 62 class PresenterButton; 63 class PresenterScrollBar; 64 65 /** A simple slide sorter for the presenter screen. It uses a preview cache 66 to create the slide previews. Painting is done via a canvas. 67 */ 68 class PresenterSlideSorter 69 : private ::cppu::BaseMutex, 70 public PresenterSlideSorterInterfaceBase, 71 public CachablePresenterView 72 { 73 public: 74 PresenterSlideSorter ( 75 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 76 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId, 77 const css::uno::Reference<css::frame::XController>& rxController, 78 const ::rtl::Reference<PresenterController>& rpPresenterController); 79 virtual ~PresenterSlideSorter (void); 80 81 virtual void SAL_CALL disposing (void); 82 83 void SetActiveState (const bool bIsActive); 84 85 86 // lang::XEventListener 87 88 virtual void SAL_CALL 89 disposing (const css::lang::EventObject& rEventObject); 90 91 92 // XWindowListener 93 94 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent); 95 96 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent); 97 98 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent); 99 100 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent); 101 102 103 // XPaintListener 104 105 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent); 106 107 108 // XMouseListener 109 110 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent); 111 112 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent); 113 114 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent); 115 116 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent); 117 118 119 // XMouseMotionListener 120 121 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent); 122 123 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent); 124 125 126 // XResourceId 127 128 virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void); 129 130 virtual sal_Bool SAL_CALL isAnchorOnly (void); 131 132 133 // XPropertyChangeListener 134 135 virtual void SAL_CALL propertyChange ( 136 const css::beans::PropertyChangeEvent& rEvent); 137 138 139 // XSlidePreviewCacheListener 140 141 virtual void SAL_CALL notifyPreviewCreation ( 142 sal_Int32 nSlideIndex); 143 144 145 // XDrawView 146 147 virtual void SAL_CALL setCurrentPage ( 148 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide); 149 150 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage (void); 151 152 private: 153 css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 154 css::uno::Reference<css::drawing::framework::XResourceId> mxViewId; 155 css::uno::Reference<css::drawing::framework::XPane> mxPane; 156 css::uno::Reference<css::rendering::XCanvas> mxCanvas; 157 css::uno::Reference<css::awt::XWindow> mxWindow; 158 ::rtl::Reference<PresenterController> mpPresenterController; 159 css::uno::Reference<css::presentation::XSlideShowController> mxSlideShowController; 160 css::uno::Reference<css::drawing::XSlidePreviewCache> mxPreviewCache; 161 bool mbIsPaintPending; 162 bool mbIsLayoutPending; 163 class Layout; 164 ::boost::shared_ptr<Layout> mpLayout; 165 ::rtl::Reference<PresenterScrollBar> mpHorizontalScrollBar; 166 ::rtl::Reference<PresenterScrollBar> mpVerticalScrollBar; 167 ::rtl::Reference<PresenterButton> mpCloseButton; 168 class MouseOverManager; 169 ::boost::scoped_ptr<MouseOverManager> mpMouseOverManager; 170 sal_Int32 mnSlideIndexMousePressed; 171 sal_Int32 mnCurrentSlideIndex; 172 sal_Int32 mnSeparatorY; 173 css::util::Color maSeparatorColor; 174 css::awt::Point maCloseButtonCenter; 175 css::awt::Rectangle maCurrentSlideFrameBoundingBox; 176 class CurrentSlideFrameRenderer; 177 ::boost::shared_ptr<CurrentSlideFrameRenderer> mpCurrentSlideFrameRenderer; 178 css::uno::Reference<css::rendering::XPolyPolygon2D> mxPreviewFrame; 179 180 void UpdateLayout (void); 181 css::geometry::RealRectangle2D PlaceScrollBars ( 182 const css::geometry::RealRectangle2D& rUpperBox); 183 void PlaceCloseButton ( 184 const PresenterPaneContainer::SharedPaneDescriptor& rpPane, 185 const css::awt::Rectangle& rCenterBox, 186 const sal_Int32 nLeftFrameWidth); 187 void ClearBackground ( 188 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 189 const css::awt::Rectangle& rRedrawArea); 190 double GetSlideAspectRatio (void) const; 191 css::uno::Reference<css::rendering::XBitmap> GetPreview (const sal_Int32 nSlideIndex); 192 void PaintPreview ( 193 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 194 const css::awt::Rectangle& rUpdateBox, 195 const sal_Int32 nSlideIndex); 196 void Paint (const css::awt::Rectangle& rUpdateBox); 197 void SetHorizontalOffset (const double nXOffset); 198 void SetVerticalOffset (const double nYOffset); 199 void GotoSlide (const sal_Int32 nSlideIndex); 200 bool ProvideCanvas (void); 201 202 /** This method throws a DisposedException when the object has already been 203 disposed. 204 */ 205 void ThrowIfDisposed (void); 206 }; 207 208 } } // end of namespace ::sdext::presenter 209 210 #endif 211