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
27
29{
31 {
32 public:
33 // all-text attributes. The SdrText itself and a copy
34 // of the OPO
36 std::shared_ptr<OutlinerParaObject> mxOutlinerParaObject;
37
38 // Set when it's a FormText; contains all FormText attributes
40
41 // text distances
46
47 // #i101556# use versioning from text attributes to detect changes
49
50 // text alignments
53
54 bool mbContour : 1;
55 bool mbFitToSize : 1;
56 bool mbAutoFit : 1;
57 bool mbHideContour : 1;
58 bool mbBlink : 1;
59 bool mbScroll : 1;
60 bool mbInEditMode : 1;
62 bool mbWrongSpell : 1;
63
64 bool mbChainable : 1;
65
66
67 public:
69 const SdrText* pSdrText,
70 const OutlinerParaObject& rOutlinerParaObject,
71 XFormTextStyle eFormTextStyle,
72 sal_Int32 aTextLeftDistance,
73 sal_Int32 aTextUpperDistance,
74 sal_Int32 aTextRightDistance,
75 sal_Int32 aTextLowerDistance,
76 SdrTextHorzAdjust aSdrTextHorzAdjust,
77 SdrTextVertAdjust aSdrTextVertAdjust,
78 bool bContour,
79 bool bFitToSize,
80 bool bAutoFit,
81 bool bHideContour,
82 bool bBlink,
83 bool bScroll,
84 bool bInEditMode,
85 bool bFixedCellHeight,
86 bool bWrongSpell,
87 bool bChainable)
88 : mpSdrText(pSdrText),
90 maTextLeftDistance(aTextLeftDistance),
91 maTextUpperDistance(aTextUpperDistance),
92 maTextRightDistance(aTextRightDistance),
93 maTextLowerDistance(aTextLowerDistance),
95 maSdrTextHorzAdjust(aSdrTextHorzAdjust),
96 maSdrTextVertAdjust(aSdrTextVertAdjust),
97 mbContour(bContour),
98 mbFitToSize(bFitToSize),
99 mbAutoFit(bAutoFit),
100 mbHideContour(bHideContour),
101 mbBlink(bBlink),
102 mbScroll(bScroll),
103 mbInEditMode(bInEditMode),
104 mbFixedCellHeight(bFixedCellHeight),
105 mbWrongSpell(bWrongSpell),
106 mbChainable(bChainable)
107 {
108 if(!pSdrText)
109 return;
110
111 if(XFormTextStyle::NONE != eFormTextStyle)
112 {
113 // text on path. Create FormText attribute
114 const SfxItemSet& rSet = pSdrText->GetItemSet();
116 }
117
118 // #i101556# init with version number to detect changes of single text
119 // attribute and/or style sheets in primitive data without having to
120 // copy that data locally (which would be better from principle)
122 }
123
125 : mpSdrText(nullptr),
133 mbContour(false),
134 mbFitToSize(false),
135 mbAutoFit(false),
136 mbHideContour(false),
137 mbBlink(false),
138 mbScroll(false),
139 mbInEditMode(false),
140 mbFixedCellHeight(false),
141 mbWrongSpell(false),
142 mbChainable(false)
143 {
144 }
145
146 // data read access
147 const SdrText& getSdrText() const
148 {
149 assert(mpSdrText && "Access to text of default version of ImpSdrTextAttribute (!)");
150 return *mpSdrText;
151 }
152
154 {
155 assert(mxOutlinerParaObject && "Access to OutlinerParaObject of default version of ImpSdrTextAttribute (!)");
156 return *mxOutlinerParaObject;
157 }
158
159 bool isContour() const { return mbContour; }
160 bool isFitToSize() const { return mbFitToSize; }
161 bool isAutoFit() const { return mbAutoFit; }
162 bool isHideContour() const { return mbHideContour; }
163 bool isBlink() const { return mbBlink; }
164 bool isScroll() const { return mbScroll; }
165 bool isInEditMode() const { return mbInEditMode; }
166 bool isFixedCellHeight() const { return mbFixedCellHeight; }
167 bool isChainable() const { return mbChainable; }
169 sal_Int32 getTextLeftDistance() const { return maTextLeftDistance; }
170 sal_Int32 getTextUpperDistance() const { return maTextUpperDistance; }
171 sal_Int32 getTextRightDistance() const { return maTextRightDistance; }
172 sal_Int32 getTextLowerDistance() const { return maTextLowerDistance; }
175
176 // compare operator
177 bool operator==(const ImpSdrTextAttribute& rCandidate) const
178 {
179 if (mxOutlinerParaObject.get() != rCandidate.mxOutlinerParaObject.get())
180 {
182 {
183 // compares OPO and it's contents, but traditionally not the RedLining
184 // which is not seen as model, but as temporary information
185 if(getOutlinerParaObject() != rCandidate.getOutlinerParaObject())
186 {
187 return false;
188 }
189
190 // #i102062# for primitive visualisation, the WrongList (SpellChecking)
191 // is important, too, so use isWrongListEqual since there is no WrongList
192 // comparison in the regular OutlinerParaObject compare (since it's
193 // not-persistent data)
194 if(!(getOutlinerParaObject().isWrongListEqual(rCandidate.getOutlinerParaObject())))
195 {
196 return false;
197 }
198 }
199 else
200 {
201 // only one is zero; not equal
202 return false;
203 }
204 }
205
206 return (
208 && getTextLeftDistance() == rCandidate.getTextLeftDistance()
209 && getTextUpperDistance() == rCandidate.getTextUpperDistance()
210 && getTextRightDistance() == rCandidate.getTextRightDistance()
211 && getTextLowerDistance() == rCandidate.getTextLowerDistance()
213
214 && getSdrTextHorzAdjust() == rCandidate.getSdrTextHorzAdjust()
215 && getSdrTextVertAdjust() == rCandidate.getSdrTextVertAdjust()
216
217 && isContour() == rCandidate.isContour()
218 && isFitToSize() == rCandidate.isFitToSize()
219 && isAutoFit() == rCandidate.isAutoFit()
220 && isHideContour() == rCandidate.isHideContour()
221 && isBlink() == rCandidate.isBlink()
222 && isScroll() == rCandidate.isScroll()
223 && isInEditMode() == rCandidate.isInEditMode()
224 && isFixedCellHeight() == rCandidate.isFixedCellHeight()
225 && mbWrongSpell == rCandidate.mbWrongSpell );
226 }
227 };
228
229 namespace
230 {
231 SdrTextAttribute::ImplType& theGlobalDefault()
232 {
233 static SdrTextAttribute::ImplType SINGLETON;
234 return SINGLETON;
235 }
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())
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());
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: */
virtual sdr::properties::BaseProperties & GetProperties() const
Definition: svdobj.cxx:220
void impGetScrollTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList, double fFrameLength, double fTextLength) const
void impGetBlinkTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList) const
SdrTextObj & GetObject() const
Definition: svdtext.hxx:63
const SfxItemSet & GetItemSet() const
Definition: svdtext.cxx:67
const SdrFormTextAttribute & getSdrFormTextAttribute() 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)
bool operator==(const ImpSdrTextAttribute &rCandidate) const
std::shared_ptr< OutlinerParaObject > mxOutlinerParaObject
const OutlinerParaObject & getOutlinerParaObject() const
const OutlinerParaObject & getOutlinerParaObject() const
bool operator==(const SdrTextAttribute &rCandidate) const
void getScrollTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList, double fFrameLength, double fTextLength) const
void getBlinkTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList) const
SdrTextVertAdjust getSdrTextVertAdjust() const
SdrTextAttribute & operator=(const SdrTextAttribute &rCandidate)
const SdrFormTextAttribute & getSdrFormTextAttribute() const
o3tl::cow_wrapper< ImpSdrTextAttribute > ImplType
SdrTextHorzAdjust getSdrTextHorzAdjust() const
bool same_object(const cow_wrapper &rOther) const
virtual sal_uInt32 getVersion() const
Definition: properties.cxx:137
std::shared_ptr< T > make_shared(Args &&... args)
SdrTextVertAdjust
Definition: sdtaitm.hxx:29
@ SDRTEXTVERTADJUST_TOP
Definition: sdtaitm.hxx:29
SdrTextHorzAdjust
Definition: sdtaitm.hxx:53
@ SDRTEXTHORZADJUST_LEFT
Definition: sdtaitm.hxx:53
static SfxItemSet & rSet
XFormTextStyle
Definition: xenum.hxx:24