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  : mpOverlayManager(nullptr),
87  maOffset(0.0, 0.0),
88  maBaseColor(aBaseColor),
89  mbIsVisible(true),
90  mbIsHittable(true),
91  mbAllowsAnimation(false),
92  mbAllowsAntiAliase(true)
93  {
94  }
95 
97  {
98  OSL_ENSURE(nullptr == getOverlayManager(), "OverlayObject is destructed which is still registered at OverlayManager (!)");
99  }
100 
102  {
103  if(getPrimitive2DSequence().empty())
104  {
105  // no existing sequence; create one
106  const_cast< OverlayObject* >(this)->maPrimitive2DSequence = const_cast< OverlayObject* >(this)->createOverlayObjectPrimitive2DSequence();
107 
108  if(!getOffset().equalZero())
109  {
110  // embed to offset transformation
111  const basegfx::B2DHomMatrix aTranslateGridOffset(
113  getOffset()));
116  aTranslateGridOffset,
117  std::move(const_cast<drawinglayer::primitive2d::Primitive2DContainer&>(maPrimitive2DSequence))));
118 
120  }
121  }
122 
123  return getPrimitive2DSequence();
124  }
125 
127  {
129  {
131 
132  if(!rSequence.empty())
133  {
134  const drawinglayer::geometry::ViewInformation2D & aViewInformation2D(getOverlayManager()->getCurrentViewInformation2D());
135 
136  const_cast< sdr::overlay::OverlayObject* >(this)->maBaseRange =
137  rSequence.getB2DRange(aViewInformation2D);
138  }
139  }
140 
141  return maBaseRange;
142  }
143 
145  {
146  if(bNew != mbIsVisible)
147  {
148  // remember new value
149  mbIsVisible = bNew;
150 
151  // register change (after change)
152  objectChange();
153  }
154  }
155 
157  {
158  if(bNew != mbIsHittable)
159  {
160  // remember new value
161  mbIsHittable = bNew;
162 
163  // register change (after change)
164  objectChange();
165  }
166  }
167 
169  {
170  if(aNew != maBaseColor)
171  {
172  // remember new value
173  maBaseColor = aNew;
174 
175  // register change (after change)
176  objectChange();
177  }
178  }
179 
181  {
182  if(rOffset != maOffset)
183  {
184  // remember new value
185  maOffset = rOffset;
186 
187  // register change (after change)
188  objectChange();
189  }
190  }
191 
192  void OverlayObject::Trigger(sal_uInt32 /*nTime*/)
193  {
194  // default does not register again
195  }
196 
198  {
199  // default does not need to do anything
200  }
201 
202 
204  : OverlayObject(aBaseColor),
205  maBasePosition(rBasePos)
206  {
207  }
208 
210  {
211  }
212 
214  {
215  if(rNew != maBasePosition)
216  {
217  // remember new value
218  maBasePosition = rNew;
219 
220  // register change (after change)
221  objectChange();
222  }
223  }
224 
225 } // end of namespace
226 
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setOffset(const basegfx::B2DVector &rOffset)
const drawinglayer::primitive2d::Primitive2DContainer & getPrimitive2DSequence() const
bool equalZero(const T &rfVal)
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)