Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <comphelper/string.hxx>
31 : : #include <svx/svdotext.hxx>
32 : : #include "svx/svditext.hxx"
33 : : #include <svx/svdpagv.hxx> // for the request in Paint to see whether
34 : : #include <svx/svdview.hxx> // the object is currently being edited
35 : : #include <svx/svdpage.hxx> // and for AnimationHandler (ticker text)
36 : : #include <svx/svdetc.hxx>
37 : : #include <svx/svdoutl.hxx>
38 : : #include <svx/svdmodel.hxx> // OutlinerDefaults
39 : : #include "svx/svdglob.hxx" // Stringcache
40 : : #include "svx/svdstr.hrc" // the object's name
41 : : #include <editeng/writingmodeitem.hxx>
42 : : #include <svx/sdtfchim.hxx>
43 : : #include <svtools/colorcfg.hxx>
44 : : #include <editeng/eeitem.hxx>
45 : : #include <editeng/editstat.hxx>
46 : : #include <editeng/outlobj.hxx>
47 : : #include <editeng/editobj.hxx>
48 : : #include <editeng/outliner.hxx>
49 : : #include <editeng/fhgtitem.hxx>
50 : : #include <svl/itempool.hxx>
51 : : #include <editeng/adjitem.hxx>
52 : : #include <editeng/flditem.hxx>
53 : : #include <svx/xftouit.hxx>
54 : : #include <tools/helpers.hxx>
55 : : #include <svx/xflgrit.hxx>
56 : : #include <svx/svdpool.hxx>
57 : : #include <svx/xflclit.hxx>
58 : : #include <svl/style.hxx>
59 : : #include <editeng/editeng.hxx>
60 : : #include <svl/itemiter.hxx>
61 : : #include <svx/sdr/properties/textproperties.hxx>
62 : : #include <vcl/metaact.hxx>
63 : : #include <svx/sdr/contact/viewcontactoftextobj.hxx>
64 : : #include <basegfx/tuple/b2dtuple.hxx>
65 : : #include <basegfx/matrix/b2dhommatrix.hxx>
66 : : #include <basegfx/polygon/b2dpolygon.hxx>
67 : : #include <drawinglayer/geometry/viewinformation2d.hxx>
68 : : #include <vcl/virdev.hxx>
69 : : #include <basegfx/matrix/b2dhommatrixtools.hxx>
70 : : #include "svdconv.hxx"
71 : :
72 : : //////////////////////////////////////////////////////////////////////////////
73 : :
74 : : using namespace com::sun::star;
75 : :
76 : : //////////////////////////////////////////////////////////////////////////////
77 : : // BaseProperties section
78 : :
79 : 19551 : sdr::properties::BaseProperties* SdrTextObj::CreateObjectSpecificProperties()
80 : : {
81 [ + - ]: 19551 : return new sdr::properties::TextProperties(*this);
82 : : }
83 : :
84 : : //////////////////////////////////////////////////////////////////////////////
85 : : // DrawContact section
86 : :
87 : 0 : sdr::contact::ViewContact* SdrTextObj::CreateObjectSpecificViewContact()
88 : : {
89 [ # # ]: 0 : return new sdr::contact::ViewContactOfTextObj(*this);
90 : : }
91 : :
92 : : //////////////////////////////////////////////////////////////////////////////
93 : :
94 [ + + ][ - + ]: 3332363 : TYPEINIT1(SdrTextObj,SdrAttrObj);
95 : :
96 : 32399 : SdrTextObj::SdrTextObj()
97 : : : SdrAttrObj(),
98 : : mpText(NULL),
99 : : pEdtOutl(NULL),
100 : : pFormTextBoundRect(NULL),
101 [ + - ]: 32399 : eTextKind(OBJ_TEXT)
102 : : {
103 : 32399 : bTextSizeDirty=sal_False;
104 : 32399 : bTextFrame=sal_False;
105 : 32399 : bNoShear=sal_False;
106 : 32399 : bNoRotate=sal_False;
107 : 32399 : bNoMirror=sal_False;
108 : 32399 : bDisableAutoWidthOnDragging=sal_False;
109 : :
110 : 32399 : mbInEditMode = sal_False;
111 : 32399 : mbTextHidden = sal_False;
112 : 32399 : mbTextAnimationAllowed = sal_True;
113 : 32399 : maTextEditOffset = Point(0, 0);
114 : :
115 : : // #i25616#
116 : 32399 : mbSupportTextIndentingOnLineWidthChange = sal_True;
117 : 32399 : mbInDownScale = sal_False;
118 : 32399 : }
119 : :
120 : 1444 : SdrTextObj::SdrTextObj(const Rectangle& rNewRect)
121 : : : SdrAttrObj(),
122 : : aRect(rNewRect),
123 : : mpText(NULL),
124 : : pEdtOutl(NULL),
125 : : pFormTextBoundRect(NULL),
126 : 1444 : eTextKind(OBJ_TEXT)
127 : : {
128 : 1444 : bTextSizeDirty=sal_False;
129 : 1444 : bTextFrame=sal_False;
130 : 1444 : bNoShear=sal_False;
131 : 1444 : bNoRotate=sal_False;
132 : 1444 : bNoMirror=sal_False;
133 : 1444 : bDisableAutoWidthOnDragging=sal_False;
134 [ + - ]: 1444 : ImpJustifyRect(aRect);
135 : :
136 : 1444 : mbInEditMode = sal_False;
137 : 1444 : mbTextHidden = sal_False;
138 : 1444 : mbTextAnimationAllowed = sal_True;
139 : 1444 : mbInDownScale = sal_False;
140 : 1444 : maTextEditOffset = Point(0, 0);
141 : :
142 : : // #i25616#
143 : 1444 : mbSupportTextIndentingOnLineWidthChange = sal_True;
144 : 1444 : }
145 : :
146 : 23663 : SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind)
147 : : : SdrAttrObj(),
148 : : mpText(NULL),
149 : : pEdtOutl(NULL),
150 : : pFormTextBoundRect(NULL),
151 [ + - ]: 23663 : eTextKind(eNewTextKind)
152 : : {
153 : 23663 : bTextSizeDirty=sal_False;
154 : 23663 : bTextFrame=sal_True;
155 : 23663 : bNoShear=sal_True;
156 : 23663 : bNoRotate=sal_False;
157 : 23663 : bNoMirror=sal_True;
158 : 23663 : bDisableAutoWidthOnDragging=sal_False;
159 : :
160 : 23663 : mbInEditMode = sal_False;
161 : 23663 : mbTextHidden = sal_False;
162 : 23663 : mbTextAnimationAllowed = sal_True;
163 : 23663 : mbInDownScale = sal_False;
164 : 23663 : maTextEditOffset = Point(0, 0);
165 : :
166 : : // #i25616#
167 : 23663 : mbSupportTextIndentingOnLineWidthChange = sal_True;
168 : 23663 : }
169 : :
170 : 159 : SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const Rectangle& rNewRect)
171 : : : SdrAttrObj(),
172 : : aRect(rNewRect),
173 : : mpText(NULL),
174 : : pEdtOutl(NULL),
175 : : pFormTextBoundRect(NULL),
176 : 159 : eTextKind(eNewTextKind)
177 : : {
178 : 159 : bTextSizeDirty=sal_False;
179 : 159 : bTextFrame=sal_True;
180 : 159 : bNoShear=sal_True;
181 : 159 : bNoRotate=sal_False;
182 : 159 : bNoMirror=sal_True;
183 : 159 : bDisableAutoWidthOnDragging=sal_False;
184 [ + - ]: 159 : ImpJustifyRect(aRect);
185 : :
186 : 159 : mbInEditMode = sal_False;
187 : 159 : mbTextHidden = sal_False;
188 : 159 : mbTextAnimationAllowed = sal_True;
189 : 159 : mbInDownScale = sal_False;
190 : 159 : maTextEditOffset = Point(0, 0);
191 : :
192 : : // #i25616#
193 : 159 : mbSupportTextIndentingOnLineWidthChange = sal_True;
194 : 159 : }
195 : :
196 : 57567 : SdrTextObj::~SdrTextObj()
197 : : {
198 [ + + ]: 57567 : if( pModel )
199 : : {
200 : 57307 : SdrOutliner& rOutl = pModel->GetHitTestOutliner();
201 [ - + ][ + - ]: 57307 : if( rOutl.GetTextObj() == this )
202 [ # # ]: 0 : rOutl.SetTextObj( NULL );
203 : : }
204 : :
205 [ + + ]: 57567 : if(mpText!=NULL)
206 [ + - ][ + - ]: 57301 : delete mpText;
207 : :
208 [ - + ]: 57567 : if (pFormTextBoundRect!=NULL)
209 : 0 : delete pFormTextBoundRect;
210 : :
211 [ + - ]: 57567 : ImpLinkAbmeldung();
212 [ - + ]: 57567 : }
213 : :
214 : 0 : void SdrTextObj::FitFrameToTextSize()
215 : : {
216 : : DBG_ASSERT(pModel!=NULL,"SdrTextObj::FitFrameToTextSize(): pModel=NULL!");
217 : 0 : ImpJustifyRect(aRect);
218 : :
219 : 0 : SdrText* pText = getActiveText();
220 [ # # ][ # # ]: 0 : if( pText!=NULL && pText->GetOutlinerParaObject() && pModel!=NULL)
[ # # ][ # # ]
221 : : {
222 [ # # ]: 0 : SdrOutliner& rOutliner=ImpGetDrawOutliner();
223 [ # # ]: 0 : rOutliner.SetPaperSize(Size(aRect.Right()-aRect.Left(),aRect.Bottom()-aRect.Top()));
224 [ # # ]: 0 : rOutliner.SetUpdateMode(sal_True);
225 [ # # ][ # # ]: 0 : rOutliner.SetText(*pText->GetOutlinerParaObject());
226 [ # # ]: 0 : Rectangle aTextRect;
227 [ # # ]: 0 : Size aNewSize(rOutliner.CalcTextSize());
228 [ # # ]: 0 : rOutliner.Clear();
229 : 0 : aNewSize.Width()++; // because of possible rounding errors
230 [ # # ][ # # ]: 0 : aNewSize.Width()+=GetTextLeftDistance()+GetTextRightDistance();
231 [ # # ][ # # ]: 0 : aNewSize.Height()+=GetTextUpperDistance()+GetTextLowerDistance();
232 : 0 : Rectangle aNewRect(aRect);
233 [ # # ]: 0 : aNewRect.SetSize(aNewSize);
234 [ # # ]: 0 : ImpJustifyRect(aNewRect);
235 [ # # ][ # # ]: 0 : if (aNewRect!=aRect) {
236 [ # # ]: 0 : SetLogicRect(aNewRect);
237 : : }
238 : : }
239 : 0 : }
240 : :
241 : 38 : void SdrTextObj::NbcSetText(const XubString& rStr)
242 : : {
243 [ + - ]: 38 : SdrOutliner& rOutliner=ImpGetDrawOutliner();
244 [ + - ][ + - ]: 38 : rOutliner.SetStyleSheet( 0, GetStyleSheet());
245 [ + - ]: 38 : rOutliner.SetUpdateMode(sal_True);
246 [ + - ][ + - ]: 38 : rOutliner.SetText(rStr,rOutliner.GetParagraph( 0 ));
247 [ + - ]: 38 : OutlinerParaObject* pNewText=rOutliner.CreateParaObject();
248 [ + - ]: 38 : Size aSiz(rOutliner.CalcTextSize());
249 [ + - ]: 38 : rOutliner.Clear();
250 [ + - ]: 38 : NbcSetOutlinerParaObject(pNewText);
251 : 38 : aTextSize=aSiz;
252 : 38 : bTextSizeDirty=sal_False;
253 : 38 : }
254 : :
255 : 5 : void SdrTextObj::SetText(const XubString& rStr)
256 : : {
257 [ + - ][ - + ]: 5 : Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
[ # # ]
258 [ + - ]: 5 : NbcSetText(rStr);
259 [ + - ]: 5 : SetChanged();
260 [ + - ]: 5 : BroadcastObjectChange();
261 [ + - ]: 5 : SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
262 : 5 : }
263 : :
264 : 0 : void SdrTextObj::NbcSetText(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat)
265 : : {
266 [ # # ]: 0 : SdrOutliner& rOutliner=ImpGetDrawOutliner();
267 [ # # ][ # # ]: 0 : rOutliner.SetStyleSheet( 0, GetStyleSheet());
268 [ # # ]: 0 : rOutliner.Read(rInput,rBaseURL,eFormat);
269 [ # # ]: 0 : OutlinerParaObject* pNewText=rOutliner.CreateParaObject();
270 [ # # ]: 0 : rOutliner.SetUpdateMode(sal_True);
271 [ # # ]: 0 : Size aSiz(rOutliner.CalcTextSize());
272 [ # # ]: 0 : rOutliner.Clear();
273 [ # # ]: 0 : NbcSetOutlinerParaObject(pNewText);
274 : 0 : aTextSize=aSiz;
275 : 0 : bTextSizeDirty=sal_False;
276 : 0 : }
277 : :
278 : 0 : void SdrTextObj::SetText(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat)
279 : : {
280 [ # # ][ # # ]: 0 : Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
[ # # ]
281 [ # # ]: 0 : NbcSetText(rInput,rBaseURL,eFormat);
282 [ # # ]: 0 : SetChanged();
283 [ # # ]: 0 : BroadcastObjectChange();
284 [ # # ]: 0 : SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
285 : 0 : }
286 : :
287 : 0 : const Size& SdrTextObj::GetTextSize() const
288 : : {
289 [ # # ]: 0 : if (bTextSizeDirty)
290 : : {
291 : 0 : Size aSiz;
292 [ # # ]: 0 : SdrText* pText = getActiveText();
293 [ # # ][ # # ]: 0 : if( pText && pText->GetOutlinerParaObject ())
[ # # ][ # # ]
294 : : {
295 [ # # ]: 0 : SdrOutliner& rOutliner=ImpGetDrawOutliner();
296 [ # # ][ # # ]: 0 : rOutliner.SetText(*pText->GetOutlinerParaObject());
297 [ # # ]: 0 : rOutliner.SetUpdateMode(sal_True);
298 [ # # ]: 0 : aSiz=rOutliner.CalcTextSize();
299 [ # # ]: 0 : rOutliner.Clear();
300 : : }
301 : : // casting to nonconst twice
302 : 0 : ((SdrTextObj*)this)->aTextSize=aSiz;
303 : 0 : ((SdrTextObj*)this)->bTextSizeDirty=sal_False;
304 : : }
305 : 0 : return aTextSize;
306 : : }
307 : :
308 : 267264 : bool SdrTextObj::IsAutoGrowHeight() const
309 : : {
310 [ - + ]: 267264 : if(!bTextFrame)
311 : 0 : return sal_False; // AutoGrow only together with TextFrames
312 : :
313 : 267264 : const SfxItemSet& rSet = GetObjectItemSet();
314 : 267264 : sal_Bool bRet = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
315 : :
316 [ + + ]: 267264 : if(bRet)
317 : : {
318 : 256325 : SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
319 : :
320 [ + - ][ - + ]: 256325 : if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
[ + - ]
321 : : {
322 : 0 : SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
323 : :
324 [ # # ][ # # ]: 0 : if(eDirection == SDRTEXTANI_UP || eDirection == SDRTEXTANI_DOWN)
325 : : {
326 : 0 : bRet = sal_False;
327 : : }
328 : : }
329 : : }
330 : 267264 : return bRet;
331 : : }
332 : :
333 : 386580 : bool SdrTextObj::IsAutoGrowWidth() const
334 : : {
335 [ + + ]: 386580 : if(!bTextFrame)
336 : 36 : return sal_False; // AutoGrow only together with TextFrames
337 : :
338 : 386544 : const SfxItemSet& rSet = GetObjectItemSet();
339 : 386544 : sal_Bool bRet = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWWIDTH))).GetValue();
340 : :
341 : 386544 : sal_Bool bInEditMOde = IsInEditMode();
342 : :
343 [ + + ][ + - ]: 386544 : if(!bInEditMOde && bRet)
344 : : {
345 : 192623 : SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
346 : :
347 [ + - ][ - + ]: 192623 : if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
[ + - ]
348 : : {
349 : 0 : SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
350 : :
351 [ # # ][ # # ]: 0 : if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT)
352 : : {
353 : 0 : bRet = sal_False;
354 : : }
355 : : }
356 : : }
357 : 386580 : return bRet;
358 : : }
359 : :
360 : 54507 : SdrTextHorzAdjust SdrTextObj::GetTextHorizontalAdjust() const
361 : : {
362 : 54507 : return GetTextHorizontalAdjust(GetObjectItemSet());
363 : : }
364 : :
365 : 82905 : SdrTextHorzAdjust SdrTextObj::GetTextHorizontalAdjust(const SfxItemSet& rSet) const
366 : : {
367 [ - + ]: 82905 : if(IsContourTextFrame())
368 : 0 : return SDRTEXTHORZADJUST_BLOCK;
369 : :
370 : 82905 : SdrTextHorzAdjust eRet = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
371 : :
372 : 82905 : sal_Bool bInEditMode = IsInEditMode();
373 : :
374 [ + + ][ + - ]: 82905 : if(!bInEditMode && eRet == SDRTEXTHORZADJUST_BLOCK)
375 : : {
376 : 3124 : SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
377 : :
378 [ + - ][ - + ]: 3124 : if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
[ + - ]
379 : : {
380 : 0 : SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
381 : :
382 [ # # ][ # # ]: 0 : if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT)
383 : : {
384 : 0 : eRet = SDRTEXTHORZADJUST_LEFT;
385 : : }
386 : : }
387 : : }
388 : :
389 : 82905 : return eRet;
390 : : } // defaults: BLOCK (justify) for text frame, CENTER for captions of drawing objects
391 : :
392 : 117064 : SdrTextVertAdjust SdrTextObj::GetTextVerticalAdjust() const
393 : : {
394 : 117064 : return GetTextVerticalAdjust(GetObjectItemSet());
395 : : }
396 : :
397 : 145462 : SdrTextVertAdjust SdrTextObj::GetTextVerticalAdjust(const SfxItemSet& rSet) const
398 : : {
399 [ - + ]: 145462 : if(IsContourTextFrame())
400 : 0 : return SDRTEXTVERTADJUST_TOP;
401 : :
402 : : // Take care for vertical text animation here
403 : 145462 : SdrTextVertAdjust eRet = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
404 : 145462 : sal_Bool bInEditMode = IsInEditMode();
405 : :
406 : : // Take care for vertical text animation here
407 [ - + ][ + - ]: 145462 : if(!bInEditMode && eRet == SDRTEXTVERTADJUST_BLOCK)
408 : : {
409 : 0 : SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
410 : :
411 [ # # ][ # # ]: 0 : if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
[ # # ]
412 : : {
413 : 0 : SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
414 : :
415 [ # # ][ # # ]: 0 : if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT)
416 : : {
417 : 0 : eRet = SDRTEXTVERTADJUST_TOP;
418 : : }
419 : : }
420 : : }
421 : :
422 : 145462 : return eRet;
423 : : } // defaults: TOP for text frame, CENTER for captions of drawing objects
424 : :
425 : 154886 : void SdrTextObj::ImpJustifyRect(Rectangle& rRect) const
426 : : {
427 [ + + ]: 154886 : if (!rRect.IsEmpty()) {
428 : 152398 : rRect.Justify();
429 [ + + ]: 152398 : if (rRect.Left()==rRect.Right()) rRect.Right()++;
430 [ + + ]: 152398 : if (rRect.Top()==rRect.Bottom()) rRect.Bottom()++;
431 : : }
432 : 154886 : }
433 : :
434 : 100772 : void SdrTextObj::ImpCheckShear()
435 : : {
436 [ + + ][ - + ]: 100772 : if (bNoShear && aGeo.nShearWink!=0) {
437 : 0 : aGeo.nShearWink=0;
438 : 0 : aGeo.nTan=0;
439 : : }
440 : 100772 : }
441 : :
442 : 0 : void SdrTextObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
443 : : {
444 : 0 : bool bNoTextFrame=!IsTextFrame();
445 [ # # ][ # # ]: 0 : rInfo.bResizeFreeAllowed=bNoTextFrame || aGeo.nDrehWink%9000==0;
446 : 0 : rInfo.bResizePropAllowed=sal_True;
447 : 0 : rInfo.bRotateFreeAllowed=sal_True;
448 : 0 : rInfo.bRotate90Allowed =sal_True;
449 : 0 : rInfo.bMirrorFreeAllowed=bNoTextFrame;
450 : 0 : rInfo.bMirror45Allowed =bNoTextFrame;
451 : 0 : rInfo.bMirror90Allowed =bNoTextFrame;
452 : :
453 : : // allow transparency
454 : 0 : rInfo.bTransparenceAllowed = sal_True;
455 : :
456 : : // gradient depends on fillstyle
457 : 0 : XFillStyle eFillStyle = ((XFillStyleItem&)(GetObjectItem(XATTR_FILLSTYLE))).GetValue();
458 : 0 : rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT);
459 : 0 : rInfo.bShearAllowed =bNoTextFrame;
460 : 0 : rInfo.bEdgeRadiusAllowed=sal_True;
461 : 0 : bool bCanConv=ImpCanConvTextToCurve();
462 : 0 : rInfo.bCanConvToPath =bCanConv;
463 : 0 : rInfo.bCanConvToPoly =bCanConv;
464 : 0 : rInfo.bCanConvToPathLineToArea=bCanConv;
465 : 0 : rInfo.bCanConvToPolyLineToArea=bCanConv;
466 [ # # ][ # # ]: 0 : rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
467 : 0 : }
468 : :
469 : 0 : sal_uInt16 SdrTextObj::GetObjIdentifier() const
470 : : {
471 : 0 : return sal_uInt16(eTextKind);
472 : : }
473 : :
474 : 23181 : bool SdrTextObj::HasTextImpl( SdrOutliner* pOutliner )
475 : : {
476 : 23181 : bool bRet=false;
477 [ - + ]: 23181 : if(pOutliner)
478 : : {
479 : 0 : Paragraph* p1stPara=pOutliner->GetParagraph( 0 );
480 : 0 : sal_uIntPtr nParaAnz=pOutliner->GetParagraphCount();
481 [ # # ]: 0 : if(p1stPara==NULL)
482 : 0 : nParaAnz=0;
483 : :
484 [ # # ]: 0 : if(nParaAnz==1)
485 : : {
486 : : // if it is only one paragraph, check if that paragraph is empty
487 [ # # ]: 0 : XubString aStr(pOutliner->GetText(p1stPara));
488 : :
489 [ # # ]: 0 : if(!aStr.Len())
490 [ # # ]: 0 : nParaAnz = 0;
491 : : }
492 : :
493 : 0 : bRet= nParaAnz!=0;
494 : : }
495 : 23181 : return bRet;
496 : : }
497 : :
498 : 0 : bool SdrTextObj::HasEditText() const
499 : : {
500 : 0 : return HasTextImpl( pEdtOutl );
501 : : }
502 : :
503 : 155964 : void SdrTextObj::SetPage(SdrPage* pNewPage)
504 : : {
505 [ + + ][ + + ]: 155964 : bool bRemove=pNewPage==NULL && pPage!=NULL;
506 [ + + ][ + + ]: 155964 : bool bInsert=pNewPage!=NULL && pPage==NULL;
507 : 155964 : bool bLinked=IsLinkedText();
508 : :
509 [ # # ][ - + ]: 155964 : if (bLinked && bRemove) {
510 : 0 : ImpLinkAbmeldung();
511 : : }
512 : :
513 : 155964 : SdrAttrObj::SetPage(pNewPage);
514 : :
515 [ # # ][ - + ]: 155964 : if (bLinked && bInsert) {
516 : 0 : ImpLinkAnmeldung();
517 : : }
518 : 155964 : }
519 : :
520 : 108932 : void SdrTextObj::SetModel(SdrModel* pNewModel)
521 : : {
522 : 108932 : SdrModel* pOldModel=pModel;
523 : 108932 : bool bLinked=IsLinkedText();
524 : 108932 : bool bChg=pNewModel!=pModel;
525 : :
526 [ # # ][ - + ]: 108932 : if (bLinked && bChg)
527 : : {
528 : 0 : ImpLinkAbmeldung();
529 : : }
530 : :
531 : 108932 : SdrAttrObj::SetModel(pNewModel);
532 : :
533 [ + + ]: 108932 : if( bChg )
534 : : {
535 [ + - ][ - + ]: 57388 : if( pNewModel != 0 && pOldModel != 0 )
536 : 0 : SetTextSizeDirty();
537 : :
538 : 57388 : sal_Int32 nCount = getTextCount();
539 [ + + ]: 114776 : for( sal_Int32 nText = 0; nText < nCount; nText++ )
540 : : {
541 : 57388 : SdrText* pText = getText( nText );
542 [ + - ]: 57388 : if( pText )
543 : 57388 : pText->SetModel( pNewModel );
544 : : }
545 : : }
546 : :
547 [ - + ][ # # ]: 108932 : if (bLinked && bChg)
548 : : {
549 : 0 : ImpLinkAnmeldung();
550 : : }
551 : 108932 : }
552 : :
553 : 0 : bool SdrTextObj::NbcSetEckenradius(long nRad)
554 : : {
555 [ # # ]: 0 : SetObjectItem(SdrEckenradiusItem(nRad));
556 : 0 : return true;
557 : : }
558 : :
559 : 76083 : bool SdrTextObj::NbcSetMinTextFrameHeight(long nHgt)
560 : : {
561 [ + - ][ + + ]: 76083 : if( bTextFrame && ( !pModel || !pModel->isLocked() ) ) // #i44922#
[ + + ][ + + ]
562 : : {
563 [ + - ]: 1554 : SetObjectItem(SdrTextMinFrameHeightItem(nHgt));
564 : :
565 : : // use bDisableAutoWidthOnDragging as
566 : : // bDisableAutoHeightOnDragging if vertical.
567 [ # # ][ - + ]: 1554 : if(IsVerticalWriting() && bDisableAutoWidthOnDragging)
[ - + ]
568 : : {
569 : 0 : bDisableAutoWidthOnDragging = sal_False;
570 [ # # ]: 0 : SetObjectItem(SdrTextAutoGrowHeightItem(sal_False));
571 : : }
572 : :
573 : 1554 : return true;
574 : : }
575 : 76083 : return false;
576 : : }
577 : :
578 : 29433 : bool SdrTextObj::NbcSetMinTextFrameWidth(long nWdt)
579 : : {
580 [ + - ][ + - ]: 29433 : if( bTextFrame && ( !pModel || !pModel->isLocked() ) ) // #i44922#
[ - + ][ - + ]
581 : : {
582 [ # # ]: 0 : SetObjectItem(SdrTextMinFrameWidthItem(nWdt));
583 : :
584 : : // use bDisableAutoWidthOnDragging only
585 : : // when not vertical.
586 [ # # ][ # # ]: 0 : if(!IsVerticalWriting() && bDisableAutoWidthOnDragging)
[ # # ]
587 : : {
588 : 0 : bDisableAutoWidthOnDragging = sal_False;
589 [ # # ]: 0 : SetObjectItem(SdrTextAutoGrowWidthItem(sal_False));
590 : : }
591 : :
592 : 0 : return true;
593 : : }
594 : 29433 : return false;
595 : : }
596 : :
597 : 0 : void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, Rectangle& rAnchorRect, sal_Bool bLineWidth ) const
598 : : {
599 [ # # ]: 0 : basegfx::B2DPolyPolygon aXorPolyPolygon(TakeXorPoly());
600 : 0 : basegfx::B2DPolyPolygon* pContourPolyPolygon = 0L;
601 : : basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix(
602 [ # # ]: 0 : -rAnchorRect.Left(), -rAnchorRect.Top()));
603 : :
604 [ # # ]: 0 : if(aGeo.nDrehWink)
605 : : {
606 : : // Unrotate!
607 [ # # ]: 0 : aMatrix.rotate(-aGeo.nDrehWink * nPi180);
608 : : }
609 : :
610 [ # # ]: 0 : aXorPolyPolygon.transform(aMatrix);
611 : :
612 [ # # ]: 0 : if( bLineWidth )
613 : : {
614 : : // Take line width into account.
615 : : // When doing the hit test, avoid this. (Performance!)
616 [ # # ][ # # ]: 0 : pContourPolyPolygon = new basegfx::B2DPolyPolygon();
617 : :
618 : : // test if shadow needs to be avoided for TakeContour()
619 [ # # ]: 0 : const SfxItemSet& rSet = GetObjectItemSet();
620 [ # # ]: 0 : sal_Bool bShadowOn = ((SdrShadowItem&)(rSet.Get(SDRATTR_SHADOW))).GetValue();
621 : :
622 : : // #i33696#
623 : : // Remember TextObject currently set at the DrawOutliner, it WILL be
624 : : // replaced during calculating the outline since it uses an own paint
625 : : // and that one uses the DrawOutliner, too.
626 [ # # ]: 0 : const SdrTextObj* pLastTextObject = rOutliner.GetTextObj();
627 : :
628 [ # # ]: 0 : if(bShadowOn)
629 : : {
630 : : // force shadow off
631 [ # # ]: 0 : SdrObject* pCopy = Clone();
632 [ # # ][ # # ]: 0 : pCopy->SetMergedItem(SdrShadowItem(sal_False));
[ # # ]
633 [ # # ][ # # ]: 0 : *pContourPolyPolygon = pCopy->TakeContour();
[ # # ]
634 [ # # ]: 0 : SdrObject::Free( pCopy );
635 : : }
636 : : else
637 : : {
638 [ # # ][ # # ]: 0 : *pContourPolyPolygon = TakeContour();
[ # # ]
639 : : }
640 : :
641 : : // #i33696#
642 : : // restore remembered text object
643 [ # # ][ # # ]: 0 : if(pLastTextObject != rOutliner.GetTextObj())
644 : : {
645 [ # # ]: 0 : rOutliner.SetTextObj(pLastTextObject);
646 : : }
647 : :
648 [ # # ]: 0 : pContourPolyPolygon->transform(aMatrix);
649 : : }
650 : :
651 [ # # ][ # # ]: 0 : rOutliner.SetPolygon(aXorPolyPolygon, pContourPolyPolygon);
[ # # ]
652 : 0 : }
653 : :
654 : 0 : void SdrTextObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
655 : : {
656 : 0 : rRect=aRect;
657 : 0 : }
658 : :
659 : 0 : void SdrTextObj::TakeTextAnchorRect(Rectangle& rAnchorRect) const
660 : : {
661 [ # # ]: 0 : long nLeftDist=GetTextLeftDistance();
662 [ # # ]: 0 : long nRightDist=GetTextRightDistance();
663 [ # # ]: 0 : long nUpperDist=GetTextUpperDistance();
664 [ # # ]: 0 : long nLowerDist=GetTextLowerDistance();
665 : 0 : Rectangle aAnkRect(aRect); // the rectangle in which we anchor
666 : 0 : bool bFrame=IsTextFrame();
667 [ # # ]: 0 : if (!bFrame) {
668 [ # # ]: 0 : TakeUnrotatedSnapRect(aAnkRect);
669 : : }
670 : 0 : Point aRotateRef(aAnkRect.TopLeft());
671 : 0 : aAnkRect.Left()+=nLeftDist;
672 : 0 : aAnkRect.Top()+=nUpperDist;
673 : 0 : aAnkRect.Right()-=nRightDist;
674 : 0 : aAnkRect.Bottom()-=nLowerDist;
675 : :
676 : : // Since sizes may be bigger than the object bounds it is necessary to
677 : : // justify the rect now.
678 [ # # ]: 0 : ImpJustifyRect(aAnkRect);
679 : :
680 [ # # ]: 0 : if (bFrame) {
681 : : // TODO: Optimize this.
682 [ # # ][ # # ]: 0 : if (aAnkRect.GetWidth()<2) aAnkRect.Right()=aAnkRect.Left()+1; // minimum size h and v: 2 px
683 [ # # ][ # # ]: 0 : if (aAnkRect.GetHeight()<2) aAnkRect.Bottom()=aAnkRect.Top()+1;
684 : : }
685 [ # # ]: 0 : if (aGeo.nDrehWink!=0) {
686 : 0 : Point aTmpPt(aAnkRect.TopLeft());
687 : 0 : RotatePoint(aTmpPt,aRotateRef,aGeo.nSin,aGeo.nCos);
688 : 0 : aTmpPt-=aAnkRect.TopLeft();
689 [ # # ]: 0 : aAnkRect.Move(aTmpPt.X(),aTmpPt.Y());
690 : : }
691 : 0 : rAnchorRect=aAnkRect;
692 : 0 : }
693 : :
694 : 0 : void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText,
695 : : Rectangle* pAnchorRect, bool bLineWidth ) const
696 : : {
697 [ # # ]: 0 : Rectangle aAnkRect; // the rectangle in which we anchor
698 [ # # ]: 0 : TakeTextAnchorRect(aAnkRect);
699 [ # # ]: 0 : SdrTextVertAdjust eVAdj=GetTextVerticalAdjust();
700 [ # # ]: 0 : SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust();
701 [ # # ]: 0 : SdrTextAniKind eAniKind=GetTextAniKind();
702 [ # # ]: 0 : SdrTextAniDirection eAniDirection=GetTextAniDirection();
703 : :
704 [ # # ]: 0 : bool bFitToSize(IsFitToSize());
705 [ # # ]: 0 : bool bContourFrame=IsContourTextFrame();
706 : :
707 : 0 : bool bFrame=IsTextFrame();
708 [ # # ]: 0 : sal_uIntPtr nStat0=rOutliner.GetControlWord();
709 : 0 : Size aNullSize;
710 [ # # ]: 0 : if (!bContourFrame)
711 : : {
712 [ # # ]: 0 : rOutliner.SetControlWord(nStat0|EE_CNTRL_AUTOPAGESIZE);
713 [ # # ]: 0 : rOutliner.SetMinAutoPaperSize(aNullSize);
714 [ # # ]: 0 : rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
715 : : }
716 : :
717 [ # # ][ # # ]: 0 : if (!bFitToSize && !bContourFrame)
718 : : {
719 [ # # ]: 0 : long nAnkWdt=aAnkRect.GetWidth();
720 [ # # ]: 0 : long nAnkHgt=aAnkRect.GetHeight();
721 [ # # ]: 0 : if (bFrame)
722 : : {
723 : 0 : long nWdt=nAnkWdt;
724 : 0 : long nHgt=nAnkHgt;
725 : :
726 : 0 : sal_Bool bInEditMode = IsInEditMode();
727 : :
728 [ # # ][ # # ]: 0 : if (!bInEditMode && (eAniKind==SDRTEXTANI_SCROLL || eAniKind==SDRTEXTANI_ALTERNATE || eAniKind==SDRTEXTANI_SLIDE))
[ # # ][ # # ]
729 : : {
730 : : // unlimited paper size for ticker text
731 [ # # ][ # # ]: 0 : if (eAniDirection==SDRTEXTANI_LEFT || eAniDirection==SDRTEXTANI_RIGHT) nWdt=1000000;
732 [ # # ][ # # ]: 0 : if (eAniDirection==SDRTEXTANI_UP || eAniDirection==SDRTEXTANI_DOWN) nHgt=1000000;
733 : : }
734 [ # # ]: 0 : rOutliner.SetMaxAutoPaperSize(Size(nWdt,nHgt));
735 : : }
736 : :
737 : : // New try with _BLOCK for hor and ver after completely
738 : : // supporting full width for vertical text.
739 [ # # ][ # # ]: 0 : if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
[ # # ][ # # ]
740 : : {
741 [ # # ]: 0 : rOutliner.SetMinAutoPaperSize(Size(nAnkWdt, 0));
742 : : }
743 : :
744 [ # # ][ # # ]: 0 : if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting())
[ # # ][ # # ]
745 : : {
746 [ # # ]: 0 : rOutliner.SetMinAutoPaperSize(Size(0, nAnkHgt));
747 : : }
748 : : }
749 : :
750 [ # # ]: 0 : rOutliner.SetPaperSize(aNullSize);
751 [ # # ]: 0 : if (bContourFrame)
752 [ # # ]: 0 : ImpSetContourPolygon( rOutliner, aAnkRect, bLineWidth );
753 : :
754 : : // put text into the outliner, if available from the edit outliner
755 [ # # ]: 0 : SdrText* pText = getActiveText();
756 [ # # ][ # # ]: 0 : OutlinerParaObject* pOutlinerParaObject = pText ? pText->GetOutlinerParaObject() : 0;
757 [ # # ][ # # ]: 0 : OutlinerParaObject* pPara = (pEdtOutl && !bNoEditText) ? pEdtOutl->CreateParaObject() : pOutlinerParaObject;
[ # # ]
758 : :
759 [ # # ]: 0 : if (pPara)
760 : : {
761 : 0 : sal_Bool bHitTest = sal_False;
762 [ # # ]: 0 : if( pModel )
763 : 0 : bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
764 : :
765 [ # # ]: 0 : const SdrTextObj* pTestObj = rOutliner.GetTextObj();
766 [ # # ][ # # ]: 0 : if( !pTestObj || !bHitTest || pTestObj != this ||
[ # # ][ # # ]
[ # # ]
767 [ # # ]: 0 : pTestObj->GetOutlinerParaObject() != pOutlinerParaObject )
768 : : {
769 [ # # ]: 0 : if( bHitTest ) // #i33696# take back fix #i27510#
770 : : {
771 [ # # ]: 0 : rOutliner.SetTextObj( this );
772 [ # # ][ # # ]: 0 : rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
773 : : }
774 : :
775 [ # # ]: 0 : rOutliner.SetUpdateMode(sal_True);
776 [ # # ]: 0 : rOutliner.SetText(*pPara);
777 : : }
778 : : }
779 : : else
780 : : {
781 [ # # ]: 0 : rOutliner.SetTextObj( NULL );
782 : : }
783 : :
784 [ # # ][ # # ]: 0 : if (pEdtOutl && !bNoEditText && pPara)
[ # # ]
785 [ # # ][ # # ]: 0 : delete pPara;
786 : :
787 [ # # ]: 0 : rOutliner.SetUpdateMode(sal_True);
788 [ # # ]: 0 : rOutliner.SetControlWord(nStat0);
789 : :
790 [ # # ]: 0 : if( pText )
791 [ # # ]: 0 : pText->CheckPortionInfo(rOutliner);
792 : :
793 : 0 : Point aTextPos(aAnkRect.TopLeft());
794 [ # # ]: 0 : Size aTextSiz(rOutliner.GetPaperSize()); // GetPaperSize() adds a little tolerance, right?
795 : :
796 : : // For draw objects containing text correct hor/ver alignment if text is bigger
797 : : // than the object itself. Without that correction, the text would always be
798 : : // formatted to the left edge (or top edge when vertical) of the draw object.
799 [ # # ]: 0 : if(!IsTextFrame())
800 : : {
801 [ # # ][ # # ]: 0 : if(aAnkRect.GetWidth() < aTextSiz.Width() && !IsVerticalWriting())
[ # # ][ # # ]
[ # # ]
802 : : {
803 : : // Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK,
804 : : // else the alignment is wanted.
805 [ # # ]: 0 : if(SDRTEXTHORZADJUST_BLOCK == eHAdj)
806 : : {
807 : 0 : eHAdj = SDRTEXTHORZADJUST_CENTER;
808 : : }
809 : : }
810 : :
811 [ # # ][ # # ]: 0 : if(aAnkRect.GetHeight() < aTextSiz.Height() && IsVerticalWriting())
[ # # ][ # # ]
[ # # ]
812 : : {
813 : : // Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK,
814 : : // else the alignment is wanted.
815 [ # # ]: 0 : if(SDRTEXTVERTADJUST_BLOCK == eVAdj)
816 : : {
817 : 0 : eVAdj = SDRTEXTVERTADJUST_CENTER;
818 : : }
819 : : }
820 : : }
821 : :
822 [ # # ][ # # ]: 0 : if (eHAdj==SDRTEXTHORZADJUST_CENTER || eHAdj==SDRTEXTHORZADJUST_RIGHT)
823 : : {
824 [ # # ]: 0 : long nFreeWdt=aAnkRect.GetWidth()-aTextSiz.Width();
825 [ # # ]: 0 : if (eHAdj==SDRTEXTHORZADJUST_CENTER)
826 : 0 : aTextPos.X()+=nFreeWdt/2;
827 [ # # ]: 0 : if (eHAdj==SDRTEXTHORZADJUST_RIGHT)
828 : 0 : aTextPos.X()+=nFreeWdt;
829 : : }
830 [ # # ][ # # ]: 0 : if (eVAdj==SDRTEXTVERTADJUST_CENTER || eVAdj==SDRTEXTVERTADJUST_BOTTOM)
831 : : {
832 [ # # ]: 0 : long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height();
833 [ # # ]: 0 : if (eVAdj==SDRTEXTVERTADJUST_CENTER)
834 : 0 : aTextPos.Y()+=nFreeHgt/2;
835 [ # # ]: 0 : if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
836 : 0 : aTextPos.Y()+=nFreeHgt;
837 : : }
838 [ # # ]: 0 : if (aGeo.nDrehWink!=0)
839 : 0 : RotatePoint(aTextPos,aAnkRect.TopLeft(),aGeo.nSin,aGeo.nCos);
840 : :
841 [ # # ]: 0 : if (pAnchorRect)
842 : 0 : *pAnchorRect=aAnkRect;
843 : :
844 : : // rTextRect might not be correct in some cases at ContourFrame
845 [ # # ]: 0 : rTextRect=Rectangle(aTextPos,aTextSiz);
846 [ # # ]: 0 : if (bContourFrame)
847 : 0 : rTextRect=aAnkRect;
848 : 0 : }
849 : :
850 : 23181 : OutlinerParaObject* SdrTextObj::GetEditOutlinerParaObject() const
851 : : {
852 : 23181 : OutlinerParaObject* pPara=NULL;
853 [ - + ]: 23181 : if( HasTextImpl( pEdtOutl ) )
854 : : {
855 : 0 : sal_uInt16 nParaAnz = static_cast< sal_uInt16 >( pEdtOutl->GetParagraphCount() );
856 : 0 : pPara = pEdtOutl->CreateParaObject(0, nParaAnz);
857 : : }
858 : 23181 : return pPara;
859 : : }
860 : :
861 : 0 : void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextSize, const Size& rShapeSize, Fraction& rFitXKorreg) const
862 : : {
863 : 0 : OutputDevice* pOut = rOutliner.GetRefDevice();
864 : 0 : sal_Bool bNoStretching(sal_False);
865 : :
866 [ # # ][ # # ]: 0 : if(pOut && pOut->GetOutDevType() == OUTDEV_PRINTER)
[ # # ]
867 : : {
868 : : // check whether CharStretching is possible at all
869 : 0 : GDIMetaFile* pMtf = pOut->GetConnectMetaFile();
870 : 0 : rtl::OUString aTestString(static_cast<sal_Unicode>('J'));
871 : :
872 [ # # ][ # # ]: 0 : if(pMtf && (!pMtf->IsRecord() || pMtf->IsPause()))
[ # # ][ # # ]
873 : 0 : pMtf = NULL;
874 : :
875 [ # # ]: 0 : if(pMtf)
876 [ # # ]: 0 : pMtf->Pause(sal_True);
877 : :
878 [ # # ]: 0 : Font aFontMerk(pOut->GetFont());
879 [ # # ]: 0 : Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_SERIF, LANGUAGE_SYSTEM, DEFAULTFONT_FLAGS_ONLYONE ) );
880 : :
881 [ # # ]: 0 : aTmpFont.SetSize(Size(0,100));
882 [ # # ]: 0 : pOut->SetFont(aTmpFont);
883 [ # # ][ # # ]: 0 : Size aSize1(pOut->GetTextWidth(aTestString), pOut->GetTextHeight());
[ # # ][ # # ]
884 [ # # ]: 0 : aTmpFont.SetSize(Size(800,100));
885 [ # # ]: 0 : pOut->SetFont(aTmpFont);
886 [ # # ][ # # ]: 0 : Size aSize2(pOut->GetTextWidth(aTestString), pOut->GetTextHeight());
[ # # ][ # # ]
887 [ # # ]: 0 : pOut->SetFont(aFontMerk);
888 : :
889 [ # # ]: 0 : if(pMtf)
890 [ # # ]: 0 : pMtf->Pause(sal_False);
891 : :
892 [ # # ][ # # ]: 0 : bNoStretching = (aSize1 == aSize2);
893 : :
894 : : #ifdef WNT
895 : : // Windows zooms the font proportionally when using Size(100,500),
896 : : // we don't like that.
897 : : if(aSize2.Height() >= aSize1.Height() * 2)
898 : : {
899 : : bNoStretching = sal_True;
900 : : }
901 : : #endif
902 : : }
903 : 0 : unsigned nLoopCount=0;
904 : 0 : bool bNoMoreLoop = false;
905 : 0 : long nXDiff0=0x7FFFFFFF;
906 : 0 : long nWantWdt=rShapeSize.Width();
907 : 0 : long nIsWdt=rTextSize.Width();
908 [ # # ]: 0 : if (nIsWdt==0) nIsWdt=1;
909 : :
910 : 0 : long nWantHgt=rShapeSize.Height();
911 : 0 : long nIsHgt=rTextSize.Height();
912 [ # # ]: 0 : if (nIsHgt==0) nIsHgt=1;
913 : :
914 : 0 : long nXTolPl=nWantWdt/100; // tolerance: +1%
915 : 0 : long nXTolMi=nWantWdt/25; // tolerance: -4%
916 : 0 : long nXKorr =nWantWdt/20; // correction scale: 5%
917 : :
918 : 0 : long nX=(nWantWdt*100) /nIsWdt; // calculate X stretching
919 : 0 : long nY=(nWantHgt*100) /nIsHgt; // calculate Y stretching
920 : 0 : bool bChkX = true;
921 [ # # ]: 0 : if (bNoStretching) { // might only be be possible proportionally
922 [ # # ]: 0 : if (nX>nY) { nX=nY; bChkX=sal_False; }
923 : 0 : else { nY=nX; }
924 : : }
925 : :
926 [ # # ][ # # ]: 0 : while (nLoopCount<5 && !bNoMoreLoop) {
[ # # ]
927 [ # # ]: 0 : if (nX<0) nX=-nX;
928 [ # # ]: 0 : if (nX<1) { nX=1; bNoMoreLoop = true; }
929 [ # # ]: 0 : if (nX>65535) { nX=65535; bNoMoreLoop = true; }
930 : :
931 [ # # ]: 0 : if (nY<0) nY=-nY;
932 [ # # ]: 0 : if (nY<1) { nY=1; bNoMoreLoop = true; }
933 [ # # ]: 0 : if (nY>65535) { nY=65535; bNoMoreLoop = true; }
934 : :
935 : : // exception, there is no text yet (horizontal case)
936 [ # # ]: 0 : if(nIsWdt <= 1)
937 : : {
938 : 0 : nX = nY;
939 : 0 : bNoMoreLoop = true;
940 : : }
941 : :
942 : : // exception, there is no text yet (vertical case)
943 [ # # ]: 0 : if(nIsHgt <= 1)
944 : : {
945 : 0 : nY = nX;
946 : 0 : bNoMoreLoop = true;
947 : : }
948 : :
949 [ # # ]: 0 : rOutliner.SetGlobalCharStretching((sal_uInt16)nX,(sal_uInt16)nY);
950 : 0 : nLoopCount++;
951 [ # # ]: 0 : Size aSiz(rOutliner.CalcTextSize());
952 : 0 : long nXDiff=aSiz.Width()-nWantWdt;
953 [ # # ][ # # ]: 0 : rFitXKorreg=Fraction(nWantWdt,aSiz.Width());
954 [ # # ][ # # ]: 0 : if (((nXDiff>=nXTolMi || !bChkX) && nXDiff<=nXTolPl) || nXDiff==nXDiff0) {
[ # # ][ # # ]
955 : 0 : bNoMoreLoop = true;
956 : : } else {
957 : : // correct stretching factors
958 : 0 : long nMul=nWantWdt;
959 : 0 : long nDiv=aSiz.Width();
960 [ # # ]: 0 : if (Abs(nXDiff)<=2*nXKorr) {
961 [ # # ]: 0 : if (nMul>nDiv) nDiv+=(nMul-nDiv)/2; // but only add half of what we calculated,
962 : 0 : else nMul+=(nDiv-nMul)/2; // because the EditEngine calculates wrongly later on
963 : : }
964 : 0 : nX=nX*nMul/nDiv;
965 [ # # ]: 0 : if (bNoStretching) nY=nX;
966 : : }
967 : 0 : nXDiff0=nXDiff;
968 : : }
969 : 0 : }
970 : :
971 : 66 : void SdrTextObj::TakeObjNameSingul(XubString& rName) const
972 : : {
973 [ + - ]: 66 : XubString aStr;
974 : :
975 [ + + + ]: 66 : switch(eTextKind)
976 : : {
977 : : case OBJ_OUTLINETEXT:
978 : : {
979 [ + - ][ + - ]: 6 : aStr = ImpGetResStr(STR_ObjNameSingulOUTLINETEXT);
[ + - ]
980 : 6 : break;
981 : : }
982 : :
983 : : case OBJ_TITLETEXT :
984 : : {
985 [ + - ][ + - ]: 18 : aStr = ImpGetResStr(STR_ObjNameSingulTITLETEXT);
[ + - ]
986 : 18 : break;
987 : : }
988 : :
989 : : default:
990 : : {
991 [ + - ][ - + ]: 42 : if(IsLinkedText())
992 [ # # ][ # # ]: 0 : aStr = ImpGetResStr(STR_ObjNameSingulTEXTLNK);
[ # # ]
993 : : else
994 [ + - ][ + - ]: 42 : aStr = ImpGetResStr(STR_ObjNameSingulTEXT);
[ + - ]
995 : 42 : break;
996 : : }
997 : : }
998 : :
999 [ + - ]: 66 : OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
1000 [ + - ][ + + ]: 66 : if(pOutlinerParaObject && eTextKind != OBJ_OUTLINETEXT)
1001 : : {
1002 : : // shouldn't currently cause any problems at OUTLINETEXT
1003 [ + - ][ + - ]: 60 : XubString aStr2(comphelper::string::stripStart(pOutlinerParaObject->GetTextObject().GetText(0), ' '));
[ + - ][ + - ]
[ + - ][ + - ]
1004 : :
1005 : : // avoid non expanded text portions in object name
1006 : : // (second condition is new)
1007 [ + - ][ + - ]: 60 : if(aStr2.Len() && aStr2.Search(sal_Unicode(255)) == STRING_NOTFOUND)
[ + - ][ + - ]
1008 : : {
1009 : : // space between ResStr and content text
1010 [ + - ]: 60 : aStr += sal_Unicode(' ');
1011 : :
1012 [ + - ]: 60 : aStr += sal_Unicode('\'');
1013 : :
1014 [ + + ]: 60 : if(aStr2.Len() > 10)
1015 : : {
1016 [ + - ]: 24 : aStr2.Erase(8);
1017 [ + - ]: 24 : aStr2.AppendAscii("...", 3);
1018 : : }
1019 : :
1020 [ + - ]: 60 : aStr += aStr2;
1021 [ + - ]: 60 : aStr += sal_Unicode('\'');
1022 [ + - ]: 60 : }
1023 : : }
1024 : :
1025 [ + - ]: 66 : rName = aStr;
1026 : :
1027 [ + - ][ + - ]: 66 : String aName( GetName() );
1028 [ - + ]: 66 : if(aName.Len())
1029 : : {
1030 [ # # ]: 0 : rName += sal_Unicode(' ');
1031 [ # # ]: 0 : rName += sal_Unicode('\'');
1032 [ # # ]: 0 : rName += aName;
1033 [ # # ]: 0 : rName += sal_Unicode('\'');
1034 [ + - ][ + - ]: 66 : }
1035 : :
1036 : 66 : }
1037 : :
1038 : 0 : void SdrTextObj::TakeObjNamePlural(XubString& rName) const
1039 : : {
1040 [ # # # ]: 0 : switch (eTextKind) {
1041 [ # # ]: 0 : case OBJ_OUTLINETEXT: rName=ImpGetResStr(STR_ObjNamePluralOUTLINETEXT); break;
1042 [ # # ]: 0 : case OBJ_TITLETEXT : rName=ImpGetResStr(STR_ObjNamePluralTITLETEXT); break;
1043 : : default: {
1044 [ # # ]: 0 : if (IsLinkedText()) {
1045 [ # # ]: 0 : rName=ImpGetResStr(STR_ObjNamePluralTEXTLNK);
1046 : : } else {
1047 [ # # ]: 0 : rName=ImpGetResStr(STR_ObjNamePluralTEXT);
1048 : : }
1049 : 0 : } break;
1050 : : } // switch
1051 : 0 : }
1052 : :
1053 : 0 : SdrTextObj* SdrTextObj::Clone() const
1054 : : {
1055 : 0 : return CloneHelper< SdrTextObj >();
1056 : : }
1057 : :
1058 : 6 : SdrTextObj& SdrTextObj::operator=(const SdrTextObj& rObj)
1059 : : {
1060 [ - + ]: 6 : if( this == &rObj )
1061 : 0 : return *this;
1062 : : // call parent
1063 : 6 : SdrObject::operator=(rObj);
1064 : :
1065 : 6 : aRect =rObj.aRect;
1066 : 6 : aGeo =rObj.aGeo;
1067 : 6 : eTextKind =rObj.eTextKind;
1068 : 6 : bTextFrame=rObj.bTextFrame;
1069 : 6 : aTextSize=rObj.aTextSize;
1070 : 6 : bTextSizeDirty=rObj.bTextSizeDirty;
1071 : :
1072 : : // Not all of the necessary parameters were copied yet.
1073 : 6 : bNoShear = rObj.bNoShear;
1074 : 6 : bNoRotate = rObj.bNoRotate;
1075 : 6 : bNoMirror = rObj.bNoMirror;
1076 : 6 : bDisableAutoWidthOnDragging = rObj.bDisableAutoWidthOnDragging;
1077 : :
1078 : 6 : OutlinerParaObject* pNewOutlinerParaObject = 0;
1079 : :
1080 : 6 : SdrText* pText = getActiveText();
1081 : :
1082 [ - + ][ - + ]: 6 : if( pText && rObj.HasText() )
[ + - ]
1083 : : {
1084 : 0 : const Outliner* pEO=rObj.pEdtOutl;
1085 [ # # ]: 0 : if (pEO!=NULL)
1086 : : {
1087 : 0 : pNewOutlinerParaObject = pEO->CreateParaObject();
1088 : : }
1089 : : else
1090 : : {
1091 [ # # ]: 0 : pNewOutlinerParaObject = new OutlinerParaObject(*rObj.getActiveText()->GetOutlinerParaObject());
1092 : : }
1093 : : }
1094 : :
1095 : 6 : mpText->SetOutlinerParaObject( pNewOutlinerParaObject );
1096 : 6 : ImpSetTextStyleSheetListeners();
1097 : 6 : return *this;
1098 : : }
1099 : :
1100 : 0 : basegfx::B2DPolyPolygon SdrTextObj::TakeXorPoly() const
1101 : : {
1102 [ # # ]: 0 : Polygon aPol(aRect);
1103 [ # # ][ # # ]: 0 : if (aGeo.nShearWink!=0) ShearPoly(aPol,aRect.TopLeft(),aGeo.nTan);
1104 [ # # ][ # # ]: 0 : if (aGeo.nDrehWink!=0) RotatePoly(aPol,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
1105 : :
1106 [ # # ]: 0 : basegfx::B2DPolyPolygon aRetval;
1107 [ # # ][ # # ]: 0 : aRetval.append(aPol.getB2DPolygon());
[ # # ]
1108 [ # # ]: 0 : return aRetval;
1109 : : }
1110 : :
1111 : 0 : basegfx::B2DPolyPolygon SdrTextObj::TakeContour() const
1112 : : {
1113 : 0 : basegfx::B2DPolyPolygon aRetval(SdrAttrObj::TakeContour());
1114 : :
1115 : : // and now add the BoundRect of the text, if necessary
1116 [ # # ][ # # ]: 0 : if ( pModel && GetOutlinerParaObject() && !IsFontwork() && !IsContourTextFrame() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1117 : : {
1118 : : // using Clone()-Paint() strategy inside TakeContour() leaves a destroyed
1119 : : // SdrObject as pointer in DrawOutliner. Set *this again in fetching the outliner
1120 : : // in every case
1121 [ # # ]: 0 : SdrOutliner& rOutliner=ImpGetDrawOutliner();
1122 : :
1123 [ # # ]: 0 : Rectangle aAnchor2;
1124 [ # # ]: 0 : Rectangle aR;
1125 [ # # ]: 0 : TakeTextRect(rOutliner,aR,sal_False,&aAnchor2);
1126 [ # # ]: 0 : rOutliner.Clear();
1127 [ # # ]: 0 : bool bFitToSize(IsFitToSize());
1128 [ # # ]: 0 : if (bFitToSize) aR=aAnchor2;
1129 [ # # ]: 0 : Polygon aPol(aR);
1130 [ # # ][ # # ]: 0 : if (aGeo.nDrehWink!=0) RotatePoly(aPol,aR.TopLeft(),aGeo.nSin,aGeo.nCos);
1131 : :
1132 [ # # ][ # # ]: 0 : aRetval.append(aPol.getB2DPolygon());
[ # # ][ # # ]
1133 : : }
1134 : :
1135 : 0 : return aRetval;
1136 : : }
1137 : :
1138 : 51796 : void SdrTextObj::RecalcSnapRect()
1139 : : {
1140 [ + + ][ - + ]: 51796 : if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) {
1141 [ + - ]: 546 : Polygon aPol(aRect);
1142 [ - + ][ # # ]: 546 : if (aGeo.nShearWink!=0) ShearPoly(aPol,aRect.TopLeft(),aGeo.nTan);
1143 [ + - ][ + - ]: 546 : if (aGeo.nDrehWink!=0) RotatePoly(aPol,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
1144 [ + - ][ + - ]: 546 : maSnapRect=aPol.GetBoundRect();
1145 : : } else {
1146 : 51250 : maSnapRect=aRect;
1147 : : }
1148 : 51796 : }
1149 : :
1150 : 0 : sal_uInt32 SdrTextObj::GetSnapPointCount() const
1151 : : {
1152 : 0 : return 4L;
1153 : : }
1154 : :
1155 : 0 : Point SdrTextObj::GetSnapPoint(sal_uInt32 i) const
1156 : : {
1157 : 0 : Point aP;
1158 [ # # # # : 0 : switch (i) {
# ]
1159 : 0 : case 0: aP=aRect.TopLeft(); break;
1160 : 0 : case 1: aP=aRect.TopRight(); break;
1161 : 0 : case 2: aP=aRect.BottomLeft(); break;
1162 : 0 : case 3: aP=aRect.BottomRight(); break;
1163 : 0 : default: aP=aRect.Center(); break;
1164 : : }
1165 [ # # ]: 0 : if (aGeo.nShearWink!=0) ShearPoint(aP,aRect.TopLeft(),aGeo.nTan);
1166 [ # # ]: 0 : if (aGeo.nDrehWink!=0) RotatePoint(aP,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
1167 : 0 : return aP;
1168 : : }
1169 : :
1170 : 54082 : void SdrTextObj::ImpCheckMasterCachable()
1171 : : {
1172 : 54082 : bNotMasterCachable=sal_False;
1173 : :
1174 : 54082 : OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
1175 : :
1176 [ + + ][ + + ]: 54082 : if(!bNotVisibleAsMaster && pOutlinerParaObject && pOutlinerParaObject->IsEditDoc() )
[ + + ][ + + ]
1177 : : {
1178 : 52941 : const EditTextObject& rText= pOutlinerParaObject->GetTextObject();
1179 : 52941 : bNotMasterCachable=rText.HasField(SvxPageField::StaticType());
1180 [ + + ]: 52941 : if( !bNotMasterCachable )
1181 : : {
1182 : 52408 : bNotMasterCachable=rText.HasField(SvxHeaderField::StaticType());
1183 [ + + ]: 52408 : if( !bNotMasterCachable )
1184 : : {
1185 : 52108 : bNotMasterCachable=rText.HasField(SvxFooterField::StaticType());
1186 [ + + ]: 52108 : if( !bNotMasterCachable )
1187 : : {
1188 : 51593 : bNotMasterCachable=rText.HasField(SvxDateTimeField::StaticType());
1189 : : }
1190 : : }
1191 : : }
1192 : : }
1193 : 54082 : }
1194 : :
1195 : : // Extracted from ImpGetDrawOutliner()
1196 : 230226 : void SdrTextObj::ImpInitDrawOutliner( SdrOutliner& rOutl ) const
1197 : : {
1198 [ + - ]: 230226 : rOutl.SetUpdateMode(sal_False);
1199 : 230226 : sal_uInt16 nOutlinerMode = OUTLINERMODE_OUTLINEOBJECT;
1200 [ + + ]: 230226 : if ( !IsOutlText() )
1201 : 226954 : nOutlinerMode = OUTLINERMODE_TEXTOBJECT;
1202 [ + - ]: 230226 : rOutl.Init( nOutlinerMode );
1203 : :
1204 [ + - ]: 230226 : rOutl.SetGlobalCharStretching(100,100);
1205 [ + - ]: 230226 : sal_uIntPtr nStat=rOutl.GetControlWord();
1206 : 230226 : nStat&=~(EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE);
1207 [ + - ]: 230226 : rOutl.SetControlWord(nStat);
1208 : 230226 : Size aNullSize;
1209 : 230226 : Size aMaxSize(100000,100000);
1210 [ + - ]: 230226 : rOutl.SetMinAutoPaperSize(aNullSize);
1211 [ + - ]: 230226 : rOutl.SetMaxAutoPaperSize(aMaxSize);
1212 [ + - ]: 230226 : rOutl.SetPaperSize(aMaxSize);
1213 [ + - ]: 230226 : rOutl.ClearPolygon();
1214 : 230226 : }
1215 : :
1216 : 230226 : SdrOutliner& SdrTextObj::ImpGetDrawOutliner() const
1217 : : {
1218 : 230226 : SdrOutliner& rOutl=pModel->GetDrawOutliner(this);
1219 : :
1220 : : // Code extracted to ImpInitDrawOutliner()
1221 : 230226 : ImpInitDrawOutliner( rOutl );
1222 : :
1223 : 230226 : return rOutl;
1224 : : }
1225 : :
1226 : : // Extracted from Paint()
1227 : 0 : void SdrTextObj::ImpSetupDrawOutlinerForPaint( bool bContourFrame,
1228 : : SdrOutliner& rOutliner,
1229 : : Rectangle& rTextRect,
1230 : : Rectangle& rAnchorRect,
1231 : : Rectangle& rPaintRect,
1232 : : Fraction& rFitXKorreg ) const
1233 : : {
1234 [ # # ]: 0 : if (!bContourFrame)
1235 : : {
1236 : : // FitToSize can't be used together with ContourFrame for now
1237 [ # # ][ # # ]: 0 : if (IsFitToSize() || IsAutoFit())
[ # # ]
1238 : : {
1239 : 0 : sal_uIntPtr nStat=rOutliner.GetControlWord();
1240 : 0 : nStat|=EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE;
1241 : 0 : rOutliner.SetControlWord(nStat);
1242 : : }
1243 : : }
1244 : 0 : rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
1245 : 0 : TakeTextRect(rOutliner, rTextRect, sal_False, &rAnchorRect);
1246 : 0 : rPaintRect = rTextRect;
1247 : :
1248 [ # # ]: 0 : if (!bContourFrame)
1249 : : {
1250 : : // FitToSize can't be used together with ContourFrame for now
1251 [ # # ]: 0 : if (IsFitToSize())
1252 : : {
1253 [ # # ][ # # ]: 0 : ImpSetCharStretching(rOutliner,rTextRect.GetSize(),rAnchorRect.GetSize(),rFitXKorreg);
1254 : 0 : rPaintRect=rAnchorRect;
1255 : : }
1256 [ # # ]: 0 : else if (IsAutoFit())
1257 : : {
1258 : 0 : ImpAutoFitText(rOutliner);
1259 : : }
1260 : : }
1261 : 0 : }
1262 : :
1263 : 0 : void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner ) const
1264 : : {
1265 [ # # ][ # # ]: 0 : const Size aShapeSize=GetSnapRect().GetSize();
1266 : : ImpAutoFitText( rOutliner,
1267 [ # # ][ # # ]: 0 : Size(aShapeSize.Width()-GetTextLeftDistance()-GetTextRightDistance(),
1268 [ # # ][ # # ]: 0 : aShapeSize.Height()-GetTextUpperDistance()-GetTextLowerDistance()),
1269 [ # # ][ # # ]: 0 : IsVerticalWriting() );
1270 : 0 : }
1271 : :
1272 : 31 : void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner, const Size& rTextSize, bool bIsVerticalWriting )
1273 : : {
1274 : : // EditEngine formatting is unstable enough for
1275 : : // line-breaking text that we need some more samples
1276 : :
1277 : : // loop early-exits if we detect an already attained value
1278 : 31 : sal_uInt16 nMinStretchX=0, nMinStretchY=0;
1279 : 31 : sal_uInt16 aOldStretchXVals[]={0,0,0,0,0,0,0,0,0,0};
1280 : 31 : const size_t aStretchArySize=SAL_N_ELEMENTS(aOldStretchXVals);
1281 [ + - ]: 93 : for(unsigned int i=0; i<aStretchArySize; ++i)
1282 : : {
1283 [ + - ]: 62 : const Size aCurrTextSize = rOutliner.CalcTextSizeNTP();
1284 : 62 : double fFactor(1.0);
1285 [ - + ]: 62 : if( bIsVerticalWriting )
1286 : 0 : fFactor = double(rTextSize.Width())/aCurrTextSize.Width();
1287 : : else
1288 : 62 : fFactor = double(rTextSize.Height())/aCurrTextSize.Height();
1289 : :
1290 : : sal_uInt16 nCurrStretchX, nCurrStretchY;
1291 [ + - ]: 62 : rOutliner.GetGlobalCharStretching(nCurrStretchX, nCurrStretchY);
1292 : :
1293 [ + - ]: 62 : if (fFactor >= 1.0 )
1294 : : {
1295 : : // resulting text area fits into available shape rect -
1296 : : // err on the larger stretching, to optimally fill area
1297 [ + - ]: 62 : nMinStretchX = std::max(nMinStretchX,nCurrStretchX);
1298 [ + - ]: 62 : nMinStretchY = std::max(nMinStretchY,nCurrStretchY);
1299 : : }
1300 : :
1301 : 62 : aOldStretchXVals[i] = nCurrStretchX;
1302 [ + - ][ + + ]: 62 : if( std::find(aOldStretchXVals, aOldStretchXVals+i, nCurrStretchX) != aOldStretchXVals+i )
1303 : : break; // same value already attained once; algo is looping, exit
1304 : :
1305 [ + - ][ + - ]: 31 : if (fFactor < 1.0 || (fFactor >= 1.0 && nCurrStretchX != 100))
[ - + ]
1306 : : {
1307 : 0 : nCurrStretchX = sal::static_int_cast<sal_uInt16>(nCurrStretchX*fFactor);
1308 : 0 : nCurrStretchY = sal::static_int_cast<sal_uInt16>(nCurrStretchY*fFactor);
1309 [ # # ]: 0 : rOutliner.SetGlobalCharStretching(std::min(sal_uInt16(100),nCurrStretchX),
1310 [ # # ][ # # ]: 0 : std::min(sal_uInt16(100),nCurrStretchY));
1311 : : OSL_TRACE("SdrTextObj::onEditOutlinerStatusEvent(): zoom is %d", nCurrStretchX);
1312 : : }
1313 : : }
1314 : :
1315 : : OSL_TRACE("---- SdrTextObj::onEditOutlinerStatusEvent(): final zoom is %d ----", nMinStretchX);
1316 [ + - ]: 31 : rOutliner.SetGlobalCharStretching(std::min(sal_uInt16(100),nMinStretchX),
1317 [ + - ][ + - ]: 62 : std::min(sal_uInt16(100),nMinStretchY));
1318 : 31 : }
1319 : :
1320 : 0 : void SdrTextObj::SetupOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaintRect ) const
1321 : : {
1322 : 0 : ImpInitDrawOutliner( rOutl );
1323 : 0 : UpdateOutlinerFormatting( rOutl, rPaintRect );
1324 : 0 : }
1325 : :
1326 : 0 : void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaintRect ) const
1327 : : {
1328 [ # # ]: 0 : Rectangle aTextRect;
1329 [ # # ]: 0 : Rectangle aAnchorRect;
1330 [ # # ]: 0 : Fraction aFitXKorreg(1,1);
1331 : :
1332 [ # # ]: 0 : bool bContourFrame=IsContourTextFrame();
1333 : :
1334 [ # # ][ # # ]: 0 : if( GetModel() )
1335 : : {
1336 : : MapMode aMapMode(GetModel()->GetScaleUnit(), Point(0,0),
1337 [ # # ]: 0 : GetModel()->GetScaleFraction(),
1338 [ # # ][ # # ]: 0 : GetModel()->GetScaleFraction());
[ # # ]
1339 [ # # ][ # # ]: 0 : rOutl.SetRefMapMode(aMapMode);
1340 : : }
1341 : :
1342 [ # # ]: 0 : ImpSetupDrawOutlinerForPaint( bContourFrame, rOutl, aTextRect, aAnchorRect, rPaintRect, aFitXKorreg );
1343 : 0 : }
1344 : :
1345 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1346 : :
1347 : 289101 : OutlinerParaObject* SdrTextObj::GetOutlinerParaObject() const
1348 : : {
1349 : 289101 : SdrText* pText = getActiveText();
1350 [ + - ]: 289101 : if( pText )
1351 : 289101 : return pText->GetOutlinerParaObject();
1352 : : else
1353 : 289101 : return 0;
1354 : : }
1355 : :
1356 : 0 : bool SdrTextObj::HasOutlinerParaObject() const
1357 : : {
1358 : 0 : SdrText* pText = getActiveText();
1359 [ # # ][ # # ]: 0 : if( pText && pText->GetOutlinerParaObject() )
[ # # ]
1360 : 0 : return true;
1361 : 0 : return false;
1362 : : }
1363 : :
1364 : 1500 : void SdrTextObj::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject)
1365 : : {
1366 : 1500 : NbcSetOutlinerParaObjectForText( pTextObject, getActiveText() );
1367 : 1500 : }
1368 : :
1369 : 54082 : void SdrTextObj::NbcSetOutlinerParaObjectForText( OutlinerParaObject* pTextObject, SdrText* pText )
1370 : : {
1371 [ + - ]: 54082 : if( pText )
1372 : 54082 : pText->SetOutlinerParaObject( pTextObject );
1373 : :
1374 [ + + ]: 54082 : if( pText->GetOutlinerParaObject() )
1375 : : {
1376 [ + - ][ + - ]: 53789 : SvxWritingModeItem aWritingMode(pText->GetOutlinerParaObject()->IsVertical()
1377 : : ? com::sun::star::text::WritingMode_TB_RL
1378 : : : com::sun::star::text::WritingMode_LR_TB,
1379 [ - + ][ + - ]: 53789 : SDRATTR_TEXTDIRECTION);
1380 [ + - ][ + - ]: 53789 : GetProperties().SetObjectItemDirect(aWritingMode);
[ + - ]
1381 : : }
1382 : :
1383 : 54082 : SetTextSizeDirty();
1384 [ + + ][ - + ]: 54082 : if (IsTextFrame() && (IsAutoGrowHeight() || IsAutoGrowWidth()))
[ + + ][ + + ]
1385 : : { // adapt text frame!
1386 : 50705 : NbcAdjustTextFrameWidthAndHeight();
1387 : : }
1388 [ + + ]: 54082 : if (!IsTextFrame())
1389 : : {
1390 : : // the SnapRect keeps its size
1391 : 816 : SetRectsDirty(sal_True);
1392 : : }
1393 : :
1394 : : // always invalidate BoundRect on change
1395 : 54082 : SetBoundRectDirty();
1396 : 54082 : ActionChanged();
1397 : :
1398 : 54082 : ImpSetTextStyleSheetListeners();
1399 : 54082 : ImpCheckMasterCachable();
1400 : 54082 : }
1401 : :
1402 : 14 : void SdrTextObj::NbcReformatText()
1403 : : {
1404 : 14 : SdrText* pText = getActiveText();
1405 [ - + ][ - + ]: 14 : if( pText && pText->GetOutlinerParaObject() )
[ + - ]
1406 : : {
1407 : 0 : pText->ReformatText();
1408 [ # # ]: 0 : if (bTextFrame)
1409 : : {
1410 : 0 : NbcAdjustTextFrameWidthAndHeight();
1411 : : }
1412 : : else
1413 : : {
1414 : : // the SnapRect keeps its size
1415 : 0 : SetBoundRectDirty();
1416 : 0 : SetRectsDirty(sal_True);
1417 : : }
1418 : 0 : SetTextSizeDirty();
1419 : 0 : ActionChanged();
1420 : : // i22396
1421 : : // Necessary here since we have no compare operator at the outliner
1422 : : // para object which may detect changes regarding the combination
1423 : : // of outliner para data and configuration (e.g., change of
1424 : : // formatting of text numerals)
1425 : 0 : GetViewContact().flushViewObjectContacts(false);
1426 : : }
1427 : 14 : }
1428 : :
1429 : 0 : void SdrTextObj::ReformatText()
1430 : : {
1431 [ # # ]: 0 : if(GetOutlinerParaObject())
1432 : : {
1433 [ # # ]: 0 : Rectangle aBoundRect0;
1434 [ # # ]: 0 : if (pUserCall!=NULL)
1435 [ # # ]: 0 : aBoundRect0=GetLastBoundRect();
1436 : :
1437 [ # # ]: 0 : NbcReformatText();
1438 [ # # ]: 0 : SetChanged();
1439 [ # # ]: 0 : BroadcastObjectChange();
1440 [ # # ]: 0 : SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1441 : : }
1442 : 0 : }
1443 : :
1444 : 0 : SdrObjGeoData* SdrTextObj::NewGeoData() const
1445 : : {
1446 [ # # ]: 0 : return new SdrTextObjGeoData;
1447 : : }
1448 : :
1449 : 228 : void SdrTextObj::SaveGeoData(SdrObjGeoData& rGeo) const
1450 : : {
1451 : 228 : SdrAttrObj::SaveGeoData(rGeo);
1452 : 228 : SdrTextObjGeoData& rTGeo=(SdrTextObjGeoData&)rGeo;
1453 : 228 : rTGeo.aRect =aRect;
1454 : 228 : rTGeo.aGeo =aGeo;
1455 : 228 : }
1456 : :
1457 : 0 : void SdrTextObj::RestGeoData(const SdrObjGeoData& rGeo)
1458 : : { // RectsDirty is called by SdrObject
1459 : 0 : SdrAttrObj::RestGeoData(rGeo);
1460 : 0 : SdrTextObjGeoData& rTGeo=(SdrTextObjGeoData&)rGeo;
1461 : 0 : NbcSetLogicRect(rTGeo.aRect);
1462 : 0 : aGeo =rTGeo.aGeo;
1463 : 0 : SetTextSizeDirty();
1464 : 0 : }
1465 : :
1466 : 193717 : SdrFitToSizeType SdrTextObj::GetFitToSize() const
1467 : : {
1468 : 193717 : SdrFitToSizeType eType = SDRTEXTFIT_NONE;
1469 : :
1470 [ + + ]: 193717 : if(!IsAutoGrowWidth())
1471 : 86866 : eType = ((SdrTextFitToSizeTypeItem&)(GetObjectItem(SDRATTR_TEXT_FITTOSIZE))).GetValue();
1472 : :
1473 : 193717 : return eType;
1474 : : }
1475 : :
1476 : 216 : void SdrTextObj::ForceOutlinerParaObject()
1477 : : {
1478 : 216 : SdrText* pText = getActiveText();
1479 [ + + ][ + + ]: 216 : if( pText && (pText->GetOutlinerParaObject() == 0) )
[ + - ]
1480 : : {
1481 : 9 : sal_uInt16 nOutlMode = OUTLINERMODE_TEXTOBJECT;
1482 [ - + ][ # # ]: 9 : if( IsTextFrame() && eTextKind == OBJ_OUTLINETEXT )
[ - + ]
1483 : 0 : nOutlMode = OUTLINERMODE_OUTLINEOBJECT;
1484 : :
1485 : 9 : pText->ForceOutlinerParaObject( nOutlMode );
1486 : : }
1487 : 216 : }
1488 : :
1489 : 1840 : sal_Bool SdrTextObj::IsVerticalWriting() const
1490 : : {
1491 [ - + ]: 1840 : if(pEdtOutl)
1492 : : {
1493 : 0 : return pEdtOutl->IsVertical();
1494 : : }
1495 : :
1496 : 1840 : OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
1497 [ + + ]: 1840 : if(pOutlinerParaObject)
1498 : : {
1499 : 284 : return pOutlinerParaObject->IsVertical();
1500 : : }
1501 : :
1502 : 1840 : return sal_False;
1503 : : }
1504 : :
1505 : 75917 : void SdrTextObj::SetVerticalWriting(sal_Bool bVertical)
1506 : : {
1507 : 75917 : OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
1508 [ # # ][ - + ]: 75917 : if( !pOutlinerParaObject && bVertical )
1509 : : {
1510 : : // we only need to force a outliner para object if the default of
1511 : : // horizontal text is changed
1512 : 0 : ForceOutlinerParaObject();
1513 : 0 : pOutlinerParaObject = GetOutlinerParaObject();
1514 : : }
1515 : :
1516 [ + - ][ - + ]: 75917 : if( pOutlinerParaObject && (pOutlinerParaObject->IsVertical() != (bool)bVertical) )
[ - + ]
1517 : : {
1518 : : // get item settings
1519 [ # # ]: 0 : const SfxItemSet& rSet = GetObjectItemSet();
1520 [ # # ]: 0 : sal_Bool bAutoGrowWidth = ((SdrTextAutoGrowWidthItem&)rSet.Get(SDRATTR_TEXT_AUTOGROWWIDTH)).GetValue();
1521 [ # # ]: 0 : sal_Bool bAutoGrowHeight = ((SdrTextAutoGrowHeightItem&)rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue();
1522 : :
1523 : : // Also exchange hor/ver adjust items
1524 [ # # ]: 0 : SdrTextHorzAdjust eHorz = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
1525 [ # # ]: 0 : SdrTextVertAdjust eVert = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
1526 : :
1527 : : // rescue object size
1528 [ # # ]: 0 : Rectangle aObjectRect = GetSnapRect();
1529 : :
1530 : : // prepare ItemSet to set exchanged width and height items
1531 : 0 : SfxItemSet aNewSet(*rSet.GetPool(),
1532 : : SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT,
1533 : : // Expanded item ranges to also support hor and ver adjust.
1534 : : SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST,
1535 : : SDRATTR_TEXT_AUTOGROWWIDTH, SDRATTR_TEXT_HORZADJUST,
1536 [ # # ]: 0 : 0, 0);
1537 : :
1538 [ # # ]: 0 : aNewSet.Put(rSet);
1539 [ # # ][ # # ]: 0 : aNewSet.Put(SdrTextAutoGrowWidthItem(bAutoGrowHeight));
[ # # ]
1540 [ # # ][ # # ]: 0 : aNewSet.Put(SdrTextAutoGrowHeightItem(bAutoGrowWidth));
[ # # ]
1541 : :
1542 : : // Exchange horz and vert adjusts
1543 [ # # # # : 0 : switch(eVert)
# ]
1544 : : {
1545 [ # # ][ # # ]: 0 : case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break;
[ # # ]
1546 [ # # ][ # # ]: 0 : case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break;
[ # # ]
1547 [ # # ][ # # ]: 0 : case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break;
[ # # ]
1548 [ # # ][ # # ]: 0 : case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break;
[ # # ]
1549 : : }
1550 [ # # # # : 0 : switch(eHorz)
# ]
1551 : : {
1552 [ # # ][ # # ]: 0 : case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break;
[ # # ]
1553 [ # # ][ # # ]: 0 : case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break;
[ # # ]
1554 [ # # ][ # # ]: 0 : case SDRTEXTHORZADJUST_RIGHT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); break;
[ # # ]
1555 [ # # ][ # # ]: 0 : case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break;
[ # # ]
1556 : : }
1557 : :
1558 [ # # ]: 0 : SetObjectItemSet(aNewSet);
1559 : :
1560 [ # # ]: 0 : pOutlinerParaObject = GetOutlinerParaObject();
1561 [ # # ]: 0 : if( pOutlinerParaObject )
1562 : : {
1563 : : // set ParaObject orientation accordingly
1564 [ # # ]: 0 : pOutlinerParaObject->SetVertical(bVertical);
1565 : : }
1566 : :
1567 : : // restore object size
1568 [ # # ][ # # ]: 0 : SetSnapRect(aObjectRect);
1569 : : }
1570 : 75917 : }
1571 : :
1572 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1573 : : //
1574 : : // transformation interface for StarOfficeAPI. This implements support for
1575 : : // homogeneous 3x3 matrices containing the transformation of the SdrObject. At the
1576 : : // moment it contains a shearX, rotation and translation, but for setting all linear
1577 : : // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
1578 : : //
1579 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1580 : : // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
1581 : : // with the base geometry and returns TRUE. Otherwise it returns FALSE.
1582 : 29938 : sal_Bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
1583 : : {
1584 : : // get turn and shear
1585 : 29938 : double fRotate = (aGeo.nDrehWink / 100.0) * F_PI180;
1586 : 29938 : double fShearX = (aGeo.nShearWink / 100.0) * F_PI180;
1587 : :
1588 : : // get aRect, this is the unrotated snaprect
1589 : 29938 : Rectangle aRectangle(aRect);
1590 : :
1591 : : // fill other values
1592 [ + - ][ + - ]: 29938 : basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
1593 : 29938 : basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
1594 : :
1595 : : // position maybe relative to anchorpos, convert
1596 [ + + ][ + + ]: 29938 : if( pModel && pModel->IsWriter() )
[ + - ]
1597 : : {
1598 [ + - ][ + - ]: 29 : if(GetAnchorPos().X() || GetAnchorPos().Y())
[ + - ][ - + ]
[ - + ]
1599 : : {
1600 [ # # ][ # # ]: 0 : aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
1601 : : }
1602 : : }
1603 : :
1604 : : // force MapUnit to 100th mm
1605 [ + - ][ + - ]: 29938 : SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
1606 [ + + ]: 29938 : if(eMapUnit != SFX_MAPUNIT_100TH_MM)
1607 : : {
1608 [ + - ]: 29 : switch(eMapUnit)
1609 : : {
1610 : : case SFX_MAPUNIT_TWIP :
1611 : : {
1612 : : // postion
1613 : 29 : aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
1614 : 29 : aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
1615 : :
1616 : : // size
1617 : 29 : aScale.setX(ImplTwipsToMM(aScale.getX()));
1618 : 29 : aScale.setY(ImplTwipsToMM(aScale.getY()));
1619 : :
1620 : 29 : break;
1621 : : }
1622 : : default:
1623 : : {
1624 : : OSL_FAIL("TRGetBaseGeometry: Missing unit translation to 100th mm!");
1625 : : }
1626 : : }
1627 : : }
1628 : :
1629 : : // build matrix
1630 : : rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
1631 : : aScale,
1632 : 29938 : basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX),
1633 : 29938 : basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate,
1634 [ + - ][ + - ]: 59876 : aTranslate);
[ + - ][ + - ]
[ + + ]
1635 : :
1636 : 29938 : return sal_False;
1637 : : }
1638 : :
1639 : : // sets the base geometry of the object using infos contained in the homogeneous 3x3 matrix.
1640 : : // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
1641 : : // to use (0,0) as upper left and will be scaled to the given size in the matrix.
1642 : 29679 : void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
1643 : : {
1644 : : // break up matrix
1645 : 29679 : basegfx::B2DTuple aScale;
1646 : 29679 : basegfx::B2DTuple aTranslate;
1647 : 29679 : double fRotate(0.0);
1648 : 29679 : double fShearX(0.0);
1649 [ + - ]: 29679 : rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
1650 : :
1651 : : // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
1652 : : // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
1653 [ - + ][ # # ]: 29679 : if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
[ - + ][ - + ]
[ + - ][ + - ]
[ - + ]
1654 : : {
1655 : 0 : aScale.setX(fabs(aScale.getX()));
1656 : 0 : aScale.setY(fabs(aScale.getY()));
1657 : 0 : fRotate = fmod(fRotate + F_PI, F_2PI);
1658 : : }
1659 : :
1660 : : // reset object shear and rotations
1661 : 29679 : aGeo.nDrehWink = 0;
1662 [ + - ]: 29679 : aGeo.RecalcSinCos();
1663 : 29679 : aGeo.nShearWink = 0;
1664 [ + - ]: 29679 : aGeo.RecalcTan();
1665 : :
1666 : : // force metric to pool metric
1667 [ + - ][ + - ]: 29679 : SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
1668 [ + + ]: 29679 : if(eMapUnit != SFX_MAPUNIT_100TH_MM)
1669 : : {
1670 [ + - ]: 29 : switch(eMapUnit)
1671 : : {
1672 : : case SFX_MAPUNIT_TWIP :
1673 : : {
1674 : : // position
1675 : 29 : aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
1676 : 29 : aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
1677 : :
1678 : : // size
1679 : 29 : aScale.setX(ImplMMToTwips(aScale.getX()));
1680 : 29 : aScale.setY(ImplMMToTwips(aScale.getY()));
1681 : :
1682 : 29 : break;
1683 : : }
1684 : : default:
1685 : : {
1686 : : OSL_FAIL("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
1687 : : }
1688 : : }
1689 : : }
1690 : :
1691 : : // if anchor is used, make position relative to it
1692 [ + - ][ + + ]: 29679 : if( pModel && pModel->IsWriter() )
[ + + ]
1693 : : {
1694 [ + - ][ + - ]: 29 : if(GetAnchorPos().X() || GetAnchorPos().Y())
[ + - ][ - + ]
[ - + ]
1695 : : {
1696 [ # # ][ # # ]: 0 : aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
1697 : : }
1698 : : }
1699 : :
1700 : : // build and set BaseRect (use scale)
1701 : 29679 : Point aPoint = Point();
1702 : 29679 : Size aSize(FRound(aScale.getX()), FRound(aScale.getY()));
1703 [ + - ]: 29679 : Rectangle aBaseRect(aPoint, aSize);
1704 [ + - ]: 29679 : SetSnapRect(aBaseRect);
1705 : :
1706 : : // shear?
1707 [ - + ]: 29679 : if(!basegfx::fTools::equalZero(fShearX))
1708 : : {
1709 : 0 : GeoStat aGeoStat;
1710 : 0 : aGeoStat.nShearWink = FRound((atan(fShearX) / F_PI180) * 100.0);
1711 [ # # ]: 0 : aGeoStat.RecalcTan();
1712 [ # # ]: 0 : Shear(Point(), aGeoStat.nShearWink, aGeoStat.nTan, sal_False);
1713 : : }
1714 : :
1715 : : // rotation?
1716 [ + + ]: 29679 : if(!basegfx::fTools::equalZero(fRotate))
1717 : : {
1718 : 842 : GeoStat aGeoStat;
1719 : :
1720 : : // #i78696#
1721 : : // fRotate is matematically correct, but aGeoStat.nDrehWink is
1722 : : // mirrored -> mirror value here
1723 [ + - ]: 842 : aGeoStat.nDrehWink = NormAngle360(FRound(-fRotate / F_PI18000));
1724 [ + - ]: 842 : aGeoStat.RecalcSinCos();
1725 [ + - ]: 842 : Rotate(Point(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos);
1726 : : }
1727 : :
1728 : : // translate?
1729 [ + - ][ + + ]: 29679 : if(!aTranslate.equalZero())
1730 : : {
1731 [ + - ]: 28741 : Move(Size(FRound(aTranslate.getX()), FRound(aTranslate.getY())));
1732 : 29679 : }
1733 : 29679 : }
1734 : :
1735 : 0 : bool SdrTextObj::IsRealyEdited() const
1736 : : {
1737 [ # # ][ # # ]: 0 : return pEdtOutl && pEdtOutl->IsModified();
1738 : : }
1739 : :
1740 : : /////////////////////////////////////////////////////////////////////////////////////////////////
1741 : : // moved inlines here form hxx
1742 : :
1743 : 51158 : long SdrTextObj::GetEckenradius() const
1744 : : {
1745 : 51158 : return ((SdrEckenradiusItem&)(GetObjectItemSet().Get(SDRATTR_ECKENRADIUS))).GetValue();
1746 : : }
1747 : :
1748 : 129556 : long SdrTextObj::GetMinTextFrameHeight() const
1749 : : {
1750 : 129556 : return ((SdrTextMinFrameHeightItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MINFRAMEHEIGHT))).GetValue();
1751 : : }
1752 : :
1753 : 129556 : long SdrTextObj::GetMaxTextFrameHeight() const
1754 : : {
1755 : 129556 : return ((SdrTextMaxFrameHeightItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MAXFRAMEHEIGHT))).GetValue();
1756 : : }
1757 : :
1758 : 56339 : long SdrTextObj::GetMinTextFrameWidth() const
1759 : : {
1760 : 56339 : return ((SdrTextMinFrameWidthItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MINFRAMEWIDTH))).GetValue();
1761 : : }
1762 : :
1763 : 56339 : long SdrTextObj::GetMaxTextFrameWidth() const
1764 : : {
1765 : 56339 : return ((SdrTextMaxFrameWidthItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MAXFRAMEWIDTH))).GetValue();
1766 : : }
1767 : :
1768 : 55 : bool SdrTextObj::IsFontwork() const
1769 : : {
1770 : : return (bTextFrame) ? false // Default is FALSE
1771 [ + - ][ - + ]: 55 : : ((XFormTextStyleItem&)(GetObjectItemSet().Get(XATTR_FORMTXTSTYLE))).GetValue()!=XFT_NONE;
1772 : : }
1773 : :
1774 : 0 : bool SdrTextObj::IsHideContour() const
1775 : : {
1776 : : return (bTextFrame) ? false // Default is: no, don't HideContour; HideContour not together with TextFrames
1777 [ # # ][ # # ]: 0 : : ((XFormTextHideFormItem&)(GetObjectItemSet().Get(XATTR_FORMTXTHIDEFORM))).GetValue();
1778 : : }
1779 : :
1780 : 228367 : bool SdrTextObj::IsContourTextFrame() const
1781 : : {
1782 : : return (bTextFrame) ? false // ContourFrame not together with normal TextFrames
1783 [ + + ][ - + ]: 228367 : : ((SdrTextContourFrameItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_CONTOURFRAME))).GetValue();
1784 : : }
1785 : :
1786 : 309377 : long SdrTextObj::GetTextLeftDistance() const
1787 : : {
1788 : 309377 : return ((SdrTextLeftDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_LEFTDIST))).GetValue();
1789 : : }
1790 : :
1791 : 309377 : long SdrTextObj::GetTextRightDistance() const
1792 : : {
1793 : 309377 : return ((SdrTextRightDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_RIGHTDIST))).GetValue();
1794 : : }
1795 : :
1796 : 309377 : long SdrTextObj::GetTextUpperDistance() const
1797 : : {
1798 : 309377 : return ((SdrTextUpperDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_UPPERDIST))).GetValue();
1799 : : }
1800 : :
1801 : 309377 : long SdrTextObj::GetTextLowerDistance() const
1802 : : {
1803 : 309377 : return ((SdrTextLowerDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_LOWERDIST))).GetValue();
1804 : : }
1805 : :
1806 : 702225 : SdrTextAniKind SdrTextObj::GetTextAniKind() const
1807 : : {
1808 : 702225 : return ((SdrTextAniKindItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_ANIKIND))).GetValue();
1809 : : }
1810 : :
1811 : 136983 : SdrTextAniDirection SdrTextObj::GetTextAniDirection() const
1812 : : {
1813 : 136983 : return ((SdrTextAniDirectionItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
1814 : : }
1815 : :
1816 : : // Get necessary data for text scroll animation. ATM base it on a Text-Metafile and a
1817 : : // painting rectangle. Rotation is excluded from the returned values.
1818 : 0 : GDIMetaFile* SdrTextObj::GetTextScrollMetaFileAndRectangle(
1819 : : Rectangle& rScrollRectangle, Rectangle& rPaintRectangle)
1820 : : {
1821 : 0 : GDIMetaFile* pRetval = 0L;
1822 [ # # ]: 0 : SdrOutliner& rOutliner = ImpGetDrawOutliner();
1823 [ # # ]: 0 : Rectangle aTextRect;
1824 [ # # ]: 0 : Rectangle aAnchorRect;
1825 [ # # ]: 0 : Rectangle aPaintRect;
1826 [ # # ]: 0 : Fraction aFitXKorreg(1,1);
1827 [ # # ]: 0 : bool bContourFrame(IsContourTextFrame());
1828 : :
1829 : : // get outliner set up. To avoid getting a somehow rotated MetaFile,
1830 : : // temporarily disable object rotation.
1831 : 0 : sal_Int32 nAngle(aGeo.nDrehWink);
1832 : 0 : aGeo.nDrehWink = 0L;
1833 [ # # ]: 0 : ImpSetupDrawOutlinerForPaint( bContourFrame, rOutliner, aTextRect, aAnchorRect, aPaintRect, aFitXKorreg );
1834 : 0 : aGeo.nDrehWink = nAngle;
1835 : :
1836 : 0 : Rectangle aScrollFrameRect(aPaintRect);
1837 [ # # ]: 0 : const SfxItemSet& rSet = GetObjectItemSet();
1838 [ # # ]: 0 : SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
1839 : :
1840 [ # # ][ # # ]: 0 : if(SDRTEXTANI_LEFT == eDirection || SDRTEXTANI_RIGHT == eDirection)
1841 : : {
1842 : 0 : aScrollFrameRect.Left() = aAnchorRect.Left();
1843 : 0 : aScrollFrameRect.Right() = aAnchorRect.Right();
1844 : : }
1845 : :
1846 [ # # ][ # # ]: 0 : if(SDRTEXTANI_UP == eDirection || SDRTEXTANI_DOWN == eDirection)
1847 : : {
1848 : 0 : aScrollFrameRect.Top() = aAnchorRect.Top();
1849 : 0 : aScrollFrameRect.Bottom() = aAnchorRect.Bottom();
1850 : : }
1851 : :
1852 : : // create the MetaFile
1853 [ # # ][ # # ]: 0 : pRetval = new GDIMetaFile;
1854 [ # # ]: 0 : VirtualDevice aBlackHole;
1855 [ # # ]: 0 : aBlackHole.EnableOutput(sal_False);
1856 [ # # ]: 0 : pRetval->Record(&aBlackHole);
1857 : 0 : Point aPaintPos = aPaintRect.TopLeft();
1858 : :
1859 [ # # ]: 0 : rOutliner.Draw(&aBlackHole, aPaintPos);
1860 : :
1861 [ # # ]: 0 : pRetval->Stop();
1862 [ # # ]: 0 : pRetval->WindStart();
1863 : :
1864 : : // return PaintRectanglePixel and pRetval;
1865 : 0 : rScrollRectangle = aScrollFrameRect;
1866 : 0 : rPaintRectangle = aPaintRect;
1867 : :
1868 [ # # ]: 0 : return pRetval;
1869 : : }
1870 : :
1871 : : // Access to TextAnimationAllowed flag
1872 : 28367 : bool SdrTextObj::IsAutoFit() const
1873 : : {
1874 : 28367 : return GetFitToSize()==SDRTEXTFIT_AUTOFIT;
1875 : : }
1876 : :
1877 : 165350 : bool SdrTextObj::IsFitToSize() const
1878 : : {
1879 : 165350 : const SdrFitToSizeType eFit=GetFitToSize();
1880 [ - + ][ + - ]: 165350 : return (eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES);
1881 : : }
1882 : :
1883 : 0 : void SdrTextObj::SetTextAnimationAllowed(sal_Bool bNew)
1884 : : {
1885 [ # # ]: 0 : if(mbTextAnimationAllowed != bNew)
1886 : : {
1887 : 0 : mbTextAnimationAllowed = bNew;
1888 : 0 : ActionChanged();
1889 : : }
1890 : 0 : }
1891 : :
1892 : : /** called from the SdrObjEditView during text edit when the status of the edit outliner changes */
1893 : 0 : void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
1894 : : {
1895 : 0 : const sal_uInt32 nStat = pEditStatus->GetStatusWord();
1896 : 0 : const bool bGrowX=(nStat & EE_STAT_TEXTWIDTHCHANGED) !=0;
1897 : 0 : const bool bGrowY=(nStat & EE_STAT_TEXTHEIGHTCHANGED) !=0;
1898 [ # # ][ # # ]: 0 : if(bTextFrame && (bGrowX || bGrowY))
[ # # ]
1899 : : {
1900 [ # # ][ # # ]: 0 : if ((bGrowX && IsAutoGrowWidth()) || (bGrowY && IsAutoGrowHeight()))
[ # # ][ # # ]
[ # # ]
1901 : : {
1902 : 0 : AdjustTextFrameWidthAndHeight();
1903 : : }
1904 [ # # ][ # # ]: 0 : else if (IsAutoFit() && !mbInDownScale)
[ # # ]
1905 : : {
1906 : : OSL_ASSERT(pEdtOutl);
1907 : 0 : mbInDownScale = sal_True;
1908 : :
1909 : : // sucks that we cannot disable paints via
1910 : : // pEdtOutl->SetUpdateMode(FALSE) - but EditEngine skips
1911 : : // formatting as well, then.
1912 : 0 : ImpAutoFitText(*pEdtOutl);
1913 : 0 : mbInDownScale = sal_False;
1914 : : }
1915 : : }
1916 : 0 : }
1917 : :
1918 : : /** returns the currently active text. */
1919 : 313938 : SdrText* SdrTextObj::getActiveText() const
1920 : : {
1921 [ + + ]: 313938 : if( !mpText )
1922 : 154 : return getText( 0 );
1923 : : else
1924 : 313938 : return mpText;
1925 : : }
1926 : :
1927 : : /** returns the nth available text. */
1928 : 439049 : SdrText* SdrTextObj::getText( sal_Int32 nIndex ) const
1929 : : {
1930 [ + - ]: 439049 : if( nIndex == 0 )
1931 : : {
1932 [ + + ]: 439049 : if( mpText == 0 )
1933 [ + - ]: 57394 : const_cast< SdrTextObj* >(this)->mpText = new SdrText( *(const_cast< SdrTextObj* >(this)) );
1934 : 439049 : return mpText;
1935 : : }
1936 : : else
1937 : : {
1938 : 439049 : return 0;
1939 : : }
1940 : : }
1941 : :
1942 : : /** returns the number of texts available for this object. */
1943 : 299187 : sal_Int32 SdrTextObj::getTextCount() const
1944 : : {
1945 : 299187 : return 1;
1946 : : }
1947 : :
1948 : : /** changes the current active text */
1949 : 0 : void SdrTextObj::setActiveText( sal_Int32 /*nIndex*/ )
1950 : : {
1951 : 0 : }
1952 : :
1953 : : /** returns the index of the text that contains the given point or -1 */
1954 : 0 : sal_Int32 SdrTextObj::CheckTextHit(const Point& /*rPnt*/) const
1955 : : {
1956 : 0 : return 0;
1957 : : }
1958 : :
1959 : 0 : void SdrTextObj::SetObjectItemNoBroadcast(const SfxPoolItem& rItem)
1960 : : {
1961 : 0 : static_cast< sdr::properties::TextProperties& >(GetProperties()).SetObjectItemNoBroadcast(rItem);
1962 : 0 : }
1963 : :
1964 : : /////////////////////////////////////////////////////////////////////////////////////////////////
1965 : : //
1966 : : // The concept of the text object:
1967 : : // ~~~~~~~~~~~~~~~~~~~~~~~~
1968 : : // Attributes/Variations:
1969 : : // - sal_Bool text frame / graphics object with caption
1970 : : // - sal_Bool FontWork (if it is not a text frame and not a ContourTextFrame)
1971 : : // - sal_Bool ContourTextFrame (if it is not a text frame and not Fontwork)
1972 : : // - long rotation angle (if it is not FontWork)
1973 : : // - long text frame margins (if it is not FontWork)
1974 : : // - sal_Bool FitToSize (if it is not FontWork)
1975 : : // - sal_Bool AutoGrowingWidth/Height (if it is not FitToSize and not FontWork)
1976 : : // - long Min/MaxFrameWidth/Height (if AutoGrowingWidth/Height)
1977 : : // - enum horizontal text anchoring left,center,right,justify/block,Stretch(ni)
1978 : : // - enum vertical text anchoring top, middle, bottom, block, stretch(ni)
1979 : : // - enum ticker text (if it is not FontWork)
1980 : : //
1981 : : // Every derived object is either a text frame (bTextFrame=sal_True)
1982 : : // or a drawing object with a caption (bTextFrame=sal_False).
1983 : : //
1984 : : // Default anchoring for text frames:
1985 : : // SDRTEXTHORZADJUST_BLOCK, SDRTEXTVERTADJUST_TOP
1986 : : // = static Pool defaults
1987 : : // Default anchoring for drawing objects with a caption:
1988 : : // SDRTEXTHORZADJUST_CENTER, SDRTEXTVERTADJUST_CENTER
1989 : : // via "hard" attribution of SdrAttrObj
1990 : : //
1991 : : // Every object derived from SdrTextObj must return an "UnrotatedSnapRect"
1992 : : // (->TakeUnrotatedSnapRect()) (the reference point for the rotation is the top
1993 : : // left of the rectangle (aGeo.nDrehWink)) which is the basis for anchoring
1994 : : // text. We then subtract the text frame margins from this rectangle, as a re-
1995 : : // sult we get the anchoring area (->TakeTextAnchorRect()). Within this area, we
1996 : : // calculate the anchoring point and the painting area, depending on the hori-
1997 : : // zontal and vertical adjustment of the text (SdrTextVertAdjust,
1998 : : // SdrTextHorzAdjust).
1999 : : // In the case of drawing objects with a caption the painting area might well
2000 : : // be larger than the anchoring area, for text frames on the other hand, it is
2001 : : // always of the same or a smaller size (except when there are negative text
2002 : : // frame margins).
2003 : : //
2004 : : // FitToSize takes priority over text anchoring and AutoGrowHeight/Width. When
2005 : : // FitToSize is turned on, the painting area is always equal to the anchoring
2006 : : // area. Additionally, FitToSize doesn't allow automatic line breaks.
2007 : : //
2008 : : // ContourTextFrame:
2009 : : // - long rotation angle
2010 : : // - long text frame margins (maybe later)
2011 : : // - sal_Bool FitToSize (maybe later)
2012 : : // - sal_Bool AutoGrowingWidth/Height (maybe much later)
2013 : : // - long Min/MaxFrameWidth/Height (maybe much later)
2014 : : // - enum horizontal text anchoring (maybe later, for now: left, centered)
2015 : : // - enum vertical text anchoring (maybe later, for now: top)
2016 : : // - enum ticker text (maybe later, maybe even with correct clipping)
2017 : : //
2018 : : // When making changes, check these:
2019 : : // - Paint
2020 : : // - HitTest
2021 : : // - ConvertToPoly
2022 : : // - Edit
2023 : : // - Printing, Saving, Painting in neighboring View while editing
2024 : : // - ModelChanged (e. g. through a neighboring View or rulers) while editing
2025 : : // - FillColorChanged while editin
2026 : : // - and many more...
2027 : : //
2028 : : /////////////////////////////////////////////////////////////////////////////////////////////////
2029 : :
2030 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|