1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <drawinglayer/drawinglayerdllapi.h>
24 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
25 #include <basegfx/matrix/b2dhommatrix.hxx>
27 namespace com::sun::star::awt
31 namespace com::sun::star::awt
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
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 /** used from getXControl() to create a local awt::XControl which is remembered in mxXControl
59 and from thereon always used and returned by getXControl()
61 void createXControl();
63 /// single local decompositions, used from create2DDecomposition()
65 createBitmapDecomposition(const geometry::ViewInformation2D
& rViewInformation
) const;
66 Primitive2DReference
createPlaceholderDecomposition() const;
68 /// local decomposition
70 create2DDecomposition(Primitive2DContainer
& rContainer
,
71 const geometry::ViewInformation2D
& rViewInformation
) const override
;
75 ControlPrimitive2D(const basegfx::B2DHomMatrix
& rTransform
,
76 const css::uno::Reference
<css::awt::XControlModel
>& rxControlModel
);
78 /** constructor with an additional XControl as parameter to allow to hand it over at incarnation time
79 if it exists. This will avoid to create a 2nd one on demand in createXControl()
80 and thus double the XControls.
82 ControlPrimitive2D(const basegfx::B2DHomMatrix
& rTransform
,
83 const css::uno::Reference
<css::awt::XControlModel
>& rxControlModel
,
84 const css::uno::Reference
<css::awt::XControl
>& rxXControl
);
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
97 const css::uno::Reference
<css::awt::XControl
>& getXControl() const;
100 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
103 virtual basegfx::B2DRange
104 getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
106 /// provide unique ID
107 virtual sal_uInt32
getPrimitive2DID() const override
;
109 /// Override standard getDecomposition to be view-dependent here
111 get2DDecomposition(Primitive2DDecompositionVisitor
& rVisitor
,
112 const geometry::ViewInformation2D
& rViewInformation
) const override
;
115 } // end of namespace drawinglayer::primitive2d
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */