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 
27 namespace sdr::overlay
28 {
30  {
31  const basegfx::B2DRange aPreviousRange(maBaseRange);
34 // setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DContainer());
35 
36  if(getOverlayManager() && !aPreviousRange.isEmpty())
37  {
38  getOverlayManager()->invalidateRange(aPreviousRange);
39  }
40 
41  const basegfx::B2DRange& rCurrentRange = getBaseRange();
42 
43  if(getOverlayManager() && rCurrentRange != aPreviousRange && !rCurrentRange.isEmpty())
44  {
45  getOverlayManager()->invalidateRange(rCurrentRange);
46  }
47  }
48 
49  // OverlayObject implementations.
51  {
52  // Default implementation has to assert a missing implementation. It cannot
53  // be useful to have overlay object derivations which have no visualisation
54  // at all
55  OSL_FAIL("OverlayObject derivation without visualisation definition (missing createOverlayObjectPrimitive2DSequence implementation) (!)");
57  }
58 
59  sal_uInt32 OverlayObject::impCheckBlinkTimeValueRange(sal_uInt64 nBlinkTime)
60  {
61  if(nBlinkTime < 25)
62  {
63  nBlinkTime = 25;
64  }
65  else if(nBlinkTime > 10000)
66  {
67  nBlinkTime = 10000;
68  }
69 
70  return nBlinkTime;
71  }
72 
74  {
75  if(bNew != mbAllowsAntiAliase)
76  {
77  // remember new value
78  mbAllowsAntiAliase = bNew;
79 
80  // register change (after change)
81  objectChange();
82  }
83  }
84 
86  : Event(),
87  mpOverlayManager(nullptr),
88  maPrimitive2DSequence(),
89  maOffset(0.0, 0.0),
90  maBaseColor(aBaseColor),
91  mbIsVisible(true),
92  mbIsHittable(true),
93  mbAllowsAnimation(false),
94  mbAllowsAntiAliase(true)
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: */
void setOffset(const basegfx::B2DVector &rOffset)
const drawinglayer::primitive2d::Primitive2DContainer & getPrimitive2DSequence() const
virtual void stripeDefinitionHasChanged()
OverlayManager * getOverlayManager() const
const basegfx::B2DRange & getBaseRange() const
virtual ~OverlayObject() override
bool isEmpty() const
OverlayObject(const OverlayObject &)=delete
static sal_uInt32 impCheckBlinkTimeValueRange(sal_uInt64 nBlinkTime)
OverlayObjectWithBasePosition(const basegfx::B2DPoint &rBasePos, Color aBaseColor)
basegfx::B2DRange maBaseRange
virtual drawinglayer::primitive2d::Primitive2DContainer getOverlayObjectPrimitive2DSequence() const
void allowAntiAliase(bool bNew)
virtual drawinglayer::primitive2d::Primitive2DContainer createOverlayObjectPrimitive2DSequence()
virtual void Trigger(sal_uInt32 nTime) override
css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference
drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence
void setBasePosition(const basegfx::B2DPoint &rNew)
const basegfx::B2DVector & getOffset() const
basegfx::B2DVector maOffset
basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &aViewInformation) const
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
basegfx::B2DPoint maBasePosition
virtual void invalidateRange(const basegfx::B2DRange &rRange)