1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5f6e50924SAndrew Rist * distributed with this work for additional information
6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10f6e50924SAndrew Rist *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist *
13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist * software distributed under the License is distributed on an
15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17f6e50924SAndrew Rist * specific language governing permissions and limitations
18f6e50924SAndrew Rist * under the License.
19f6e50924SAndrew Rist *
20f6e50924SAndrew Rist *************************************************************/
21f6e50924SAndrew Rist
22f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <svx/svdotext.hxx>
28cdf0e10cSrcweir #include "svx/svditext.hxx"
29cdf0e10cSrcweir #include <svx/svdpagv.hxx> // fuer Abfrage im Paint, ob das
30cdf0e10cSrcweir #include <svx/svdview.hxx> // Objekt gerade editiert wird
31cdf0e10cSrcweir #include <svx/svdpage.hxx> // und fuer AnimationHandler (Laufschrift)
32cdf0e10cSrcweir #include <svx/svdetc.hxx>
33cdf0e10cSrcweir #include <svx/svdoutl.hxx>
34cdf0e10cSrcweir #include <svx/svdmodel.hxx> // OutlinerDefaults
35cdf0e10cSrcweir #include "svx/svdglob.hxx" // Stringcache
36cdf0e10cSrcweir #include "svx/svdstr.hrc" // Objektname
37cdf0e10cSrcweir #include <editeng/writingmodeitem.hxx>
38cdf0e10cSrcweir #include <svx/sdtfchim.hxx>
39cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
40cdf0e10cSrcweir #include <editeng/eeitem.hxx>
41cdf0e10cSrcweir #include <editeng/editstat.hxx>
42cdf0e10cSrcweir #include <editeng/outlobj.hxx>
43cdf0e10cSrcweir #include <editeng/editobj.hxx>
44cdf0e10cSrcweir #include <editeng/outliner.hxx>
45cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
46cdf0e10cSrcweir #include <svl/itempool.hxx>
47cdf0e10cSrcweir #include <editeng/adjitem.hxx>
48cdf0e10cSrcweir #include <editeng/flditem.hxx>
49cdf0e10cSrcweir #include <svx/xftouit.hxx>
50cdf0e10cSrcweir #include <vcl/salbtype.hxx> // FRound
51cdf0e10cSrcweir #include <svx/xflgrit.hxx>
52cdf0e10cSrcweir #include <svx/svdpool.hxx>
53cdf0e10cSrcweir #include <svx/xflclit.hxx>
54cdf0e10cSrcweir #include <svl/style.hxx>
55cdf0e10cSrcweir #include <editeng/editeng.hxx>
56cdf0e10cSrcweir #include <svl/itemiter.hxx>
57cdf0e10cSrcweir #include <svx/sdr/properties/textproperties.hxx>
58cdf0e10cSrcweir #include <vcl/metaact.hxx>
59cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactoftextobj.hxx>
60cdf0e10cSrcweir #include <basegfx/tuple/b2dtuple.hxx>
61cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
62cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
63cdf0e10cSrcweir #include <drawinglayer/geometry/viewinformation2d.hxx>
64cdf0e10cSrcweir #include <vcl/virdev.hxx>
65cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx>
66cdf0e10cSrcweir
67cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
68cdf0e10cSrcweir
69cdf0e10cSrcweir using namespace com::sun::star;
70cdf0e10cSrcweir
71cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
72cdf0e10cSrcweir // #104018# replace macros above with type-safe methods
ImplTwipsToMM(double fVal)73cdf0e10cSrcweir inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
ImplMMToTwips(double fVal)74cdf0e10cSrcweir inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
75cdf0e10cSrcweir
76cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
77cdf0e10cSrcweir //
78cdf0e10cSrcweir // @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@
79cdf0e10cSrcweir // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
80cdf0e10cSrcweir // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
81cdf0e10cSrcweir // @@ @@@@ @@@ @@ @@ @@ @@@@@ @@
82cdf0e10cSrcweir // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
83cdf0e10cSrcweir // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@
84cdf0e10cSrcweir // @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
85cdf0e10cSrcweir //
86cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
87cdf0e10cSrcweir
88cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
89cdf0e10cSrcweir // BaseProperties section
90cdf0e10cSrcweir
CreateObjectSpecificProperties()91cdf0e10cSrcweir sdr::properties::BaseProperties* SdrTextObj::CreateObjectSpecificProperties()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir return new sdr::properties::TextProperties(*this);
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
97cdf0e10cSrcweir // DrawContact section
98cdf0e10cSrcweir
CreateObjectSpecificViewContact()99cdf0e10cSrcweir sdr::contact::ViewContact* SdrTextObj::CreateObjectSpecificViewContact()
100cdf0e10cSrcweir {
101cdf0e10cSrcweir return new sdr::contact::ViewContactOfTextObj(*this);
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
105cdf0e10cSrcweir
106cdf0e10cSrcweir TYPEINIT1(SdrTextObj,SdrAttrObj);
107cdf0e10cSrcweir
SdrTextObj()108cdf0e10cSrcweir SdrTextObj::SdrTextObj()
109cdf0e10cSrcweir : SdrAttrObj(),
110cdf0e10cSrcweir mpText(NULL),
111cdf0e10cSrcweir pEdtOutl(NULL),
112cdf0e10cSrcweir pFormTextBoundRect(NULL),
113cdf0e10cSrcweir eTextKind(OBJ_TEXT)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir bTextSizeDirty=sal_False;
116cdf0e10cSrcweir bTextFrame=sal_False;
117cdf0e10cSrcweir bNoShear=sal_False;
118cdf0e10cSrcweir bNoRotate=sal_False;
119cdf0e10cSrcweir bNoMirror=sal_False;
120cdf0e10cSrcweir bDisableAutoWidthOnDragging=sal_False;
121cdf0e10cSrcweir
122cdf0e10cSrcweir // #101684#
123cdf0e10cSrcweir mbInEditMode = sal_False;
124cdf0e10cSrcweir
125cdf0e10cSrcweir // #111096#
126cdf0e10cSrcweir mbTextHidden = sal_False;
127cdf0e10cSrcweir
128cdf0e10cSrcweir // #111096#
129cdf0e10cSrcweir mbTextAnimationAllowed = sal_True;
130cdf0e10cSrcweir
131cdf0e10cSrcweir // #108784#
132cdf0e10cSrcweir maTextEditOffset = Point(0, 0);
133cdf0e10cSrcweir
134cdf0e10cSrcweir // #i25616#
135cdf0e10cSrcweir mbSupportTextIndentingOnLineWidthChange = sal_True;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
SdrTextObj(const Rectangle & rNewRect)138cdf0e10cSrcweir SdrTextObj::SdrTextObj(const Rectangle& rNewRect)
139cdf0e10cSrcweir : SdrAttrObj(),
140cdf0e10cSrcweir aRect(rNewRect),
141cdf0e10cSrcweir mpText(NULL),
142cdf0e10cSrcweir pEdtOutl(NULL),
143cdf0e10cSrcweir pFormTextBoundRect(NULL)
144cdf0e10cSrcweir {
145cdf0e10cSrcweir bTextSizeDirty=sal_False;
146cdf0e10cSrcweir bTextFrame=sal_False;
147cdf0e10cSrcweir bNoShear=sal_False;
148cdf0e10cSrcweir bNoRotate=sal_False;
149cdf0e10cSrcweir bNoMirror=sal_False;
150cdf0e10cSrcweir bDisableAutoWidthOnDragging=sal_False;
151cdf0e10cSrcweir ImpJustifyRect(aRect);
152cdf0e10cSrcweir
153cdf0e10cSrcweir // #101684#
154cdf0e10cSrcweir mbInEditMode = sal_False;
155cdf0e10cSrcweir
156cdf0e10cSrcweir // #111096#
157cdf0e10cSrcweir mbTextHidden = sal_False;
158cdf0e10cSrcweir
159cdf0e10cSrcweir // #111096#
160cdf0e10cSrcweir mbTextAnimationAllowed = sal_True;
161cdf0e10cSrcweir
162cdf0e10cSrcweir // #108784#
163cdf0e10cSrcweir maTextEditOffset = Point(0, 0);
164cdf0e10cSrcweir
165cdf0e10cSrcweir // #i25616#
166cdf0e10cSrcweir mbSupportTextIndentingOnLineWidthChange = sal_True;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
SdrTextObj(SdrObjKind eNewTextKind)169cdf0e10cSrcweir SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind)
170cdf0e10cSrcweir : SdrAttrObj(),
171cdf0e10cSrcweir mpText(NULL),
172cdf0e10cSrcweir pEdtOutl(NULL),
173cdf0e10cSrcweir pFormTextBoundRect(NULL),
174cdf0e10cSrcweir eTextKind(eNewTextKind)
175cdf0e10cSrcweir {
176cdf0e10cSrcweir bTextSizeDirty=sal_False;
177cdf0e10cSrcweir bTextFrame=sal_True;
178cdf0e10cSrcweir bNoShear=sal_True;
179cdf0e10cSrcweir bNoRotate=sal_False;
180cdf0e10cSrcweir bNoMirror=sal_True;
181cdf0e10cSrcweir bDisableAutoWidthOnDragging=sal_False;
182cdf0e10cSrcweir
183cdf0e10cSrcweir // #101684#
184cdf0e10cSrcweir mbInEditMode = sal_False;
185cdf0e10cSrcweir
186cdf0e10cSrcweir // #111096#
187cdf0e10cSrcweir mbTextHidden = sal_False;
188cdf0e10cSrcweir
189cdf0e10cSrcweir // #111096#
190cdf0e10cSrcweir mbTextAnimationAllowed = sal_True;
191cdf0e10cSrcweir
192cdf0e10cSrcweir // #108784#
193cdf0e10cSrcweir maTextEditOffset = Point(0, 0);
194cdf0e10cSrcweir
195cdf0e10cSrcweir // #i25616#
196cdf0e10cSrcweir mbSupportTextIndentingOnLineWidthChange = sal_True;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
SdrTextObj(SdrObjKind eNewTextKind,const Rectangle & rNewRect)199cdf0e10cSrcweir SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const Rectangle& rNewRect)
200cdf0e10cSrcweir : SdrAttrObj(),
201cdf0e10cSrcweir aRect(rNewRect),
202cdf0e10cSrcweir mpText(NULL),
203cdf0e10cSrcweir pEdtOutl(NULL),
204cdf0e10cSrcweir pFormTextBoundRect(NULL),
205cdf0e10cSrcweir eTextKind(eNewTextKind)
206cdf0e10cSrcweir {
207cdf0e10cSrcweir bTextSizeDirty=sal_False;
208cdf0e10cSrcweir bTextFrame=sal_True;
209cdf0e10cSrcweir bNoShear=sal_True;
210cdf0e10cSrcweir bNoRotate=sal_False;
211cdf0e10cSrcweir bNoMirror=sal_True;
212cdf0e10cSrcweir bDisableAutoWidthOnDragging=sal_False;
213cdf0e10cSrcweir ImpJustifyRect(aRect);
214cdf0e10cSrcweir
215cdf0e10cSrcweir // #101684#
216cdf0e10cSrcweir mbInEditMode = sal_False;
217cdf0e10cSrcweir
218cdf0e10cSrcweir // #111096#
219cdf0e10cSrcweir mbTextHidden = sal_False;
220cdf0e10cSrcweir
221cdf0e10cSrcweir // #111096#
222cdf0e10cSrcweir mbTextAnimationAllowed = sal_True;
223cdf0e10cSrcweir
224cdf0e10cSrcweir // #108784#
225cdf0e10cSrcweir maTextEditOffset = Point(0, 0);
226cdf0e10cSrcweir
227cdf0e10cSrcweir // #i25616#
228cdf0e10cSrcweir mbSupportTextIndentingOnLineWidthChange = sal_True;
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
SdrTextObj(SdrObjKind eNewTextKind,const Rectangle & rNewRect,SvStream & rInput,const String & rBaseURL,sal_uInt16 eFormat)231cdf0e10cSrcweir SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const Rectangle& rNewRect, SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat)
232cdf0e10cSrcweir : SdrAttrObj(),
233cdf0e10cSrcweir aRect(rNewRect),
234cdf0e10cSrcweir mpText(NULL),
235cdf0e10cSrcweir pEdtOutl(NULL),
236cdf0e10cSrcweir pFormTextBoundRect(NULL),
237cdf0e10cSrcweir eTextKind(eNewTextKind)
238cdf0e10cSrcweir {
239cdf0e10cSrcweir bTextSizeDirty=sal_False;
240cdf0e10cSrcweir bTextFrame=sal_True;
241cdf0e10cSrcweir bNoShear=sal_True;
242cdf0e10cSrcweir bNoRotate=sal_False;
243cdf0e10cSrcweir bNoMirror=sal_True;
244cdf0e10cSrcweir bDisableAutoWidthOnDragging=sal_False;
245cdf0e10cSrcweir ImpJustifyRect(aRect);
246cdf0e10cSrcweir
247cdf0e10cSrcweir NbcSetText(rInput, rBaseURL, eFormat);
248cdf0e10cSrcweir
249cdf0e10cSrcweir // #101684#
250cdf0e10cSrcweir mbInEditMode = sal_False;
251cdf0e10cSrcweir
252cdf0e10cSrcweir // #111096#
253cdf0e10cSrcweir mbTextHidden = sal_False;
254cdf0e10cSrcweir
255cdf0e10cSrcweir // #111096#
256cdf0e10cSrcweir mbTextAnimationAllowed = sal_True;
257cdf0e10cSrcweir
258cdf0e10cSrcweir // #108784#
259cdf0e10cSrcweir maTextEditOffset = Point(0, 0);
260cdf0e10cSrcweir
261cdf0e10cSrcweir // #i25616#
262cdf0e10cSrcweir mbSupportTextIndentingOnLineWidthChange = sal_True;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
~SdrTextObj()265cdf0e10cSrcweir SdrTextObj::~SdrTextObj()
266cdf0e10cSrcweir {
267cdf0e10cSrcweir if( pModel )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir SdrOutliner& rOutl = pModel->GetHitTestOutliner();
270cdf0e10cSrcweir if( rOutl.GetTextObj() == this )
271cdf0e10cSrcweir rOutl.SetTextObj( NULL );
272cdf0e10cSrcweir }
273cdf0e10cSrcweir
274cdf0e10cSrcweir if(mpText!=NULL)
275cdf0e10cSrcweir delete mpText;
276cdf0e10cSrcweir
277cdf0e10cSrcweir if (pFormTextBoundRect!=NULL)
278cdf0e10cSrcweir delete pFormTextBoundRect;
279cdf0e10cSrcweir
280cdf0e10cSrcweir ImpLinkAbmeldung();
281cdf0e10cSrcweir }
282cdf0e10cSrcweir
FitFrameToTextSize()283cdf0e10cSrcweir void SdrTextObj::FitFrameToTextSize()
284cdf0e10cSrcweir {
285cdf0e10cSrcweir DBG_ASSERT(pModel!=NULL,"SdrTextObj::FitFrameToTextSize(): pModel=NULL!");
286cdf0e10cSrcweir ImpJustifyRect(aRect);
287cdf0e10cSrcweir
288cdf0e10cSrcweir SdrText* pText = getActiveText();
289cdf0e10cSrcweir if( pText!=NULL && pText->GetOutlinerParaObject() && pModel!=NULL)
290cdf0e10cSrcweir {
291cdf0e10cSrcweir SdrOutliner& rOutliner=ImpGetDrawOutliner();
292cdf0e10cSrcweir rOutliner.SetPaperSize(Size(aRect.Right()-aRect.Left(),aRect.Bottom()-aRect.Top()));
293cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_True);
294cdf0e10cSrcweir rOutliner.SetText(*pText->GetOutlinerParaObject());
295cdf0e10cSrcweir Rectangle aTextRect;
296cdf0e10cSrcweir Size aNewSize(rOutliner.CalcTextSize());
297cdf0e10cSrcweir rOutliner.Clear();
298cdf0e10cSrcweir aNewSize.Width()++; // wegen evtl. Rundungsfehler
299cdf0e10cSrcweir aNewSize.Width()+=GetTextLeftDistance()+GetTextRightDistance();
300cdf0e10cSrcweir aNewSize.Height()+=GetTextUpperDistance()+GetTextLowerDistance();
301cdf0e10cSrcweir Rectangle aNewRect(aRect);
302cdf0e10cSrcweir aNewRect.SetSize(aNewSize);
303cdf0e10cSrcweir ImpJustifyRect(aNewRect);
304cdf0e10cSrcweir if (aNewRect!=aRect) {
305cdf0e10cSrcweir SetLogicRect(aNewRect);
306cdf0e10cSrcweir }
307cdf0e10cSrcweir }
308cdf0e10cSrcweir }
309cdf0e10cSrcweir
NbcSetText(const XubString & rStr)310cdf0e10cSrcweir void SdrTextObj::NbcSetText(const XubString& rStr)
311cdf0e10cSrcweir {
312cdf0e10cSrcweir SdrOutliner& rOutliner=ImpGetDrawOutliner();
313cdf0e10cSrcweir rOutliner.SetStyleSheet( 0, GetStyleSheet());
314cdf0e10cSrcweir //OutputDevice* pRef1=rOutliner.GetRefDevice();
315cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_True);
316cdf0e10cSrcweir rOutliner.SetText(rStr,rOutliner.GetParagraph( 0 ));
317cdf0e10cSrcweir OutlinerParaObject* pNewText=rOutliner.CreateParaObject();
318cdf0e10cSrcweir Size aSiz(rOutliner.CalcTextSize());
319cdf0e10cSrcweir //OutputDevice* pRef2=rOutliner.GetRefDevice();
320cdf0e10cSrcweir rOutliner.Clear();
321cdf0e10cSrcweir NbcSetOutlinerParaObject(pNewText);
322cdf0e10cSrcweir aTextSize=aSiz;
323cdf0e10cSrcweir bTextSizeDirty=sal_False;
324cdf0e10cSrcweir }
325cdf0e10cSrcweir
SetText(const XubString & rStr)326cdf0e10cSrcweir void SdrTextObj::SetText(const XubString& rStr)
327cdf0e10cSrcweir {
328cdf0e10cSrcweir Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
329cdf0e10cSrcweir // #110094#-14 SendRepaintBroadcast();
330cdf0e10cSrcweir NbcSetText(rStr);
331cdf0e10cSrcweir SetChanged();
332cdf0e10cSrcweir BroadcastObjectChange();
333cdf0e10cSrcweir SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
334cdf0e10cSrcweir //if (GetBoundRect()!=aBoundRect0) {
335cdf0e10cSrcweir // SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
336cdf0e10cSrcweir //}
337cdf0e10cSrcweir }
338cdf0e10cSrcweir
NbcSetText(SvStream & rInput,const String & rBaseURL,sal_uInt16 eFormat)339cdf0e10cSrcweir void SdrTextObj::NbcSetText(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat)
340cdf0e10cSrcweir {
341cdf0e10cSrcweir SdrOutliner& rOutliner=ImpGetDrawOutliner();
342cdf0e10cSrcweir rOutliner.SetStyleSheet( 0, GetStyleSheet());
343cdf0e10cSrcweir rOutliner.Read(rInput,rBaseURL,eFormat);
344cdf0e10cSrcweir OutlinerParaObject* pNewText=rOutliner.CreateParaObject();
345cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_True);
346cdf0e10cSrcweir Size aSiz(rOutliner.CalcTextSize());
347cdf0e10cSrcweir rOutliner.Clear();
348cdf0e10cSrcweir NbcSetOutlinerParaObject(pNewText);
349cdf0e10cSrcweir aTextSize=aSiz;
350cdf0e10cSrcweir bTextSizeDirty=sal_False;
351cdf0e10cSrcweir }
352cdf0e10cSrcweir
SetText(SvStream & rInput,const String & rBaseURL,sal_uInt16 eFormat)353cdf0e10cSrcweir void SdrTextObj::SetText(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
356cdf0e10cSrcweir // #110094#-14 SendRepaintBroadcast();
357cdf0e10cSrcweir NbcSetText(rInput,rBaseURL,eFormat);
358cdf0e10cSrcweir SetChanged();
359cdf0e10cSrcweir BroadcastObjectChange();
360cdf0e10cSrcweir SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
GetTextSize() const363cdf0e10cSrcweir const Size& SdrTextObj::GetTextSize() const
364cdf0e10cSrcweir {
365cdf0e10cSrcweir if (bTextSizeDirty)
366cdf0e10cSrcweir {
367cdf0e10cSrcweir Size aSiz;
368cdf0e10cSrcweir SdrText* pText = getActiveText();
369cdf0e10cSrcweir if( pText && pText->GetOutlinerParaObject ())
370cdf0e10cSrcweir {
371cdf0e10cSrcweir SdrOutliner& rOutliner=ImpGetDrawOutliner();
372cdf0e10cSrcweir rOutliner.SetText(*pText->GetOutlinerParaObject());
373cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_True);
374cdf0e10cSrcweir aSiz=rOutliner.CalcTextSize();
375cdf0e10cSrcweir rOutliner.Clear();
376cdf0e10cSrcweir }
377cdf0e10cSrcweir // 2x casting auf nonconst
378cdf0e10cSrcweir ((SdrTextObj*)this)->aTextSize=aSiz;
379cdf0e10cSrcweir ((SdrTextObj*)this)->bTextSizeDirty=sal_False;
380cdf0e10cSrcweir }
381cdf0e10cSrcweir return aTextSize;
382cdf0e10cSrcweir }
383cdf0e10cSrcweir
IsAutoGrowHeight() const384cdf0e10cSrcweir FASTBOOL SdrTextObj::IsAutoGrowHeight() const
385cdf0e10cSrcweir {
386cdf0e10cSrcweir if(!bTextFrame)
387cdf0e10cSrcweir return sal_False; // AutoGrow nur bei TextFrames
388cdf0e10cSrcweir
389cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet();
390cdf0e10cSrcweir sal_Bool bRet = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
391cdf0e10cSrcweir
392cdf0e10cSrcweir if(bRet)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
395cdf0e10cSrcweir
396cdf0e10cSrcweir if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
397cdf0e10cSrcweir {
398cdf0e10cSrcweir SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
399cdf0e10cSrcweir
400cdf0e10cSrcweir if(eDirection == SDRTEXTANI_UP || eDirection == SDRTEXTANI_DOWN)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir bRet = sal_False;
403cdf0e10cSrcweir }
404cdf0e10cSrcweir }
405cdf0e10cSrcweir }
406cdf0e10cSrcweir return bRet;
407cdf0e10cSrcweir }
408cdf0e10cSrcweir
IsAutoGrowWidth() const409cdf0e10cSrcweir FASTBOOL SdrTextObj::IsAutoGrowWidth() const
410cdf0e10cSrcweir {
411cdf0e10cSrcweir if(!bTextFrame)
412cdf0e10cSrcweir return sal_False; // AutoGrow nur bei TextFrames
413cdf0e10cSrcweir
414cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet();
415cdf0e10cSrcweir sal_Bool bRet = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWWIDTH))).GetValue();
416cdf0e10cSrcweir
417cdf0e10cSrcweir // #101684#
418cdf0e10cSrcweir sal_Bool bInEditMOde = IsInEditMode();
419cdf0e10cSrcweir
420cdf0e10cSrcweir if(!bInEditMOde && bRet)
421cdf0e10cSrcweir {
422cdf0e10cSrcweir SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
423cdf0e10cSrcweir
424cdf0e10cSrcweir if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
425cdf0e10cSrcweir {
426cdf0e10cSrcweir SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
427cdf0e10cSrcweir
428cdf0e10cSrcweir if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT)
429cdf0e10cSrcweir {
430cdf0e10cSrcweir bRet = sal_False;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir }
433cdf0e10cSrcweir }
434cdf0e10cSrcweir return bRet;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir
GetTextHorizontalAdjust() const437cdf0e10cSrcweir SdrTextHorzAdjust SdrTextObj::GetTextHorizontalAdjust() const
438cdf0e10cSrcweir {
439cdf0e10cSrcweir return GetTextHorizontalAdjust(GetObjectItemSet());
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
GetTextHorizontalAdjust(const SfxItemSet & rSet) const442cdf0e10cSrcweir SdrTextHorzAdjust SdrTextObj::GetTextHorizontalAdjust(const SfxItemSet& rSet) const
443cdf0e10cSrcweir {
444cdf0e10cSrcweir if(IsContourTextFrame())
445cdf0e10cSrcweir return SDRTEXTHORZADJUST_BLOCK;
446cdf0e10cSrcweir
447cdf0e10cSrcweir SdrTextHorzAdjust eRet = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
448cdf0e10cSrcweir
449cdf0e10cSrcweir // #101684#
450cdf0e10cSrcweir sal_Bool bInEditMode = IsInEditMode();
451cdf0e10cSrcweir
452cdf0e10cSrcweir if(!bInEditMode && eRet == SDRTEXTHORZADJUST_BLOCK)
453cdf0e10cSrcweir {
454cdf0e10cSrcweir SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
455cdf0e10cSrcweir
456cdf0e10cSrcweir if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
457cdf0e10cSrcweir {
458cdf0e10cSrcweir SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
459cdf0e10cSrcweir
460cdf0e10cSrcweir if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT)
461cdf0e10cSrcweir {
462cdf0e10cSrcweir eRet = SDRTEXTHORZADJUST_LEFT;
463cdf0e10cSrcweir }
464cdf0e10cSrcweir }
465cdf0e10cSrcweir }
466cdf0e10cSrcweir
467cdf0e10cSrcweir return eRet;
468cdf0e10cSrcweir } // defaults: BLOCK fuer Textrahmen, CENTER fuer beschriftete Grafikobjekte
469cdf0e10cSrcweir
GetTextVerticalAdjust() const470cdf0e10cSrcweir SdrTextVertAdjust SdrTextObj::GetTextVerticalAdjust() const
471cdf0e10cSrcweir {
472cdf0e10cSrcweir return GetTextVerticalAdjust(GetObjectItemSet());
473cdf0e10cSrcweir }
474cdf0e10cSrcweir
GetTextVerticalAdjust(const SfxItemSet & rSet) const475cdf0e10cSrcweir SdrTextVertAdjust SdrTextObj::GetTextVerticalAdjust(const SfxItemSet& rSet) const
476cdf0e10cSrcweir {
477cdf0e10cSrcweir if(IsContourTextFrame())
478cdf0e10cSrcweir return SDRTEXTVERTADJUST_TOP;
479cdf0e10cSrcweir
480cdf0e10cSrcweir // #103516# Take care for vertical text animation here
481cdf0e10cSrcweir SdrTextVertAdjust eRet = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
482cdf0e10cSrcweir sal_Bool bInEditMode = IsInEditMode();
483cdf0e10cSrcweir
484cdf0e10cSrcweir // #103516# Take care for vertical text animation here
485cdf0e10cSrcweir if(!bInEditMode && eRet == SDRTEXTVERTADJUST_BLOCK)
486cdf0e10cSrcweir {
487cdf0e10cSrcweir SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
488cdf0e10cSrcweir
489cdf0e10cSrcweir if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
490cdf0e10cSrcweir {
491cdf0e10cSrcweir SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
492cdf0e10cSrcweir
493cdf0e10cSrcweir if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT)
494cdf0e10cSrcweir {
495cdf0e10cSrcweir eRet = SDRTEXTVERTADJUST_TOP;
496cdf0e10cSrcweir }
497cdf0e10cSrcweir }
498cdf0e10cSrcweir }
499cdf0e10cSrcweir
500cdf0e10cSrcweir return eRet;
501cdf0e10cSrcweir } // defaults: TOP fuer Textrahmen, CENTER fuer beschriftete Grafikobjekte
502cdf0e10cSrcweir
ImpJustifyRect(Rectangle & rRect) const503cdf0e10cSrcweir void SdrTextObj::ImpJustifyRect(Rectangle& rRect) const
504cdf0e10cSrcweir {
505cdf0e10cSrcweir if (!rRect.IsEmpty()) {
506cdf0e10cSrcweir rRect.Justify();
507cdf0e10cSrcweir if (rRect.Left()==rRect.Right()) rRect.Right()++;
508cdf0e10cSrcweir if (rRect.Top()==rRect.Bottom()) rRect.Bottom()++;
509cdf0e10cSrcweir }
510cdf0e10cSrcweir }
511cdf0e10cSrcweir
ImpCheckShear()512cdf0e10cSrcweir void SdrTextObj::ImpCheckShear()
513cdf0e10cSrcweir {
514cdf0e10cSrcweir if (bNoShear && aGeo.nShearWink!=0) {
515cdf0e10cSrcweir aGeo.nShearWink=0;
516cdf0e10cSrcweir aGeo.nTan=0;
517cdf0e10cSrcweir }
518cdf0e10cSrcweir }
519cdf0e10cSrcweir
TakeObjInfo(SdrObjTransformInfoRec & rInfo) const520cdf0e10cSrcweir void SdrTextObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
521cdf0e10cSrcweir {
522cdf0e10cSrcweir FASTBOOL bNoTextFrame=!IsTextFrame();
523cdf0e10cSrcweir rInfo.bResizeFreeAllowed=bNoTextFrame || aGeo.nDrehWink%9000==0;
524cdf0e10cSrcweir rInfo.bResizePropAllowed=sal_True;
525cdf0e10cSrcweir rInfo.bRotateFreeAllowed=sal_True;
526cdf0e10cSrcweir rInfo.bRotate90Allowed =sal_True;
527cdf0e10cSrcweir rInfo.bMirrorFreeAllowed=bNoTextFrame;
528cdf0e10cSrcweir rInfo.bMirror45Allowed =bNoTextFrame;
529cdf0e10cSrcweir rInfo.bMirror90Allowed =bNoTextFrame;
530cdf0e10cSrcweir
531cdf0e10cSrcweir // allow transparence
532cdf0e10cSrcweir rInfo.bTransparenceAllowed = sal_True;
533cdf0e10cSrcweir
534cdf0e10cSrcweir // gradient depends on fillstyle
535cdf0e10cSrcweir XFillStyle eFillStyle = ((XFillStyleItem&)(GetObjectItem(XATTR_FILLSTYLE))).GetValue();
536cdf0e10cSrcweir rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT);
537cdf0e10cSrcweir rInfo.bShearAllowed =bNoTextFrame;
538cdf0e10cSrcweir rInfo.bEdgeRadiusAllowed=sal_True;
539cdf0e10cSrcweir FASTBOOL bCanConv=ImpCanConvTextToCurve();
540cdf0e10cSrcweir rInfo.bCanConvToPath =bCanConv;
541cdf0e10cSrcweir rInfo.bCanConvToPoly =bCanConv;
542cdf0e10cSrcweir rInfo.bCanConvToPathLineToArea=bCanConv;
543cdf0e10cSrcweir rInfo.bCanConvToPolyLineToArea=bCanConv;
544cdf0e10cSrcweir rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
GetObjIdentifier() const547cdf0e10cSrcweir sal_uInt16 SdrTextObj::GetObjIdentifier() const
548cdf0e10cSrcweir {
549cdf0e10cSrcweir return sal_uInt16(eTextKind);
550cdf0e10cSrcweir }
551cdf0e10cSrcweir
HasTextImpl(SdrOutliner * pOutliner)552cdf0e10cSrcweir bool SdrTextObj::HasTextImpl( SdrOutliner* pOutliner )
553cdf0e10cSrcweir {
554cdf0e10cSrcweir bool bRet=false;
555cdf0e10cSrcweir if(pOutliner)
556cdf0e10cSrcweir {
557cdf0e10cSrcweir Paragraph* p1stPara=pOutliner->GetParagraph( 0 );
558cdf0e10cSrcweir sal_uIntPtr nParaAnz=pOutliner->GetParagraphCount();
559cdf0e10cSrcweir if(p1stPara==NULL)
560cdf0e10cSrcweir nParaAnz=0;
561cdf0e10cSrcweir
562cdf0e10cSrcweir if(nParaAnz==1)
563cdf0e10cSrcweir {
564cdf0e10cSrcweir // if it is only one paragraph, check if that paragraph is empty
565cdf0e10cSrcweir XubString aStr(pOutliner->GetText(p1stPara));
566cdf0e10cSrcweir
567cdf0e10cSrcweir if(!aStr.Len())
568cdf0e10cSrcweir nParaAnz = 0;
569cdf0e10cSrcweir }
570cdf0e10cSrcweir
571cdf0e10cSrcweir bRet= nParaAnz!=0;
572cdf0e10cSrcweir }
573cdf0e10cSrcweir return bRet;
574cdf0e10cSrcweir }
575cdf0e10cSrcweir
HasEditText() const576cdf0e10cSrcweir FASTBOOL SdrTextObj::HasEditText() const
577cdf0e10cSrcweir {
578cdf0e10cSrcweir return HasTextImpl( pEdtOutl );
579cdf0e10cSrcweir }
580cdf0e10cSrcweir
SetPage(SdrPage * pNewPage)581cdf0e10cSrcweir void SdrTextObj::SetPage(SdrPage* pNewPage)
582cdf0e10cSrcweir {
583cdf0e10cSrcweir FASTBOOL bRemove=pNewPage==NULL && pPage!=NULL;
584cdf0e10cSrcweir FASTBOOL bInsert=pNewPage!=NULL && pPage==NULL;
585cdf0e10cSrcweir FASTBOOL bLinked=IsLinkedText();
586cdf0e10cSrcweir
587cdf0e10cSrcweir if (bLinked && bRemove) {
588cdf0e10cSrcweir ImpLinkAbmeldung();
589cdf0e10cSrcweir }
590cdf0e10cSrcweir
591cdf0e10cSrcweir SdrAttrObj::SetPage(pNewPage);
592cdf0e10cSrcweir
593cdf0e10cSrcweir if (bLinked && bInsert) {
594cdf0e10cSrcweir ImpLinkAnmeldung();
595cdf0e10cSrcweir }
596cdf0e10cSrcweir }
597cdf0e10cSrcweir
SetModel(SdrModel * pNewModel)598cdf0e10cSrcweir void SdrTextObj::SetModel(SdrModel* pNewModel)
599cdf0e10cSrcweir {
600cdf0e10cSrcweir SdrModel* pOldModel=pModel;
601cdf0e10cSrcweir bool bLinked=IsLinkedText();
602cdf0e10cSrcweir bool bChg=pNewModel!=pModel;
603cdf0e10cSrcweir
604cdf0e10cSrcweir if (bLinked && bChg)
605cdf0e10cSrcweir {
606cdf0e10cSrcweir ImpLinkAbmeldung();
607cdf0e10cSrcweir }
608cdf0e10cSrcweir
609cdf0e10cSrcweir SdrAttrObj::SetModel(pNewModel);
610cdf0e10cSrcweir
611cdf0e10cSrcweir if( bChg )
612cdf0e10cSrcweir {
613cdf0e10cSrcweir if( pNewModel != 0 && pOldModel != 0 )
614cdf0e10cSrcweir SetTextSizeDirty();
615cdf0e10cSrcweir
616cdf0e10cSrcweir sal_Int32 nCount = getTextCount();
617cdf0e10cSrcweir for( sal_Int32 nText = 0; nText < nCount; nText++ )
618cdf0e10cSrcweir {
619cdf0e10cSrcweir SdrText* pText = getText( nText );
620cdf0e10cSrcweir if( pText )
621cdf0e10cSrcweir pText->SetModel( pNewModel );
622cdf0e10cSrcweir }
623cdf0e10cSrcweir }
624cdf0e10cSrcweir
625cdf0e10cSrcweir if (bLinked && bChg)
626cdf0e10cSrcweir {
627cdf0e10cSrcweir ImpLinkAnmeldung();
628cdf0e10cSrcweir }
629cdf0e10cSrcweir }
630cdf0e10cSrcweir
NbcSetEckenradius(long nRad)631cdf0e10cSrcweir FASTBOOL SdrTextObj::NbcSetEckenradius(long nRad)
632cdf0e10cSrcweir {
633cdf0e10cSrcweir SetObjectItem(SdrEckenradiusItem(nRad));
634cdf0e10cSrcweir return sal_True;
635cdf0e10cSrcweir }
636cdf0e10cSrcweir
NbcSetAutoGrowHeight(bool bAuto)637cdf0e10cSrcweir FASTBOOL SdrTextObj::NbcSetAutoGrowHeight(bool bAuto)
638cdf0e10cSrcweir {
639cdf0e10cSrcweir if(bTextFrame)
640cdf0e10cSrcweir {
641cdf0e10cSrcweir SetObjectItem(SdrTextAutoGrowHeightItem(bAuto));
642cdf0e10cSrcweir return sal_True;
643cdf0e10cSrcweir }
644cdf0e10cSrcweir return sal_False;
645cdf0e10cSrcweir }
646cdf0e10cSrcweir
647215d8f42SArmin Le Grand // #115391# This implementation is based on the object size (aRect) and the
648215d8f42SArmin Le Grand // states of IsAutoGrowWidth/Height to correctly set TextMinFrameWidth/Height
AdaptTextMinSize()649215d8f42SArmin Le Grand void SdrTextObj::AdaptTextMinSize()
650cdf0e10cSrcweir {
6514eaf0ff5SArmin Le Grand if(bTextFrame && (!pModel || !pModel->IsPasteResize()))
652215d8f42SArmin Le Grand {
653215d8f42SArmin Le Grand const bool bW(IsAutoGrowWidth());
654215d8f42SArmin Le Grand const bool bH(IsAutoGrowHeight());
655cdf0e10cSrcweir
656215d8f42SArmin Le Grand if(bW || bH)
657215d8f42SArmin Le Grand {
658*9dc4e1a1SArmin Le Grand SfxItemSet aSet(
659*9dc4e1a1SArmin Le Grand *GetObjectItemSet().GetPool(),
660*9dc4e1a1SArmin Le Grand SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT,
661*9dc4e1a1SArmin Le Grand SDRATTR_TEXT_MINFRAMEWIDTH, SDRATTR_TEXT_AUTOGROWWIDTH, // contains SDRATTR_TEXT_MAXFRAMEWIDTH
662*9dc4e1a1SArmin Le Grand 0, 0);
663cdf0e10cSrcweir
664215d8f42SArmin Le Grand if(bW)
665215d8f42SArmin Le Grand {
666215d8f42SArmin Le Grand const long nDist(GetTextLeftDistance() + GetTextRightDistance());
667215d8f42SArmin Le Grand const long nW(std::max(long(0), (long)(aRect.GetWidth() - 1 - nDist)));
668215d8f42SArmin Le Grand
669215d8f42SArmin Le Grand aSet.Put(SdrTextMinFrameWidthItem(nW));
670215d8f42SArmin Le Grand
671215d8f42SArmin Le Grand if(!IsVerticalWriting() && bDisableAutoWidthOnDragging)
672215d8f42SArmin Le Grand {
673215d8f42SArmin Le Grand bDisableAutoWidthOnDragging = true;
674215d8f42SArmin Le Grand aSet.Put(SdrTextAutoGrowWidthItem(false));
675215d8f42SArmin Le Grand }
676215d8f42SArmin Le Grand }
677215d8f42SArmin Le Grand
678215d8f42SArmin Le Grand if(bH)
679215d8f42SArmin Le Grand {
680215d8f42SArmin Le Grand const long nDist(GetTextUpperDistance() + GetTextLowerDistance());
681215d8f42SArmin Le Grand const long nH(std::max(long(0), (long)(aRect.GetHeight() - 1 - nDist)));
682215d8f42SArmin Le Grand
683215d8f42SArmin Le Grand aSet.Put(SdrTextMinFrameHeightItem(nH));
684215d8f42SArmin Le Grand
685215d8f42SArmin Le Grand if(IsVerticalWriting() && bDisableAutoWidthOnDragging)
686215d8f42SArmin Le Grand {
687215d8f42SArmin Le Grand bDisableAutoWidthOnDragging = false;
68805fed2dbSArmin Le Grand aSet.Put(SdrTextAutoGrowHeightItem(false));
689215d8f42SArmin Le Grand }
690215d8f42SArmin Le Grand }
691215d8f42SArmin Le Grand
692215d8f42SArmin Le Grand SetObjectItemSet(aSet);
693215d8f42SArmin Le Grand NbcAdjustTextFrameWidthAndHeight();
694215d8f42SArmin Le Grand }
695215d8f42SArmin Le Grand }
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
NbcSetMaxTextFrameHeight(long nHgt)698cdf0e10cSrcweir FASTBOOL SdrTextObj::NbcSetMaxTextFrameHeight(long nHgt)
699cdf0e10cSrcweir {
700cdf0e10cSrcweir if(bTextFrame)
701cdf0e10cSrcweir {
702cdf0e10cSrcweir SetObjectItem(SdrTextMaxFrameHeightItem(nHgt));
703cdf0e10cSrcweir return sal_True;
704cdf0e10cSrcweir }
705cdf0e10cSrcweir return sal_False;
706cdf0e10cSrcweir }
707cdf0e10cSrcweir
NbcSetAutoGrowWidth(bool bAuto)708cdf0e10cSrcweir FASTBOOL SdrTextObj::NbcSetAutoGrowWidth(bool bAuto)
709cdf0e10cSrcweir {
710cdf0e10cSrcweir if(bTextFrame)
711cdf0e10cSrcweir {
712cdf0e10cSrcweir SetObjectItem(SdrTextAutoGrowWidthItem(bAuto));
713cdf0e10cSrcweir return sal_True;
714cdf0e10cSrcweir }
715cdf0e10cSrcweir return sal_False;
716cdf0e10cSrcweir }
717cdf0e10cSrcweir
NbcSetMaxTextFrameWidth(long nWdt)718cdf0e10cSrcweir FASTBOOL SdrTextObj::NbcSetMaxTextFrameWidth(long nWdt)
719cdf0e10cSrcweir {
720cdf0e10cSrcweir if(bTextFrame)
721cdf0e10cSrcweir {
722cdf0e10cSrcweir SetObjectItem(SdrTextMaxFrameWidthItem(nWdt));
723cdf0e10cSrcweir return sal_True;
724cdf0e10cSrcweir }
725cdf0e10cSrcweir return sal_False;
726cdf0e10cSrcweir }
727cdf0e10cSrcweir
NbcSetFitToSize(SdrFitToSizeType eFit)72826734c99SArmin Le Grand FASTBOOL SdrTextObj::NbcSetFitToSize(SdrFitToSizeType eFit)
729cdf0e10cSrcweir {
730cdf0e10cSrcweir if(bTextFrame)
731cdf0e10cSrcweir {
73226734c99SArmin Le Grand SetObjectItem(SdrTextFitToSizeTypeItem(eFit));
733cdf0e10cSrcweir return sal_True;
734cdf0e10cSrcweir }
735cdf0e10cSrcweir return sal_False;
736cdf0e10cSrcweir }
737cdf0e10cSrcweir
ImpSetContourPolygon(SdrOutliner & rOutliner,Rectangle & rAnchorRect,sal_Bool bLineWidth) const738cdf0e10cSrcweir void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, Rectangle& rAnchorRect, sal_Bool bLineWidth ) const
739cdf0e10cSrcweir {
740cdf0e10cSrcweir basegfx::B2DPolyPolygon aXorPolyPolygon(TakeXorPoly());
741cdf0e10cSrcweir basegfx::B2DPolyPolygon* pContourPolyPolygon = 0L;
742cdf0e10cSrcweir basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix(
743cdf0e10cSrcweir -rAnchorRect.Left(), -rAnchorRect.Top()));
744cdf0e10cSrcweir
745cdf0e10cSrcweir if(aGeo.nDrehWink)
746cdf0e10cSrcweir {
747cdf0e10cSrcweir // Unrotate!
748cdf0e10cSrcweir aMatrix.rotate(-aGeo.nDrehWink * nPi180);
749cdf0e10cSrcweir }
750cdf0e10cSrcweir
751cdf0e10cSrcweir aXorPolyPolygon.transform(aMatrix);
752cdf0e10cSrcweir
753cdf0e10cSrcweir if( bLineWidth )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir // Strichstaerke beruecksichtigen
756cdf0e10cSrcweir // Beim Hittest muss das unterbleiben (Performance!)
757cdf0e10cSrcweir pContourPolyPolygon = new basegfx::B2DPolyPolygon();
758cdf0e10cSrcweir
759cdf0e10cSrcweir // #86258# test if shadow needs to be avoided for TakeContour()
760cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet();
761cdf0e10cSrcweir sal_Bool bShadowOn = ((SdrShadowItem&)(rSet.Get(SDRATTR_SHADOW))).GetValue();
762cdf0e10cSrcweir
763cdf0e10cSrcweir // #i33696#
764cdf0e10cSrcweir // Remember TextObject currently set at the DrawOutliner, it WILL be
765cdf0e10cSrcweir // replaced during calculating the outline since it uses an own paint
766cdf0e10cSrcweir // and that one uses the DrawOutliner, too.
767cdf0e10cSrcweir const SdrTextObj* pLastTextObject = rOutliner.GetTextObj();
768cdf0e10cSrcweir
769cdf0e10cSrcweir if(bShadowOn)
770cdf0e10cSrcweir {
771cdf0e10cSrcweir // #86258# force shadow off
772cdf0e10cSrcweir SdrObject* pCopy = Clone();
773cdf0e10cSrcweir pCopy->SetMergedItem(SdrShadowItem(sal_False));
774cdf0e10cSrcweir *pContourPolyPolygon = pCopy->TakeContour();
775cdf0e10cSrcweir SdrObject::Free( pCopy );
776cdf0e10cSrcweir }
777cdf0e10cSrcweir else
778cdf0e10cSrcweir {
779cdf0e10cSrcweir *pContourPolyPolygon = TakeContour();
780cdf0e10cSrcweir }
781cdf0e10cSrcweir
782cdf0e10cSrcweir // #i33696#
783cdf0e10cSrcweir // restore remembered text object
784cdf0e10cSrcweir if(pLastTextObject != rOutliner.GetTextObj())
785cdf0e10cSrcweir {
786cdf0e10cSrcweir rOutliner.SetTextObj(pLastTextObject);
787cdf0e10cSrcweir }
788cdf0e10cSrcweir
789cdf0e10cSrcweir pContourPolyPolygon->transform(aMatrix);
790cdf0e10cSrcweir }
791cdf0e10cSrcweir
792cdf0e10cSrcweir rOutliner.SetPolygon(aXorPolyPolygon, pContourPolyPolygon);
793cdf0e10cSrcweir }
794cdf0e10cSrcweir
TakeUnrotatedSnapRect(Rectangle & rRect) const795cdf0e10cSrcweir void SdrTextObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
796cdf0e10cSrcweir {
797cdf0e10cSrcweir rRect=aRect;
798cdf0e10cSrcweir }
799cdf0e10cSrcweir
TakeTextAnchorRect(Rectangle & rAnchorRect) const800cdf0e10cSrcweir void SdrTextObj::TakeTextAnchorRect(Rectangle& rAnchorRect) const
801cdf0e10cSrcweir {
802cdf0e10cSrcweir long nLeftDist=GetTextLeftDistance();
803cdf0e10cSrcweir long nRightDist=GetTextRightDistance();
804cdf0e10cSrcweir long nUpperDist=GetTextUpperDistance();
805cdf0e10cSrcweir long nLowerDist=GetTextLowerDistance();
806cdf0e10cSrcweir Rectangle aAnkRect(aRect); // Rect innerhalb dem geankert wird
807cdf0e10cSrcweir FASTBOOL bFrame=IsTextFrame();
808cdf0e10cSrcweir if (!bFrame) {
809cdf0e10cSrcweir TakeUnrotatedSnapRect(aAnkRect);
810cdf0e10cSrcweir }
811cdf0e10cSrcweir Point aRotateRef(aAnkRect.TopLeft());
812cdf0e10cSrcweir aAnkRect.Left()+=nLeftDist;
813cdf0e10cSrcweir aAnkRect.Top()+=nUpperDist;
814cdf0e10cSrcweir aAnkRect.Right()-=nRightDist;
815cdf0e10cSrcweir aAnkRect.Bottom()-=nLowerDist;
816cdf0e10cSrcweir
817cdf0e10cSrcweir // #108816#
818cdf0e10cSrcweir // Since sizes may be bigger than the object bounds it is necessary to
819cdf0e10cSrcweir // justify the rect now.
820cdf0e10cSrcweir ImpJustifyRect(aAnkRect);
821cdf0e10cSrcweir
822cdf0e10cSrcweir if (bFrame) {
823cdf0e10cSrcweir // !!! hier noch etwas verfeinern !!!
824cdf0e10cSrcweir if (aAnkRect.GetWidth()<2) aAnkRect.Right()=aAnkRect.Left()+1; // Mindestgroesse 2
825cdf0e10cSrcweir if (aAnkRect.GetHeight()<2) aAnkRect.Bottom()=aAnkRect.Top()+1; // Mindestgroesse 2
826cdf0e10cSrcweir }
827cdf0e10cSrcweir if (aGeo.nDrehWink!=0) {
828cdf0e10cSrcweir Point aTmpPt(aAnkRect.TopLeft());
829cdf0e10cSrcweir RotatePoint(aTmpPt,aRotateRef,aGeo.nSin,aGeo.nCos);
830cdf0e10cSrcweir aTmpPt-=aAnkRect.TopLeft();
831cdf0e10cSrcweir aAnkRect.Move(aTmpPt.X(),aTmpPt.Y());
832cdf0e10cSrcweir }
833cdf0e10cSrcweir rAnchorRect=aAnkRect;
834cdf0e10cSrcweir }
835cdf0e10cSrcweir
TakeTextRect(SdrOutliner & rOutliner,Rectangle & rTextRect,FASTBOOL bNoEditText,Rectangle * pAnchorRect,sal_Bool bLineWidth) const836cdf0e10cSrcweir void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, FASTBOOL bNoEditText,
837cdf0e10cSrcweir Rectangle* pAnchorRect, sal_Bool bLineWidth ) const
838cdf0e10cSrcweir {
839cdf0e10cSrcweir Rectangle aAnkRect; // Rect innerhalb dem geankert wird
840cdf0e10cSrcweir TakeTextAnchorRect(aAnkRect);
841cdf0e10cSrcweir SdrTextVertAdjust eVAdj=GetTextVerticalAdjust();
842cdf0e10cSrcweir SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust();
843cdf0e10cSrcweir SdrTextAniKind eAniKind=GetTextAniKind();
844cdf0e10cSrcweir SdrTextAniDirection eAniDirection=GetTextAniDirection();
84526734c99SArmin Le Grand
84626734c99SArmin Le Grand SdrFitToSizeType eFit=GetFitToSize();
84726734c99SArmin Le Grand FASTBOOL bFitToSize=(eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES);
848cdf0e10cSrcweir FASTBOOL bContourFrame=IsContourTextFrame();
84926734c99SArmin Le Grand
850cdf0e10cSrcweir FASTBOOL bFrame=IsTextFrame();
851cdf0e10cSrcweir sal_uIntPtr nStat0=rOutliner.GetControlWord();
852cdf0e10cSrcweir Size aNullSize;
853cdf0e10cSrcweir if (!bContourFrame)
854cdf0e10cSrcweir {
855cdf0e10cSrcweir rOutliner.SetControlWord(nStat0|EE_CNTRL_AUTOPAGESIZE);
856cdf0e10cSrcweir rOutliner.SetMinAutoPaperSize(aNullSize);
857cdf0e10cSrcweir rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
858cdf0e10cSrcweir }
859cdf0e10cSrcweir
86026734c99SArmin Le Grand if (!bFitToSize && !bContourFrame)
861cdf0e10cSrcweir {
862cdf0e10cSrcweir long nAnkWdt=aAnkRect.GetWidth();
863cdf0e10cSrcweir long nAnkHgt=aAnkRect.GetHeight();
864cdf0e10cSrcweir if (bFrame)
865cdf0e10cSrcweir {
866cdf0e10cSrcweir long nWdt=nAnkWdt;
867cdf0e10cSrcweir long nHgt=nAnkHgt;
868cdf0e10cSrcweir
869cdf0e10cSrcweir // #101684#
870cdf0e10cSrcweir sal_Bool bInEditMode = IsInEditMode();
871cdf0e10cSrcweir
872cdf0e10cSrcweir if (!bInEditMode && (eAniKind==SDRTEXTANI_SCROLL || eAniKind==SDRTEXTANI_ALTERNATE || eAniKind==SDRTEXTANI_SLIDE))
873cdf0e10cSrcweir {
874cdf0e10cSrcweir // Grenzenlose Papiergroesse fuer Laufschrift
875cdf0e10cSrcweir if (eAniDirection==SDRTEXTANI_LEFT || eAniDirection==SDRTEXTANI_RIGHT) nWdt=1000000;
876cdf0e10cSrcweir if (eAniDirection==SDRTEXTANI_UP || eAniDirection==SDRTEXTANI_DOWN) nHgt=1000000;
877cdf0e10cSrcweir }
8785df46f50SArmin Le Grand
8795df46f50SArmin Le Grand // #119885# Do not limit/force height to geometrical frame (vice versa for vertical writing)
8805df46f50SArmin Le Grand if(IsVerticalWriting())
8815df46f50SArmin Le Grand {
8825df46f50SArmin Le Grand nWdt = 1000000;
8835df46f50SArmin Le Grand }
8845df46f50SArmin Le Grand else
8855df46f50SArmin Le Grand {
8865df46f50SArmin Le Grand nHgt = 1000000;
8875df46f50SArmin Le Grand }
8885df46f50SArmin Le Grand
889cdf0e10cSrcweir rOutliner.SetMaxAutoPaperSize(Size(nWdt,nHgt));
890cdf0e10cSrcweir }
891cdf0e10cSrcweir
892cdf0e10cSrcweir // #103516# New try with _BLOCK for hor and ver after completely
893cdf0e10cSrcweir // supporting full width for vertical text.
894cdf0e10cSrcweir if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
895cdf0e10cSrcweir {
896cdf0e10cSrcweir rOutliner.SetMinAutoPaperSize(Size(nAnkWdt, 0));
897cdf0e10cSrcweir }
898cdf0e10cSrcweir
899cdf0e10cSrcweir if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting())
900cdf0e10cSrcweir {
901cdf0e10cSrcweir rOutliner.SetMinAutoPaperSize(Size(0, nAnkHgt));
902cdf0e10cSrcweir }
903cdf0e10cSrcweir }
904cdf0e10cSrcweir
905cdf0e10cSrcweir rOutliner.SetPaperSize(aNullSize);
906cdf0e10cSrcweir if (bContourFrame)
907cdf0e10cSrcweir ImpSetContourPolygon( rOutliner, aAnkRect, bLineWidth );
908cdf0e10cSrcweir
909cdf0e10cSrcweir // put text into the outliner, if available from the edit outliner
910cdf0e10cSrcweir SdrText* pText = getActiveText();
911cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = pText ? pText->GetOutlinerParaObject() : 0;
912cdf0e10cSrcweir OutlinerParaObject* pPara = (pEdtOutl && !bNoEditText) ? pEdtOutl->CreateParaObject() : pOutlinerParaObject;
913cdf0e10cSrcweir
914cdf0e10cSrcweir if (pPara)
915cdf0e10cSrcweir {
916cdf0e10cSrcweir sal_Bool bHitTest = sal_False;
917cdf0e10cSrcweir if( pModel )
918cdf0e10cSrcweir bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
919cdf0e10cSrcweir
920cdf0e10cSrcweir const SdrTextObj* pTestObj = rOutliner.GetTextObj();
921cdf0e10cSrcweir if( !pTestObj || !bHitTest || pTestObj != this ||
922cdf0e10cSrcweir pTestObj->GetOutlinerParaObject() != pOutlinerParaObject )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir if( bHitTest ) // #i33696# take back fix #i27510#
925cdf0e10cSrcweir {
926cdf0e10cSrcweir rOutliner.SetTextObj( this );
927cdf0e10cSrcweir rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
928cdf0e10cSrcweir }
929cdf0e10cSrcweir
930cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_True);
931cdf0e10cSrcweir rOutliner.SetText(*pPara);
932cdf0e10cSrcweir }
933cdf0e10cSrcweir }
934cdf0e10cSrcweir else
935cdf0e10cSrcweir {
936cdf0e10cSrcweir rOutliner.SetTextObj( NULL );
937cdf0e10cSrcweir }
938cdf0e10cSrcweir
939cdf0e10cSrcweir if (pEdtOutl && !bNoEditText && pPara)
940cdf0e10cSrcweir delete pPara;
941cdf0e10cSrcweir
942cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_True);
943cdf0e10cSrcweir rOutliner.SetControlWord(nStat0);
944cdf0e10cSrcweir
945cdf0e10cSrcweir if( pText )
946cdf0e10cSrcweir pText->CheckPortionInfo(rOutliner);
947cdf0e10cSrcweir
948cdf0e10cSrcweir Point aTextPos(aAnkRect.TopLeft());
949cdf0e10cSrcweir Size aTextSiz(rOutliner.GetPaperSize()); // GetPaperSize() hat etwas Toleranz drauf, oder?
950cdf0e10cSrcweir
951cdf0e10cSrcweir // #106653#
952cdf0e10cSrcweir // For draw objects containing text correct hor/ver alignment if text is bigger
953cdf0e10cSrcweir // than the object itself. Without that correction, the text would always be
954cdf0e10cSrcweir // formatted to the left edge (or top edge when vertical) of the draw object.
955cdf0e10cSrcweir if(!IsTextFrame())
956cdf0e10cSrcweir {
957cdf0e10cSrcweir if(aAnkRect.GetWidth() < aTextSiz.Width() && !IsVerticalWriting())
958cdf0e10cSrcweir {
959cdf0e10cSrcweir // #110129#
960cdf0e10cSrcweir // Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK,
961cdf0e10cSrcweir // else the alignment is wanted.
962cdf0e10cSrcweir if(SDRTEXTHORZADJUST_BLOCK == eHAdj)
963cdf0e10cSrcweir {
964cdf0e10cSrcweir eHAdj = SDRTEXTHORZADJUST_CENTER;
965cdf0e10cSrcweir }
966cdf0e10cSrcweir }
967cdf0e10cSrcweir
968cdf0e10cSrcweir if(aAnkRect.GetHeight() < aTextSiz.Height() && IsVerticalWriting())
969cdf0e10cSrcweir {
970cdf0e10cSrcweir // #110129#
971cdf0e10cSrcweir // Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK,
972cdf0e10cSrcweir // else the alignment is wanted.
973cdf0e10cSrcweir if(SDRTEXTVERTADJUST_BLOCK == eVAdj)
974cdf0e10cSrcweir {
975cdf0e10cSrcweir eVAdj = SDRTEXTVERTADJUST_CENTER;
976cdf0e10cSrcweir }
977cdf0e10cSrcweir }
978cdf0e10cSrcweir }
979cdf0e10cSrcweir
980cdf0e10cSrcweir if (eHAdj==SDRTEXTHORZADJUST_CENTER || eHAdj==SDRTEXTHORZADJUST_RIGHT)
981cdf0e10cSrcweir {
982cdf0e10cSrcweir long nFreeWdt=aAnkRect.GetWidth()-aTextSiz.Width();
983cdf0e10cSrcweir if (eHAdj==SDRTEXTHORZADJUST_CENTER)
984cdf0e10cSrcweir aTextPos.X()+=nFreeWdt/2;
985cdf0e10cSrcweir if (eHAdj==SDRTEXTHORZADJUST_RIGHT)
986cdf0e10cSrcweir aTextPos.X()+=nFreeWdt;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir if (eVAdj==SDRTEXTVERTADJUST_CENTER || eVAdj==SDRTEXTVERTADJUST_BOTTOM)
989cdf0e10cSrcweir {
990cdf0e10cSrcweir long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height();
991cdf0e10cSrcweir if (eVAdj==SDRTEXTVERTADJUST_CENTER)
992cdf0e10cSrcweir aTextPos.Y()+=nFreeHgt/2;
993cdf0e10cSrcweir if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
994cdf0e10cSrcweir aTextPos.Y()+=nFreeHgt;
995cdf0e10cSrcweir }
996cdf0e10cSrcweir if (aGeo.nDrehWink!=0)
997cdf0e10cSrcweir RotatePoint(aTextPos,aAnkRect.TopLeft(),aGeo.nSin,aGeo.nCos);
998cdf0e10cSrcweir
999cdf0e10cSrcweir if (pAnchorRect)
1000cdf0e10cSrcweir *pAnchorRect=aAnkRect;
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir // rTextRect ist bei ContourFrame in einigen Faellen nicht korrekt
1003cdf0e10cSrcweir rTextRect=Rectangle(aTextPos,aTextSiz);
1004cdf0e10cSrcweir if (bContourFrame)
1005cdf0e10cSrcweir rTextRect=aAnkRect;
1006cdf0e10cSrcweir }
1007cdf0e10cSrcweir
GetEditOutlinerParaObject() const1008cdf0e10cSrcweir OutlinerParaObject* SdrTextObj::GetEditOutlinerParaObject() const
1009cdf0e10cSrcweir {
1010cdf0e10cSrcweir OutlinerParaObject* pPara=NULL;
1011cdf0e10cSrcweir if( HasTextImpl( pEdtOutl ) )
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir sal_uInt16 nParaAnz = static_cast< sal_uInt16 >( pEdtOutl->GetParagraphCount() );
1014cdf0e10cSrcweir pPara = pEdtOutl->CreateParaObject(0, nParaAnz);
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir return pPara;
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir
ImpSetCharStretching(SdrOutliner & rOutliner,const Rectangle & rTextRect,const Rectangle & rAnchorRect,Fraction & rFitXKorreg) const1019cdf0e10cSrcweir void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Rectangle& rTextRect, const Rectangle& rAnchorRect, Fraction& rFitXKorreg) const
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir OutputDevice* pOut = rOutliner.GetRefDevice();
1022cdf0e10cSrcweir sal_Bool bNoStretching(sal_False);
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir if(pOut && pOut->GetOutDevType() == OUTDEV_PRINTER)
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir // #35762#: Checken ob CharStretching ueberhaupt moeglich
1027cdf0e10cSrcweir GDIMetaFile* pMtf = pOut->GetConnectMetaFile();
1028cdf0e10cSrcweir UniString aTestString(sal_Unicode('J'));
1029cdf0e10cSrcweir
1030cdf0e10cSrcweir if(pMtf && (!pMtf->IsRecord() || pMtf->IsPause()))
1031cdf0e10cSrcweir pMtf = NULL;
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir if(pMtf)
1034cdf0e10cSrcweir pMtf->Pause(sal_True);
1035cdf0e10cSrcweir
1036cdf0e10cSrcweir Font aFontMerk(pOut->GetFont());
1037cdf0e10cSrcweir Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_SERIF, LANGUAGE_SYSTEM, DEFAULTFONT_FLAGS_ONLYONE ) );
1038cdf0e10cSrcweir
1039cdf0e10cSrcweir aTmpFont.SetSize(Size(0,100));
1040cdf0e10cSrcweir pOut->SetFont(aTmpFont);
1041cdf0e10cSrcweir Size aSize1(pOut->GetTextWidth(aTestString), pOut->GetTextHeight());
1042cdf0e10cSrcweir aTmpFont.SetSize(Size(800,100));
1043cdf0e10cSrcweir pOut->SetFont(aTmpFont);
1044cdf0e10cSrcweir Size aSize2(pOut->GetTextWidth(aTestString), pOut->GetTextHeight());
1045cdf0e10cSrcweir pOut->SetFont(aFontMerk);
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir if(pMtf)
1048cdf0e10cSrcweir pMtf->Pause(sal_False);
1049cdf0e10cSrcweir
1050cdf0e10cSrcweir bNoStretching = (aSize1 == aSize2);
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir #ifdef WNT
1053cdf0e10cSrcweir // #35762# Windows vergroessert bei Size(100,500) den Font proportional
1054cdf0e10cSrcweir // Und das finden wir nicht so schoen.
1055cdf0e10cSrcweir if(aSize2.Height() >= aSize1.Height() * 2)
1056cdf0e10cSrcweir {
1057cdf0e10cSrcweir bNoStretching = sal_True;
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir #endif
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir unsigned nLoopCount=0;
1062cdf0e10cSrcweir FASTBOOL bNoMoreLoop=sal_False;
1063cdf0e10cSrcweir long nXDiff0=0x7FFFFFFF;
1064cdf0e10cSrcweir long nWantWdt=rAnchorRect.Right()-rAnchorRect.Left();
1065cdf0e10cSrcweir long nIsWdt=rTextRect.Right()-rTextRect.Left();
1066cdf0e10cSrcweir if (nIsWdt==0) nIsWdt=1;
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir long nWantHgt=rAnchorRect.Bottom()-rAnchorRect.Top();
1069cdf0e10cSrcweir long nIsHgt=rTextRect.Bottom()-rTextRect.Top();
1070cdf0e10cSrcweir if (nIsHgt==0) nIsHgt=1;
1071cdf0e10cSrcweir
1072cdf0e10cSrcweir long nXTolPl=nWantWdt/100; // Toleranz +1%
1073cdf0e10cSrcweir long nXTolMi=nWantWdt/25; // Toleranz -4%
1074cdf0e10cSrcweir long nXKorr =nWantWdt/20; // Korrekturmasstab 5%
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir long nX=(nWantWdt*100) /nIsWdt; // X-Stretching berechnen
1077cdf0e10cSrcweir long nY=(nWantHgt*100) /nIsHgt; // Y-Stretching berechnen
1078cdf0e10cSrcweir FASTBOOL bChkX=sal_True;
1079cdf0e10cSrcweir FASTBOOL bChkY=sal_True;
1080cdf0e10cSrcweir if (bNoStretching) { // #35762# evtl. nur proportional moeglich
1081cdf0e10cSrcweir if (nX>nY) { nX=nY; bChkX=sal_False; }
1082cdf0e10cSrcweir else { nY=nX; bChkY=sal_False; }
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir
1085cdf0e10cSrcweir while (nLoopCount<5 && !bNoMoreLoop) {
1086cdf0e10cSrcweir if (nX<0) nX=-nX;
1087cdf0e10cSrcweir if (nX<1) { nX=1; bNoMoreLoop=sal_True; }
1088cdf0e10cSrcweir if (nX>65535) { nX=65535; bNoMoreLoop=sal_True; }
1089cdf0e10cSrcweir
1090cdf0e10cSrcweir if (nY<0) nY=-nY;
1091cdf0e10cSrcweir if (nY<1) { nY=1; bNoMoreLoop=sal_True; }
1092cdf0e10cSrcweir if (nY>65535) { nY=65535; bNoMoreLoop=sal_True; }
1093cdf0e10cSrcweir
1094cdf0e10cSrcweir // exception, there is no text yet (horizontal case)
1095cdf0e10cSrcweir if(nIsWdt <= 1)
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir nX = nY;
1098cdf0e10cSrcweir bNoMoreLoop = sal_True;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir
1101cdf0e10cSrcweir // #87877# exception, there is no text yet (vertical case)
1102cdf0e10cSrcweir if(nIsHgt <= 1)
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir nY = nX;
1105cdf0e10cSrcweir bNoMoreLoop = sal_True;
1106cdf0e10cSrcweir }
1107cdf0e10cSrcweir
1108cdf0e10cSrcweir rOutliner.SetGlobalCharStretching((sal_uInt16)nX,(sal_uInt16)nY);
1109cdf0e10cSrcweir nLoopCount++;
1110cdf0e10cSrcweir Size aSiz(rOutliner.CalcTextSize());
1111cdf0e10cSrcweir long nXDiff=aSiz.Width()-nWantWdt;
1112cdf0e10cSrcweir rFitXKorreg=Fraction(nWantWdt,aSiz.Width());
1113cdf0e10cSrcweir if (((nXDiff>=nXTolMi || !bChkX) && nXDiff<=nXTolPl) || nXDiff==nXDiff0/*&& Abs(nYDiff)<=nYTol*/) {
1114cdf0e10cSrcweir bNoMoreLoop=sal_True;
1115cdf0e10cSrcweir } else {
1116cdf0e10cSrcweir // Stretchingfaktoren korregieren
1117cdf0e10cSrcweir long nMul=nWantWdt;
1118cdf0e10cSrcweir long nDiv=aSiz.Width();
1119cdf0e10cSrcweir if (Abs(nXDiff)<=2*nXKorr) {
1120cdf0e10cSrcweir if (nMul>nDiv) nDiv+=(nMul-nDiv)/2; // und zwar nur um die haelfte des berechneten
1121cdf0e10cSrcweir else nMul+=(nDiv-nMul)/2; // weil die EE ja eh wieder falsch rechnet
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir nX=nX*nMul/nDiv;
1124cdf0e10cSrcweir if (bNoStretching) nY=nX;
1125cdf0e10cSrcweir }
1126cdf0e10cSrcweir nXDiff0=nXDiff;
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir }
1129cdf0e10cSrcweir
StartTextAnimation(OutputDevice *,const Point &,long)1130cdf0e10cSrcweir void SdrTextObj::StartTextAnimation(OutputDevice* /*pOutDev*/, const Point& /*rOffset*/, long /*nExtraData*/)
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir // #111096#
1133cdf0e10cSrcweir // use new text animation
1134cdf0e10cSrcweir SetTextAnimationAllowed(sal_True);
1135cdf0e10cSrcweir }
1136cdf0e10cSrcweir
StopTextAnimation(OutputDevice *,long)1137cdf0e10cSrcweir void SdrTextObj::StopTextAnimation(OutputDevice* /*pOutDev*/, long /*nExtraData*/)
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir // #111096#
1140cdf0e10cSrcweir // use new text animation
1141cdf0e10cSrcweir SetTextAnimationAllowed(sal_False);
1142cdf0e10cSrcweir }
1143cdf0e10cSrcweir
TakeObjNameSingul(XubString & rName) const1144cdf0e10cSrcweir void SdrTextObj::TakeObjNameSingul(XubString& rName) const
1145cdf0e10cSrcweir {
1146cdf0e10cSrcweir XubString aStr;
1147cdf0e10cSrcweir
1148cdf0e10cSrcweir switch(eTextKind)
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir case OBJ_OUTLINETEXT:
1151cdf0e10cSrcweir {
1152cdf0e10cSrcweir aStr = ImpGetResStr(STR_ObjNameSingulOUTLINETEXT);
1153cdf0e10cSrcweir break;
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir
1156cdf0e10cSrcweir case OBJ_TITLETEXT :
1157cdf0e10cSrcweir {
1158cdf0e10cSrcweir aStr = ImpGetResStr(STR_ObjNameSingulTITLETEXT);
1159cdf0e10cSrcweir break;
1160cdf0e10cSrcweir }
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir default:
1163cdf0e10cSrcweir {
1164cdf0e10cSrcweir if(IsLinkedText())
1165cdf0e10cSrcweir aStr = ImpGetResStr(STR_ObjNameSingulTEXTLNK);
1166cdf0e10cSrcweir else
1167cdf0e10cSrcweir aStr = ImpGetResStr(STR_ObjNameSingulTEXT);
1168cdf0e10cSrcweir break;
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir
1172cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
1173cdf0e10cSrcweir if(pOutlinerParaObject && eTextKind != OBJ_OUTLINETEXT)
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir // Macht bei OUTLINETEXT wohl derzeit noch etwas Probleme
1176cdf0e10cSrcweir XubString aStr2(pOutlinerParaObject->GetTextObject().GetText(0));
1177cdf0e10cSrcweir aStr2.EraseLeadingChars();
1178cdf0e10cSrcweir
1179cdf0e10cSrcweir // #69446# avoid non expanded text portions in object name
1180cdf0e10cSrcweir // (second condition is new)
1181cdf0e10cSrcweir if(aStr2.Len() && aStr2.Search(sal_Unicode(255)) == STRING_NOTFOUND)
1182cdf0e10cSrcweir {
1183cdf0e10cSrcweir // #76681# space between ResStr and content text
1184cdf0e10cSrcweir aStr += sal_Unicode(' ');
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir aStr += sal_Unicode('\'');
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir if(aStr2.Len() > 10)
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir aStr2.Erase(8);
1191cdf0e10cSrcweir aStr2.AppendAscii("...", 3);
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir aStr += aStr2;
1195cdf0e10cSrcweir aStr += sal_Unicode('\'');
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir
1199cdf0e10cSrcweir rName = aStr;
1200cdf0e10cSrcweir
1201cdf0e10cSrcweir String aName( GetName() );
1202cdf0e10cSrcweir if(aName.Len())
1203cdf0e10cSrcweir {
1204cdf0e10cSrcweir rName += sal_Unicode(' ');
1205cdf0e10cSrcweir rName += sal_Unicode('\'');
1206cdf0e10cSrcweir rName += aName;
1207cdf0e10cSrcweir rName += sal_Unicode('\'');
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir
1210cdf0e10cSrcweir }
1211cdf0e10cSrcweir
TakeObjNamePlural(XubString & rName) const1212cdf0e10cSrcweir void SdrTextObj::TakeObjNamePlural(XubString& rName) const
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir switch (eTextKind) {
1215cdf0e10cSrcweir case OBJ_OUTLINETEXT: rName=ImpGetResStr(STR_ObjNamePluralOUTLINETEXT); break;
1216cdf0e10cSrcweir case OBJ_TITLETEXT : rName=ImpGetResStr(STR_ObjNamePluralTITLETEXT); break;
1217cdf0e10cSrcweir default: {
1218cdf0e10cSrcweir if (IsLinkedText()) {
1219cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNamePluralTEXTLNK);
1220cdf0e10cSrcweir } else {
1221cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNamePluralTEXT);
1222cdf0e10cSrcweir }
1223cdf0e10cSrcweir } break;
1224cdf0e10cSrcweir } // switch
1225cdf0e10cSrcweir }
1226cdf0e10cSrcweir
operator =(const SdrObject & rObj)1227cdf0e10cSrcweir void SdrTextObj::operator=(const SdrObject& rObj)
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir // call parent
1230cdf0e10cSrcweir SdrObject::operator=(rObj);
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >( &rObj );
1233cdf0e10cSrcweir if (pTextObj!=NULL)
1234cdf0e10cSrcweir {
1235cdf0e10cSrcweir aRect =pTextObj->aRect;
1236cdf0e10cSrcweir aGeo =pTextObj->aGeo;
1237cdf0e10cSrcweir eTextKind =pTextObj->eTextKind;
1238cdf0e10cSrcweir bTextFrame=pTextObj->bTextFrame;
1239cdf0e10cSrcweir aTextSize=pTextObj->aTextSize;
1240cdf0e10cSrcweir bTextSizeDirty=pTextObj->bTextSizeDirty;
1241cdf0e10cSrcweir
1242cdf0e10cSrcweir // #101776# Not all of the necessary parameters were copied yet.
1243cdf0e10cSrcweir bNoShear = pTextObj->bNoShear;
1244cdf0e10cSrcweir bNoRotate = pTextObj->bNoRotate;
1245cdf0e10cSrcweir bNoMirror = pTextObj->bNoMirror;
1246cdf0e10cSrcweir bDisableAutoWidthOnDragging = pTextObj->bDisableAutoWidthOnDragging;
1247cdf0e10cSrcweir
1248cdf0e10cSrcweir OutlinerParaObject* pNewOutlinerParaObject = 0;
1249cdf0e10cSrcweir
1250cdf0e10cSrcweir SdrText* pText = getActiveText();
1251cdf0e10cSrcweir
1252cdf0e10cSrcweir if( pText && pTextObj->HasText() )
1253cdf0e10cSrcweir {
1254cdf0e10cSrcweir const Outliner* pEO=pTextObj->pEdtOutl;
1255cdf0e10cSrcweir if (pEO!=NULL)
1256cdf0e10cSrcweir {
1257cdf0e10cSrcweir pNewOutlinerParaObject = pEO->CreateParaObject();
1258cdf0e10cSrcweir }
1259cdf0e10cSrcweir else
1260cdf0e10cSrcweir {
1261cdf0e10cSrcweir pNewOutlinerParaObject = new OutlinerParaObject(*pTextObj->getActiveText()->GetOutlinerParaObject());
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir }
1264cdf0e10cSrcweir
1265cdf0e10cSrcweir mpText->SetOutlinerParaObject( pNewOutlinerParaObject );
1266cdf0e10cSrcweir ImpSetTextStyleSheetListeners();
1267cdf0e10cSrcweir }
1268cdf0e10cSrcweir }
1269cdf0e10cSrcweir
TakeXorPoly() const1270cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrTextObj::TakeXorPoly() const
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir Polygon aPol(aRect);
1273cdf0e10cSrcweir if (aGeo.nShearWink!=0) ShearPoly(aPol,aRect.TopLeft(),aGeo.nTan);
1274cdf0e10cSrcweir if (aGeo.nDrehWink!=0) RotatePoly(aPol,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
1275cdf0e10cSrcweir
1276cdf0e10cSrcweir basegfx::B2DPolyPolygon aRetval;
1277cdf0e10cSrcweir aRetval.append(aPol.getB2DPolygon());
1278cdf0e10cSrcweir return aRetval;
1279cdf0e10cSrcweir }
1280cdf0e10cSrcweir
TakeContour() const1281cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrTextObj::TakeContour() const
1282cdf0e10cSrcweir {
1283cdf0e10cSrcweir basegfx::B2DPolyPolygon aRetval(SdrAttrObj::TakeContour());
1284cdf0e10cSrcweir
1285cdf0e10cSrcweir // und nun noch ggf. das BoundRect des Textes dazu
1286cdf0e10cSrcweir if ( pModel && GetOutlinerParaObject() && !IsFontwork() && !IsContourTextFrame() )
1287cdf0e10cSrcweir {
1288cdf0e10cSrcweir // #80328# using Clone()-Paint() strategy inside TakeContour() leaves a destroyed
1289cdf0e10cSrcweir // SdrObject as pointer in DrawOutliner. Set *this again in fetching the outliner
1290cdf0e10cSrcweir // in every case
1291cdf0e10cSrcweir SdrOutliner& rOutliner=ImpGetDrawOutliner();
1292cdf0e10cSrcweir
1293cdf0e10cSrcweir Rectangle aAnchor2;
1294cdf0e10cSrcweir Rectangle aR;
1295cdf0e10cSrcweir TakeTextRect(rOutliner,aR,sal_False,&aAnchor2);
1296cdf0e10cSrcweir rOutliner.Clear();
129726734c99SArmin Le Grand SdrFitToSizeType eFit=GetFitToSize();
129826734c99SArmin Le Grand FASTBOOL bFitToSize=(eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES);
129926734c99SArmin Le Grand if (bFitToSize) aR=aAnchor2;
1300cdf0e10cSrcweir Polygon aPol(aR);
1301cdf0e10cSrcweir if (aGeo.nDrehWink!=0) RotatePoly(aPol,aR.TopLeft(),aGeo.nSin,aGeo.nCos);
1302cdf0e10cSrcweir
1303cdf0e10cSrcweir aRetval.append(aPol.getB2DPolygon());
1304cdf0e10cSrcweir }
1305cdf0e10cSrcweir
1306cdf0e10cSrcweir return aRetval;
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir
RecalcSnapRect()1309cdf0e10cSrcweir void SdrTextObj::RecalcSnapRect()
1310cdf0e10cSrcweir {
1311cdf0e10cSrcweir if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) {
1312cdf0e10cSrcweir Polygon aPol(aRect);
1313cdf0e10cSrcweir if (aGeo.nShearWink!=0) ShearPoly(aPol,aRect.TopLeft(),aGeo.nTan);
1314cdf0e10cSrcweir if (aGeo.nDrehWink!=0) RotatePoly(aPol,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
1315cdf0e10cSrcweir maSnapRect=aPol.GetBoundRect();
1316cdf0e10cSrcweir } else {
1317cdf0e10cSrcweir maSnapRect=aRect;
1318cdf0e10cSrcweir }
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir
GetSnapPointCount() const1321cdf0e10cSrcweir sal_uInt32 SdrTextObj::GetSnapPointCount() const
1322cdf0e10cSrcweir {
1323cdf0e10cSrcweir return 4L;
1324cdf0e10cSrcweir }
1325cdf0e10cSrcweir
GetSnapPoint(sal_uInt32 i) const1326cdf0e10cSrcweir Point SdrTextObj::GetSnapPoint(sal_uInt32 i) const
1327cdf0e10cSrcweir {
1328cdf0e10cSrcweir Point aP;
1329cdf0e10cSrcweir switch (i) {
1330cdf0e10cSrcweir case 0: aP=aRect.TopLeft(); break;
1331cdf0e10cSrcweir case 1: aP=aRect.TopRight(); break;
1332cdf0e10cSrcweir case 2: aP=aRect.BottomLeft(); break;
1333cdf0e10cSrcweir case 3: aP=aRect.BottomRight(); break;
1334cdf0e10cSrcweir default: aP=aRect.Center(); break;
1335cdf0e10cSrcweir }
1336cdf0e10cSrcweir if (aGeo.nShearWink!=0) ShearPoint(aP,aRect.TopLeft(),aGeo.nTan);
1337cdf0e10cSrcweir if (aGeo.nDrehWink!=0) RotatePoint(aP,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
1338cdf0e10cSrcweir return aP;
1339cdf0e10cSrcweir }
1340cdf0e10cSrcweir
ImpCheckMasterCachable()1341cdf0e10cSrcweir void SdrTextObj::ImpCheckMasterCachable()
1342cdf0e10cSrcweir {
1343cdf0e10cSrcweir bNotMasterCachable=sal_False;
1344cdf0e10cSrcweir
1345cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
1346cdf0e10cSrcweir
1347cdf0e10cSrcweir if(!bNotVisibleAsMaster && pOutlinerParaObject && pOutlinerParaObject->IsEditDoc() )
1348cdf0e10cSrcweir {
1349cdf0e10cSrcweir const EditTextObject& rText= pOutlinerParaObject->GetTextObject();
1350cdf0e10cSrcweir bNotMasterCachable=rText.HasField(SvxPageField::StaticType());
1351cdf0e10cSrcweir if( !bNotMasterCachable )
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir bNotMasterCachable=rText.HasField(SvxHeaderField::StaticType());
1354cdf0e10cSrcweir if( !bNotMasterCachable )
1355cdf0e10cSrcweir {
1356cdf0e10cSrcweir bNotMasterCachable=rText.HasField(SvxFooterField::StaticType());
1357cdf0e10cSrcweir if( !bNotMasterCachable )
1358cdf0e10cSrcweir {
1359cdf0e10cSrcweir bNotMasterCachable=rText.HasField(SvxDateTimeField::StaticType());
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir }
1362cdf0e10cSrcweir }
1363cdf0e10cSrcweir }
1364cdf0e10cSrcweir }
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir // #101029#: Extracted from ImpGetDrawOutliner()
ImpInitDrawOutliner(SdrOutliner & rOutl) const1367cdf0e10cSrcweir void SdrTextObj::ImpInitDrawOutliner( SdrOutliner& rOutl ) const
1368cdf0e10cSrcweir {
1369cdf0e10cSrcweir rOutl.SetUpdateMode(sal_False);
1370cdf0e10cSrcweir sal_uInt16 nOutlinerMode = OUTLINERMODE_OUTLINEOBJECT;
1371cdf0e10cSrcweir if ( !IsOutlText() )
1372cdf0e10cSrcweir nOutlinerMode = OUTLINERMODE_TEXTOBJECT;
1373cdf0e10cSrcweir rOutl.Init( nOutlinerMode );
1374cdf0e10cSrcweir
1375cdf0e10cSrcweir rOutl.SetGlobalCharStretching(100,100);
1376cdf0e10cSrcweir sal_uIntPtr nStat=rOutl.GetControlWord();
1377cdf0e10cSrcweir nStat&=~(EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE);
1378cdf0e10cSrcweir rOutl.SetControlWord(nStat);
1379cdf0e10cSrcweir Size aNullSize;
1380cdf0e10cSrcweir Size aMaxSize(100000,100000);
1381cdf0e10cSrcweir rOutl.SetMinAutoPaperSize(aNullSize);
1382cdf0e10cSrcweir rOutl.SetMaxAutoPaperSize(aMaxSize);
1383cdf0e10cSrcweir rOutl.SetPaperSize(aMaxSize);
1384cdf0e10cSrcweir rOutl.ClearPolygon();
1385cdf0e10cSrcweir }
1386cdf0e10cSrcweir
ImpGetDrawOutliner() const1387cdf0e10cSrcweir SdrOutliner& SdrTextObj::ImpGetDrawOutliner() const
1388cdf0e10cSrcweir {
1389cdf0e10cSrcweir SdrOutliner& rOutl=pModel->GetDrawOutliner(this);
1390cdf0e10cSrcweir
1391cdf0e10cSrcweir // #101029#: Code extracted to ImpInitDrawOutliner()
1392cdf0e10cSrcweir ImpInitDrawOutliner( rOutl );
1393cdf0e10cSrcweir
1394cdf0e10cSrcweir return rOutl;
1395cdf0e10cSrcweir }
1396cdf0e10cSrcweir
CreateDrawOutliner()1397cdf0e10cSrcweir boost::shared_ptr< SdrOutliner > SdrTextObj::CreateDrawOutliner()
1398cdf0e10cSrcweir {
1399cdf0e10cSrcweir boost::shared_ptr< SdrOutliner > xDrawOutliner( pModel->CreateDrawOutliner(this) );
1400cdf0e10cSrcweir ImpInitDrawOutliner( *(xDrawOutliner.get()) );
1401cdf0e10cSrcweir return xDrawOutliner;
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir
1404cdf0e10cSrcweir // #101029#: Extracted from Paint()
ImpSetupDrawOutlinerForPaint(FASTBOOL bContourFrame,SdrOutliner & rOutliner,Rectangle & rTextRect,Rectangle & rAnchorRect,Rectangle & rPaintRect,Fraction & rFitXKorreg) const1405cdf0e10cSrcweir void SdrTextObj::ImpSetupDrawOutlinerForPaint( FASTBOOL bContourFrame,
1406cdf0e10cSrcweir SdrOutliner& rOutliner,
1407cdf0e10cSrcweir Rectangle& rTextRect,
1408cdf0e10cSrcweir Rectangle& rAnchorRect,
1409cdf0e10cSrcweir Rectangle& rPaintRect,
1410cdf0e10cSrcweir Fraction& rFitXKorreg ) const
1411cdf0e10cSrcweir {
1412cdf0e10cSrcweir if (!bContourFrame)
1413cdf0e10cSrcweir {
1414cdf0e10cSrcweir // FitToSize erstmal nicht mit ContourFrame
141526734c99SArmin Le Grand SdrFitToSizeType eFit=GetFitToSize();
141626734c99SArmin Le Grand if (eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES)
1417cdf0e10cSrcweir {
1418cdf0e10cSrcweir sal_uIntPtr nStat=rOutliner.GetControlWord();
1419cdf0e10cSrcweir nStat|=EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE;
1420cdf0e10cSrcweir rOutliner.SetControlWord(nStat);
1421cdf0e10cSrcweir }
1422cdf0e10cSrcweir }
1423cdf0e10cSrcweir rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
1424cdf0e10cSrcweir TakeTextRect(rOutliner, rTextRect, sal_False, &rAnchorRect);
1425cdf0e10cSrcweir rPaintRect = rTextRect;
1426cdf0e10cSrcweir
1427cdf0e10cSrcweir if (!bContourFrame)
1428cdf0e10cSrcweir {
1429cdf0e10cSrcweir // FitToSize erstmal nicht mit ContourFrame
143026734c99SArmin Le Grand SdrFitToSizeType eFit=GetFitToSize();
143126734c99SArmin Le Grand if (eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES)
1432cdf0e10cSrcweir {
1433cdf0e10cSrcweir ImpSetCharStretching(rOutliner,rTextRect,rAnchorRect,rFitXKorreg);
1434cdf0e10cSrcweir rPaintRect=rAnchorRect;
1435cdf0e10cSrcweir }
1436cdf0e10cSrcweir }
1437cdf0e10cSrcweir }
1438cdf0e10cSrcweir
SetupOutlinerFormatting(SdrOutliner & rOutl,Rectangle & rPaintRect) const1439cdf0e10cSrcweir void SdrTextObj::SetupOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaintRect ) const
1440cdf0e10cSrcweir {
1441cdf0e10cSrcweir ImpInitDrawOutliner( rOutl );
1442cdf0e10cSrcweir UpdateOutlinerFormatting( rOutl, rPaintRect );
1443cdf0e10cSrcweir }
1444cdf0e10cSrcweir
UpdateOutlinerFormatting(SdrOutliner & rOutl,Rectangle & rPaintRect) const1445cdf0e10cSrcweir void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaintRect ) const
1446cdf0e10cSrcweir {
1447cdf0e10cSrcweir Rectangle aTextRect;
1448cdf0e10cSrcweir Rectangle aAnchorRect;
1449cdf0e10cSrcweir Fraction aFitXKorreg(1,1);
1450cdf0e10cSrcweir
1451cdf0e10cSrcweir FASTBOOL bContourFrame=IsContourTextFrame();
1452cdf0e10cSrcweir
1453cdf0e10cSrcweir if( GetModel() )
1454cdf0e10cSrcweir {
1455cdf0e10cSrcweir MapMode aMapMode(GetModel()->GetScaleUnit(), Point(0,0),
1456cdf0e10cSrcweir GetModel()->GetScaleFraction(),
1457cdf0e10cSrcweir GetModel()->GetScaleFraction());
1458cdf0e10cSrcweir rOutl.SetRefMapMode(aMapMode);
1459cdf0e10cSrcweir }
1460cdf0e10cSrcweir
1461cdf0e10cSrcweir ImpSetupDrawOutlinerForPaint( bContourFrame, rOutl, aTextRect, aAnchorRect, rPaintRect, aFitXKorreg );
1462cdf0e10cSrcweir }
1463cdf0e10cSrcweir
1464cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1465cdf0e10cSrcweir
GetOutlinerParaObject() const1466cdf0e10cSrcweir OutlinerParaObject* SdrTextObj::GetOutlinerParaObject() const
1467cdf0e10cSrcweir {
1468cdf0e10cSrcweir SdrText* pText = getActiveText();
1469cdf0e10cSrcweir if( pText )
1470cdf0e10cSrcweir return pText->GetOutlinerParaObject();
1471cdf0e10cSrcweir else
1472cdf0e10cSrcweir return 0;
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir
HasOutlinerParaObject() const1475cdf0e10cSrcweir bool SdrTextObj::HasOutlinerParaObject() const
1476cdf0e10cSrcweir {
1477cdf0e10cSrcweir SdrText* pText = getActiveText();
1478cdf0e10cSrcweir if( pText && pText->GetOutlinerParaObject() )
1479cdf0e10cSrcweir return true;
1480cdf0e10cSrcweir return false;
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir
NbcSetOutlinerParaObject(OutlinerParaObject * pTextObject)1483cdf0e10cSrcweir void SdrTextObj::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject)
1484cdf0e10cSrcweir {
1485cdf0e10cSrcweir NbcSetOutlinerParaObjectForText( pTextObject, getActiveText() );
1486cdf0e10cSrcweir }
1487cdf0e10cSrcweir
NbcSetOutlinerParaObjectForText(OutlinerParaObject * pTextObject,SdrText * pText)1488cdf0e10cSrcweir void SdrTextObj::NbcSetOutlinerParaObjectForText( OutlinerParaObject* pTextObject, SdrText* pText )
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir if( pText )
1491cdf0e10cSrcweir pText->SetOutlinerParaObject( pTextObject );
1492cdf0e10cSrcweir
1493cdf0e10cSrcweir if( pText->GetOutlinerParaObject() )
1494cdf0e10cSrcweir {
1495cdf0e10cSrcweir SvxWritingModeItem aWritingMode(pText->GetOutlinerParaObject()->IsVertical()
1496cdf0e10cSrcweir ? com::sun::star::text::WritingMode_TB_RL
1497cdf0e10cSrcweir : com::sun::star::text::WritingMode_LR_TB,
1498cdf0e10cSrcweir SDRATTR_TEXTDIRECTION);
1499cdf0e10cSrcweir GetProperties().SetObjectItemDirect(aWritingMode);
1500cdf0e10cSrcweir }
1501cdf0e10cSrcweir
1502cdf0e10cSrcweir SetTextSizeDirty();
1503cdf0e10cSrcweir if (IsTextFrame() && (IsAutoGrowHeight() || IsAutoGrowWidth()))
1504cdf0e10cSrcweir { // Textrahmen anpassen!
1505cdf0e10cSrcweir NbcAdjustTextFrameWidthAndHeight();
1506cdf0e10cSrcweir }
1507cdf0e10cSrcweir if (!IsTextFrame())
1508cdf0e10cSrcweir {
1509cdf0e10cSrcweir // Das SnapRect behaelt seine Groesse bei
1510cdf0e10cSrcweir SetRectsDirty(sal_True);
1511cdf0e10cSrcweir }
1512cdf0e10cSrcweir
1513cdf0e10cSrcweir // always invalidate BoundRect on change
1514cdf0e10cSrcweir SetBoundRectDirty();
1515cdf0e10cSrcweir ActionChanged();
1516cdf0e10cSrcweir
1517cdf0e10cSrcweir ImpSetTextStyleSheetListeners();
1518cdf0e10cSrcweir ImpCheckMasterCachable();
1519cdf0e10cSrcweir }
1520cdf0e10cSrcweir
NbcReformatText()1521cdf0e10cSrcweir void SdrTextObj::NbcReformatText()
1522cdf0e10cSrcweir {
1523cdf0e10cSrcweir SdrText* pText = getActiveText();
1524cdf0e10cSrcweir if( pText && pText->GetOutlinerParaObject() )
1525cdf0e10cSrcweir {
1526cdf0e10cSrcweir pText->ReformatText();
1527cdf0e10cSrcweir if (bTextFrame)
1528cdf0e10cSrcweir {
1529cdf0e10cSrcweir NbcAdjustTextFrameWidthAndHeight();
1530cdf0e10cSrcweir }
1531cdf0e10cSrcweir else
1532cdf0e10cSrcweir {
1533cdf0e10cSrcweir // Das SnapRect behaelt seine Groesse bei
1534cdf0e10cSrcweir SetBoundRectDirty();
1535cdf0e10cSrcweir SetRectsDirty(sal_True);
1536cdf0e10cSrcweir }
1537cdf0e10cSrcweir SetTextSizeDirty();
1538cdf0e10cSrcweir ActionChanged();
1539cdf0e10cSrcweir // FME, AW: i22396
1540cdf0e10cSrcweir // Necessary here since we have no compare operator at the outliner
1541cdf0e10cSrcweir // para object which may detect changes regarding the combination
1542cdf0e10cSrcweir // of outliner para data and configuration (e.g., change of
1543cdf0e10cSrcweir // formatting of text numerals)
1544cdf0e10cSrcweir GetViewContact().flushViewObjectContacts(false);
1545cdf0e10cSrcweir }
1546cdf0e10cSrcweir }
1547cdf0e10cSrcweir
ReformatText()1548cdf0e10cSrcweir void SdrTextObj::ReformatText()
1549cdf0e10cSrcweir {
1550cdf0e10cSrcweir if(GetOutlinerParaObject())
1551cdf0e10cSrcweir {
1552cdf0e10cSrcweir Rectangle aBoundRect0;
1553cdf0e10cSrcweir if (pUserCall!=NULL)
1554cdf0e10cSrcweir aBoundRect0=GetLastBoundRect();
1555cdf0e10cSrcweir
1556cdf0e10cSrcweir // #110094#-14 SendRepaintBroadcast();
1557cdf0e10cSrcweir NbcReformatText();
1558cdf0e10cSrcweir SetChanged();
1559cdf0e10cSrcweir BroadcastObjectChange();
1560cdf0e10cSrcweir SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
1561cdf0e10cSrcweir }
1562cdf0e10cSrcweir }
1563cdf0e10cSrcweir
NewGeoData() const1564cdf0e10cSrcweir SdrObjGeoData* SdrTextObj::NewGeoData() const
1565cdf0e10cSrcweir {
1566cdf0e10cSrcweir return new SdrTextObjGeoData;
1567cdf0e10cSrcweir }
1568cdf0e10cSrcweir
SaveGeoData(SdrObjGeoData & rGeo) const1569cdf0e10cSrcweir void SdrTextObj::SaveGeoData(SdrObjGeoData& rGeo) const
1570cdf0e10cSrcweir {
1571cdf0e10cSrcweir SdrAttrObj::SaveGeoData(rGeo);
1572cdf0e10cSrcweir SdrTextObjGeoData& rTGeo=(SdrTextObjGeoData&)rGeo;
1573cdf0e10cSrcweir rTGeo.aRect =aRect;
1574cdf0e10cSrcweir rTGeo.aGeo =aGeo;
1575cdf0e10cSrcweir }
1576cdf0e10cSrcweir
RestGeoData(const SdrObjGeoData & rGeo)1577cdf0e10cSrcweir void SdrTextObj::RestGeoData(const SdrObjGeoData& rGeo)
1578cdf0e10cSrcweir { // RectsDirty wird von SdrObject gerufen
1579cdf0e10cSrcweir SdrAttrObj::RestGeoData(rGeo);
1580cdf0e10cSrcweir SdrTextObjGeoData& rTGeo=(SdrTextObjGeoData&)rGeo;
1581cdf0e10cSrcweir aRect =rTGeo.aRect;
1582cdf0e10cSrcweir aGeo =rTGeo.aGeo;
1583cdf0e10cSrcweir SetTextSizeDirty();
1584cdf0e10cSrcweir }
1585cdf0e10cSrcweir
GetFitToSize() const158626734c99SArmin Le Grand SdrFitToSizeType SdrTextObj::GetFitToSize() const
1587cdf0e10cSrcweir {
158826734c99SArmin Le Grand SdrFitToSizeType eType = SDRTEXTFIT_NONE;
1589cdf0e10cSrcweir
1590cdf0e10cSrcweir if(!IsAutoGrowWidth())
159126734c99SArmin Le Grand eType = ((SdrTextFitToSizeTypeItem&)(GetObjectItem(SDRATTR_TEXT_FITTOSIZE))).GetValue();
1592cdf0e10cSrcweir
159326734c99SArmin Le Grand return eType;
1594cdf0e10cSrcweir }
1595cdf0e10cSrcweir
ForceOutlinerParaObject()1596cdf0e10cSrcweir void SdrTextObj::ForceOutlinerParaObject()
1597cdf0e10cSrcweir {
1598cdf0e10cSrcweir SdrText* pText = getActiveText();
1599cdf0e10cSrcweir if( pText && (pText->GetOutlinerParaObject() == 0) )
1600cdf0e10cSrcweir {
1601cdf0e10cSrcweir sal_uInt16 nOutlMode = OUTLINERMODE_TEXTOBJECT;
1602cdf0e10cSrcweir if( IsTextFrame() && eTextKind == OBJ_OUTLINETEXT )
1603cdf0e10cSrcweir nOutlMode = OUTLINERMODE_OUTLINEOBJECT;
1604cdf0e10cSrcweir
1605cdf0e10cSrcweir pText->ForceOutlinerParaObject( nOutlMode );
1606cdf0e10cSrcweir }
1607cdf0e10cSrcweir }
1608cdf0e10cSrcweir
IsVerticalWriting() const1609cdf0e10cSrcweir sal_Bool SdrTextObj::IsVerticalWriting() const
1610cdf0e10cSrcweir {
1611cdf0e10cSrcweir // #89459#
1612cdf0e10cSrcweir if(pEdtOutl)
1613cdf0e10cSrcweir {
1614cdf0e10cSrcweir return pEdtOutl->IsVertical();
1615cdf0e10cSrcweir }
1616cdf0e10cSrcweir
1617cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
1618cdf0e10cSrcweir if(pOutlinerParaObject)
1619cdf0e10cSrcweir {
1620cdf0e10cSrcweir return pOutlinerParaObject->IsVertical();
1621cdf0e10cSrcweir }
1622cdf0e10cSrcweir
1623cdf0e10cSrcweir return sal_False;
1624cdf0e10cSrcweir }
1625cdf0e10cSrcweir
SetVerticalWriting(sal_Bool bVertical)1626cdf0e10cSrcweir void SdrTextObj::SetVerticalWriting(sal_Bool bVertical)
1627cdf0e10cSrcweir {
1628cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
1629cdf0e10cSrcweir if( !pOutlinerParaObject && bVertical )
1630cdf0e10cSrcweir {
1631cdf0e10cSrcweir // we only need to force a outliner para object if the default of
1632cdf0e10cSrcweir // horizontal text is changed
1633cdf0e10cSrcweir ForceOutlinerParaObject();
1634cdf0e10cSrcweir pOutlinerParaObject = GetOutlinerParaObject();
1635cdf0e10cSrcweir }
1636cdf0e10cSrcweir
1637cdf0e10cSrcweir if( pOutlinerParaObject && (pOutlinerParaObject->IsVertical() != (bool)bVertical) )
1638cdf0e10cSrcweir {
1639cdf0e10cSrcweir // get item settings
1640cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet();
1641cdf0e10cSrcweir sal_Bool bAutoGrowWidth = ((SdrTextAutoGrowWidthItem&)rSet.Get(SDRATTR_TEXT_AUTOGROWWIDTH)).GetValue();
1642cdf0e10cSrcweir sal_Bool bAutoGrowHeight = ((SdrTextAutoGrowHeightItem&)rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue();
1643cdf0e10cSrcweir
1644cdf0e10cSrcweir // #103516# Also exchange hor/ver adjust items
1645cdf0e10cSrcweir SdrTextHorzAdjust eHorz = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
1646cdf0e10cSrcweir SdrTextVertAdjust eVert = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
1647cdf0e10cSrcweir
1648cdf0e10cSrcweir // rescue object size
1649cdf0e10cSrcweir Rectangle aObjectRect = GetSnapRect();
1650cdf0e10cSrcweir
1651cdf0e10cSrcweir // prepare ItemSet to set exchanged width and height items
1652cdf0e10cSrcweir SfxItemSet aNewSet(*rSet.GetPool(),
1653cdf0e10cSrcweir SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT,
1654cdf0e10cSrcweir // #103516# Expanded item ranges to also support hor and ver adjust.
1655cdf0e10cSrcweir SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST,
1656cdf0e10cSrcweir SDRATTR_TEXT_AUTOGROWWIDTH, SDRATTR_TEXT_HORZADJUST,
1657cdf0e10cSrcweir 0, 0);
1658cdf0e10cSrcweir
1659cdf0e10cSrcweir aNewSet.Put(rSet);
1660cdf0e10cSrcweir aNewSet.Put(SdrTextAutoGrowWidthItem(bAutoGrowHeight));
1661cdf0e10cSrcweir aNewSet.Put(SdrTextAutoGrowHeightItem(bAutoGrowWidth));
1662cdf0e10cSrcweir
1663cdf0e10cSrcweir // #103516# Exchange horz and vert adjusts
1664cdf0e10cSrcweir switch(eVert)
1665cdf0e10cSrcweir {
1666cdf0e10cSrcweir case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break;
1667cdf0e10cSrcweir case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break;
1668cdf0e10cSrcweir case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break;
1669cdf0e10cSrcweir case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break;
1670cdf0e10cSrcweir }
1671cdf0e10cSrcweir switch(eHorz)
1672cdf0e10cSrcweir {
1673cdf0e10cSrcweir case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break;
1674cdf0e10cSrcweir case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break;
1675cdf0e10cSrcweir case SDRTEXTHORZADJUST_RIGHT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); break;
1676cdf0e10cSrcweir case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break;
1677cdf0e10cSrcweir }
1678cdf0e10cSrcweir
1679cdf0e10cSrcweir SetObjectItemSet(aNewSet);
1680cdf0e10cSrcweir
1681cdf0e10cSrcweir pOutlinerParaObject = GetOutlinerParaObject();
1682cdf0e10cSrcweir if( pOutlinerParaObject )
1683cdf0e10cSrcweir {
1684cdf0e10cSrcweir // set ParaObject orientation accordingly
1685cdf0e10cSrcweir pOutlinerParaObject->SetVertical(bVertical);
1686cdf0e10cSrcweir }
1687cdf0e10cSrcweir
1688cdf0e10cSrcweir // restore object size
1689cdf0e10cSrcweir SetSnapRect(aObjectRect);
1690cdf0e10cSrcweir }
1691cdf0e10cSrcweir }
1692cdf0e10cSrcweir
1693cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1694cdf0e10cSrcweir //
1695cdf0e10cSrcweir // transformation interface for StarOfficeAPI. This implements support for
1696cdf0e10cSrcweir // homogen 3x3 matrices containing the transformation of the SdrObject. At the
1697cdf0e10cSrcweir // moment it contains a shearX, rotation and translation, but for setting all linear
1698cdf0e10cSrcweir // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
1699cdf0e10cSrcweir //
1700cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1701cdf0e10cSrcweir // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
1702cdf0e10cSrcweir // with the base geometry and returns TRUE. Otherwise it returns FALSE.
TRGetBaseGeometry(basegfx::B2DHomMatrix & rMatrix,basegfx::B2DPolyPolygon &) const1703cdf0e10cSrcweir sal_Bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
1704cdf0e10cSrcweir {
1705cdf0e10cSrcweir // get turn and shear
1706cdf0e10cSrcweir double fRotate = (aGeo.nDrehWink / 100.0) * F_PI180;
1707cdf0e10cSrcweir double fShearX = (aGeo.nShearWink / 100.0) * F_PI180;
1708cdf0e10cSrcweir
1709cdf0e10cSrcweir // get aRect, this is the unrotated snaprect
1710cdf0e10cSrcweir Rectangle aRectangle(aRect);
1711cdf0e10cSrcweir
1712cdf0e10cSrcweir // fill other values
1713cdf0e10cSrcweir basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
1714cdf0e10cSrcweir basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
1715cdf0e10cSrcweir
1716cdf0e10cSrcweir // position maybe relative to anchorpos, convert
1717cdf0e10cSrcweir if( pModel && pModel->IsWriter() )
1718cdf0e10cSrcweir {
1719cdf0e10cSrcweir if(GetAnchorPos().X() || GetAnchorPos().Y())
1720cdf0e10cSrcweir {
1721cdf0e10cSrcweir aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
1722cdf0e10cSrcweir }
1723cdf0e10cSrcweir }
1724cdf0e10cSrcweir
1725cdf0e10cSrcweir // force MapUnit to 100th mm
17267ed960daSArmin Le Grand const SfxMapUnit eMapUnit(GetObjectMapUnit());
1727cdf0e10cSrcweir if(eMapUnit != SFX_MAPUNIT_100TH_MM)
1728cdf0e10cSrcweir {
1729cdf0e10cSrcweir switch(eMapUnit)
1730cdf0e10cSrcweir {
1731cdf0e10cSrcweir case SFX_MAPUNIT_TWIP :
1732cdf0e10cSrcweir {
1733cdf0e10cSrcweir // postion
1734cdf0e10cSrcweir aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
1735cdf0e10cSrcweir aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
1736cdf0e10cSrcweir
1737cdf0e10cSrcweir // size
1738cdf0e10cSrcweir aScale.setX(ImplTwipsToMM(aScale.getX()));
1739cdf0e10cSrcweir aScale.setY(ImplTwipsToMM(aScale.getY()));
1740cdf0e10cSrcweir
1741cdf0e10cSrcweir break;
1742cdf0e10cSrcweir }
1743cdf0e10cSrcweir default:
1744cdf0e10cSrcweir {
1745cdf0e10cSrcweir DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
1746cdf0e10cSrcweir }
1747cdf0e10cSrcweir }
1748cdf0e10cSrcweir }
1749cdf0e10cSrcweir
1750cdf0e10cSrcweir // build matrix
1751cdf0e10cSrcweir rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
1752cdf0e10cSrcweir aScale,
1753cdf0e10cSrcweir basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX),
1754cdf0e10cSrcweir basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate,
1755cdf0e10cSrcweir aTranslate);
1756cdf0e10cSrcweir
1757cdf0e10cSrcweir return sal_False;
1758cdf0e10cSrcweir }
1759cdf0e10cSrcweir
1760cdf0e10cSrcweir // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
1761cdf0e10cSrcweir // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
1762cdf0e10cSrcweir // to use (0,0) as upper left and will be scaled to the given size in the matrix.
TRSetBaseGeometry(const basegfx::B2DHomMatrix & rMatrix,const basegfx::B2DPolyPolygon &)1763cdf0e10cSrcweir void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
1764cdf0e10cSrcweir {
1765cdf0e10cSrcweir // break up matrix
1766cdf0e10cSrcweir basegfx::B2DTuple aScale;
1767cdf0e10cSrcweir basegfx::B2DTuple aTranslate;
1768cdf0e10cSrcweir double fRotate(0.0);
1769cdf0e10cSrcweir double fShearX(0.0);
1770cdf0e10cSrcweir rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
1771cdf0e10cSrcweir
1772cdf0e10cSrcweir // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
1773cdf0e10cSrcweir // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
1774cdf0e10cSrcweir if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
1775cdf0e10cSrcweir {
1776cdf0e10cSrcweir aScale.setX(fabs(aScale.getX()));
1777cdf0e10cSrcweir aScale.setY(fabs(aScale.getY()));
1778cdf0e10cSrcweir fRotate = fmod(fRotate + F_PI, F_2PI);
1779cdf0e10cSrcweir }
1780cdf0e10cSrcweir
1781cdf0e10cSrcweir // reset object shear and rotations
1782cdf0e10cSrcweir aGeo.nDrehWink = 0;
1783cdf0e10cSrcweir aGeo.RecalcSinCos();
1784cdf0e10cSrcweir aGeo.nShearWink = 0;
1785cdf0e10cSrcweir aGeo.RecalcTan();
1786cdf0e10cSrcweir
1787cdf0e10cSrcweir // force metric to pool metric
17887ed960daSArmin Le Grand const SfxMapUnit eMapUnit(GetObjectMapUnit());
1789cdf0e10cSrcweir if(eMapUnit != SFX_MAPUNIT_100TH_MM)
1790cdf0e10cSrcweir {
1791cdf0e10cSrcweir switch(eMapUnit)
1792cdf0e10cSrcweir {
1793cdf0e10cSrcweir case SFX_MAPUNIT_TWIP :
1794cdf0e10cSrcweir {
1795cdf0e10cSrcweir // position
1796cdf0e10cSrcweir aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
1797cdf0e10cSrcweir aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
1798cdf0e10cSrcweir
1799cdf0e10cSrcweir // size
1800cdf0e10cSrcweir aScale.setX(ImplMMToTwips(aScale.getX()));
1801cdf0e10cSrcweir aScale.setY(ImplMMToTwips(aScale.getY()));
1802cdf0e10cSrcweir
1803cdf0e10cSrcweir break;
1804cdf0e10cSrcweir }
1805cdf0e10cSrcweir default:
1806cdf0e10cSrcweir {
1807cdf0e10cSrcweir DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
1808cdf0e10cSrcweir }
1809cdf0e10cSrcweir }
1810cdf0e10cSrcweir }
1811cdf0e10cSrcweir
1812cdf0e10cSrcweir // if anchor is used, make position relative to it
1813cdf0e10cSrcweir if( pModel && pModel->IsWriter() )
1814cdf0e10cSrcweir {
1815cdf0e10cSrcweir if(GetAnchorPos().X() || GetAnchorPos().Y())
1816cdf0e10cSrcweir {
1817cdf0e10cSrcweir aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
1818cdf0e10cSrcweir }
1819cdf0e10cSrcweir }
1820cdf0e10cSrcweir
1821cdf0e10cSrcweir // build and set BaseRect (use scale)
1822cdf0e10cSrcweir Point aPoint = Point();
1823cdf0e10cSrcweir Size aSize(FRound(aScale.getX()), FRound(aScale.getY()));
1824cdf0e10cSrcweir Rectangle aBaseRect(aPoint, aSize);
1825cdf0e10cSrcweir SetSnapRect(aBaseRect);
1826cdf0e10cSrcweir
1827cdf0e10cSrcweir // shear?
1828cdf0e10cSrcweir if(!basegfx::fTools::equalZero(fShearX))
1829cdf0e10cSrcweir {
1830cdf0e10cSrcweir GeoStat aGeoStat;
1831cdf0e10cSrcweir aGeoStat.nShearWink = FRound((atan(fShearX) / F_PI180) * 100.0);
1832cdf0e10cSrcweir aGeoStat.RecalcTan();
1833cdf0e10cSrcweir Shear(Point(), aGeoStat.nShearWink, aGeoStat.nTan, sal_False);
1834cdf0e10cSrcweir }
1835cdf0e10cSrcweir
1836cdf0e10cSrcweir // rotation?
1837cdf0e10cSrcweir if(!basegfx::fTools::equalZero(fRotate))
1838cdf0e10cSrcweir {
1839cdf0e10cSrcweir GeoStat aGeoStat;
1840cdf0e10cSrcweir
1841cdf0e10cSrcweir // #i78696#
1842cdf0e10cSrcweir // fRotate is matematically correct, but aGeoStat.nDrehWink is
1843cdf0e10cSrcweir // mirrored -> mirror value here
1844cdf0e10cSrcweir aGeoStat.nDrehWink = NormAngle360(FRound(-fRotate / F_PI18000));
1845cdf0e10cSrcweir aGeoStat.RecalcSinCos();
1846cdf0e10cSrcweir Rotate(Point(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos);
1847cdf0e10cSrcweir }
1848cdf0e10cSrcweir
1849cdf0e10cSrcweir // translate?
1850cdf0e10cSrcweir if(!aTranslate.equalZero())
1851cdf0e10cSrcweir {
1852cdf0e10cSrcweir Move(Size(FRound(aTranslate.getX()), FRound(aTranslate.getY())));
1853cdf0e10cSrcweir }
1854cdf0e10cSrcweir }
1855cdf0e10cSrcweir
IsRealyEdited() const1856cdf0e10cSrcweir bool SdrTextObj::IsRealyEdited() const
1857cdf0e10cSrcweir {
1858cdf0e10cSrcweir return pEdtOutl && pEdtOutl->IsModified();
1859cdf0e10cSrcweir }
1860cdf0e10cSrcweir
1861cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////////////////////////
1862cdf0e10cSrcweir // moved inlines here form hxx
1863cdf0e10cSrcweir
GetEckenradius() const1864cdf0e10cSrcweir long SdrTextObj::GetEckenradius() const
1865cdf0e10cSrcweir {
1866cdf0e10cSrcweir return ((SdrEckenradiusItem&)(GetObjectItemSet().Get(SDRATTR_ECKENRADIUS))).GetValue();
1867cdf0e10cSrcweir }
1868cdf0e10cSrcweir
GetMinTextFrameHeight() const1869cdf0e10cSrcweir long SdrTextObj::GetMinTextFrameHeight() const
1870cdf0e10cSrcweir {
1871cdf0e10cSrcweir return ((SdrTextMinFrameHeightItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MINFRAMEHEIGHT))).GetValue();
1872cdf0e10cSrcweir }
1873cdf0e10cSrcweir
GetMaxTextFrameHeight() const1874cdf0e10cSrcweir long SdrTextObj::GetMaxTextFrameHeight() const
1875cdf0e10cSrcweir {
1876cdf0e10cSrcweir return ((SdrTextMaxFrameHeightItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MAXFRAMEHEIGHT))).GetValue();
1877cdf0e10cSrcweir }
1878cdf0e10cSrcweir
GetMinTextFrameWidth() const1879cdf0e10cSrcweir long SdrTextObj::GetMinTextFrameWidth() const
1880cdf0e10cSrcweir {
1881cdf0e10cSrcweir return ((SdrTextMinFrameWidthItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MINFRAMEWIDTH))).GetValue();
1882cdf0e10cSrcweir }
1883cdf0e10cSrcweir
GetMaxTextFrameWidth() const1884cdf0e10cSrcweir long SdrTextObj::GetMaxTextFrameWidth() const
1885cdf0e10cSrcweir {
1886cdf0e10cSrcweir return ((SdrTextMaxFrameWidthItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MAXFRAMEWIDTH))).GetValue();
1887cdf0e10cSrcweir }
1888cdf0e10cSrcweir
IsFontwork() const1889cdf0e10cSrcweir FASTBOOL SdrTextObj::IsFontwork() const
1890cdf0e10cSrcweir {
1891cdf0e10cSrcweir return (bTextFrame) ? sal_False // Default ist FALSE
1892cdf0e10cSrcweir : ((XFormTextStyleItem&)(GetObjectItemSet().Get(XATTR_FORMTXTSTYLE))).GetValue()!=XFT_NONE;
1893cdf0e10cSrcweir }
1894cdf0e10cSrcweir
IsHideContour() const1895cdf0e10cSrcweir FASTBOOL SdrTextObj::IsHideContour() const
1896cdf0e10cSrcweir {
1897cdf0e10cSrcweir return (bTextFrame) ? sal_False // Default ist: Nein, kein HideContour; HideContour nicht bei TextFrames
1898cdf0e10cSrcweir : ((XFormTextHideFormItem&)(GetObjectItemSet().Get(XATTR_FORMTXTHIDEFORM))).GetValue();
1899cdf0e10cSrcweir }
1900cdf0e10cSrcweir
IsContourTextFrame() const1901cdf0e10cSrcweir FASTBOOL SdrTextObj::IsContourTextFrame() const
1902cdf0e10cSrcweir {
1903cdf0e10cSrcweir return (bTextFrame) ? sal_False // ContourFrame nicht bei normalen TextFrames
1904cdf0e10cSrcweir : ((SdrTextContourFrameItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_CONTOURFRAME))).GetValue();
1905cdf0e10cSrcweir }
1906cdf0e10cSrcweir
GetTextLeftDistance() const1907cdf0e10cSrcweir long SdrTextObj::GetTextLeftDistance() const
1908cdf0e10cSrcweir {
1909cdf0e10cSrcweir return ((SdrTextLeftDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_LEFTDIST))).GetValue();
1910cdf0e10cSrcweir }
1911cdf0e10cSrcweir
GetTextRightDistance() const1912cdf0e10cSrcweir long SdrTextObj::GetTextRightDistance() const
1913cdf0e10cSrcweir {
1914cdf0e10cSrcweir return ((SdrTextRightDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_RIGHTDIST))).GetValue();
1915cdf0e10cSrcweir }
1916cdf0e10cSrcweir
GetTextUpperDistance() const1917cdf0e10cSrcweir long SdrTextObj::GetTextUpperDistance() const
1918cdf0e10cSrcweir {
1919cdf0e10cSrcweir return ((SdrTextUpperDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_UPPERDIST))).GetValue();
1920cdf0e10cSrcweir }
1921cdf0e10cSrcweir
GetTextLowerDistance() const1922cdf0e10cSrcweir long SdrTextObj::GetTextLowerDistance() const
1923cdf0e10cSrcweir {
1924cdf0e10cSrcweir return ((SdrTextLowerDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_LOWERDIST))).GetValue();
1925cdf0e10cSrcweir }
1926cdf0e10cSrcweir
GetTextAniKind() const1927cdf0e10cSrcweir SdrTextAniKind SdrTextObj::GetTextAniKind() const
1928cdf0e10cSrcweir {
1929cdf0e10cSrcweir return ((SdrTextAniKindItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_ANIKIND))).GetValue();
1930cdf0e10cSrcweir }
1931cdf0e10cSrcweir
GetTextAniDirection() const1932cdf0e10cSrcweir SdrTextAniDirection SdrTextObj::GetTextAniDirection() const
1933cdf0e10cSrcweir {
1934cdf0e10cSrcweir return ((SdrTextAniDirectionItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
1935cdf0e10cSrcweir }
1936cdf0e10cSrcweir
1937cdf0e10cSrcweir // #111096#
1938cdf0e10cSrcweir // Access to thext hidden flag
GetTextHidden() const1939cdf0e10cSrcweir sal_Bool SdrTextObj::GetTextHidden() const
1940cdf0e10cSrcweir {
1941cdf0e10cSrcweir return mbTextHidden;
1942cdf0e10cSrcweir }
1943cdf0e10cSrcweir
NbcSetTextHidden(sal_Bool bNew)1944cdf0e10cSrcweir void SdrTextObj::NbcSetTextHidden(sal_Bool bNew)
1945cdf0e10cSrcweir {
1946cdf0e10cSrcweir if(bNew != mbTextHidden)
1947cdf0e10cSrcweir {
1948cdf0e10cSrcweir mbTextHidden = bNew;
1949cdf0e10cSrcweir }
1950cdf0e10cSrcweir }
1951cdf0e10cSrcweir
1952cdf0e10cSrcweir // #111096#
1953cdf0e10cSrcweir // Get necessary data for text scroll animation. ATM base it on a Text-Metafile and a
1954cdf0e10cSrcweir // painting rectangle. Rotation is excluded from the returned values.
GetTextScrollMetaFileAndRectangle(Rectangle & rScrollRectangle,Rectangle & rPaintRectangle)1955cdf0e10cSrcweir GDIMetaFile* SdrTextObj::GetTextScrollMetaFileAndRectangle(
1956cdf0e10cSrcweir Rectangle& rScrollRectangle, Rectangle& rPaintRectangle)
1957cdf0e10cSrcweir {
1958cdf0e10cSrcweir GDIMetaFile* pRetval = 0L;
1959cdf0e10cSrcweir SdrOutliner& rOutliner = ImpGetDrawOutliner();
1960cdf0e10cSrcweir Rectangle aTextRect;
1961cdf0e10cSrcweir Rectangle aAnchorRect;
1962cdf0e10cSrcweir Rectangle aPaintRect;
1963cdf0e10cSrcweir Fraction aFitXKorreg(1,1);
1964cdf0e10cSrcweir bool bContourFrame(IsContourTextFrame());
1965cdf0e10cSrcweir
1966cdf0e10cSrcweir // get outliner set up. To avoid getting a somehow rotated MetaFile,
1967cdf0e10cSrcweir // temporarily disable object rotation.
1968cdf0e10cSrcweir sal_Int32 nAngle(aGeo.nDrehWink);
1969cdf0e10cSrcweir aGeo.nDrehWink = 0L;
1970cdf0e10cSrcweir ImpSetupDrawOutlinerForPaint( bContourFrame, rOutliner, aTextRect, aAnchorRect, aPaintRect, aFitXKorreg );
1971cdf0e10cSrcweir aGeo.nDrehWink = nAngle;
1972cdf0e10cSrcweir
1973cdf0e10cSrcweir Rectangle aScrollFrameRect(aPaintRect);
1974cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet();
1975cdf0e10cSrcweir SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
1976cdf0e10cSrcweir
1977cdf0e10cSrcweir if(SDRTEXTANI_LEFT == eDirection || SDRTEXTANI_RIGHT == eDirection)
1978cdf0e10cSrcweir {
1979cdf0e10cSrcweir aScrollFrameRect.Left() = aAnchorRect.Left();
1980cdf0e10cSrcweir aScrollFrameRect.Right() = aAnchorRect.Right();
1981cdf0e10cSrcweir }
1982cdf0e10cSrcweir
1983cdf0e10cSrcweir if(SDRTEXTANI_UP == eDirection || SDRTEXTANI_DOWN == eDirection)
1984cdf0e10cSrcweir {
1985cdf0e10cSrcweir aScrollFrameRect.Top() = aAnchorRect.Top();
1986cdf0e10cSrcweir aScrollFrameRect.Bottom() = aAnchorRect.Bottom();
1987cdf0e10cSrcweir }
1988cdf0e10cSrcweir
1989cdf0e10cSrcweir // create the MetaFile
1990cdf0e10cSrcweir pRetval = new GDIMetaFile;
1991cdf0e10cSrcweir VirtualDevice aBlackHole;
1992cdf0e10cSrcweir aBlackHole.EnableOutput(sal_False);
1993cdf0e10cSrcweir pRetval->Record(&aBlackHole);
1994cdf0e10cSrcweir Point aPaintPos = aPaintRect.TopLeft();
1995cdf0e10cSrcweir
1996cdf0e10cSrcweir rOutliner.Draw(&aBlackHole, aPaintPos);
1997cdf0e10cSrcweir
1998cdf0e10cSrcweir pRetval->Stop();
1999cdf0e10cSrcweir pRetval->WindStart();
2000cdf0e10cSrcweir
2001cdf0e10cSrcweir // return PaintRectanglePixel and pRetval;
2002cdf0e10cSrcweir rScrollRectangle = aScrollFrameRect;
2003cdf0e10cSrcweir rPaintRectangle = aPaintRect;
2004cdf0e10cSrcweir
2005cdf0e10cSrcweir return pRetval;
2006cdf0e10cSrcweir }
2007cdf0e10cSrcweir
2008cdf0e10cSrcweir // #111096#
2009cdf0e10cSrcweir // Access to TextAnimationAllowed flag
IsTextAnimationAllowed() const2010cdf0e10cSrcweir bool SdrTextObj::IsTextAnimationAllowed() const
2011cdf0e10cSrcweir {
2012cdf0e10cSrcweir return mbTextAnimationAllowed;
2013cdf0e10cSrcweir }
2014cdf0e10cSrcweir
SetTextAnimationAllowed(sal_Bool bNew)2015cdf0e10cSrcweir void SdrTextObj::SetTextAnimationAllowed(sal_Bool bNew)
2016cdf0e10cSrcweir {
2017cdf0e10cSrcweir if(mbTextAnimationAllowed != bNew)
2018cdf0e10cSrcweir {
2019cdf0e10cSrcweir mbTextAnimationAllowed = bNew;
2020cdf0e10cSrcweir ActionChanged();
2021cdf0e10cSrcweir }
2022cdf0e10cSrcweir }
2023cdf0e10cSrcweir
2024cdf0e10cSrcweir /** called from the SdrObjEditView during text edit when the status of the edit outliner changes */
onEditOutlinerStatusEvent(EditStatus * pEditStatus)2025cdf0e10cSrcweir void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
2026cdf0e10cSrcweir {
2027cdf0e10cSrcweir const sal_uInt32 nStat = pEditStatus->GetStatusWord();
2028cdf0e10cSrcweir const bool bGrowX=(nStat & EE_STAT_TEXTWIDTHCHANGED) !=0;
2029cdf0e10cSrcweir const bool bGrowY=(nStat & EE_STAT_TEXTHEIGHTCHANGED) !=0;
2030cdf0e10cSrcweir if(bTextFrame && (bGrowX || bGrowY))
2031cdf0e10cSrcweir {
2032cdf0e10cSrcweir const bool bAutoGrowHgt= bTextFrame && IsAutoGrowHeight();
2033cdf0e10cSrcweir const bool bAutoGrowWdt= bTextFrame && IsAutoGrowWidth();
2034cdf0e10cSrcweir
2035cdf0e10cSrcweir if ((bGrowX && bAutoGrowWdt) || (bGrowY && bAutoGrowHgt))
2036cdf0e10cSrcweir {
2037cdf0e10cSrcweir AdjustTextFrameWidthAndHeight();
2038cdf0e10cSrcweir }
2039cdf0e10cSrcweir }
2040cdf0e10cSrcweir }
2041cdf0e10cSrcweir
2042cdf0e10cSrcweir /** returns the currently active text. */
getActiveText() const2043cdf0e10cSrcweir SdrText* SdrTextObj::getActiveText() const
2044cdf0e10cSrcweir {
2045cdf0e10cSrcweir if( !mpText )
2046cdf0e10cSrcweir return getText( 0 );
2047cdf0e10cSrcweir else
2048cdf0e10cSrcweir return mpText;
2049cdf0e10cSrcweir }
2050cdf0e10cSrcweir
2051cdf0e10cSrcweir /** returns the nth available text. */
getText(sal_Int32 nIndex) const2052cdf0e10cSrcweir SdrText* SdrTextObj::getText( sal_Int32 nIndex ) const
2053cdf0e10cSrcweir {
2054cdf0e10cSrcweir if( nIndex == 0 )
2055cdf0e10cSrcweir {
2056cdf0e10cSrcweir if( mpText == 0 )
2057cdf0e10cSrcweir const_cast< SdrTextObj* >(this)->mpText = new SdrText( *(const_cast< SdrTextObj* >(this)) );
2058cdf0e10cSrcweir return mpText;
2059cdf0e10cSrcweir }
2060cdf0e10cSrcweir else
2061cdf0e10cSrcweir {
2062cdf0e10cSrcweir return 0;
2063cdf0e10cSrcweir }
2064cdf0e10cSrcweir }
2065cdf0e10cSrcweir
2066cdf0e10cSrcweir /** returns the number of texts available for this object. */
getTextCount() const2067cdf0e10cSrcweir sal_Int32 SdrTextObj::getTextCount() const
2068cdf0e10cSrcweir {
2069cdf0e10cSrcweir return 1;
2070cdf0e10cSrcweir }
2071cdf0e10cSrcweir
2072cdf0e10cSrcweir /** changes the current active text */
setActiveText(sal_Int32)2073cdf0e10cSrcweir void SdrTextObj::setActiveText( sal_Int32 /*nIndex*/ )
2074cdf0e10cSrcweir {
2075cdf0e10cSrcweir }
2076cdf0e10cSrcweir
2077cdf0e10cSrcweir /** returns the index of the text that contains the given point or -1 */
CheckTextHit(const Point &) const2078cdf0e10cSrcweir sal_Int32 SdrTextObj::CheckTextHit(const Point& /*rPnt*/) const
2079cdf0e10cSrcweir {
2080cdf0e10cSrcweir return 0;
2081cdf0e10cSrcweir }
2082cdf0e10cSrcweir
SetObjectItemNoBroadcast(const SfxPoolItem & rItem)2083cdf0e10cSrcweir void SdrTextObj::SetObjectItemNoBroadcast(const SfxPoolItem& rItem)
2084cdf0e10cSrcweir {
2085cdf0e10cSrcweir static_cast< sdr::properties::TextProperties& >(GetProperties()).SetObjectItemNoBroadcast(rItem);
2086cdf0e10cSrcweir }
2087cdf0e10cSrcweir
2088cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////////////////////////
2089cdf0e10cSrcweir //
2090cdf0e10cSrcweir // Konzept des TextObjekts:
2091cdf0e10cSrcweir // ~~~~~~~~~~~~~~~~~~~~~~~~
2092cdf0e10cSrcweir // Attribute/Varianten:
2093cdf0e10cSrcweir // - sal_Bool Textrahmen / beschriftetes Zeichenobjekt
2094cdf0e10cSrcweir // - sal_Bool FontWork (wenn nicht Textrahmen und nicht ContourTextFrame)
2095cdf0e10cSrcweir // - sal_Bool ContourTextFrame (wenn nicht Textrahmen und nicht Fontwork)
2096cdf0e10cSrcweir // - long Drehwinkel (wenn nicht FontWork)
2097cdf0e10cSrcweir // - long Textrahmenabstaende (wenn nicht FontWork)
2098cdf0e10cSrcweir // - sal_Bool FitToSize (wenn nicht FontWork)
2099cdf0e10cSrcweir // - sal_Bool AutoGrowingWidth/Height (wenn nicht FitToSize und nicht FontWork)
2100cdf0e10cSrcweir // - long Min/MaxFrameWidth/Height (wenn AutoGrowingWidth/Height)
2101cdf0e10cSrcweir // - enum Horizontale Textverankerung Links,Mitte,Rechts,Block,Stretch(ni)
2102cdf0e10cSrcweir // - enum Vertikale Textverankerung Oben,Mitte,Unten,Block,Stretch(ni)
2103cdf0e10cSrcweir // - enum Laufschrift (wenn nicht FontWork)
2104cdf0e10cSrcweir //
2105cdf0e10cSrcweir // Jedes abgeleitete Objekt ist entweder ein Textrahmen (bTextFrame=sal_True)
2106cdf0e10cSrcweir // oder ein beschriftetes Zeichenobjekt (bTextFrame=sal_False).
2107cdf0e10cSrcweir //
2108cdf0e10cSrcweir // Defaultverankerung von Textrahmen:
2109cdf0e10cSrcweir // SDRTEXTHORZADJUST_BLOCK, SDRTEXTVERTADJUST_TOP
2110cdf0e10cSrcweir // = statische Pooldefaults
2111cdf0e10cSrcweir // Defaultverankerung von beschrifteten Zeichenobjekten:
2112cdf0e10cSrcweir // SDRTEXTHORZADJUST_CENTER, SDRTEXTVERTADJUST_CENTER
2113cdf0e10cSrcweir // durch harte Attributierung von SdrAttrObj
2114cdf0e10cSrcweir //
2115cdf0e10cSrcweir // Jedes vom SdrTextObj abgeleitete Objekt muss ein "UnrotatedSnapRect"
2116cdf0e10cSrcweir // (->TakeUnrotatedSnapRect()) liefern (Drehreferenz ist TopLeft dieses
2117cdf0e10cSrcweir // Rechtecks (aGeo.nDrehWink)), welches die Grundlage der Textverankerung
2118cdf0e10cSrcweir // bildet. Von diesem werden dann ringsum die Textrahmenabstaende abgezogen;
2119cdf0e10cSrcweir // das Ergebnis ist der Ankerbereich (->TakeTextAnchorRect()). Innerhalb
2120cdf0e10cSrcweir // dieses Bereichs wird dann in Abhaengigkeit von der horizontalen und
2121cdf0e10cSrcweir // vertikalen Ausrichtung (SdrTextVertAdjust,SdrTextHorzAdjust) der Ankerpunkt
2122cdf0e10cSrcweir // sowie der Ausgabebereich bestimmt. Bei beschrifteten Grafikobjekten kann
2123cdf0e10cSrcweir // der Ausgabebereich durchaus groesser als der Ankerbereich werden, bei
2124cdf0e10cSrcweir // Textrahmen ist er stets kleiner oder gleich (ausser bei negativen Textrahmen-
2125cdf0e10cSrcweir // abstaenden).
2126cdf0e10cSrcweir //
2127cdf0e10cSrcweir // FitToSize hat Prioritaet vor Textverankerung und AutoGrowHeight/Width. Der
2128cdf0e10cSrcweir // Ausgabebereich ist bei FitToSize immer genau der Ankerbereich. Weiterhin
2129cdf0e10cSrcweir // gibt es bei FitToSize keinen automatischen Zeilenumbruch.
2130cdf0e10cSrcweir //
2131cdf0e10cSrcweir // ContourTextFrame:
2132cdf0e10cSrcweir // - long Drehwinkel
2133cdf0e10cSrcweir // - long Textrahmenabstaende spaeter vielleicht
2134cdf0e10cSrcweir // - sal_Bool FitToSize spaeter vielleicht
2135cdf0e10cSrcweir // - sal_Bool AutoGrowingWidth/Height viel spaeter vielleicht
2136cdf0e10cSrcweir // - long Min/MaxFrameWidth/Height viel spaeter vielleicht
2137cdf0e10cSrcweir // - enum Horizontale Textverankerung spaeter vielleicht, erstmal Links, Absatz zentr.
2138cdf0e10cSrcweir // - enum Vertikale Textverankerung spaeter vielleicht, erstmal oben
2139cdf0e10cSrcweir // - enum Laufschrift spaeter vielleicht (evtl. sogar mit korrektem Clipping)
2140cdf0e10cSrcweir //
2141cdf0e10cSrcweir // Bei Aenderungen zu beachten:
2142cdf0e10cSrcweir // - Paint
2143cdf0e10cSrcweir // - HitTest
2144cdf0e10cSrcweir // - ConvertToPoly
2145cdf0e10cSrcweir // - Edit
2146cdf0e10cSrcweir // - Drucken,Speichern, Paint in Nachbarview waerend Edit
2147cdf0e10cSrcweir // - ModelChanged (z.B. durch NachbarView oder Lineale) waerend Edit
2148cdf0e10cSrcweir // - FillColorChanged waerend Edit
2149cdf0e10cSrcweir // - uvm...
2150cdf0e10cSrcweir //
2151cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////////////////////////
2152cdf0e10cSrcweir
2153