tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / include / drawinglayer / primitive2d / controlprimitive2d.hxx
blobe33c26886cd9c644bd706b85f21efdc743aaaf1f
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 /** used from getXControl() to create a local awt::XControl which is remembered in mxXControl
62 and from thereon always used and returned by getXControl()
64 void createXControl();
66 /// single local decompositions, used from create2DDecomposition()
67 Primitive2DReference
68 createBitmapDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
69 Primitive2DReference createPlaceholderDecomposition() const;
71 /// local decomposition
72 virtual void
73 create2DDecomposition(Primitive2DContainer& rContainer,
74 const geometry::ViewInformation2D& rViewInformation) const override;
76 public:
77 /** constructor with an optional XControl as parameter to allow to hand it over at incarnation time
78 if it exists. This will avoid to create a 2nd one on demand in createXControl()
79 and thus double the XControls.
81 ControlPrimitive2D(basegfx::B2DHomMatrix aTransform,
82 css::uno::Reference<css::awt::XControlModel> xControlModel,
83 css::uno::Reference<css::awt::XControl> xXControl,
84 ::std::u16string_view rTitle, ::std::u16string_view rDescription);
86 /// data read access
87 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
88 const css::uno::Reference<css::awt::XControlModel>& getControlModel() const
90 return mxControlModel;
93 /** mxControl access. This will on demand create the awt::XControl using createXControl()
94 if it does not exist. It may already have been created or even handed over at
95 incarnation
97 const css::uno::Reference<css::awt::XControl>& getXControl() const;
99 OUString const& GetAltText() const { return m_AltText; }
101 /// compare operator
102 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
104 /// get range
105 virtual basegfx::B2DRange
106 getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
108 /// provide unique ID
109 virtual sal_uInt32 getPrimitive2DID() const override;
111 /// Override standard getDecomposition to be view-dependent here
112 virtual void
113 get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
114 const geometry::ViewInformation2D& rViewInformation) const override;
117 } // end of namespace drawinglayer::primitive2d
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */