Branch libreoffice-6-3
[LibreOffice.git] / include / drawinglayer / primitive2d / controlprimitive2d.hxx
blobc568ada2eb64c62225681ea68d5ecacca8c2aa58
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 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CONTROLPRIMITIVE2D_HXX
21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CONTROLPRIMITIVE2D_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
25 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 #include <basegfx/matrix/b2dhommatrix.hxx>
28 namespace com::sun::star::awt { class XControl; }
29 namespace com::sun::star::awt { class XControlModel; }
32 namespace drawinglayer
34 namespace primitive2d
36 /** ControlPrimitive2D class
38 Base class for ControlPrimitive handling. It decomposes to a
39 graphical representation (Bitmap data) of the control. This
40 representation is limited to a quadratic pixel maximum defined
41 in the application settings.
43 class DRAWINGLAYER_DLLPUBLIC ControlPrimitive2D : public BufferedDecompositionPrimitive2D
45 private:
46 /// object's base data
47 basegfx::B2DHomMatrix maTransform;
48 css::uno::Reference< css::awt::XControlModel > mxControlModel;
50 /// the created an cached awt::XControl
51 css::uno::Reference< css::awt::XControl > mxXControl;
53 /// the last used scaling, used from getDecomposition for buffering
54 basegfx::B2DVector maLastViewScaling;
56 /** used from getXControl() to create a local awt::XControl which is remembered in mxXControl
57 and from thereon always used and returned by getXControl()
59 void createXControl();
61 /// single local decompositions, used from create2DDecomposition()
62 Primitive2DReference createBitmapDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
63 Primitive2DReference createPlaceholderDecomposition() const;
65 protected:
66 /// local decomposition
67 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override;
69 public:
70 /// constructor
71 ControlPrimitive2D(
72 const basegfx::B2DHomMatrix& rTransform,
73 const css::uno::Reference< css::awt::XControlModel >& rxControlModel);
75 /** constructor with an additional XControl as parameter to allow to hand it over at incarnation time
76 if it exists. This will avoid to create a 2nd one on demand in createXControl()
77 and thus double the XControls.
79 ControlPrimitive2D(
80 const basegfx::B2DHomMatrix& rTransform,
81 const css::uno::Reference< css::awt::XControlModel >& rxControlModel,
82 const css::uno::Reference< css::awt::XControl >& rxXControl);
84 /// data read access
85 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
86 const css::uno::Reference< css::awt::XControlModel >& getControlModel() const { return mxControlModel; }
88 /** mxControl access. This will on demand create the awt::XControl using createXControl()
89 if it does not exist. It may already have been created or even handed over at
90 incarnation
92 const css::uno::Reference< css::awt::XControl >& getXControl() const;
94 /// compare operator
95 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
97 /// get range
98 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
100 /// provide unique ID
101 DeclPrimitive2DIDBlock()
103 /// Override standard getDecomposition to be view-dependent here
104 virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
106 } // end of namespace primitive2d
107 } // end of namespace drawinglayer
110 #endif // INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CONTROLPRIMITIVE2D_HXX
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */