1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CONTROLPRIMITIVE2D_HXX 29 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CONTROLPRIMITIVE2D_HXX 30 31 #include <drawinglayer/drawinglayerdllapi.h> 32 #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 33 #include <basegfx/matrix/b2dhommatrix.hxx> 34 #include <com/sun/star/awt/XControlModel.hpp> 35 #include <com/sun/star/awt/XControl.hpp> 36 37 ////////////////////////////////////////////////////////////////////////////// 38 39 namespace drawinglayer 40 { 41 namespace primitive2d 42 { 43 /** ControlPrimitive2D class 44 45 Base class for ControlPrimitive handling. It decoposes to a 46 graphical representation (Bitmap data) of the control. This 47 representation is limited to a quadratic pixel maximum defined 48 in the applicatin settings. 49 */ 50 class DRAWINGLAYER_DLLPUBLIC ControlPrimitive2D : public BufferedDecompositionPrimitive2D 51 { 52 private: 53 /// object's base data 54 basegfx::B2DHomMatrix maTransform; 55 com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > mxControlModel; 56 57 /// the created an cached awt::XControl 58 com::sun::star::uno::Reference< com::sun::star::awt::XControl > mxXControl; 59 60 /// the last used scaling, used from getDecomposition for buffering 61 basegfx::B2DVector maLastViewScaling; 62 63 /** used from getXControl() to create a local awt::XControl which is remembered in mxXControl 64 and from thereon always used and returned by getXControl() 65 */ 66 void createXControl(); 67 68 /// single local decompositions, used from create2DDecomposition() 69 Primitive2DReference createBitmapDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 70 Primitive2DReference createPlaceholderDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 71 72 protected: 73 /// local decomposition 74 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 75 76 public: 77 /// constructor 78 ControlPrimitive2D( 79 const basegfx::B2DHomMatrix& rTransform, 80 const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& rxControlModel); 81 82 /** constructor with an additional XControl as parameter to allow to hand it over at incarnation time 83 if it exists. This will avoid to create a 2nd one on demand in createXControl() 84 and thus double the XControls. 85 */ 86 ControlPrimitive2D( 87 const basegfx::B2DHomMatrix& rTransform, 88 const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& rxControlModel, 89 const com::sun::star::uno::Reference< com::sun::star::awt::XControl >& rxXControl); 90 91 /// data read access 92 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } 93 const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& getControlModel() const { return mxControlModel; } 94 95 /** mxControl access. This will on demand create the awt::XControl using createXControl() 96 if it does not exist. It may already have been created or even handed over at 97 incarnation 98 */ 99 const com::sun::star::uno::Reference< com::sun::star::awt::XControl >& getXControl() const; 100 101 /// compare operator 102 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 103 104 /// get range 105 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; 106 107 /// provide unique ID 108 DeclPrimitrive2DIDBlock() 109 110 /// Overload standard getDecomposition call to be view-dependent here 111 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 112 }; 113 } // end of namespace primitive2d 114 } // end of namespace drawinglayer 115 116 ////////////////////////////////////////////////////////////////////////////// 117 118 #endif // INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CONTROLPRIMITIVE2D_HXX 119 120 ////////////////////////////////////////////////////////////////////////////// 121 // eof 122