1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <sdr/attribute/sdrtextattribute.hxx>
22 #include <sdr/attribute/sdrformtextattribute.hxx>
23 #include <svx/svdotext.hxx>
24 #include <editeng/outlobj.hxx>
25 #include <svx/sdr/properties/properties.hxx>
28 namespace drawinglayer::attribute
30 class ImpSdrTextAttribute
33 // all-text attributes. The SdrText itself and a copy
35 const SdrText
* mpSdrText
;
36 std::shared_ptr
<OutlinerParaObject
> mxOutlinerParaObject
;
38 // Set when it's a FormText; contains all FormText attributes
39 SdrFormTextAttribute maSdrFormTextAttribute
;
42 sal_Int32 maTextLeftDistance
;
43 sal_Int32 maTextUpperDistance
;
44 sal_Int32 maTextRightDistance
;
45 sal_Int32 maTextLowerDistance
;
47 // #i101556# use versioning from text attributes to detect changes
48 sal_uInt32 maPropertiesVersion
;
51 SdrTextHorzAdjust maSdrTextHorzAdjust
;
52 SdrTextVertAdjust maSdrTextVertAdjust
;
57 bool mbHideContour
: 1;
60 bool mbInEditMode
: 1;
61 bool mbFixedCellHeight
: 1;
62 bool mbWrongSpell
: 1;
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
,
85 bool bFixedCellHeight
,
88 : mpSdrText(pSdrText
),
89 mxOutlinerParaObject(std::make_shared
<OutlinerParaObject
>(rOutlinerParaObject
)),
90 maTextLeftDistance(aTextLeftDistance
),
91 maTextUpperDistance(aTextUpperDistance
),
92 maTextRightDistance(aTextRightDistance
),
93 maTextLowerDistance(aTextLowerDistance
),
94 maPropertiesVersion(0),
95 maSdrTextHorzAdjust(aSdrTextHorzAdjust
),
96 maSdrTextVertAdjust(aSdrTextVertAdjust
),
98 mbFitToSize(bFitToSize
),
100 mbHideContour(bHideContour
),
103 mbInEditMode(bInEditMode
),
104 mbFixedCellHeight(bFixedCellHeight
),
105 mbWrongSpell(bWrongSpell
),
106 mbChainable(bChainable
)
111 if(XFormTextStyle::NONE
!= eFormTextStyle
)
113 // text on path. Create FormText attribute
114 const SfxItemSet
& rSet
= pSdrText
->GetItemSet();
115 maSdrFormTextAttribute
= SdrFormTextAttribute(rSet
);
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)
121 maPropertiesVersion
= pSdrText
->GetObject().GetProperties().getVersion();
124 ImpSdrTextAttribute()
125 : mpSdrText(nullptr),
126 maTextLeftDistance(0),
127 maTextUpperDistance(0),
128 maTextRightDistance(0),
129 maTextLowerDistance(0),
130 maPropertiesVersion(0),
131 maSdrTextHorzAdjust(SDRTEXTHORZADJUST_LEFT
),
132 maSdrTextVertAdjust(SDRTEXTVERTADJUST_TOP
),
136 mbHideContour(false),
140 mbFixedCellHeight(false),
147 const SdrText
& getSdrText() const
149 assert(mpSdrText
&& "Access to text of default version of ImpSdrTextAttribute (!)");
153 const OutlinerParaObject
& getOutlinerParaObject() const
155 assert(mxOutlinerParaObject
&& "Access to OutlinerParaObject of default version of ImpSdrTextAttribute (!)");
156 return *mxOutlinerParaObject
;
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
; }
168 const SdrFormTextAttribute
& getSdrFormTextAttribute() const { return maSdrFormTextAttribute
; }
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
; }
173 SdrTextHorzAdjust
getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust
; }
174 SdrTextVertAdjust
getSdrTextVertAdjust() const { return maSdrTextVertAdjust
; }
177 bool operator==(const ImpSdrTextAttribute
& rCandidate
) const
179 if (mxOutlinerParaObject
.get() != rCandidate
.mxOutlinerParaObject
.get())
181 if (mxOutlinerParaObject
&& rCandidate
.mxOutlinerParaObject
)
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())
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())))
201 // only one is zero; not equal
207 getSdrFormTextAttribute() == rCandidate
.getSdrFormTextAttribute()
208 && getTextLeftDistance() == rCandidate
.getTextLeftDistance()
209 && getTextUpperDistance() == rCandidate
.getTextUpperDistance()
210 && getTextRightDistance() == rCandidate
.getTextRightDistance()
211 && getTextLowerDistance() == rCandidate
.getTextLowerDistance()
212 && maPropertiesVersion
== rCandidate
.maPropertiesVersion
214 && getSdrTextHorzAdjust() == rCandidate
.getSdrTextHorzAdjust()
215 && getSdrTextVertAdjust() == rCandidate
.getSdrTextVertAdjust()
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
);
231 SdrTextAttribute::ImplType
& theGlobalDefault()
233 static SdrTextAttribute::ImplType SINGLETON
;
238 SdrTextAttribute::SdrTextAttribute(
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
,
255 bool bFixedCellHeight
,
258 : mpSdrTextAttribute(
260 &rSdrText
, rOutlinerParaObject
, eFormTextStyle
, aTextLeftDistance
,
261 aTextUpperDistance
, aTextRightDistance
, aTextLowerDistance
,
262 aSdrTextHorzAdjust
, aSdrTextVertAdjust
, bContour
, bFitToSize
, bAutoFit
,
263 bHideContour
, bBlink
, bScroll
, bInEditMode
, bFixedCellHeight
, bWrongSpell
,
268 SdrTextAttribute::SdrTextAttribute()
269 : mpSdrTextAttribute(theGlobalDefault())
273 SdrTextAttribute::SdrTextAttribute(const SdrTextAttribute
& rCandidate
)
274 : mpSdrTextAttribute(rCandidate
.mpSdrTextAttribute
)
278 SdrTextAttribute::SdrTextAttribute(SdrTextAttribute
&& rCandidate
) noexcept
279 : mpSdrTextAttribute(std::move(rCandidate
.mpSdrTextAttribute
))
283 SdrTextAttribute::~SdrTextAttribute()
287 bool SdrTextAttribute::isDefault() const
289 return mpSdrTextAttribute
.same_object(theGlobalDefault());
292 SdrTextAttribute
& SdrTextAttribute::operator=(const SdrTextAttribute
& rCandidate
)
294 mpSdrTextAttribute
= rCandidate
.mpSdrTextAttribute
;
298 SdrTextAttribute
& SdrTextAttribute::operator=(SdrTextAttribute
&& rCandidate
) noexcept
300 mpSdrTextAttribute
= std::move(rCandidate
.mpSdrTextAttribute
);
304 bool SdrTextAttribute::operator==(const SdrTextAttribute
& rCandidate
) const
306 // tdf#87509 default attr is always != non-default attr, even with same values
307 if(rCandidate
.isDefault() != isDefault())
310 return rCandidate
.mpSdrTextAttribute
== mpSdrTextAttribute
;
313 const SdrText
& SdrTextAttribute::getSdrText() const
315 return mpSdrTextAttribute
->getSdrText();
318 const OutlinerParaObject
& SdrTextAttribute::getOutlinerParaObject() const
320 return mpSdrTextAttribute
->getOutlinerParaObject();
323 bool SdrTextAttribute::isContour() const
325 return mpSdrTextAttribute
->isContour();
328 bool SdrTextAttribute::isFitToSize() const
330 return mpSdrTextAttribute
->isFitToSize();
333 bool SdrTextAttribute::isAutoFit() const
335 return mpSdrTextAttribute
->isAutoFit();
338 bool SdrTextAttribute::isHideContour() const
340 return mpSdrTextAttribute
->isHideContour();
343 bool SdrTextAttribute::isBlink() const
345 return mpSdrTextAttribute
->isBlink();
348 bool SdrTextAttribute::isScroll() const
350 return mpSdrTextAttribute
->isScroll();
353 bool SdrTextAttribute::isInEditMode() const
355 return mpSdrTextAttribute
->isInEditMode();
358 bool SdrTextAttribute::isChainable() const
360 return mpSdrTextAttribute
->isChainable();
364 bool SdrTextAttribute::isFixedCellHeight() const
366 return mpSdrTextAttribute
->isFixedCellHeight();
369 const SdrFormTextAttribute
& SdrTextAttribute::getSdrFormTextAttribute() const
371 return mpSdrTextAttribute
->getSdrFormTextAttribute();
374 sal_Int32
SdrTextAttribute::getTextLeftDistance() const
376 return mpSdrTextAttribute
->getTextLeftDistance();
379 sal_Int32
SdrTextAttribute::getTextUpperDistance() const
381 return mpSdrTextAttribute
->getTextUpperDistance();
384 sal_Int32
SdrTextAttribute::getTextRightDistance() const
386 return mpSdrTextAttribute
->getTextRightDistance();
389 sal_Int32
SdrTextAttribute::getTextLowerDistance() const
391 return mpSdrTextAttribute
->getTextLowerDistance();
394 SdrTextHorzAdjust
SdrTextAttribute::getSdrTextHorzAdjust() const
396 return mpSdrTextAttribute
->getSdrTextHorzAdjust();
399 SdrTextVertAdjust
SdrTextAttribute::getSdrTextVertAdjust() const
401 return mpSdrTextAttribute
->getSdrTextVertAdjust();
404 void SdrTextAttribute::getBlinkTextTiming(drawinglayer::animation::AnimationEntryList
& rAnimList
) const
408 getSdrText().GetObject().impGetBlinkTextTiming(rAnimList
);
412 void SdrTextAttribute::getScrollTextTiming(drawinglayer::animation::AnimationEntryList
& rAnimList
, double fFrameLength
, double fTextLength
) const
416 getSdrText().GetObject().impGetScrollTextTiming(rAnimList
, fFrameLength
, fTextLength
);
420 } // end of namespace
422 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */