Update git submodules
[LibreOffice.git] / include / drawinglayer / primitive2d / controlprimitive2d.hxx
blob19226797d659ee648a1f338eb562429bb0faf389
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <drawinglayer/drawinglayerdllapi.h>
24 #include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx>
25 #include <basegfx/matrix/b2dhommatrix.hxx>
27 namespace com::sun::star::awt
29 class XControl;
31 namespace com::sun::star::awt
33 class XControlModel;
36 namespace drawinglayer::primitive2d
38 /** ControlPrimitive2D class
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.
45 class DRAWINGLAYER_DLLPUBLIC ControlPrimitive2D final : public BufferedDecompositionPrimitive2D
47 private:
48 /// object's base data
49 basegfx::B2DHomMatrix maTransform;
50 css::uno::Reference<css::awt::XControlModel> mxControlModel;
52 /// the created and cached awt::XControl
53 css::uno::Reference<css::awt::XControl> mxXControl;
55 /// the last used scaling, used from getDecomposition for buffering
56 basegfx::B2DVector maLastViewScaling;
58 /// yet another special snowflake way to generate PDF Alt text
59 OUString m_AltText;
61 /// anchor structure element (Writer)
62 void const* const m_pAnchorStructureElementKey;
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()
67 void createXControl();
69 /// single local decompositions, used from create2DDecomposition()
70 Primitive2DReference
71 createBitmapDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
72 Primitive2DReference createPlaceholderDecomposition() const;
74 /// local decomposition
75 virtual Primitive2DReference
76 create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
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.
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);
89 /// data read access
90 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
91 const css::uno::Reference<css::awt::XControlModel>& getControlModel() const
93 return mxControlModel;
96 /// check if this control is visible as ChildWindow
97 bool isVisibleAsChildWindow() const;
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
103 const css::uno::Reference<css::awt::XControl>& getXControl() const;
105 OUString const& GetAltText() const { return m_AltText; }
107 void const* GetAnchorStructureElementKey() const { return m_pAnchorStructureElementKey; }
109 /// compare operator
110 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
112 /// get range
113 virtual basegfx::B2DRange
114 getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
116 /// provide unique ID
117 virtual sal_uInt32 getPrimitive2DID() const override;
119 /// Override standard getDecomposition to be view-dependent here
120 virtual void
121 get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
122 const geometry::ViewInformation2D& rViewInformation) const override;
125 } // end of namespace drawinglayer::primitive2d
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */