merge the formfield patch from ooo-build
[ooovba.git] / svx / source / sdr / attribute / sdrtextattribute.cxx
blobfa650a5e1fa42183c11c8fd2eb03aa8b5f9141b3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrtextattribute.cxx,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "precompiled_svx.hxx"
34 #include <svx/sdr/attribute/sdrtextattribute.hxx>
35 #include <svx/sdr/attribute/sdrformtextattribute.hxx>
36 #include <svx/svdotext.hxx>
37 #include <svx/outlobj.hxx>
38 #include <svx/editobj.hxx>
39 #include <svx/flditem.hxx>
40 #include <svx/sdr/properties/properties.hxx>
42 //////////////////////////////////////////////////////////////////////////////
43 // pointer compare define
44 #define pointerOrContentEqual(p, q) ((p == q) || (p && q && *p == *q))
46 //////////////////////////////////////////////////////////////////////////////
48 namespace drawinglayer
50 namespace attribute
52 SdrTextAttribute::SdrTextAttribute(
53 const SdrText& rSdrText,
54 const OutlinerParaObject& rOutlinerParaObject,
55 XFormTextStyle eFormTextStyle,
56 sal_Int32 aTextLeftDistance,
57 sal_Int32 aTextUpperDistance,
58 sal_Int32 aTextRightDistance,
59 sal_Int32 aTextLowerDistance,
60 SdrTextHorzAdjust aSdrTextHorzAdjust,
61 SdrTextVertAdjust aSdrTextVertAdjust,
62 bool bContour,
63 bool bFitToSize,
64 bool bAutoFit,
65 bool bHideContour,
66 bool bBlink,
67 bool bScroll,
68 bool bInEditMode,
69 bool bFixedCellHeight)
70 : mpSdrText(&rSdrText),
71 maOutlinerParaObject(rOutlinerParaObject),
72 mpSdrFormTextAttribute(0),
73 maTextLeftDistance(aTextLeftDistance),
74 maTextUpperDistance(aTextUpperDistance),
75 maTextRightDistance(aTextRightDistance),
76 maTextLowerDistance(aTextLowerDistance),
77 maPropertiesVersion(0),
78 maSdrTextHorzAdjust(aSdrTextHorzAdjust),
79 maSdrTextVertAdjust(aSdrTextVertAdjust),
80 mbContour(bContour),
81 mbFitToSize(bFitToSize),
82 mbAutoFit(bAutoFit),
83 mbHideContour(bHideContour),
84 mbBlink(bBlink),
85 mbScroll(bScroll),
86 mbInEditMode(bInEditMode),
87 mbFixedCellHeight(bFixedCellHeight)
89 if(XFT_NONE != eFormTextStyle)
91 // text on path. Create FormText attribute
92 const SfxItemSet& rSet = getSdrText().GetItemSet();
93 mpSdrFormTextAttribute = new SdrFormTextAttribute(rSet);
96 // #i101556# init with version number to detect changes of single text
97 // attribute and/or style sheets in primitive data without having to
98 // copy that data locally (which would be better from principle)
99 maPropertiesVersion = rSdrText.GetObject().GetProperties().getVersion();
102 SdrTextAttribute::~SdrTextAttribute()
104 if(mpSdrFormTextAttribute)
106 delete mpSdrFormTextAttribute;
107 mpSdrFormTextAttribute = 0;
111 SdrTextAttribute::SdrTextAttribute(const SdrTextAttribute& rCandidate)
112 : mpSdrText(&rCandidate.getSdrText()),
113 maOutlinerParaObject(rCandidate.getOutlinerParaObject()),
114 mpSdrFormTextAttribute(0),
115 maTextLeftDistance(rCandidate.getTextLeftDistance()),
116 maTextUpperDistance(rCandidate.getTextUpperDistance()),
117 maTextRightDistance(rCandidate.getTextRightDistance()),
118 maTextLowerDistance(rCandidate.getTextLowerDistance()),
119 maPropertiesVersion(rCandidate.getPropertiesVersion()),
120 maSdrTextHorzAdjust(rCandidate.getSdrTextHorzAdjust()),
121 maSdrTextVertAdjust(rCandidate.getSdrTextVertAdjust()),
122 mbContour(rCandidate.isContour()),
123 mbFitToSize(rCandidate.isFitToSize()),
124 mbHideContour(rCandidate.isHideContour()),
125 mbBlink(rCandidate.isBlink()),
126 mbScroll(rCandidate.isScroll()),
127 mbInEditMode(rCandidate.isInEditMode()),
128 mbFixedCellHeight(rCandidate.isFixedCellHeight())
130 if(rCandidate.getSdrFormTextAttribute())
132 mpSdrFormTextAttribute = new SdrFormTextAttribute(*rCandidate.getSdrFormTextAttribute());
136 SdrTextAttribute& SdrTextAttribute::operator=(const SdrTextAttribute& rCandidate)
138 mpSdrText = &rCandidate.getSdrText();
139 maOutlinerParaObject = rCandidate.getOutlinerParaObject();
141 if(mpSdrFormTextAttribute)
143 delete mpSdrFormTextAttribute;
146 mpSdrFormTextAttribute = 0;
148 if(rCandidate.getSdrFormTextAttribute())
150 mpSdrFormTextAttribute = new SdrFormTextAttribute(*rCandidate.getSdrFormTextAttribute());
153 maTextLeftDistance = rCandidate.getTextLeftDistance();
154 maTextUpperDistance = rCandidate.getTextUpperDistance();
155 maTextRightDistance = rCandidate.getTextRightDistance();
156 maTextLowerDistance = rCandidate.getTextLowerDistance();
157 maPropertiesVersion = rCandidate.getPropertiesVersion();
159 maSdrTextHorzAdjust = rCandidate.getSdrTextHorzAdjust();
160 maSdrTextVertAdjust = rCandidate.getSdrTextVertAdjust();
162 mbContour = rCandidate.isContour();
163 mbFitToSize = rCandidate.isFitToSize();
164 mbHideContour = rCandidate.isHideContour();
165 mbBlink = rCandidate.isBlink();
166 mbScroll = rCandidate.isScroll();
167 mbInEditMode = rCandidate.isInEditMode();
168 mbFixedCellHeight = rCandidate.isFixedCellHeight();
170 return *this;
173 bool SdrTextAttribute::operator==(const SdrTextAttribute& rCandidate) const
175 return (
176 // compares OPO and it's contents, but traditionally not the RedLining
177 // which is not seen as model, but as temporary information
178 getOutlinerParaObject() == rCandidate.getOutlinerParaObject()
180 // #i102062# for primitive visualisation, the WrongList (SpellChecking)
181 // is important, too, so use isWrongListEqual since there is no WrongList
182 // comparison in the regular OutlinerParaObject compare (since it's
183 // not-persistent data)
184 && getOutlinerParaObject().isWrongListEqual(rCandidate.getOutlinerParaObject())
186 && pointerOrContentEqual(getSdrFormTextAttribute(), rCandidate.getSdrFormTextAttribute())
187 && getTextLeftDistance() == rCandidate.getTextLeftDistance()
188 && getTextUpperDistance() == rCandidate.getTextUpperDistance()
189 && getTextRightDistance() == rCandidate.getTextRightDistance()
190 && getTextLowerDistance() == rCandidate.getTextLowerDistance()
191 && getPropertiesVersion() == rCandidate.getPropertiesVersion()
193 && getSdrTextHorzAdjust() == rCandidate.getSdrTextHorzAdjust()
194 && getSdrTextVertAdjust() == rCandidate.getSdrTextVertAdjust()
196 && isContour() == rCandidate.isContour()
197 && isFitToSize() == rCandidate.isFitToSize()
198 && isAutoFit() == rCandidate.isAutoFit()
199 && isHideContour() == rCandidate.isHideContour()
200 && isBlink() == rCandidate.isBlink()
201 && isScroll() == rCandidate.isScroll()
202 && isInEditMode() == rCandidate.isInEditMode()
203 && isFixedCellHeight() == rCandidate.isFixedCellHeight());
206 void SdrTextAttribute::getBlinkTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList) const
208 if(isBlink())
210 mpSdrText->GetObject().impGetBlinkTextTiming(rAnimList);
214 void SdrTextAttribute::getScrollTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList, double fFrameLength, double fTextLength) const
216 if(isScroll())
218 mpSdrText->GetObject().impGetScrollTextTiming(rAnimList, fFrameLength, fTextLength);
221 } // end of namespace attribute
222 } // end of namespace drawinglayer
224 //////////////////////////////////////////////////////////////////////////////
225 // eof