LibreOffice Module svx (master)  1
sdrtextattribute.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 
20 
23 #include <svx/svdotext.hxx>
24 #include <editeng/outlobj.hxx>
26 #include <rtl/instance.hxx>
27 
28 
30 {
32  {
33  public:
34  // all-text attributes. The SdrText itself and a copy
35  // of the OPO
37  std::shared_ptr<OutlinerParaObject> mxOutlinerParaObject;
38 
39  // Set when it's a FormText; contains all FormText attributes
41 
42  // text distances
43  sal_Int32 maTextLeftDistance;
47 
48  // #i101556# use versioning from text attributes to detect changes
49  sal_uInt32 maPropertiesVersion;
50 
51  // text alignments
54 
55  bool mbContour : 1;
56  bool mbFitToSize : 1;
57  bool mbAutoFit : 1;
58  bool mbHideContour : 1;
59  bool mbBlink : 1;
60  bool mbScroll : 1;
61  bool mbInEditMode : 1;
63  bool mbWrongSpell : 1;
64 
65  bool mbChainable : 1;
66 
67 
68  public:
70  const SdrText* pSdrText,
71  const OutlinerParaObject& rOutlinerParaObject,
72  XFormTextStyle eFormTextStyle,
73  sal_Int32 aTextLeftDistance,
74  sal_Int32 aTextUpperDistance,
75  sal_Int32 aTextRightDistance,
76  sal_Int32 aTextLowerDistance,
77  SdrTextHorzAdjust aSdrTextHorzAdjust,
78  SdrTextVertAdjust aSdrTextVertAdjust,
79  bool bContour,
80  bool bFitToSize,
81  bool bAutoFit,
82  bool bHideContour,
83  bool bBlink,
84  bool bScroll,
85  bool bInEditMode,
86  bool bFixedCellHeight,
87  bool bWrongSpell,
88  bool bChainable)
89  : mpSdrText(pSdrText),
90  mxOutlinerParaObject(std::make_shared<OutlinerParaObject>(rOutlinerParaObject)),
91  maTextLeftDistance(aTextLeftDistance),
92  maTextUpperDistance(aTextUpperDistance),
93  maTextRightDistance(aTextRightDistance),
94  maTextLowerDistance(aTextLowerDistance),
95  maPropertiesVersion(0),
96  maSdrTextHorzAdjust(aSdrTextHorzAdjust),
97  maSdrTextVertAdjust(aSdrTextVertAdjust),
98  mbContour(bContour),
99  mbFitToSize(bFitToSize),
100  mbAutoFit(bAutoFit),
101  mbHideContour(bHideContour),
102  mbBlink(bBlink),
103  mbScroll(bScroll),
104  mbInEditMode(bInEditMode),
105  mbFixedCellHeight(bFixedCellHeight),
106  mbWrongSpell(bWrongSpell),
107  mbChainable(bChainable)
108  {
109  if(!pSdrText)
110  return;
111 
112  if(XFormTextStyle::NONE != eFormTextStyle)
113  {
114  // text on path. Create FormText attribute
115  const SfxItemSet& rSet = pSdrText->GetItemSet();
116  maSdrFormTextAttribute = SdrFormTextAttribute(rSet);
117  }
118 
119  // #i101556# init with version number to detect changes of single text
120  // attribute and/or style sheets in primitive data without having to
121  // copy that data locally (which would be better from principle)
122  maPropertiesVersion = pSdrText->GetObject().GetProperties().getVersion();
123  }
124 
126  : mpSdrText(nullptr),
127  maTextLeftDistance(0),
128  maTextUpperDistance(0),
129  maTextRightDistance(0),
130  maTextLowerDistance(0),
131  maPropertiesVersion(0),
132  maSdrTextHorzAdjust(SDRTEXTHORZADJUST_LEFT),
133  maSdrTextVertAdjust(SDRTEXTVERTADJUST_TOP),
134  mbContour(false),
135  mbFitToSize(false),
136  mbAutoFit(false),
137  mbHideContour(false),
138  mbBlink(false),
139  mbScroll(false),
140  mbInEditMode(false),
141  mbFixedCellHeight(false),
142  mbWrongSpell(false),
143  mbChainable(false)
144  {
145  }
146 
147  // data read access
148  const SdrText& getSdrText() const
149  {
150  assert(mpSdrText && "Access to text of default version of ImpSdrTextAttribute (!)");
151  return *mpSdrText;
152  }
153 
155  {
156  assert(mxOutlinerParaObject && "Access to OutlinerParaObject of default version of ImpSdrTextAttribute (!)");
157  return *mxOutlinerParaObject;
158  }
159 
160  bool isContour() const { return mbContour; }
161  bool isFitToSize() const { return mbFitToSize; }
162  bool isAutoFit() const { return mbAutoFit; }
163  bool isHideContour() const { return mbHideContour; }
164  bool isBlink() const { return mbBlink; }
165  bool isScroll() const { return mbScroll; }
166  bool isInEditMode() const { return mbInEditMode; }
167  bool isFixedCellHeight() const { return mbFixedCellHeight; }
168  bool isChainable() const { return mbChainable; }
170  sal_Int32 getTextLeftDistance() const { return maTextLeftDistance; }
171  sal_Int32 getTextUpperDistance() const { return maTextUpperDistance; }
172  sal_Int32 getTextRightDistance() const { return maTextRightDistance; }
173  sal_Int32 getTextLowerDistance() const { return maTextLowerDistance; }
176 
177  // compare operator
178  bool operator==(const ImpSdrTextAttribute& rCandidate) const
179  {
180  if (mxOutlinerParaObject.get() != rCandidate.mxOutlinerParaObject.get())
181  {
182  if (mxOutlinerParaObject && rCandidate.mxOutlinerParaObject)
183  {
184  // compares OPO and it's contents, but traditionally not the RedLining
185  // which is not seen as model, but as temporary information
186  if(getOutlinerParaObject() != rCandidate.getOutlinerParaObject())
187  {
188  return false;
189  }
190 
191  // #i102062# for primitive visualisation, the WrongList (SpellChecking)
192  // is important, too, so use isWrongListEqual since there is no WrongList
193  // comparison in the regular OutlinerParaObject compare (since it's
194  // not-persistent data)
195  if(!(getOutlinerParaObject().isWrongListEqual(rCandidate.getOutlinerParaObject())))
196  {
197  return false;
198  }
199  }
200  else
201  {
202  // only one is zero; not equal
203  return false;
204  }
205  }
206 
207  return (
209  && getTextLeftDistance() == rCandidate.getTextLeftDistance()
210  && getTextUpperDistance() == rCandidate.getTextUpperDistance()
211  && getTextRightDistance() == rCandidate.getTextRightDistance()
212  && getTextLowerDistance() == rCandidate.getTextLowerDistance()
213  && maPropertiesVersion == rCandidate.maPropertiesVersion
214 
215  && getSdrTextHorzAdjust() == rCandidate.getSdrTextHorzAdjust()
216  && getSdrTextVertAdjust() == rCandidate.getSdrTextVertAdjust()
217 
218  && isContour() == rCandidate.isContour()
219  && isFitToSize() == rCandidate.isFitToSize()
220  && isAutoFit() == rCandidate.isAutoFit()
221  && isHideContour() == rCandidate.isHideContour()
222  && isBlink() == rCandidate.isBlink()
223  && isScroll() == rCandidate.isScroll()
224  && isInEditMode() == rCandidate.isInEditMode()
225  && isFixedCellHeight() == rCandidate.isFixedCellHeight()
226  && mbWrongSpell == rCandidate.mbWrongSpell );
227  }
228  };
229 
230  namespace
231  {
232  struct theGlobalDefault :
233  public rtl::Static< SdrTextAttribute::ImplType, theGlobalDefault > {};
234  }
235 
237  const SdrText& rSdrText,
238  const OutlinerParaObject& rOutlinerParaObject,
239  XFormTextStyle eFormTextStyle,
240  sal_Int32 aTextLeftDistance,
241  sal_Int32 aTextUpperDistance,
242  sal_Int32 aTextRightDistance,
243  sal_Int32 aTextLowerDistance,
244  SdrTextHorzAdjust aSdrTextHorzAdjust,
245  SdrTextVertAdjust aSdrTextVertAdjust,
246  bool bContour,
247  bool bFitToSize,
248  bool bAutoFit,
249  bool bHideContour,
250  bool bBlink,
251  bool bScroll,
252  bool bInEditMode,
253  bool bFixedCellHeight,
254  bool bWrongSpell,
255  bool bChainable)
256  : mpSdrTextAttribute(
258  &rSdrText, rOutlinerParaObject, eFormTextStyle, aTextLeftDistance,
259  aTextUpperDistance, aTextRightDistance, aTextLowerDistance,
260  aSdrTextHorzAdjust, aSdrTextVertAdjust, bContour, bFitToSize, bAutoFit,
261  bHideContour, bBlink, bScroll, bInEditMode, bFixedCellHeight, bWrongSpell,
262  bChainable))
263  {
264  }
265 
267  : mpSdrTextAttribute(theGlobalDefault::get())
268  {
269  }
270 
272  : mpSdrTextAttribute(rCandidate.mpSdrTextAttribute)
273  {
274  }
275 
277  : mpSdrTextAttribute(std::move(rCandidate.mpSdrTextAttribute))
278  {
279  }
280 
282  {
283  }
284 
286  {
287  return mpSdrTextAttribute.same_object(theGlobalDefault::get());
288  }
289 
291  {
293  return *this;
294  }
295 
297  {
298  mpSdrTextAttribute = std::move(rCandidate.mpSdrTextAttribute);
299  return *this;
300  }
301 
302  bool SdrTextAttribute::operator==(const SdrTextAttribute& rCandidate) const
303  {
304  // tdf#87509 default attr is always != non-default attr, even with same values
305  if(rCandidate.isDefault() != isDefault())
306  return false;
307 
308  return rCandidate.mpSdrTextAttribute == mpSdrTextAttribute;
309  }
310 
312  {
313  return mpSdrTextAttribute->getSdrText();
314  }
315 
317  {
318  return mpSdrTextAttribute->getOutlinerParaObject();
319  }
320 
322  {
323  return mpSdrTextAttribute->isContour();
324  }
325 
327  {
328  return mpSdrTextAttribute->isFitToSize();
329  }
330 
332  {
333  return mpSdrTextAttribute->isAutoFit();
334  }
335 
337  {
338  return mpSdrTextAttribute->isHideContour();
339  }
340 
342  {
343  return mpSdrTextAttribute->isBlink();
344  }
345 
347  {
348  return mpSdrTextAttribute->isScroll();
349  }
350 
352  {
353  return mpSdrTextAttribute->isInEditMode();
354  }
355 
357  {
358  return mpSdrTextAttribute->isChainable();
359  }
360 
361 
363  {
364  return mpSdrTextAttribute->isFixedCellHeight();
365  }
366 
368  {
369  return mpSdrTextAttribute->getSdrFormTextAttribute();
370  }
371 
373  {
374  return mpSdrTextAttribute->getTextLeftDistance();
375  }
376 
378  {
379  return mpSdrTextAttribute->getTextUpperDistance();
380  }
381 
383  {
384  return mpSdrTextAttribute->getTextRightDistance();
385  }
386 
388  {
389  return mpSdrTextAttribute->getTextLowerDistance();
390  }
391 
393  {
394  return mpSdrTextAttribute->getSdrTextHorzAdjust();
395  }
396 
398  {
399  return mpSdrTextAttribute->getSdrTextVertAdjust();
400  }
401 
403  {
404  if(isBlink())
405  {
407  }
408  }
409 
410  void SdrTextAttribute::getScrollTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList, double fFrameLength, double fTextLength) const
411  {
412  if(isScroll())
413  {
414  getSdrText().GetObject().impGetScrollTextTiming(rAnimList, fFrameLength, fTextLength);
415  }
416  }
417 
418 } // end of namespace
419 
420 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
const SfxItemSet & GetItemSet() const
Definition: svdtext.cxx:68
XFormTextStyle
Definition: xenum.hxx:24
const SdrFormTextAttribute & getSdrFormTextAttribute() const
void impGetScrollTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList, double fFrameLength, double fTextLength) const
SdrTextHorzAdjust
Definition: sdtaitm.hxx:53
const OutlinerParaObject & getOutlinerParaObject() const
std::shared_ptr< T > make_shared(Args &&...args)
virtual sdr::properties::BaseProperties & GetProperties() const
Definition: svdobj.cxx:210
void impGetBlinkTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList) const
bool operator==(const SdrTextAttribute &rCandidate) const
std::shared_ptr< OutlinerParaObject > mxOutlinerParaObject
SdrTextHorzAdjust getSdrTextHorzAdjust() const
const OutlinerParaObject & getOutlinerParaObject() const
void getScrollTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList, double fFrameLength, double fTextLength) const
SdrTextObj & GetObject() const
Definition: svdtext.hxx:66
bool same_object(const cow_wrapper &rOther) const
SdrTextAttribute & operator=(const SdrTextAttribute &rCandidate)
bool operator==(const ImpSdrTextAttribute &rCandidate) const
void getBlinkTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList) const
ImpSdrTextAttribute(const SdrText *pSdrText, const OutlinerParaObject &rOutlinerParaObject, XFormTextStyle eFormTextStyle, sal_Int32 aTextLeftDistance, sal_Int32 aTextUpperDistance, sal_Int32 aTextRightDistance, sal_Int32 aTextLowerDistance, SdrTextHorzAdjust aSdrTextHorzAdjust, SdrTextVertAdjust aSdrTextVertAdjust, bool bContour, bool bFitToSize, bool bAutoFit, bool bHideContour, bool bBlink, bool bScroll, bool bInEditMode, bool bFixedCellHeight, bool bWrongSpell, bool bChainable)
const SdrFormTextAttribute & getSdrFormTextAttribute() const
SdrTextVertAdjust getSdrTextVertAdjust() const
virtual sal_uInt32 getVersion() const
Definition: properties.cxx:151
SdrTextVertAdjust
Definition: sdtaitm.hxx:29