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_PRESENTERPANEBORDERPAINTER_HXX 21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERPANEBORDERPAINTER_HXX 22 23 #include <com/sun/star/uno/XComponentContext.hpp> 24 #include <com/sun/star/awt/Rectangle.hpp> 25 #include <com/sun/star/drawing/framework/XPaneBorderPainter.hpp> 26 #include <com/sun/star/rendering/XCanvas.hpp> 27 #include <cppuhelper/basemutex.hxx> 28 #include <cppuhelper/compbase.hxx> 29 #include <memory> 30 31 namespace sdext::presenter { 32 33 class PresenterPane; 34 class PresenterTheme; 35 36 typedef ::cppu::WeakComponentImplHelper< 37 css::drawing::framework::XPaneBorderPainter 38 > PresenterPaneBorderPainterInterfaceBase; 39 40 /** This class is responsible for painting window borders of PresenterPane 41 objects. 42 */ 43 class PresenterPaneBorderPainter 44 : protected ::cppu::BaseMutex, 45 public PresenterPaneBorderPainterInterfaceBase 46 { 47 public: 48 explicit PresenterPaneBorderPainter ( 49 const css::uno::Reference<css::uno::XComponentContext>& rxContext); 50 virtual ~PresenterPaneBorderPainter() override; 51 PresenterPaneBorderPainter(const PresenterPaneBorderPainter&) = delete; 52 PresenterPaneBorderPainter& operator=(const PresenterPaneBorderPainter&) = delete; 53 54 /** Transform the bounding box of the window content to the outer 55 bounding box of the border that is painted around it. 56 @param rsPaneURL 57 Specifies the pane style that is used to determine the border sizes. 58 @param rInnerBox 59 The rectangle of the inner window content. 60 */ 61 css::awt::Rectangle AddBorder ( 62 const OUString& rsPaneURL, 63 const css::awt::Rectangle& rInnerBox, 64 const css::drawing::framework::BorderType eBorderType) const; 65 66 /** Transform the outer bounding box of a window to the bounding box of 67 the inner content area. 68 @param rsPaneURL 69 Specifies the pane style that is used to determine the border sizes. 70 @param rOuterBox 71 The bounding box of the rectangle around the window. 72 @param bIsTitleVisible 73 This flag controls whether the upper part of the frame is 74 supposed to contain the window title. 75 */ 76 css::awt::Rectangle RemoveBorder ( 77 const OUString& rsPaneURL, 78 const css::awt::Rectangle& rOuterBox, 79 const css::drawing::framework::BorderType eBorderType) const; 80 81 void SetTheme (const std::shared_ptr<PresenterTheme>& rpTheme); 82 83 class Renderer; 84 85 // XPaneBorderPainter 86 87 virtual css::awt::Rectangle SAL_CALL addBorder ( 88 const OUString& rsPaneBorderStyleName, 89 const css::awt::Rectangle& rRectangle, 90 css::drawing::framework::BorderType eBorderType) override; 91 92 virtual css::awt::Rectangle SAL_CALL removeBorder ( 93 const OUString& rsPaneBorderStyleName, 94 const css::awt::Rectangle& rRectangle, 95 css::drawing::framework::BorderType eBorderType) override; 96 97 virtual void SAL_CALL paintBorder ( 98 const OUString& rsPaneBorderStyleName, 99 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 100 const css::awt::Rectangle& rOuterBorderRectangle, 101 const css::awt::Rectangle& rRepaintArea, 102 const OUString& rsTitle) override; 103 104 virtual void SAL_CALL paintBorderWithCallout ( 105 const OUString& rsPaneBorderStyleName, 106 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 107 const css::awt::Rectangle& rOuterBorderRectangle, 108 const css::awt::Rectangle& rRepaintArea, 109 const OUString& rsTitle, 110 const css::awt::Point& rCalloutAnchor) override; 111 112 virtual css::awt::Point SAL_CALL getCalloutOffset ( 113 const OUString& rsPaneBorderStyleName) override; 114 115 private: 116 css::uno::Reference<css::uno::XComponentContext> mxContext; 117 std::shared_ptr<PresenterTheme> mpTheme; 118 std::unique_ptr<Renderer> mpRenderer; 119 120 /** When the theme for the border has not yet been loaded then try again 121 when this method is called. 122 @return 123 Returns <TRUE/> only one time when the theme is loaded and/or the 124 renderer is initialized. 125 */ 126 bool ProvideTheme ( 127 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas); 128 void ProvideTheme(); 129 130 /// @throws css::lang::DisposedException 131 void ThrowIfDisposed() const; 132 }; 133 134 } // end of namespace ::sd::presenter 135 136 #endif 137 138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 139