Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/drawinglayer/primitive2d/controlprimitive2d.hxx
Line
Count
Source
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
#pragma once
21
22
#include <drawinglayer/drawinglayerdllapi.h>
23
24
#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx>
25
#include <basegfx/matrix/b2dhommatrix.hxx>
26
27
namespace com::sun::star::awt
28
{
29
class XControl;
30
}
31
namespace com::sun::star::awt
32
{
33
class XControlModel;
34
}
35
36
namespace drawinglayer::primitive2d
37
{
38
/** ControlPrimitive2D class
39
40
    Base class for ControlPrimitive handling. It decomposes to a
41
    graphical representation (Bitmap data) of the control. This
42
    representation is limited to a quadratic pixel maximum defined
43
    in the application settings.
44
 */
45
class DRAWINGLAYER_DLLPUBLIC ControlPrimitive2D final : public BufferedDecompositionPrimitive2D
46
{
47
private:
48
    /// object's base data
49
    basegfx::B2DHomMatrix maTransform;
50
    css::uno::Reference<css::awt::XControlModel> mxControlModel;
51
52
    /// the created and cached awt::XControl
53
    css::uno::Reference<css::awt::XControl> mxXControl;
54
55
    /// the last used scaling, used from getDecomposition for buffering
56
    basegfx::B2DVector maLastViewScaling;
57
58
    /// yet another special snowflake way to generate PDF Alt text
59
    OUString m_AltText;
60
61
    /// anchor structure element (Writer)
62
    void const* const m_pAnchorStructureElementKey;
63
64
    /** used from getXControl() to create a local awt::XControl which is remembered in mxXControl
65
                and from thereon always used and returned by getXControl()
66
             */
67
    void createXControl();
68
69
    /// single local decompositions, used from create2DDecomposition()
70
    Primitive2DReference
71
    createBitmapDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
72
    Primitive2DReference createPlaceholderDecomposition() const;
73
74
    /// local decomposition
75
    virtual Primitive2DReference
76
    create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
77
78
public:
79
    /** constructor with an optional XControl as parameter to allow to hand it over at incarnation time
80
        if it exists. This will avoid to create a 2nd one on demand in createXControl()
81
        and thus double the XControls.
82
     */
83
    ControlPrimitive2D(basegfx::B2DHomMatrix aTransform,
84
                       css::uno::Reference<css::awt::XControlModel> xControlModel,
85
                       css::uno::Reference<css::awt::XControl> xXControl,
86
                       ::std::u16string_view rTitle, ::std::u16string_view rDescription,
87
                       void const* pAnchorKey);
88
89
    /// data read access
90
0
    const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
91
    const css::uno::Reference<css::awt::XControlModel>& getControlModel() const
92
0
    {
93
0
        return mxControlModel;
94
0
    }
95
96
    /// check if this control is visible as ChildWindow
97
    bool isVisibleAsChildWindow() const;
98
99
    /** mxControl access. This will on demand create the awt::XControl using createXControl()
100
        if it does not exist. It may already have been created or even handed over at
101
        incarnation
102
     */
103
    const css::uno::Reference<css::awt::XControl>& getXControl() const;
104
105
0
    OUString const& GetAltText() const { return m_AltText; }
106
107
0
    void const* GetAnchorStructureElementKey() const { return m_pAnchorStructureElementKey; }
108
109
    /// compare operator
110
    virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
111
112
    /// get range
113
    virtual basegfx::B2DRange
114
    getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
115
116
    /// provide unique ID
117
    virtual sal_uInt32 getPrimitive2DID() const override;
118
119
    /// Override standard getDecomposition to be view-dependent here
120
    virtual void
121
    get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
122
                       const geometry::ViewInformation2D& rViewInformation) const override;
123
};
124
125
} // end of namespace drawinglayer::primitive2d
126
127
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */