Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / drawinglayer / primitive2d / controlprimitive2d.hxx
blob9bd3783e07a9bd9bbee443fe1dc845bcb2c5b65b
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>
27 #include <com/sun/star/awt/XControlModel.hpp>
28 #include <com/sun/star/awt/XControl.hpp>
31 namespace drawinglayer
33 namespace primitive2d
35 /** ControlPrimitive2D class
37 Base class for ControlPrimitive handling. It decomposes to a
38 graphical representation (Bitmap data) of the control. This
39 representation is limited to a quadratic pixel maximum defined
40 in the application settings.
42 class DRAWINGLAYER_DLLPUBLIC ControlPrimitive2D : public BufferedDecompositionPrimitive2D
44 private:
45 /// object's base data
46 basegfx::B2DHomMatrix maTransform;
47 css::uno::Reference< css::awt::XControlModel > mxControlModel;
49 /// the created an cached awt::XControl
50 css::uno::Reference< css::awt::XControl > mxXControl;
52 /// the last used scaling, used from getDecomposition for buffering
53 basegfx::B2DVector maLastViewScaling;
55 /** used from getXControl() to create a local awt::XControl which is remembered in mxXControl
56 and from thereon always used and returned by getXControl()
58 void createXControl();
60 /// single local decompositions, used from create2DDecomposition()
61 Primitive2DReference createBitmapDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
62 Primitive2DReference createPlaceholderDecomposition() const;
64 protected:
65 /// local decomposition
66 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override;
68 public:
69 /// constructor
70 ControlPrimitive2D(
71 const basegfx::B2DHomMatrix& rTransform,
72 const css::uno::Reference< css::awt::XControlModel >& rxControlModel);
74 /** constructor with an additional XControl as parameter to allow to hand it over at incarnation time
75 if it exists. This will avoid to create a 2nd one on demand in createXControl()
76 and thus double the XControls.
78 ControlPrimitive2D(
79 const basegfx::B2DHomMatrix& rTransform,
80 const css::uno::Reference< css::awt::XControlModel >& rxControlModel,
81 const css::uno::Reference< css::awt::XControl >& rxXControl);
83 /// data read access
84 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
85 const css::uno::Reference< css::awt::XControlModel >& getControlModel() const { return mxControlModel; }
87 /** mxControl access. This will on demand create the awt::XControl using createXControl()
88 if it does not exist. It may already have been created or even handed over at
89 incarnation
91 const css::uno::Reference< css::awt::XControl >& getXControl() const;
93 /// compare operator
94 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
96 /// get range
97 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
99 /// provide unique ID
100 DeclPrimitive2DIDBlock()
102 /// Override standard getDecomposition to be view-dependent here
103 virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
105 } // end of namespace primitive2d
106 } // end of namespace drawinglayer
109 #endif // INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CONTROLPRIMITIVE2D_HXX
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */