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  maSdrFormTextAttribute(),
92  maTextLeftDistance(aTextLeftDistance),
93  maTextUpperDistance(aTextUpperDistance),
94  maTextRightDistance(aTextRightDistance),
95  maTextLowerDistance(aTextLowerDistance),
96  maPropertiesVersion(0),
97  maSdrTextHorzAdjust(aSdrTextHorzAdjust),
98  maSdrTextVertAdjust(aSdrTextVertAdjust),
99  mbContour(bContour),
100  mbFitToSize(bFitToSize),
101  mbAutoFit(bAutoFit),
102  mbHideContour(bHideContour),
103  mbBlink(bBlink),
104  mbScroll(bScroll),
105  mbInEditMode(bInEditMode),
106  mbFixedCellHeight(bFixedCellHeight),
107  mbWrongSpell(bWrongSpell),
108  mbChainable(bChainable)
109  {
110  if(pSdrText)
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  }
125 
127  : mpSdrText(nullptr),
128  maSdrFormTextAttribute(),
129  maTextLeftDistance(0),
130  maTextUpperDistance(0),
131  maTextRightDistance(0),
132  maTextLowerDistance(0),
133  maPropertiesVersion(0),
134  maSdrTextHorzAdjust(SDRTEXTHORZADJUST_LEFT),
135  maSdrTextVertAdjust(SDRTEXTVERTADJUST_TOP),
136  mbContour(false),
137  mbFitToSize(false),
138  mbAutoFit(false),
139  mbHideContour(false),
140  mbBlink(false),
141  mbScroll(false),
142  mbInEditMode(false),
143  mbFixedCellHeight(false),
144  mbWrongSpell(false),
145  mbChainable(false)
146  {
147  }
148 
149  // data read access
150  const SdrText& getSdrText() const
151  {
152  assert(mpSdrText && "Access to text of default version of ImpSdrTextAttribute (!)");
153  return *mpSdrText;
154  }
155 
157  {
158  assert(mxOutlinerParaObject && "Access to OutlinerParaObject of default version of ImpSdrTextAttribute (!)");
159  return *mxOutlinerParaObject;
160  }
161 
162  bool isContour() const { return mbContour; }
163  bool isFitToSize() const { return mbFitToSize; }
164  bool isAutoFit() const { return mbAutoFit; }
165  bool isHideContour() const { return mbHideContour; }
166  bool isBlink() const { return mbBlink; }
167  bool isScroll() const { return mbScroll; }
168  bool isInEditMode() const { return mbInEditMode; }
169  bool isFixedCellHeight() const { return mbFixedCellHeight; }
170  bool isChainable() const { return mbChainable; }
172  sal_Int32 getTextLeftDistance() const { return maTextLeftDistance; }
173  sal_Int32 getTextUpperDistance() const { return maTextUpperDistance; }
174  sal_Int32 getTextRightDistance() const { return maTextRightDistance; }
175  sal_Int32 getTextLowerDistance() const { return maTextLowerDistance; }
178 
179  // compare operator
180  bool operator==(const ImpSdrTextAttribute& rCandidate) const
181  {
182  if (mxOutlinerParaObject.get() != rCandidate.mxOutlinerParaObject.get())
183  {
184  if (mxOutlinerParaObject && rCandidate.mxOutlinerParaObject)
185  {
186  // compares OPO and it's contents, but traditionally not the RedLining
187  // which is not seen as model, but as temporary information
188  if(!(getOutlinerParaObject() == rCandidate.getOutlinerParaObject()))
189  {
190  return false;
191  }
192 
193  // #i102062# for primitive visualisation, the WrongList (SpellChecking)
194  // is important, too, so use isWrongListEqual since there is no WrongList
195  // comparison in the regular OutlinerParaObject compare (since it's
196  // not-persistent data)
198  {
199  return false;
200  }
201  }
202  else
203  {
204  // only one is zero; not equal
205  return false;
206  }
207  }
208 
209  return (
211  && getTextLeftDistance() == rCandidate.getTextLeftDistance()
212  && getTextUpperDistance() == rCandidate.getTextUpperDistance()
213  && getTextRightDistance() == rCandidate.getTextRightDistance()
214  && getTextLowerDistance() == rCandidate.getTextLowerDistance()
215  && maPropertiesVersion == rCandidate.maPropertiesVersion
216 
217  && getSdrTextHorzAdjust() == rCandidate.getSdrTextHorzAdjust()
218  && getSdrTextVertAdjust() == rCandidate.getSdrTextVertAdjust()
219 
220  && isContour() == rCandidate.isContour()
221  && isFitToSize() == rCandidate.isFitToSize()
222  && isAutoFit() == rCandidate.isAutoFit()
223  && isHideContour() == rCandidate.isHideContour()
224  && isBlink() == rCandidate.isBlink()
225  && isScroll() == rCandidate.isScroll()
226  && isInEditMode() == rCandidate.isInEditMode()
227  && isFixedCellHeight() == rCandidate.isFixedCellHeight()
228  && mbWrongSpell == rCandidate.mbWrongSpell );
229  }
230  };
231 
232  namespace
233  {
234  struct theGlobalDefault :
235  public rtl::Static< SdrTextAttribute::ImplType, theGlobalDefault > {};
236  }
237 
239  const SdrText& rSdrText,
240  const OutlinerParaObject& rOutlinerParaObject,
241  XFormTextStyle eFormTextStyle,
242  sal_Int32 aTextLeftDistance,
243  sal_Int32 aTextUpperDistance,
244  sal_Int32 aTextRightDistance,
245  sal_Int32 aTextLowerDistance,
246  SdrTextHorzAdjust aSdrTextHorzAdjust,
247  SdrTextVertAdjust aSdrTextVertAdjust,
248  bool bContour,
249  bool bFitToSize,
250  bool bAutoFit,
251  bool bHideContour,
252  bool bBlink,
253  bool bScroll,
254  bool bInEditMode,
255  bool bFixedCellHeight,
256  bool bWrongSpell,
257  bool bChainable)
258  : mpSdrTextAttribute(
260  &rSdrText, rOutlinerParaObject, eFormTextStyle, aTextLeftDistance,
261  aTextUpperDistance, aTextRightDistance, aTextLowerDistance,
262  aSdrTextHorzAdjust, aSdrTextVertAdjust, bContour, bFitToSize, bAutoFit,
263  bHideContour, bBlink, bScroll, bInEditMode, bFixedCellHeight, bWrongSpell,
264  bChainable))
265  {
266  }
267 
269  : mpSdrTextAttribute(theGlobalDefault::get())
270  {
271  }
272 
274  : mpSdrTextAttribute(rCandidate.mpSdrTextAttribute)
275  {
276  }
277 
279  : mpSdrTextAttribute(std::move(rCandidate.mpSdrTextAttribute))
280  {
281  }
282 
284  {
285  }
286 
288  {
289  return mpSdrTextAttribute.same_object(theGlobalDefault::get());
290  }
291 
293  {
295  return *this;
296  }
297 
299  {
300  mpSdrTextAttribute = std::move(rCandidate.mpSdrTextAttribute);
301  return *this;
302  }
303 
304  bool SdrTextAttribute::operator==(const SdrTextAttribute& rCandidate) const
305  {
306  // tdf#87509 default attr is always != non-default attr, even with same values
307  if(rCandidate.isDefault() != isDefault())
308  return false;
309 
310  return rCandidate.mpSdrTextAttribute == mpSdrTextAttribute;
311  }
312 
314  {
315  return mpSdrTextAttribute->getSdrText();
316  }
317 
319  {
320  return mpSdrTextAttribute->getOutlinerParaObject();
321  }
322 
324  {
325  return mpSdrTextAttribute->isContour();
326  }
327 
329  {
330  return mpSdrTextAttribute->isFitToSize();
331  }
332 
334  {
335  return mpSdrTextAttribute->isAutoFit();
336  }
337 
339  {
340  return mpSdrTextAttribute->isHideContour();
341  }
342 
344  {
345  return mpSdrTextAttribute->isBlink();
346  }
347 
349  {
350  return mpSdrTextAttribute->isScroll();
351  }
352 
354  {
355  return mpSdrTextAttribute->isInEditMode();
356  }
357 
359  {
360  return mpSdrTextAttribute->isChainable();
361  }
362 
363 
365  {
366  return mpSdrTextAttribute->isFixedCellHeight();
367  }
368 
370  {
371  return mpSdrTextAttribute->getSdrFormTextAttribute();
372  }
373 
375  {
376  return mpSdrTextAttribute->getTextLeftDistance();
377  }
378 
380  {
381  return mpSdrTextAttribute->getTextUpperDistance();
382  }
383 
385  {
386  return mpSdrTextAttribute->getTextRightDistance();
387  }
388 
390  {
391  return mpSdrTextAttribute->getTextLowerDistance();
392  }
393 
395  {
396  return mpSdrTextAttribute->getSdrTextHorzAdjust();
397  }
398 
400  {
401  return mpSdrTextAttribute->getSdrTextVertAdjust();
402  }
403 
405  {
406  if(isBlink())
407  {
409  }
410  }
411 
412  void SdrTextAttribute::getScrollTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList, double fFrameLength, double fTextLength) const
413  {
414  if(isScroll())
415  {
416  getSdrText().GetObject().impGetScrollTextTiming(rAnimList, fFrameLength, fTextLength);
417  }
418  }
419 
420 } // end of namespace
421 
422 /* 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:67
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:203
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:151
SdrTextVertAdjust
Definition: sdtaitm.hxx:29