xref: /aoo41x/main/svx/source/svdraw/svdotxtr.cxx (revision 215d8f42)
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/svdtrans.hxx>
30cdf0e10cSrcweir #include <svx/svdogrp.hxx>
31cdf0e10cSrcweir #include <svx/svdopath.hxx>
32cdf0e10cSrcweir #include <svx/svdoutl.hxx>
33cdf0e10cSrcweir #include <svx/svdpage.hxx>   // fuer Convert
34cdf0e10cSrcweir #include <svx/svdmodel.hxx>  // fuer Convert
35cdf0e10cSrcweir #include <editeng/outliner.hxx>
36cdf0e10cSrcweir #include <svx/sdr/properties/itemsettools.hxx>
37cdf0e10cSrcweir #include <svx/sdr/properties/properties.hxx>
38cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
39cdf0e10cSrcweir #include <svl/itemset.hxx>
40cdf0e10cSrcweir #include <svx/svditer.hxx>
41cdf0e10cSrcweir #include <drawinglayer/processor2d/textaspolygonextractor2d.hxx>
42cdf0e10cSrcweir #include <svx/sdr/contact/viewcontact.hxx>
43cdf0e10cSrcweir #include <svx/xflclit.hxx>
44cdf0e10cSrcweir #include <svx/xlnclit.hxx>
45cdf0e10cSrcweir #include <svx/xlnwtit.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
48cdf0e10cSrcweir //
49cdf0e10cSrcweir //  @@@@@@ @@@@@ @@   @@ @@@@@@  @@@@  @@@@@  @@@@@@
50cdf0e10cSrcweir //    @@   @@    @@@ @@@   @@   @@  @@ @@  @@     @@
51cdf0e10cSrcweir //    @@   @@     @@@@@    @@   @@  @@ @@  @@     @@
52cdf0e10cSrcweir //    @@   @@@@    @@@     @@   @@  @@ @@@@@      @@
53cdf0e10cSrcweir //    @@   @@     @@@@@    @@   @@  @@ @@  @@     @@
54cdf0e10cSrcweir //    @@   @@    @@@ @@@   @@   @@  @@ @@  @@ @@  @@
55cdf0e10cSrcweir //    @@   @@@@@ @@   @@   @@    @@@@  @@@@@   @@@@
56cdf0e10cSrcweir //
57cdf0e10cSrcweir //  Transformationen
58cdf0e10cSrcweir //
59cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
60cdf0e10cSrcweir 
NbcSetSnapRect(const Rectangle & rRect)61cdf0e10cSrcweir void SdrTextObj::NbcSetSnapRect(const Rectangle& rRect)
62cdf0e10cSrcweir {
63cdf0e10cSrcweir 	if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) {
64cdf0e10cSrcweir 		Rectangle aSR0(GetSnapRect());
65cdf0e10cSrcweir 		long nWdt0=aSR0.Right()-aSR0.Left();
66cdf0e10cSrcweir 		long nHgt0=aSR0.Bottom()-aSR0.Top();
67cdf0e10cSrcweir 		long nWdt1=rRect.Right()-rRect.Left();
68cdf0e10cSrcweir 		long nHgt1=rRect.Bottom()-rRect.Top();
69cdf0e10cSrcweir 		SdrTextObj::NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0));
70cdf0e10cSrcweir 		SdrTextObj::NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top()));
71cdf0e10cSrcweir 	} else {
72cdf0e10cSrcweir 		long nHDist=GetTextLeftDistance()+GetTextRightDistance();
73cdf0e10cSrcweir 		long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
74cdf0e10cSrcweir 		long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0;
75cdf0e10cSrcweir 		long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0;
76cdf0e10cSrcweir 		long nTWdt1=rRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0;
77cdf0e10cSrcweir 		long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
78cdf0e10cSrcweir 		aRect=rRect;
79cdf0e10cSrcweir 		ImpJustifyRect(aRect);
80*215d8f42SArmin Le Grand 
81*215d8f42SArmin Le Grand         // #115391#
82*215d8f42SArmin Le Grand         AdaptTextMinSize();
83*215d8f42SArmin Le Grand 
84*215d8f42SArmin Le Grand         if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize()))
85*215d8f42SArmin Le Grand         {
86*215d8f42SArmin Le Grand             if(SDRTEXTFIT_RESIZEATTR == GetFitToSize())
87*215d8f42SArmin Le Grand             {
88*215d8f42SArmin Le Grand                 NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0));
89*215d8f42SArmin Le Grand             }
90*215d8f42SArmin Le Grand 
91*215d8f42SArmin Le Grand             NbcAdjustTextFrameWidthAndHeight();
92*215d8f42SArmin Le Grand         }
93*215d8f42SArmin Le Grand 
94*215d8f42SArmin Le Grand         ImpCheckShear();
95*215d8f42SArmin Le Grand         SetRectsDirty();
96*215d8f42SArmin Le Grand     }
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
GetLogicRect() const99cdf0e10cSrcweir const Rectangle& SdrTextObj::GetLogicRect() const
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	return aRect;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
NbcSetLogicRect(const Rectangle & rRect)104cdf0e10cSrcweir void SdrTextObj::NbcSetLogicRect(const Rectangle& rRect)
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	long nHDist=GetTextLeftDistance()+GetTextRightDistance();
107cdf0e10cSrcweir 	long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
108cdf0e10cSrcweir 	long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0;
109cdf0e10cSrcweir 	long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0;
110cdf0e10cSrcweir 	long nTWdt1=rRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0;
111cdf0e10cSrcweir 	long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
112cdf0e10cSrcweir 	aRect=rRect;
113cdf0e10cSrcweir 	ImpJustifyRect(aRect);
114*215d8f42SArmin Le Grand 
115*215d8f42SArmin Le Grand     // #115391#
116*215d8f42SArmin Le Grand     AdaptTextMinSize();
117*215d8f42SArmin Le Grand 
118*215d8f42SArmin Le Grand     if(bTextFrame)
119*215d8f42SArmin Le Grand     {
120*215d8f42SArmin Le Grand         if(SDRTEXTFIT_RESIZEATTR == GetFitToSize())
121*215d8f42SArmin Le Grand         {
122*215d8f42SArmin Le Grand             NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0));
123*215d8f42SArmin Le Grand         }
124*215d8f42SArmin Le Grand 
125*215d8f42SArmin Le Grand         NbcAdjustTextFrameWidthAndHeight();
126*215d8f42SArmin Le Grand     }
127*215d8f42SArmin Le Grand 
128*215d8f42SArmin Le Grand     SetRectsDirty();
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
GetRotateAngle() const131cdf0e10cSrcweir long SdrTextObj::GetRotateAngle() const
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	return aGeo.nDrehWink;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
GetShearAngle(FASTBOOL) const136cdf0e10cSrcweir long SdrTextObj::GetShearAngle(FASTBOOL /*bVertical*/) const
137cdf0e10cSrcweir {
138cdf0e10cSrcweir 	return aGeo.nShearWink;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir 
NbcMove(const Size & rSiz)141cdf0e10cSrcweir void SdrTextObj::NbcMove(const Size& rSiz)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir 	MoveRect(aRect,rSiz);
144cdf0e10cSrcweir 	MoveRect(aOutRect,rSiz);
145cdf0e10cSrcweir 	MoveRect(maSnapRect,rSiz);
146cdf0e10cSrcweir 	SetRectsDirty(sal_True);
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
NbcResize(const Point & rRef,const Fraction & xFact,const Fraction & yFact)149cdf0e10cSrcweir void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
150cdf0e10cSrcweir {
151cdf0e10cSrcweir 	FASTBOOL bNoShearMerk=aGeo.nShearWink==0;
152cdf0e10cSrcweir 	FASTBOOL bRota90Merk=bNoShearMerk && aGeo.nDrehWink % 9000 ==0;
153cdf0e10cSrcweir 	long nHDist=GetTextLeftDistance()+GetTextRightDistance();
154cdf0e10cSrcweir 	long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
155cdf0e10cSrcweir 	long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0;
156cdf0e10cSrcweir 	long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0;
157cdf0e10cSrcweir 	FASTBOOL bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
158cdf0e10cSrcweir 	FASTBOOL bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
159cdf0e10cSrcweir 	if (bXMirr || bYMirr) {
160cdf0e10cSrcweir 		Point aRef1(GetSnapRect().Center());
161cdf0e10cSrcweir 		if (bXMirr) {
162cdf0e10cSrcweir 			Point aRef2(aRef1);
163cdf0e10cSrcweir 			aRef2.Y()++;
164cdf0e10cSrcweir 			NbcMirrorGluePoints(aRef1,aRef2);
165cdf0e10cSrcweir 		}
166cdf0e10cSrcweir 		if (bYMirr) {
167cdf0e10cSrcweir 			Point aRef2(aRef1);
168cdf0e10cSrcweir 			aRef2.X()++;
169cdf0e10cSrcweir 			NbcMirrorGluePoints(aRef1,aRef2);
170cdf0e10cSrcweir 		}
171cdf0e10cSrcweir 	}
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	if (aGeo.nDrehWink==0 && aGeo.nShearWink==0) {
174cdf0e10cSrcweir 		ResizeRect(aRect,rRef,xFact,yFact);
175cdf0e10cSrcweir 		if (bYMirr) {
176cdf0e10cSrcweir 			aRect.Justify();
177cdf0e10cSrcweir 			aRect.Move(aRect.Right()-aRect.Left(),aRect.Bottom()-aRect.Top());
178cdf0e10cSrcweir 			aGeo.nDrehWink=18000;
179cdf0e10cSrcweir 			aGeo.RecalcSinCos();
180cdf0e10cSrcweir 		}
181cdf0e10cSrcweir 	}
182cdf0e10cSrcweir 	else
183cdf0e10cSrcweir 	{
184cdf0e10cSrcweir 		// #100663# aRect is NOT initialized for lines (polgon objects with two
185cdf0e10cSrcweir 		// exceptionally handled points). Thus, after this call the text rotaion is
186cdf0e10cSrcweir 		// gone. This error must be present since day one of this old drawing layer.
187cdf0e10cSrcweir 		// It's astonishing that noone discovered it earlier.
188cdf0e10cSrcweir 		// Polygon aPol(Rect2Poly(aRect,aGeo));
189cdf0e10cSrcweir 		// Polygon aPol(Rect2Poly(GetSnapRect(), aGeo));
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 		// #101412# go back to old method, side effects are impossible
192cdf0e10cSrcweir 		// to calculate.
193cdf0e10cSrcweir 		Polygon aPol(Rect2Poly(aRect,aGeo));
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 		for(sal_uInt16 a(0); a < aPol.GetSize(); a++)
196cdf0e10cSrcweir 		{
197cdf0e10cSrcweir 			 ResizePoint(aPol[a], rRef, xFact, yFact);
198cdf0e10cSrcweir 		}
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 		if(bXMirr != bYMirr)
201cdf0e10cSrcweir 		{
202cdf0e10cSrcweir 			// Polygon wenden und etwas schieben
203cdf0e10cSrcweir 			Polygon aPol0(aPol);
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 			aPol[0] = aPol0[1];
206cdf0e10cSrcweir 			aPol[1] = aPol0[0];
207cdf0e10cSrcweir 			aPol[2] = aPol0[3];
208cdf0e10cSrcweir 			aPol[3] = aPol0[2];
209cdf0e10cSrcweir 			aPol[4] = aPol0[1];
210cdf0e10cSrcweir 		}
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 		Poly2Rect(aPol, aRect, aGeo);
213cdf0e10cSrcweir 	}
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	if (bRota90Merk) {
216cdf0e10cSrcweir 		FASTBOOL bRota90=aGeo.nDrehWink % 9000 ==0;
217cdf0e10cSrcweir 		if (!bRota90) { // Scheinbar Rundungsfehler: Korregieren
218cdf0e10cSrcweir 			long a=NormAngle360(aGeo.nDrehWink);
219cdf0e10cSrcweir 			if (a<4500) a=0;
220cdf0e10cSrcweir 			else if (a<13500) a=9000;
221cdf0e10cSrcweir 			else if (a<22500) a=18000;
222cdf0e10cSrcweir 			else if (a<31500) a=27000;
223cdf0e10cSrcweir 			else a=0;
224cdf0e10cSrcweir 			aGeo.nDrehWink=a;
225cdf0e10cSrcweir 			aGeo.RecalcSinCos();
226cdf0e10cSrcweir 		}
227cdf0e10cSrcweir 		if (bNoShearMerk!=(aGeo.nShearWink==0)) { // Shear ggf. korregieren wg. Rundungsfehler
228cdf0e10cSrcweir 			aGeo.nShearWink=0;
229cdf0e10cSrcweir 			aGeo.RecalcTan();
230cdf0e10cSrcweir 		}
231cdf0e10cSrcweir 	}
232cdf0e10cSrcweir 
233*215d8f42SArmin Le Grand     ImpJustifyRect(aRect);
234*215d8f42SArmin Le Grand 
235*215d8f42SArmin Le Grand     long nTWdt1=aRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0;
236*215d8f42SArmin Le Grand     long nTHgt1=aRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
237*215d8f42SArmin Le Grand 
238*215d8f42SArmin Le Grand     // #115391#
239*215d8f42SArmin Le Grand     AdaptTextMinSize();
240*215d8f42SArmin Le Grand 
241*215d8f42SArmin Le Grand     if(bTextFrame && (!pModel || !pModel->IsPasteResize()))
242*215d8f42SArmin Le Grand     {
243*215d8f42SArmin Le Grand         if(SDRTEXTFIT_RESIZEATTR == GetFitToSize())
244*215d8f42SArmin Le Grand         {
245*215d8f42SArmin Le Grand             NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0));
246*215d8f42SArmin Le Grand         }
247*215d8f42SArmin Le Grand 
248*215d8f42SArmin Le Grand         NbcAdjustTextFrameWidthAndHeight();
249*215d8f42SArmin Le Grand     }
250*215d8f42SArmin Le Grand 
251*215d8f42SArmin Le Grand     ImpCheckShear();
252*215d8f42SArmin Le Grand     SetRectsDirty();
253cdf0e10cSrcweir }
254cdf0e10cSrcweir 
NbcRotate(const Point & rRef,long nWink,double sn,double cs)255cdf0e10cSrcweir void SdrTextObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
256cdf0e10cSrcweir {
257cdf0e10cSrcweir 	SetGlueReallyAbsolute(sal_True);
258cdf0e10cSrcweir 	long dx=aRect.Right()-aRect.Left();
259cdf0e10cSrcweir 	long dy=aRect.Bottom()-aRect.Top();
260cdf0e10cSrcweir 	Point aP(aRect.TopLeft());
261cdf0e10cSrcweir 	RotatePoint(aP,rRef,sn,cs);
262cdf0e10cSrcweir 	aRect.Left()=aP.X();
263cdf0e10cSrcweir 	aRect.Top()=aP.Y();
264cdf0e10cSrcweir 	aRect.Right()=aRect.Left()+dx;
265cdf0e10cSrcweir 	aRect.Bottom()=aRect.Top()+dy;
266cdf0e10cSrcweir 	if (aGeo.nDrehWink==0) {
267cdf0e10cSrcweir 		aGeo.nDrehWink=NormAngle360(nWink);
268cdf0e10cSrcweir 		aGeo.nSin=sn;
269cdf0e10cSrcweir 		aGeo.nCos=cs;
270cdf0e10cSrcweir 	} else {
271cdf0e10cSrcweir 		aGeo.nDrehWink=NormAngle360(aGeo.nDrehWink+nWink);
272cdf0e10cSrcweir 		aGeo.RecalcSinCos();
273cdf0e10cSrcweir 	}
274cdf0e10cSrcweir 	SetRectsDirty();
275cdf0e10cSrcweir 	NbcRotateGluePoints(rRef,nWink,sn,cs);
276cdf0e10cSrcweir 	SetGlueReallyAbsolute(sal_False);
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
NbcShear(const Point & rRef,long nWink,double tn,FASTBOOL bVShear)279cdf0e10cSrcweir void SdrTextObj::NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear)
280cdf0e10cSrcweir {
281cdf0e10cSrcweir 	SetGlueReallyAbsolute(sal_True);
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	// #75889# when this is a SdrPathObj aRect maybe not initialized
284cdf0e10cSrcweir 	Polygon aPol(Rect2Poly(aRect.IsEmpty() ? GetSnapRect() : aRect, aGeo));
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	sal_uInt16 nPointCount=aPol.GetSize();
287cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<nPointCount; i++) {
288cdf0e10cSrcweir 		 ShearPoint(aPol[i],rRef,tn,bVShear);
289cdf0e10cSrcweir 	}
290cdf0e10cSrcweir 	Poly2Rect(aPol,aRect,aGeo);
291cdf0e10cSrcweir 	ImpJustifyRect(aRect);
292cdf0e10cSrcweir 	if (bTextFrame) {
293cdf0e10cSrcweir 		NbcAdjustTextFrameWidthAndHeight();
294cdf0e10cSrcweir 	}
295cdf0e10cSrcweir 	ImpCheckShear();
296cdf0e10cSrcweir 	SetRectsDirty();
297cdf0e10cSrcweir 	NbcShearGluePoints(rRef,nWink,tn,bVShear);
298cdf0e10cSrcweir 	SetGlueReallyAbsolute(sal_False);
299cdf0e10cSrcweir }
300cdf0e10cSrcweir 
NbcMirror(const Point & rRef1,const Point & rRef2)301cdf0e10cSrcweir void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2)
302cdf0e10cSrcweir {
303cdf0e10cSrcweir 	SetGlueReallyAbsolute(sal_True);
304cdf0e10cSrcweir 	FASTBOOL bNoShearMerk=aGeo.nShearWink==0;
305cdf0e10cSrcweir 	FASTBOOL bRota90Merk=sal_False;
306cdf0e10cSrcweir 	if (bNoShearMerk &&
307cdf0e10cSrcweir 		(rRef1.X()==rRef2.X() || rRef1.Y()==rRef2.Y() ||
308cdf0e10cSrcweir 		 Abs(rRef1.X()-rRef2.X())==Abs(rRef1.Y()-rRef2.Y()))) {
309cdf0e10cSrcweir 		bRota90Merk=aGeo.nDrehWink % 9000 ==0;
310cdf0e10cSrcweir 	}
311cdf0e10cSrcweir 	Polygon aPol(Rect2Poly(aRect,aGeo));
312cdf0e10cSrcweir 	sal_uInt16 i;
313cdf0e10cSrcweir 	sal_uInt16 nPntAnz=aPol.GetSize();
314cdf0e10cSrcweir 	for (i=0; i<nPntAnz; i++) {
315cdf0e10cSrcweir 		 MirrorPoint(aPol[i],rRef1,rRef2);
316cdf0e10cSrcweir 	}
317cdf0e10cSrcweir 	// Polygon wenden und etwas schieben
318cdf0e10cSrcweir 	Polygon aPol0(aPol);
319cdf0e10cSrcweir 	aPol[0]=aPol0[1];
320cdf0e10cSrcweir 	aPol[1]=aPol0[0];
321cdf0e10cSrcweir 	aPol[2]=aPol0[3];
322cdf0e10cSrcweir 	aPol[3]=aPol0[2];
323cdf0e10cSrcweir 	aPol[4]=aPol0[1];
324cdf0e10cSrcweir 	Poly2Rect(aPol,aRect,aGeo);
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 	if (bRota90Merk) {
327cdf0e10cSrcweir 		FASTBOOL bRota90=aGeo.nDrehWink % 9000 ==0;
328cdf0e10cSrcweir 		if (bRota90Merk && !bRota90) { // Scheinbar Rundungsfehler: Korregieren
329cdf0e10cSrcweir 			long a=NormAngle360(aGeo.nDrehWink);
330cdf0e10cSrcweir 			if (a<4500) a=0;
331cdf0e10cSrcweir 			else if (a<13500) a=9000;
332cdf0e10cSrcweir 			else if (a<22500) a=18000;
333cdf0e10cSrcweir 			else if (a<31500) a=27000;
334cdf0e10cSrcweir 			else a=0;
335cdf0e10cSrcweir 			aGeo.nDrehWink=a;
336cdf0e10cSrcweir 			aGeo.RecalcSinCos();
337cdf0e10cSrcweir 		}
338cdf0e10cSrcweir 	}
339cdf0e10cSrcweir 	if (bNoShearMerk!=(aGeo.nShearWink==0)) { // Shear ggf. korregieren wg. Rundungsfehler
340cdf0e10cSrcweir 		aGeo.nShearWink=0;
341cdf0e10cSrcweir 		aGeo.RecalcTan();
342cdf0e10cSrcweir 	}
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 	ImpJustifyRect(aRect);
345cdf0e10cSrcweir 	if (bTextFrame) {
346cdf0e10cSrcweir 		NbcAdjustTextFrameWidthAndHeight();
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 	ImpCheckShear();
349cdf0e10cSrcweir 	SetRectsDirty();
350cdf0e10cSrcweir 	NbcMirrorGluePoints(rRef1,rRef2);
351cdf0e10cSrcweir 	SetGlueReallyAbsolute(sal_False);
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
355cdf0e10cSrcweir 
ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const356cdf0e10cSrcweir SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
357cdf0e10cSrcweir {
358cdf0e10cSrcweir 	SdrObject* pRetval = 0;
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 	if(!ImpCanConvTextToCurve())
361cdf0e10cSrcweir 	{
362cdf0e10cSrcweir 		// suppress HelpTexts from PresObj's
363cdf0e10cSrcweir 		return 0;
364cdf0e10cSrcweir 	}
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 	// get primitives
367cdf0e10cSrcweir 	const drawinglayer::primitive2d::Primitive2DSequence xSequence(GetViewContact().getViewIndependentPrimitive2DSequence());
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 	if(xSequence.hasElements())
370cdf0e10cSrcweir 	{
371cdf0e10cSrcweir 		// create an extractor with neutral ViewInformation
372cdf0e10cSrcweir 		const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
373cdf0e10cSrcweir 		drawinglayer::processor2d::TextAsPolygonExtractor2D aExtractor(aViewInformation2D);
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 		// extract text as polygons
376cdf0e10cSrcweir 		aExtractor.process(xSequence);
377cdf0e10cSrcweir 
378cdf0e10cSrcweir 		// get results
379cdf0e10cSrcweir 		const drawinglayer::processor2d::TextAsPolygonDataNodeVector& rResult = aExtractor.getTarget();
380cdf0e10cSrcweir 		const sal_uInt32 nResultCount(rResult.size());
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 		if(nResultCount)
383cdf0e10cSrcweir 		{
384cdf0e10cSrcweir 			// prepare own target
385cdf0e10cSrcweir 			SdrObjGroup* pGroup = new SdrObjGroup();
386cdf0e10cSrcweir 			SdrObjList* pObjectList = pGroup->GetSubList();
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 			// process results
389cdf0e10cSrcweir 			for(sal_uInt32 a(0); a < nResultCount; a++)
390cdf0e10cSrcweir 			{
391cdf0e10cSrcweir 				const drawinglayer::processor2d::TextAsPolygonDataNode& rCandidate = rResult[a];
392cdf0e10cSrcweir 				basegfx::B2DPolyPolygon aPolyPolygon(rCandidate.getB2DPolyPolygon());
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 				if(aPolyPolygon.count())
395cdf0e10cSrcweir 				{
396cdf0e10cSrcweir 					// take care of wanted polygon type
397cdf0e10cSrcweir 					if(bToPoly)
398cdf0e10cSrcweir 					{
399cdf0e10cSrcweir 						if(aPolyPolygon.areControlPointsUsed())
400cdf0e10cSrcweir 						{
401cdf0e10cSrcweir 							aPolyPolygon = basegfx::tools::adaptiveSubdivideByAngle(aPolyPolygon);
402cdf0e10cSrcweir 						}
403cdf0e10cSrcweir 					}
404cdf0e10cSrcweir 					else
405cdf0e10cSrcweir 					{
406cdf0e10cSrcweir 						if(!aPolyPolygon.areControlPointsUsed())
407cdf0e10cSrcweir 						{
408cdf0e10cSrcweir 							aPolyPolygon = basegfx::tools::expandToCurve(aPolyPolygon);
409cdf0e10cSrcweir 						}
410cdf0e10cSrcweir 					}
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 					// create ItemSet with object attributes
413cdf0e10cSrcweir 					SfxItemSet aAttributeSet(GetObjectItemSet());
414cdf0e10cSrcweir 					SdrPathObj* pPathObj = 0;
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 					// always clear objectshadow; this is included in the extraction
417cdf0e10cSrcweir 					aAttributeSet.Put(SdrShadowItem(false));
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 					if(rCandidate.getIsFilled())
420cdf0e10cSrcweir 					{
421cdf0e10cSrcweir 						// set needed items
422cdf0e10cSrcweir 						aAttributeSet.Put(XFillColorItem(String(), Color(rCandidate.getBColor())));
423cdf0e10cSrcweir 						aAttributeSet.Put(XLineStyleItem(XLINE_NONE));
424cdf0e10cSrcweir 						aAttributeSet.Put(XFillStyleItem(XFILL_SOLID));
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 						// create filled SdrPathObj
427cdf0e10cSrcweir 						pPathObj = new SdrPathObj(OBJ_PATHFILL, aPolyPolygon);
428cdf0e10cSrcweir 					}
429cdf0e10cSrcweir 					else
430cdf0e10cSrcweir 					{
431cdf0e10cSrcweir 						// set needed items
432cdf0e10cSrcweir 						aAttributeSet.Put(XLineColorItem(String(), Color(rCandidate.getBColor())));
433cdf0e10cSrcweir 						aAttributeSet.Put(XLineStyleItem(XLINE_SOLID));
434cdf0e10cSrcweir 						aAttributeSet.Put(XLineWidthItem(0));
435cdf0e10cSrcweir 						aAttributeSet.Put(XFillStyleItem(XFILL_NONE));
436cdf0e10cSrcweir 
437cdf0e10cSrcweir 						// create line SdrPathObj
438cdf0e10cSrcweir 						pPathObj = new SdrPathObj(OBJ_PATHLINE, aPolyPolygon);
439cdf0e10cSrcweir 					}
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 					// copy basic information from original
442cdf0e10cSrcweir 					pPathObj->ImpSetAnchorPos(GetAnchorPos());
443cdf0e10cSrcweir 					pPathObj->NbcSetLayer(GetLayer());
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 					if(GetModel())
446cdf0e10cSrcweir 					{
447cdf0e10cSrcweir 						pPathObj->SetModel(GetModel());
448cdf0e10cSrcweir 						pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
449cdf0e10cSrcweir 					}
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 					// apply prepared ItemSet and add to target
452cdf0e10cSrcweir 					pPathObj->SetMergedItemSet(aAttributeSet);
453cdf0e10cSrcweir 					pObjectList->InsertObject(pPathObj);
454cdf0e10cSrcweir 				}
455cdf0e10cSrcweir 			}
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 			// postprocess; if no result and/or only one object, simplify
458cdf0e10cSrcweir 			if(!pObjectList->GetObjCount())
459cdf0e10cSrcweir 			{
460cdf0e10cSrcweir 				delete pGroup;
461cdf0e10cSrcweir 			}
462cdf0e10cSrcweir 			else if(1 == pObjectList->GetObjCount())
463cdf0e10cSrcweir 			{
464cdf0e10cSrcweir 				pRetval = pObjectList->RemoveObject(0);
465cdf0e10cSrcweir 				delete pGroup;
466cdf0e10cSrcweir 			}
467cdf0e10cSrcweir 			else
468cdf0e10cSrcweir 			{
469cdf0e10cSrcweir 				pRetval = pGroup;
470cdf0e10cSrcweir 			}
471cdf0e10cSrcweir 		}
472cdf0e10cSrcweir 	}
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 	return pRetval;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
477cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
478cdf0e10cSrcweir 
DoConvertToPolyObj(sal_Bool bBezier,bool bAddText) const479a5258243SPedro Giffuni SdrObject* SdrTextObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const
480cdf0e10cSrcweir {
481a5258243SPedro Giffuni     if(bAddText)
482a5258243SPedro Giffuni     {
483a5258243SPedro Giffuni     	return ImpConvertContainedTextToSdrPathObjs(!bBezier);
484a5258243SPedro Giffuni     }
485a5258243SPedro Giffuni 
486a5258243SPedro Giffuni     return 0;
487cdf0e10cSrcweir }
488cdf0e10cSrcweir 
ImpCanConvTextToCurve() const489cdf0e10cSrcweir bool SdrTextObj::ImpCanConvTextToCurve() const
490cdf0e10cSrcweir {
491cdf0e10cSrcweir 	return !IsOutlText();
492cdf0e10cSrcweir }
493cdf0e10cSrcweir 
ImpConvertMakeObj(const basegfx::B2DPolyPolygon & rPolyPolygon,sal_Bool bClosed,sal_Bool bBezier,sal_Bool bNoSetAttr) const494cdf0e10cSrcweir SdrObject* SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPolygon, sal_Bool bClosed, sal_Bool bBezier, sal_Bool bNoSetAttr) const
495cdf0e10cSrcweir {
496cdf0e10cSrcweir 	SdrObjKind ePathKind = bClosed ? OBJ_PATHFILL : OBJ_PATHLINE;
497cdf0e10cSrcweir 	basegfx::B2DPolyPolygon aB2DPolyPolygon(rPolyPolygon);
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 	// #i37011#
500cdf0e10cSrcweir 	if(!bBezier)
501cdf0e10cSrcweir 	{
502cdf0e10cSrcweir 		aB2DPolyPolygon = basegfx::tools::adaptiveSubdivideByAngle(aB2DPolyPolygon);
503cdf0e10cSrcweir 		ePathKind = bClosed ? OBJ_POLY : OBJ_PLIN;
504cdf0e10cSrcweir 	}
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	SdrPathObj* pPathObj = new SdrPathObj(ePathKind, aB2DPolyPolygon);
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 	if(bBezier)
509cdf0e10cSrcweir 	{
510cdf0e10cSrcweir 		// create bezier curves
511cdf0e10cSrcweir 		pPathObj->SetPathPoly(basegfx::tools::expandToCurve(pPathObj->GetPathPoly()));
512cdf0e10cSrcweir 	}
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 	if(pPathObj)
515cdf0e10cSrcweir 	{
516cdf0e10cSrcweir 		pPathObj->ImpSetAnchorPos(aAnchor);
517cdf0e10cSrcweir 		pPathObj->NbcSetLayer(SdrLayerID(GetLayer()));
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 		if(pModel)
520cdf0e10cSrcweir 		{
521cdf0e10cSrcweir 			pPathObj->SetModel(pModel);
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 			if(!bNoSetAttr)
524cdf0e10cSrcweir 			{
525cdf0e10cSrcweir 				sdr::properties::ItemChangeBroadcaster aC(*pPathObj);
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 				pPathObj->ClearMergedItem();
528cdf0e10cSrcweir 				pPathObj->SetMergedItemSet(GetObjectItemSet());
529cdf0e10cSrcweir 				pPathObj->GetProperties().BroadcastItemChange(aC);
530cdf0e10cSrcweir 				pPathObj->NbcSetStyleSheet(GetStyleSheet(), sal_True);
531cdf0e10cSrcweir 			}
532cdf0e10cSrcweir 		}
533cdf0e10cSrcweir 	}
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 	return pPathObj;
536cdf0e10cSrcweir }
537cdf0e10cSrcweir 
ImpConvertAddText(SdrObject * pObj,FASTBOOL bBezier) const538cdf0e10cSrcweir SdrObject* SdrTextObj::ImpConvertAddText(SdrObject* pObj, FASTBOOL bBezier) const
539cdf0e10cSrcweir {
540cdf0e10cSrcweir 	if(!ImpCanConvTextToCurve())
541cdf0e10cSrcweir     {
542cdf0e10cSrcweir         return pObj;
543cdf0e10cSrcweir     }
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 	SdrObject* pText = ImpConvertContainedTextToSdrPathObjs(!bBezier);
546cdf0e10cSrcweir 
547cdf0e10cSrcweir     if(!pText)
548cdf0e10cSrcweir     {
549cdf0e10cSrcweir         return pObj;
550cdf0e10cSrcweir     }
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 	if(!pObj)
553cdf0e10cSrcweir     {
554cdf0e10cSrcweir         return pText;
555cdf0e10cSrcweir     }
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 	if(pText->IsGroupObject())
558cdf0e10cSrcweir     {
559cdf0e10cSrcweir         // is already group object, add partial shape in front
560cdf0e10cSrcweir 		SdrObjList* pOL=pText->GetSubList();
561cdf0e10cSrcweir 		pOL->InsertObject(pObj,0);
562cdf0e10cSrcweir 
563cdf0e10cSrcweir         return pText;
564cdf0e10cSrcweir 	}
565cdf0e10cSrcweir     else
566cdf0e10cSrcweir     {
567cdf0e10cSrcweir         // not yet a group, create one and add partial and new shapes
568cdf0e10cSrcweir 		SdrObjGroup* pGrp=new SdrObjGroup;
569cdf0e10cSrcweir 		SdrObjList* pOL=pGrp->GetSubList();
570cdf0e10cSrcweir 		pOL->InsertObject(pObj);
571cdf0e10cSrcweir 		pOL->InsertObject(pText);
572cdf0e10cSrcweir 
573cdf0e10cSrcweir         return pGrp;
574cdf0e10cSrcweir 	}
575cdf0e10cSrcweir }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
578cdf0e10cSrcweir // eof
579