1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: overlayobject.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/overlay/overlayobject.hxx>
34 #include <svx/sdr/overlay/overlaymanager.hxx>
35 #include <tools/debug.hxx>
36 #include <basegfx/matrix/b2dhommatrix.hxx>
37 #include <basegfx/vector/b2dvector.hxx>
38 #include <vcl/outdev.hxx>
39 #include <vcl/salbtype.hxx>
40 #include <basegfx/polygon/b2dpolygon.hxx>
41 #include <basegfx/polygon/b2dpolypolygon.hxx>
42 #include <basegfx/polygon/b2dpolygontools.hxx>
43 #include <basegfx/polygon/b2dpolypolygontools.hxx>
44 #include <svx/sdr/contact/objectcontacttools.hxx>
45 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
47 //////////////////////////////////////////////////////////////////////////////
53 void OverlayObject::objectChange()
55 const basegfx::B2DRange
aPreviousRange(maBaseRange
);
57 setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DSequence());
59 if(getOverlayManager() && !aPreviousRange
.isEmpty())
61 getOverlayManager()->invalidateRange(aPreviousRange
);
64 const basegfx::B2DRange
& rCurrentRange
= getBaseRange();
66 if(getOverlayManager() && rCurrentRange
!= aPreviousRange
&& !rCurrentRange
.isEmpty())
68 getOverlayManager()->invalidateRange(rCurrentRange
);
72 // OverlayObject implementations.
73 drawinglayer::primitive2d::Primitive2DSequence
OverlayObject::createOverlayObjectPrimitive2DSequence()
75 // Default implementation has to assert a missing implementation. It cannot
76 // be useful to have overlay object derivations which have no visualisation
78 OSL_ENSURE(false, "OverlayObject derivation without visualisation definition (missing createOverlayObjectPrimitive2DSequence implementation) (!)");
79 return drawinglayer::primitive2d::Primitive2DSequence();
82 void OverlayObject::allowAntiAliase(bool bNew
)
84 if(bNew
!= (bool)mbAllowsAntiAliase
)
87 mbAllowsAntiAliase
= bNew
;
89 // register change (after change)
94 OverlayObject::OverlayObject(Color aBaseColor
)
97 maBaseColor(aBaseColor
),
100 mbAllowsAnimation(false),
101 mbAllowsAntiAliase(true)
105 OverlayObject::~OverlayObject()
107 OSL_ENSURE(0 == getOverlayManager(), "OverlayObject is destructed which is still registered at OverlayManager (!)");
110 drawinglayer::primitive2d::Primitive2DSequence
OverlayObject::getOverlayObjectPrimitive2DSequence() const
112 if(!getPrimitive2DSequence().hasElements())
114 // no existing sequence; create one
115 const_cast< OverlayObject
* >(this)->setPrimitive2DSequence(
116 const_cast< OverlayObject
* >(this)->createOverlayObjectPrimitive2DSequence());
119 return getPrimitive2DSequence();
122 const basegfx::B2DRange
& OverlayObject::getBaseRange() const
124 if(getOverlayManager() && maBaseRange
.isEmpty())
126 const drawinglayer::primitive2d::Primitive2DSequence
& rSequence
= getOverlayObjectPrimitive2DSequence();
128 if(rSequence
.hasElements())
130 const drawinglayer::geometry::ViewInformation2D
aViewInformation2D(getOverlayManager()->getCurrentViewInformation2D());
132 const_cast< sdr::overlay::OverlayObject
* >(this)->maBaseRange
=
133 drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(rSequence
, aViewInformation2D
);
140 void OverlayObject::setVisible(bool bNew
)
142 if(bNew
!= (bool)mbIsVisible
)
144 // remember new value
147 // register change (after change)
152 void OverlayObject::setHittable(bool bNew
)
154 if(bNew
!= (bool)mbIsHittable
)
156 // remember new value
159 // register change (after change)
164 void OverlayObject::setBaseColor(Color aNew
)
166 if(aNew
!= maBaseColor
)
168 // remember new value
171 // register change (after change)
176 void OverlayObject::Trigger(sal_uInt32
/*nTime*/)
178 // default does not register again
181 void OverlayObject::stripeDefinitionHasChanged()
183 // default does not need to do anything
185 } // end of namespace overlay
186 } // end of namespace sdr
188 //////////////////////////////////////////////////////////////////////////////
194 OverlayObjectWithBasePosition::OverlayObjectWithBasePosition(const basegfx::B2DPoint
& rBasePos
, Color aBaseColor
)
195 : OverlayObject(aBaseColor
),
196 maBasePosition(rBasePos
)
200 OverlayObjectWithBasePosition::~OverlayObjectWithBasePosition()
204 void OverlayObjectWithBasePosition::setBasePosition(const basegfx::B2DPoint
& rNew
)
206 if(rNew
!= maBasePosition
)
208 // remember new value
209 maBasePosition
= rNew
;
211 // register change (after change)
215 } // end of namespace overlay
216 } // end of namespace sdr
218 //////////////////////////////////////////////////////////////////////////////