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