LibreOffice Module svx (master) 1
overlayobject.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
26#include <osl/diagnose.h>
27
28namespace sdr::overlay
29{
31 {
32 const basegfx::B2DRange aPreviousRange(maBaseRange);
35// setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DContainer());
36
37 if(getOverlayManager() && !aPreviousRange.isEmpty())
38 {
39 getOverlayManager()->invalidateRange(aPreviousRange);
40 }
41
42 const basegfx::B2DRange& rCurrentRange = getBaseRange();
43
44 if(getOverlayManager() && rCurrentRange != aPreviousRange && !rCurrentRange.isEmpty())
45 {
46 getOverlayManager()->invalidateRange(rCurrentRange);
47 }
48 }
49
50 // OverlayObject implementations.
52 {
53 // Default implementation has to assert a missing implementation. It cannot
54 // be useful to have overlay object derivations which have no visualisation
55 // at all
56 OSL_FAIL("OverlayObject derivation without visualisation definition (missing createOverlayObjectPrimitive2DSequence implementation) (!)");
58 }
59
60 sal_uInt32 OverlayObject::impCheckBlinkTimeValueRange(sal_uInt64 nBlinkTime)
61 {
62 if(nBlinkTime < 25)
63 {
64 nBlinkTime = 25;
65 }
66 else if(nBlinkTime > 10000)
67 {
68 nBlinkTime = 10000;
69 }
70
71 return nBlinkTime;
72 }
73
75 {
76 if(bNew != mbAllowsAntiAliase)
77 {
78 // remember new value
79 mbAllowsAntiAliase = bNew;
80
81 // register change (after change)
83 }
84 }
85
87 : mpOverlayManager(nullptr),
88 maOffset(0.0, 0.0),
89 maBaseColor(aBaseColor),
90 mbIsVisible(true),
91 mbIsHittable(true),
92 mbAllowsAnimation(false),
93 mbAllowsAntiAliase(true),
94 mbHighContrastSelection(false)
95 {
96 }
97
99 {
100 OSL_ENSURE(nullptr == getOverlayManager(), "OverlayObject is destructed which is still registered at OverlayManager (!)");
101 }
102
104 {
105 if(getPrimitive2DSequence().empty())
106 {
107 // no existing sequence; create one
108 const_cast< OverlayObject* >(this)->maPrimitive2DSequence = const_cast< OverlayObject* >(this)->createOverlayObjectPrimitive2DSequence();
109
110 if(!getOffset().equalZero())
111 {
112 // embed to offset transformation
113 const basegfx::B2DHomMatrix aTranslateGridOffset(
115 getOffset()));
118 aTranslateGridOffset,
120
122 }
123 }
124
125 return getPrimitive2DSequence();
126 }
127
129 {
131 {
133
134 if(!rSequence.empty())
135 {
136 const drawinglayer::geometry::ViewInformation2D & aViewInformation2D(getOverlayManager()->getCurrentViewInformation2D());
137
138 const_cast< sdr::overlay::OverlayObject* >(this)->maBaseRange =
139 rSequence.getB2DRange(aViewInformation2D);
140 }
141 }
142
143 return maBaseRange;
144 }
145
147 {
148 if(bNew != mbIsVisible)
149 {
150 // remember new value
151 mbIsVisible = bNew;
152
153 // register change (after change)
154 objectChange();
155 }
156 }
157
159 {
160 if(bNew != mbIsHittable)
161 {
162 // remember new value
163 mbIsHittable = bNew;
164
165 // register change (after change)
166 objectChange();
167 }
168 }
169
171 {
172 if(aNew != maBaseColor)
173 {
174 // remember new value
175 maBaseColor = aNew;
176
177 // register change (after change)
178 objectChange();
179 }
180 }
181
183 {
184 if(rOffset != maOffset)
185 {
186 // remember new value
187 maOffset = rOffset;
188
189 // register change (after change)
190 objectChange();
191 }
192 }
193
194 void OverlayObject::Trigger(sal_uInt32 /*nTime*/)
195 {
196 // default does not register again
197 }
198
200 {
201 // default does not need to do anything
202 }
203
204
206 : OverlayObject(aBaseColor),
207 maBasePosition(rBasePos)
208 {
209 }
210
212 {
213 }
214
216 {
217 if(rNew != maBasePosition)
218 {
219 // remember new value
220 maBasePosition = rNew;
221
222 // register change (after change)
223 objectChange();
224 }
225 }
226
227} // end of namespace
228
229/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::B2DPoint maBasePosition
bool isEmpty() const
bool equalZero() const
basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &aViewInformation) const
virtual void invalidateRange(const basegfx::B2DRange &rRange)
void setBasePosition(const basegfx::B2DPoint &rNew)
OverlayObjectWithBasePosition(const basegfx::B2DPoint &rBasePos, Color aBaseColor)
drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence
const basegfx::B2DVector & getOffset() const
virtual drawinglayer::primitive2d::Primitive2DContainer createOverlayObjectPrimitive2DSequence()
const basegfx::B2DRange & getBaseRange() const
basegfx::B2DRange maBaseRange
void allowAntiAliase(bool bNew)
OverlayManager * getOverlayManager() const
void setOffset(const basegfx::B2DVector &rOffset)
virtual void Trigger(sal_uInt32 nTime) override
virtual void stripeDefinitionHasChanged()
static sal_uInt32 impCheckBlinkTimeValueRange(sal_uInt64 nBlinkTime)
basegfx::B2DVector maOffset
const drawinglayer::primitive2d::Primitive2DContainer & getPrimitive2DSequence() const
virtual drawinglayer::primitive2d::Primitive2DContainer getOverlayObjectPrimitive2DSequence() const
OverlayObject(const OverlayObject &)=delete
virtual ~OverlayObject() override
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)