1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include <svx/sdr/overlay/overlayobject.hxx>
21 #include <svx/sdr/overlay/overlaymanager.hxx>
22 #include <basegfx/matrix/b2dhommatrix.hxx>
23 #include <basegfx/vector/b2dvector.hxx>
24 #include <vcl/outdev.hxx>
25 #include <basegfx/polygon/b2dpolygon.hxx>
26 #include <basegfx/polygon/b2dpolypolygon.hxx>
27 #include <basegfx/polygon/b2dpolygontools.hxx>
28 #include <basegfx/polygon/b2dpolypolygontools.hxx>
29 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
37 void OverlayObject::objectChange()
39 const basegfx::B2DRange
aPreviousRange(maBaseRange
);
41 setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DSequence());
43 if(getOverlayManager() && !aPreviousRange
.isEmpty())
45 getOverlayManager()->invalidateRange(aPreviousRange
);
48 const basegfx::B2DRange
& rCurrentRange
= getBaseRange();
50 if(getOverlayManager() && rCurrentRange
!= aPreviousRange
&& !rCurrentRange
.isEmpty())
52 getOverlayManager()->invalidateRange(rCurrentRange
);
56 // OverlayObject implementations.
57 drawinglayer::primitive2d::Primitive2DSequence
OverlayObject::createOverlayObjectPrimitive2DSequence()
59 // Default implementation has to assert a missing implementation. It cannot
60 // be useful to have overlay object derivations which have no visualisation
62 OSL_FAIL("OverlayObject derivation without visualisation definition (missing createOverlayObjectPrimitive2DSequence implementation) (!)");
63 return drawinglayer::primitive2d::Primitive2DSequence();
66 sal_uInt32
OverlayObject::impCheckBlinkTimeValueRange(sal_uInt64 nBlinkTime
)
72 else if(nBlinkTime
> 10000)
80 void OverlayObject::allowAntiAliase(bool bNew
)
82 if(bNew
!= (bool)mbAllowsAntiAliase
)
85 mbAllowsAntiAliase
= bNew
;
87 // register change (after change)
92 OverlayObject::OverlayObject(Color aBaseColor
)
95 maBaseColor(aBaseColor
),
98 mbAllowsAnimation(false),
99 mbAllowsAntiAliase(true)
103 OverlayObject::~OverlayObject()
105 OSL_ENSURE(0 == getOverlayManager(), "OverlayObject is destructed which is still registered at OverlayManager (!)");
108 drawinglayer::primitive2d::Primitive2DSequence
OverlayObject::getOverlayObjectPrimitive2DSequence() const
110 if(!getPrimitive2DSequence().hasElements())
112 // no existing sequence; create one
113 const_cast< OverlayObject
* >(this)->setPrimitive2DSequence(
114 const_cast< OverlayObject
* >(this)->createOverlayObjectPrimitive2DSequence());
117 return getPrimitive2DSequence();
120 const basegfx::B2DRange
& OverlayObject::getBaseRange() const
122 if(getOverlayManager() && maBaseRange
.isEmpty())
124 const drawinglayer::primitive2d::Primitive2DSequence
& rSequence
= getOverlayObjectPrimitive2DSequence();
126 if(rSequence
.hasElements())
128 const drawinglayer::geometry::ViewInformation2D
aViewInformation2D(getOverlayManager()->getCurrentViewInformation2D());
130 const_cast< sdr::overlay::OverlayObject
* >(this)->maBaseRange
=
131 drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(rSequence
, aViewInformation2D
);
138 void OverlayObject::setVisible(bool bNew
)
140 if(bNew
!= (bool)mbIsVisible
)
142 // remember new value
145 // register change (after change)
150 void OverlayObject::setHittable(bool bNew
)
152 if(bNew
!= (bool)mbIsHittable
)
154 // remember new value
157 // register change (after change)
162 void OverlayObject::setBaseColor(Color aNew
)
164 if(aNew
!= maBaseColor
)
166 // remember new value
169 // register change (after change)
174 void OverlayObject::Trigger(sal_uInt32
/*nTime*/)
176 // default does not register again
179 void OverlayObject::stripeDefinitionHasChanged()
181 // default does not need to do anything
183 } // end of namespace overlay
184 } // end of namespace sdr
192 OverlayObjectWithBasePosition::OverlayObjectWithBasePosition(const basegfx::B2DPoint
& rBasePos
, Color aBaseColor
)
193 : OverlayObject(aBaseColor
),
194 maBasePosition(rBasePos
)
198 OverlayObjectWithBasePosition::~OverlayObjectWithBasePosition()
202 void OverlayObjectWithBasePosition::setBasePosition(const basegfx::B2DPoint
& rNew
)
204 if(rNew
!= maBasePosition
)
206 // remember new value
207 maBasePosition
= rNew
;
209 // register change (after change)
213 } // end of namespace overlay
214 } // end of namespace sdr
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */