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>
31 //////////////////////////////////////////////////////////////////////////////
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 void OverlayObject::allowAntiAliase(bool bNew
)
68 if(bNew
!= (bool)mbAllowsAntiAliase
)
71 mbAllowsAntiAliase
= bNew
;
73 // register change (after change)
78 OverlayObject::OverlayObject(Color aBaseColor
)
81 maBaseColor(aBaseColor
),
84 mbAllowsAnimation(false),
85 mbAllowsAntiAliase(true)
89 OverlayObject::~OverlayObject()
91 OSL_ENSURE(0 == getOverlayManager(), "OverlayObject is destructed which is still registered at OverlayManager (!)");
94 drawinglayer::primitive2d::Primitive2DSequence
OverlayObject::getOverlayObjectPrimitive2DSequence() const
96 if(!getPrimitive2DSequence().hasElements())
98 // no existing sequence; create one
99 const_cast< OverlayObject
* >(this)->setPrimitive2DSequence(
100 const_cast< OverlayObject
* >(this)->createOverlayObjectPrimitive2DSequence());
103 return getPrimitive2DSequence();
106 const basegfx::B2DRange
& OverlayObject::getBaseRange() const
108 if(getOverlayManager() && maBaseRange
.isEmpty())
110 const drawinglayer::primitive2d::Primitive2DSequence
& rSequence
= getOverlayObjectPrimitive2DSequence();
112 if(rSequence
.hasElements())
114 const drawinglayer::geometry::ViewInformation2D
aViewInformation2D(getOverlayManager()->getCurrentViewInformation2D());
116 const_cast< sdr::overlay::OverlayObject
* >(this)->maBaseRange
=
117 drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(rSequence
, aViewInformation2D
);
124 void OverlayObject::setVisible(bool bNew
)
126 if(bNew
!= (bool)mbIsVisible
)
128 // remember new value
131 // register change (after change)
136 void OverlayObject::setHittable(bool bNew
)
138 if(bNew
!= (bool)mbIsHittable
)
140 // remember new value
143 // register change (after change)
148 void OverlayObject::setBaseColor(Color aNew
)
150 if(aNew
!= maBaseColor
)
152 // remember new value
155 // register change (after change)
160 void OverlayObject::Trigger(sal_uInt32
/*nTime*/)
162 // default does not register again
165 void OverlayObject::stripeDefinitionHasChanged()
167 // default does not need to do anything
169 } // end of namespace overlay
170 } // end of namespace sdr
172 //////////////////////////////////////////////////////////////////////////////
178 OverlayObjectWithBasePosition::OverlayObjectWithBasePosition(const basegfx::B2DPoint
& rBasePos
, Color aBaseColor
)
179 : OverlayObject(aBaseColor
),
180 maBasePosition(rBasePos
)
184 OverlayObjectWithBasePosition::~OverlayObjectWithBasePosition()
188 void OverlayObjectWithBasePosition::setBasePosition(const basegfx::B2DPoint
& rNew
)
190 if(rNew
!= maBasePosition
)
192 // remember new value
193 maBasePosition
= rNew
;
195 // register change (after change)
199 } // end of namespace overlay
200 } // end of namespace sdr
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */