1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERSLIDEPREVIEW_HXX 21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERSLIDEPREVIEW_HXX 22 23 #include "PresenterController.hxx" 24 25 #include <com/sun/star/awt/XPaintListener.hpp> 26 #include <com/sun/star/awt/XWindowListener.hpp> 27 #include <com/sun/star/drawing/XDrawPage.hpp> 28 #include <com/sun/star/drawing/XDrawView.hpp> 29 #include <com/sun/star/drawing/XSlideRenderer.hpp> 30 #include <com/sun/star/drawing/framework/XPane.hpp> 31 #include <com/sun/star/drawing/framework/XView.hpp> 32 #include <com/sun/star/uno/XComponentContext.hpp> 33 #include <cppuhelper/basemutex.hxx> 34 #include <cppuhelper/compbase.hxx> 35 #include <rtl/ref.hxx> 36 37 namespace sdext::presenter { 38 39 typedef ::cppu::WeakComponentImplHelper < 40 css::drawing::framework::XView, 41 css::drawing::XDrawView, 42 css::awt::XPaintListener, 43 css::awt::XWindowListener 44 > PresenterSlidePreviewInterfaceBase; 45 46 /** Static preview of a slide. Typically used for the preview of the next 47 slide. 48 This implementation shows a preview of the slide given to the 49 setCurrentSlide. For showing the next slide the PresenterViewFactory 50 uses a derived class that overrides the setCurrentSlide() method. 51 */ 52 class PresenterSlidePreview 53 : private ::cppu::BaseMutex, 54 public PresenterSlidePreviewInterfaceBase 55 { 56 public: 57 PresenterSlidePreview ( 58 const css::uno::Reference<css::uno::XComponentContext>& rxContext, 59 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId, 60 const css::uno::Reference<css::drawing::framework::XPane>& rxAnchorPane, 61 const ::rtl::Reference<PresenterController>& rpPresenterController); 62 virtual ~PresenterSlidePreview() override; 63 PresenterSlidePreview(const PresenterSlidePreview&) = delete; 64 PresenterSlidePreview& operator=(const PresenterSlidePreview&) = delete; 65 virtual void SAL_CALL disposing() override; 66 67 // XResourceId 68 69 virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId() override; 70 71 virtual sal_Bool SAL_CALL isAnchorOnly() override; 72 73 // XWindowListener 74 75 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) override; 76 77 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) override; 78 79 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) override; 80 81 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) override; 82 83 // XPaintListener 84 85 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) override; 86 87 // lang::XEventListener 88 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) override; 89 90 // XDrawView 91 92 virtual void SAL_CALL setCurrentPage ( 93 const css::uno::Reference<css::drawing::XDrawPage>& rxSlide) override; 94 95 virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage() override; 96 97 protected: 98 ::rtl::Reference<PresenterController> mpPresenterController; 99 100 private: 101 css::uno::Reference<css::drawing::framework::XResourceId> mxViewId; 102 css::uno::Reference<css::drawing::XSlideRenderer> mxPreviewRenderer; 103 104 /** This Image holds the preview of the current slide. After resize 105 requests the image may be empty. This results eventually in a call 106 to ProvideSlide() in order to created a preview in the correct new 107 size. 108 */ 109 css::uno::Reference<css::rendering::XBitmap> mxPreview; 110 std::shared_ptr<PresenterBitmapContainer> mpBitmaps; 111 112 /** The current slide for which a preview is displayed. This may or 113 may not be the same as the current slide of the PresenterView. 114 */ 115 css::uno::Reference<css::drawing::XDrawPage> mxCurrentSlide; 116 double mnSlideAspectRatio; 117 118 css::uno::Reference<css::awt::XWindow> mxWindow; 119 css::uno::Reference<css::rendering::XCanvas> mxCanvas; 120 121 /** Set the given slide as the current slide of the called PresenterSlidePreview 122 object. 123 */ 124 void SetSlide (const css::uno::Reference<css::drawing::XDrawPage>& rxPage); 125 126 /** Paint the preview of the current slide centered in the window of the 127 anchor pane. 128 */ 129 void Paint (const css::awt::Rectangle& rBoundingBox); 130 131 /** React to a resize of the anchor pane. 132 */ 133 void Resize(); 134 135 /** @throws css::lang::DisposedException when the object has already been 136 disposed. 137 */ 138 void ThrowIfDisposed(); 139 }; 140 141 } // end of namespace ::sd::presenter 142 143 #endif 144 145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 146