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