1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: backgroundcolorprimitive2d.cxx,v $
9 * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
40 #include <basegfx/polygon/b2dpolygon.hxx>
41 #include <basegfx/polygon/b2dpolygontools.hxx>
42 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
43 #include <basegfx/tools/canvastools.hxx>
44 #include <drawinglayer/geometry/viewinformation2d.hxx>
45 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
47 //////////////////////////////////////////////////////////////////////////////
49 using namespace com::sun::star
;
51 //////////////////////////////////////////////////////////////////////////////
53 namespace drawinglayer
57 Primitive2DSequence
BackgroundColorPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D
& rViewInformation
) const
59 if(!rViewInformation
.getViewport().isEmpty())
61 const basegfx::B2DPolygon
aOutline(basegfx::tools::createPolygonFromRect(rViewInformation
.getViewport()));
62 const Primitive2DReference
xRef(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline
), getBColor()));
63 return Primitive2DSequence(&xRef
, 1L);
67 return Primitive2DSequence();
71 BackgroundColorPrimitive2D::BackgroundColorPrimitive2D(
72 const basegfx::BColor
& rBColor
)
79 bool BackgroundColorPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
81 if(BasePrimitive2D::operator==(rPrimitive
))
83 const BackgroundColorPrimitive2D
& rCompare
= (BackgroundColorPrimitive2D
&)rPrimitive
;
85 return (getBColor() == rCompare
.getBColor());
91 basegfx::B2DRange
BackgroundColorPrimitive2D::getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const
93 // always as big as the view
94 return rViewInformation
.getViewport();
97 Primitive2DSequence
BackgroundColorPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D
& rViewInformation
) const
99 ::osl::MutexGuard
aGuard( m_aMutex
);
101 if(getLocalDecomposition().hasElements() && (maLastViewport
!= rViewInformation
.getViewport()))
103 // conditions of last local decomposition have changed, delete
104 const_cast< BackgroundColorPrimitive2D
* >(this)->setLocalDecomposition(Primitive2DSequence());
107 if(!getLocalDecomposition().hasElements())
109 // remember ViewRange
110 const_cast< BackgroundColorPrimitive2D
* >(this)->maLastViewport
= rViewInformation
.getViewport();
113 // use parent implementation
114 return BasePrimitive2D::get2DDecomposition(rViewInformation
);
118 ImplPrimitrive2DIDBlock(BackgroundColorPrimitive2D
, PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D
)
120 } // end of namespace primitive2d
121 } // end of namespace drawinglayer
123 //////////////////////////////////////////////////////////////////////////////