fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / sdr / overlay / overlayobject.cxx
blobda15079b7f54320ea4035a47d15410c76892a036
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 //////////////////////////////////////////////////////////////////////////////
33 namespace sdr
35 namespace overlay
37 void OverlayObject::objectChange()
39 const basegfx::B2DRange aPreviousRange(maBaseRange);
40 maBaseRange.reset();
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
61 // at all
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)
70 // remember new value
71 mbAllowsAntiAliase = bNew;
73 // register change (after change)
74 objectChange();
78 OverlayObject::OverlayObject(Color aBaseColor)
79 : Event(0),
80 mpOverlayManager(0),
81 maBaseColor(aBaseColor),
82 mbIsVisible(true),
83 mbIsHittable(true),
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);
121 return maBaseRange;
124 void OverlayObject::setVisible(bool bNew)
126 if(bNew != (bool)mbIsVisible)
128 // remember new value
129 mbIsVisible = bNew;
131 // register change (after change)
132 objectChange();
136 void OverlayObject::setHittable(bool bNew)
138 if(bNew != (bool)mbIsHittable)
140 // remember new value
141 mbIsHittable = bNew;
143 // register change (after change)
144 objectChange();
148 void OverlayObject::setBaseColor(Color aNew)
150 if(aNew != maBaseColor)
152 // remember new value
153 maBaseColor = aNew;
155 // register change (after change)
156 objectChange();
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 //////////////////////////////////////////////////////////////////////////////
174 namespace sdr
176 namespace overlay
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)
196 objectChange();
199 } // end of namespace overlay
200 } // end of namespace sdr
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */