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_PRESENTERCANVASHELPER_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERCANVASHELPER_HXX
22 
23 #include "PresenterBitmapContainer.hxx"
24 #include <com/sun/star/awt/Point.hpp>
25 #include <com/sun/star/awt/Rectangle.hpp>
26 #include <com/sun/star/rendering/TextDirection.hpp>
27 #include <com/sun/star/rendering/XCanvas.hpp>
28 #include <com/sun/star/rendering/XCanvasFont.hpp>
29 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
30 
31 namespace sdext::presenter {
32 
33 /** Collection of functions to ease the life of a canvas user.
34 */
35 class PresenterCanvasHelper
36 {
37 public:
38     PresenterCanvasHelper();
39     ~PresenterCanvasHelper();
40     PresenterCanvasHelper(const PresenterCanvasHelper&) = delete;
41     PresenterCanvasHelper& operator=(const PresenterCanvasHelper&) = delete;
42 
43     void Paint (
44         const SharedBitmapDescriptor& rpBitmap,
45         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
46         const css::awt::Rectangle& rRepaintBox,
47         const css::awt::Rectangle& rBackgroundBoundingBox,
48         const css::awt::Rectangle& rContentBoundingBox) const;
49 
50     static void PaintRectangle (
51         const SharedBitmapDescriptor& rpBitmap,
52         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
53         const css::awt::Rectangle& rRepaintBox,
54         const css::awt::Rectangle& rBackgroundBoundingBox,
55         const css::awt::Rectangle& rContentBoundingBox,
56         const css::rendering::ViewState& rDefaultViewState,
57         const css::rendering::RenderState& rDefaultRenderState);
58 
59     static void SetDeviceColor(
60         css::rendering::RenderState& rRenderState,
61         const css::util::Color aColor);
62 
63     static css::geometry::RealRectangle2D GetTextBoundingBox (
64         const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
65         const OUString& rsText,
66         const sal_Int8 = css::rendering::TextDirection::WEAK_LEFT_TO_RIGHT);
67 
68     static css::geometry::RealSize2D GetTextSize (
69         const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
70         const OUString& rsText );
71 
72 private:
73     const css::rendering::ViewState maDefaultViewState;
74     const css::rendering::RenderState maDefaultRenderState;
75 
76     static void PaintTiledBitmap (
77         const css::uno::Reference<css::rendering::XBitmap>& rxTexture,
78         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
79         const css::awt::Rectangle& rRepaintBox,
80         const css::uno::Reference<css::rendering::XPolyPolygon2D>& rxPolygon,
81         const css::awt::Rectangle& rHole,
82         const css::rendering::ViewState& rDefaultViewState,
83         const css::rendering::RenderState& rDefaultRenderState);
84 
85     static void PaintBitmap (
86         const css::uno::Reference<css::rendering::XBitmap>& rxBitmap,
87         const css::awt::Point& rLocation,
88         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
89         const css::awt::Rectangle& rRepaintBox,
90         const css::uno::Reference<css::rendering::XPolyPolygon2D>& rxPolygon,
91         const css::rendering::ViewState& rDefaultViewState,
92         const css::rendering::RenderState& rDefaultRenderState);
93 
94     static void PaintColor (
95         const css::util::Color nColor,
96         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
97         const css::awt::Rectangle& rRepaintBox,
98         const css::uno::Reference<css::rendering::XPolyPolygon2D>& rxPolygon,
99         const css::rendering::ViewState& rDefaultViewState,
100         const css::rendering::RenderState& rDefaultRenderState);
101 };
102 
103 }
104 
105 #endif
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
108