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/primitive2d/baseprimitive2d.hxx> 32 #include <basegfx/matrix/b2dhommatrix.hxx> 33 #include <com/sun/star/awt/XControlModel.hpp> 34 #include <com/sun/star/awt/XControl.hpp> 35 36 ////////////////////////////////////////////////////////////////////////////// 37 38 namespace drawinglayer 39 { 40 namespace primitive2d 41 { 42 /** ControlPrimitive2D class 43 44 Base class for ControlPrimitive handling. It decoposes to a 45 graphical representation (Bitmap data) of the control. This 46 representation is limited to a quadratic pixel maximum defined 47 in the applicatin settings. 48 */ 49 class ControlPrimitive2D : public BufferedDecompositionPrimitive2D 50 { 51 private: 52 /// object's base data 53 basegfx::B2DHomMatrix maTransform; 54 com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > mxControlModel; 55 56 /// the created an cached awt::XControl 57 com::sun::star::uno::Reference< com::sun::star::awt::XControl > mxXControl; 58 59 /// the last used scaling, used from getDecomposition for buffering 60 basegfx::B2DVector maLastViewScaling; 61 62 /** used from getXControl() to create a local awt::XControl which is remembered in mxXControl 63 and from thereon always used and returned by getXControl() 64 */ 65 void createXControl(); 66 67 /// single local decompositions, used from create2DDecomposition() 68 Primitive2DReference createBitmapDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 69 Primitive2DReference createPlaceholderDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 70 71 protected: 72 /// local decomposition 73 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 74 75 public: 76 /// constructor 77 ControlPrimitive2D( 78 const basegfx::B2DHomMatrix& rTransform, 79 const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& rxControlModel); 80 81 /** constructor with an additional XControl as parameter to allow to hand it over at incarnation time 82 if it exists. This will avoid to create a 2nd one on demand in createXControl() 83 and thus double the XControls. 84 */ 85 ControlPrimitive2D( 86 const basegfx::B2DHomMatrix& rTransform, 87 const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& rxControlModel, 88 const com::sun::star::uno::Reference< com::sun::star::awt::XControl >& rxXControl); 89 90 /// data read access 91 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } 92 const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& getControlModel() const { return mxControlModel; } 93 94 /** mxControl access. This will on demand create the awt::XControl using createXControl() 95 if it does not exist. It may already have been created or even handed over at 96 incarnation 97 */ 98 const com::sun::star::uno::Reference< com::sun::star::awt::XControl >& getXControl() const; 99 100 /// compare operator 101 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 102 103 /// get range 104 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; 105 106 /// provide unique ID 107 DeclPrimitrive2DIDBlock() 108 109 /// Overload standard getDecomposition call to be view-dependent here 110 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 111 }; 112 } // end of namespace primitive2d 113 } // end of namespace drawinglayer 114 115 ////////////////////////////////////////////////////////////////////////////// 116 117 #endif // INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CONTROLPRIMITIVE2D_HXX 118 119 ////////////////////////////////////////////////////////////////////////////// 120 // eof 121