Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <svx/svdotext.hxx>
31 : : #include "svx/svditext.hxx"
32 : : #include <svx/svdtrans.hxx>
33 : : #include <svx/svdogrp.hxx>
34 : : #include <svx/svdopath.hxx>
35 : : #include <svx/svdoutl.hxx>
36 : : #include <svx/svdpage.hxx> // for Convert
37 : : #include <svx/svdmodel.hxx> // for Convert
38 : : #include <editeng/outliner.hxx>
39 : : #include <svx/sdr/properties/itemsettools.hxx>
40 : : #include <svx/sdr/properties/properties.hxx>
41 : : #include <basegfx/polygon/b2dpolypolygontools.hxx>
42 : : #include <svl/itemset.hxx>
43 : : #include <svx/svditer.hxx>
44 : : #include <drawinglayer/processor2d/textaspolygonextractor2d.hxx>
45 : : #include <svx/sdr/contact/viewcontact.hxx>
46 : : #include <svx/xflclit.hxx>
47 : : #include <svx/xlnclit.hxx>
48 : : #include <svx/xlnwtit.hxx>
49 : :
50 : :
51 : 63474 : void SdrTextObj::NbcSetSnapRect(const Rectangle& rRect)
52 : : {
53 [ + - ][ - + ]: 63474 : if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) {
54 [ # # ]: 0 : Rectangle aSR0(GetSnapRect());
55 : 0 : long nWdt0=aSR0.Right()-aSR0.Left();
56 : 0 : long nHgt0=aSR0.Bottom()-aSR0.Top();
57 : 0 : long nWdt1=rRect.Right()-rRect.Left();
58 : 0 : long nHgt1=rRect.Bottom()-rRect.Top();
59 [ # # ][ # # ]: 0 : SdrTextObj::NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0));
[ # # ]
60 [ # # ]: 0 : SdrTextObj::NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top()));
61 : : } else {
62 : 63474 : long nHDist=GetTextLeftDistance()+GetTextRightDistance();
63 : 63474 : long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
64 [ + + ]: 63474 : long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0;
65 [ + + ]: 63474 : long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0;
66 [ + + ]: 63474 : long nTWdt1=rRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0;
67 [ + + ]: 63474 : long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
68 : 63474 : aRect=rRect;
69 : 63474 : ImpJustifyRect(aRect);
70 [ + - ][ + - ]: 63474 : if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) {
[ + + ][ + + ]
71 [ + - ][ + + ]: 52101 : if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1);
[ + + ]
72 [ + + ][ + + ]: 52101 : if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1);
[ + + ]
73 : 52101 : NbcAdjustTextFrameWidthAndHeight();
74 : : }
75 : 63474 : ImpCheckShear();
76 : 63474 : SetRectsDirty();
77 : : }
78 : 63474 : }
79 : :
80 : 269122 : const Rectangle& SdrTextObj::GetLogicRect() const
81 : : {
82 : 269122 : return aRect;
83 : : }
84 : :
85 : 52141 : void SdrTextObj::NbcSetLogicRect(const Rectangle& rRect)
86 : : {
87 : 52141 : long nHDist=GetTextLeftDistance()+GetTextRightDistance();
88 : 52141 : long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
89 [ + + ]: 52141 : long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0;
90 [ + + ]: 52141 : long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0;
91 [ + + ]: 52141 : long nTWdt1=rRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0;
92 [ + + ]: 52141 : long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
93 : 52141 : aRect=rRect;
94 : 52141 : ImpJustifyRect(aRect);
95 [ + + ]: 52141 : if (bTextFrame) {
96 [ + + ][ - + ]: 25149 : if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1);
[ - + ]
97 [ + + ][ + + ]: 25149 : if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1);
[ + + ]
98 : 25149 : NbcAdjustTextFrameWidthAndHeight();
99 : : }
100 : 52141 : SetRectsDirty();
101 : 52141 : }
102 : :
103 : 3 : long SdrTextObj::GetRotateAngle() const
104 : : {
105 : 3 : return aGeo.nDrehWink;
106 : : }
107 : :
108 : 0 : long SdrTextObj::GetShearAngle(bool /*bVertical*/) const
109 : : {
110 : 0 : return aGeo.nShearWink;
111 : : }
112 : :
113 : 94289 : void SdrTextObj::NbcMove(const Size& rSiz)
114 : : {
115 : 94289 : MoveRect(aRect,rSiz);
116 : 94289 : MoveRect(aOutRect,rSiz);
117 : 94289 : MoveRect(maSnapRect,rSiz);
118 : 94289 : SetRectsDirty(sal_True);
119 : 94289 : }
120 : :
121 : 35839 : void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
122 : : {
123 : 35839 : bool bNoShearMerk=aGeo.nShearWink==0;
124 [ + - ][ + + ]: 35839 : bool bRota90Merk=bNoShearMerk && aGeo.nDrehWink % 9000 ==0;
125 : 35839 : long nHDist=GetTextLeftDistance()+GetTextRightDistance();
126 : 35839 : long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
127 [ + + ]: 35839 : long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0;
128 [ + + ]: 35839 : long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0;
129 : 35839 : bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
130 : 35839 : bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
131 [ - + ][ + + ]: 35839 : if (bXMirr || bYMirr) {
132 [ + - ][ + - ]: 34566 : Point aRef1(GetSnapRect().Center());
133 [ + - ]: 34566 : if (bXMirr) {
134 : 34566 : Point aRef2(aRef1);
135 : 34566 : aRef2.Y()++;
136 [ + - ]: 34566 : NbcMirrorGluePoints(aRef1,aRef2);
137 : : }
138 [ + - ]: 34566 : if (bYMirr) {
139 : 34566 : Point aRef2(aRef1);
140 : 34566 : aRef2.X()++;
141 [ + - ]: 34566 : NbcMirrorGluePoints(aRef1,aRef2);
142 : : }
143 : : }
144 : :
145 [ + + ][ + - ]: 35839 : if (aGeo.nDrehWink==0 && aGeo.nShearWink==0) {
146 : 17302 : ResizeRect(aRect,rRef,xFact,yFact);
147 [ + + ]: 34585 : if (bYMirr) {
148 : 17283 : aRect.Justify();
149 : 17283 : aRect.Move(aRect.Right()-aRect.Left(),aRect.Bottom()-aRect.Top());
150 : 17283 : aGeo.nDrehWink=18000;
151 : 17283 : aGeo.RecalcSinCos();
152 : : }
153 : : }
154 : : else
155 : : {
156 [ + - ]: 18537 : Polygon aPol(Rect2Poly(aRect,aGeo));
157 : :
158 [ + - ][ + + ]: 111222 : for(sal_uInt16 a(0); a < aPol.GetSize(); a++)
159 : : {
160 [ + - ][ + - ]: 92685 : ResizePoint(aPol[a], rRef, xFact, yFact);
[ + - ][ + - ]
161 : : }
162 : :
163 [ - + ]: 18537 : if(bXMirr != bYMirr)
164 : : {
165 : : // turn polygon and move it a little
166 [ # # ]: 0 : Polygon aPol0(aPol);
167 : :
168 [ # # ][ # # ]: 0 : aPol[0] = aPol0[1];
169 [ # # ][ # # ]: 0 : aPol[1] = aPol0[0];
170 [ # # ][ # # ]: 0 : aPol[2] = aPol0[3];
171 [ # # ][ # # ]: 0 : aPol[3] = aPol0[2];
172 [ # # ][ # # ]: 0 : aPol[4] = aPol0[1];
[ # # ]
173 : : }
174 : :
175 [ + - ][ + - ]: 18537 : Poly2Rect(aPol, aRect, aGeo);
176 : : }
177 : :
178 [ + + ]: 35839 : if (bRota90Merk) {
179 : 34585 : bool bRota90=aGeo.nDrehWink % 9000 ==0;
180 [ - + ]: 34585 : if (!bRota90) { // there's seems to be a rounding error occurring: correct it
181 : 0 : long a=NormAngle360(aGeo.nDrehWink);
182 [ # # ]: 0 : if (a<4500) a=0;
183 [ # # ]: 0 : else if (a<13500) a=9000;
184 [ # # ]: 0 : else if (a<22500) a=18000;
185 [ # # ]: 0 : else if (a<31500) a=27000;
186 : 0 : else a=0;
187 : 0 : aGeo.nDrehWink=a;
188 : 0 : aGeo.RecalcSinCos();
189 : : }
190 [ + + ]: 34585 : if (bNoShearMerk!=(aGeo.nShearWink==0)) { // correct a rounding error occurring with Shear
191 : 17283 : aGeo.nShearWink=0;
192 : 17283 : aGeo.RecalcTan();
193 : : }
194 : : }
195 : :
196 : 35839 : ImpJustifyRect(aRect);
197 [ + + ]: 35839 : long nTWdt1=aRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0;
198 [ + + ]: 35839 : long nTHgt1=aRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
199 [ - + ][ # # ]: 35839 : if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) {
[ # # ][ - + ]
200 [ # # ][ # # ]: 0 : if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1);
[ # # ]
201 [ # # ][ # # ]: 0 : if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1);
[ # # ]
202 : 0 : NbcAdjustTextFrameWidthAndHeight();
203 : : }
204 : 35839 : ImpCheckShear();
205 : 35839 : SetRectsDirty();
206 : 35839 : }
207 : :
208 : 851 : void SdrTextObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
209 : : {
210 [ + - ]: 851 : SetGlueReallyAbsolute(sal_True);
211 : 851 : long dx=aRect.Right()-aRect.Left();
212 : 851 : long dy=aRect.Bottom()-aRect.Top();
213 : 851 : Point aP(aRect.TopLeft());
214 : 851 : RotatePoint(aP,rRef,sn,cs);
215 : 851 : aRect.Left()=aP.X();
216 : 851 : aRect.Top()=aP.Y();
217 : 851 : aRect.Right()=aRect.Left()+dx;
218 : 851 : aRect.Bottom()=aRect.Top()+dy;
219 [ + - ]: 851 : if (aGeo.nDrehWink==0) {
220 [ + - ]: 851 : aGeo.nDrehWink=NormAngle360(nWink);
221 : 851 : aGeo.nSin=sn;
222 : 851 : aGeo.nCos=cs;
223 : : } else {
224 [ # # ]: 0 : aGeo.nDrehWink=NormAngle360(aGeo.nDrehWink+nWink);
225 [ # # ]: 0 : aGeo.RecalcSinCos();
226 : : }
227 [ + - ]: 851 : SetRectsDirty();
228 [ + - ]: 851 : NbcRotateGluePoints(rRef,nWink,sn,cs);
229 [ + - ]: 851 : SetGlueReallyAbsolute(sal_False);
230 : 851 : }
231 : :
232 : 0 : void SdrTextObj::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
233 : : {
234 [ # # ]: 0 : SetGlueReallyAbsolute(sal_True);
235 : :
236 : : // when this is a SdrPathObj, aRect may be uninitialized
237 [ # # ][ # # ]: 0 : Polygon aPol(Rect2Poly(aRect.IsEmpty() ? GetSnapRect() : aRect, aGeo));
[ # # ][ # # ]
238 : :
239 [ # # ]: 0 : sal_uInt16 nPointCount=aPol.GetSize();
240 [ # # ]: 0 : for (sal_uInt16 i=0; i<nPointCount; i++) {
241 [ # # ]: 0 : ShearPoint(aPol[i],rRef,tn,bVShear);
242 : : }
243 [ # # ]: 0 : Poly2Rect(aPol,aRect,aGeo);
244 [ # # ]: 0 : ImpJustifyRect(aRect);
245 [ # # ]: 0 : if (bTextFrame) {
246 [ # # ]: 0 : NbcAdjustTextFrameWidthAndHeight();
247 : : }
248 [ # # ]: 0 : ImpCheckShear();
249 [ # # ]: 0 : SetRectsDirty();
250 [ # # ]: 0 : NbcShearGluePoints(rRef,nWink,tn,bVShear);
251 [ # # ][ # # ]: 0 : SetGlueReallyAbsolute(sal_False);
252 : 0 : }
253 : :
254 : 13 : void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2)
255 : : {
256 [ + - ]: 13 : SetGlueReallyAbsolute(sal_True);
257 : 13 : bool bNoShearMerk=aGeo.nShearWink==0;
258 : 13 : bool bRota90Merk = false;
259 [ + - - + : 26 : if (bNoShearMerk &&
# # # # ]
[ + - ]
260 : 13 : (rRef1.X()==rRef2.X() || rRef1.Y()==rRef2.Y() ||
261 : 0 : Abs(rRef1.X()-rRef2.X())==Abs(rRef1.Y()-rRef2.Y()))) {
262 : 13 : bRota90Merk=aGeo.nDrehWink % 9000 ==0;
263 : : }
264 [ + - ]: 13 : Polygon aPol(Rect2Poly(aRect,aGeo));
265 : : sal_uInt16 i;
266 [ + - ]: 13 : sal_uInt16 nPntAnz=aPol.GetSize();
267 [ + + ]: 78 : for (i=0; i<nPntAnz; i++) {
268 [ + - ][ + - ]: 65 : MirrorPoint(aPol[i],rRef1,rRef2);
269 : : }
270 : : // turn polygon and move it a little
271 [ + - ]: 13 : Polygon aPol0(aPol);
272 [ + - ][ + - ]: 13 : aPol[0]=aPol0[1];
273 [ + - ][ + - ]: 13 : aPol[1]=aPol0[0];
274 [ + - ][ + - ]: 13 : aPol[2]=aPol0[3];
275 [ + - ][ + - ]: 13 : aPol[3]=aPol0[2];
276 [ + - ][ + - ]: 13 : aPol[4]=aPol0[1];
277 [ + - ]: 13 : Poly2Rect(aPol,aRect,aGeo);
278 : :
279 [ + - ]: 13 : if (bRota90Merk) {
280 : 13 : bool bRota90=aGeo.nDrehWink % 9000 ==0;
281 [ + - ][ - + ]: 13 : if (bRota90Merk && !bRota90) { // there's seems to be a rounding error occurring: correct it
282 [ # # ]: 0 : long a=NormAngle360(aGeo.nDrehWink);
283 [ # # ]: 0 : if (a<4500) a=0;
284 [ # # ]: 0 : else if (a<13500) a=9000;
285 [ # # ]: 0 : else if (a<22500) a=18000;
286 [ # # ]: 0 : else if (a<31500) a=27000;
287 : 0 : else a=0;
288 : 0 : aGeo.nDrehWink=a;
289 [ # # ]: 0 : aGeo.RecalcSinCos();
290 : : }
291 : : }
292 [ - + ]: 13 : if (bNoShearMerk!=(aGeo.nShearWink==0)) { // correct a rounding error occurring with Shear
293 : 0 : aGeo.nShearWink=0;
294 [ # # ]: 0 : aGeo.RecalcTan();
295 : : }
296 : :
297 [ + - ]: 13 : ImpJustifyRect(aRect);
298 [ - + ]: 13 : if (bTextFrame) {
299 [ # # ]: 0 : NbcAdjustTextFrameWidthAndHeight();
300 : : }
301 [ + - ]: 13 : ImpCheckShear();
302 [ + - ]: 13 : SetRectsDirty();
303 [ + - ]: 13 : NbcMirrorGluePoints(rRef1,rRef2);
304 [ + - ][ + - ]: 13 : SetGlueReallyAbsolute(sal_False);
[ + - ]
305 : 13 : }
306 : :
307 : : //////////////////////////////////////////////////////////////////////////////
308 : :
309 : 40 : SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
310 : : {
311 : 40 : SdrObject* pRetval = 0;
312 : :
313 [ + - ][ - + ]: 40 : if(!ImpCanConvTextToCurve())
314 : : {
315 : : // suppress HelpTexts from PresObj's
316 : 0 : return 0;
317 : : }
318 : :
319 : : // get primitives
320 [ + - ][ + - ]: 40 : const drawinglayer::primitive2d::Primitive2DSequence xSequence(GetViewContact().getViewIndependentPrimitive2DSequence());
321 : :
322 [ + - ]: 40 : if(xSequence.hasElements())
323 : : {
324 : : // create an extractor with neutral ViewInformation
325 [ + - ]: 40 : const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
326 [ + - ]: 40 : drawinglayer::processor2d::TextAsPolygonExtractor2D aExtractor(aViewInformation2D);
327 : :
328 : : // extract text as polygons
329 [ + - ]: 40 : aExtractor.process(xSequence);
330 : :
331 : : // get results
332 : 40 : const drawinglayer::processor2d::TextAsPolygonDataNodeVector& rResult = aExtractor.getTarget();
333 : 40 : const sal_uInt32 nResultCount(rResult.size());
334 : :
335 [ - + ]: 40 : if(nResultCount)
336 : : {
337 : : // prepare own target
338 [ # # ][ # # ]: 0 : SdrObjGroup* pGroup = new SdrObjGroup();
339 [ # # ]: 0 : SdrObjList* pObjectList = pGroup->GetSubList();
340 : :
341 : : // process results
342 [ # # ]: 0 : for(sal_uInt32 a(0); a < nResultCount; a++)
343 : : {
344 : 0 : const drawinglayer::processor2d::TextAsPolygonDataNode& rCandidate = rResult[a];
345 [ # # ]: 0 : basegfx::B2DPolyPolygon aPolyPolygon(rCandidate.getB2DPolyPolygon());
346 : :
347 [ # # ][ # # ]: 0 : if(aPolyPolygon.count())
348 : : {
349 : : // take care of wanted polygon type
350 [ # # ]: 0 : if(bToPoly)
351 : : {
352 [ # # ][ # # ]: 0 : if(aPolyPolygon.areControlPointsUsed())
353 : : {
354 [ # # ][ # # ]: 0 : aPolyPolygon = basegfx::tools::adaptiveSubdivideByAngle(aPolyPolygon);
[ # # ]
355 : : }
356 : : }
357 : : else
358 : : {
359 [ # # ][ # # ]: 0 : if(!aPolyPolygon.areControlPointsUsed())
360 : : {
361 [ # # ][ # # ]: 0 : aPolyPolygon = basegfx::tools::expandToCurve(aPolyPolygon);
[ # # ]
362 : : }
363 : : }
364 : :
365 : : // create ItemSet with object attributes
366 [ # # ][ # # ]: 0 : SfxItemSet aAttributeSet(GetObjectItemSet());
367 : 0 : SdrPathObj* pPathObj = 0;
368 : :
369 : : // always clear objectshadow; this is included in the extraction
370 [ # # ][ # # ]: 0 : aAttributeSet.Put(SdrShadowItem(false));
[ # # ]
371 : :
372 [ # # ]: 0 : if(rCandidate.getIsFilled())
373 : : {
374 : : // set needed items
375 [ # # ][ # # ]: 0 : aAttributeSet.Put(XFillColorItem(String(), Color(rCandidate.getBColor())));
[ # # ][ # # ]
[ # # ]
376 [ # # ][ # # ]: 0 : aAttributeSet.Put(XLineStyleItem(XLINE_NONE));
[ # # ]
377 [ # # ][ # # ]: 0 : aAttributeSet.Put(XFillStyleItem(XFILL_SOLID));
[ # # ]
378 : :
379 : : // create filled SdrPathObj
380 [ # # ][ # # ]: 0 : pPathObj = new SdrPathObj(OBJ_PATHFILL, aPolyPolygon);
381 : : }
382 : : else
383 : : {
384 : : // set needed items
385 [ # # ][ # # ]: 0 : aAttributeSet.Put(XLineColorItem(String(), Color(rCandidate.getBColor())));
[ # # ][ # # ]
[ # # ]
386 [ # # ][ # # ]: 0 : aAttributeSet.Put(XLineStyleItem(XLINE_SOLID));
[ # # ]
387 [ # # ][ # # ]: 0 : aAttributeSet.Put(XLineWidthItem(0));
[ # # ]
388 [ # # ][ # # ]: 0 : aAttributeSet.Put(XFillStyleItem(XFILL_NONE));
[ # # ]
389 : :
390 : : // create line SdrPathObj
391 [ # # ][ # # ]: 0 : pPathObj = new SdrPathObj(OBJ_PATHLINE, aPolyPolygon);
392 : : }
393 : :
394 : : // copy basic information from original
395 [ # # ][ # # ]: 0 : pPathObj->ImpSetAnchorPos(GetAnchorPos());
396 [ # # ][ # # ]: 0 : pPathObj->NbcSetLayer(GetLayer());
397 : :
398 [ # # ][ # # ]: 0 : if(GetModel())
399 : : {
400 [ # # ][ # # ]: 0 : pPathObj->SetModel(GetModel());
401 [ # # ][ # # ]: 0 : pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
402 : : }
403 : :
404 : : // apply prepared ItemSet and add to target
405 [ # # ]: 0 : pPathObj->SetMergedItemSet(aAttributeSet);
406 [ # # ][ # # ]: 0 : pObjectList->InsertObject(pPathObj);
407 : : }
408 [ # # ]: 0 : }
409 : :
410 : : // postprocess; if no result and/or only one object, simplify
411 [ # # ][ # # ]: 0 : if(!pObjectList->GetObjCount())
412 : : {
413 [ # # ][ # # ]: 0 : delete pGroup;
414 : : }
415 [ # # ][ # # ]: 0 : else if(1 == pObjectList->GetObjCount())
416 : : {
417 [ # # ]: 0 : pRetval = pObjectList->RemoveObject(0);
418 [ # # ][ # # ]: 0 : delete pGroup;
419 : : }
420 : : else
421 : : {
422 : 0 : pRetval = pGroup;
423 : : }
424 [ + - ][ + - ]: 40 : }
425 : : }
426 : :
427 [ + - ]: 40 : return pRetval;
428 : : }
429 : :
430 : : //////////////////////////////////////////////////////////////////////////////
431 : :
432 : 0 : SdrObject* SdrTextObj::DoConvertToPolyObj(sal_Bool bBezier) const
433 : : {
434 : 0 : return ImpConvertContainedTextToSdrPathObjs(!bBezier);
435 : : }
436 : :
437 : 80 : bool SdrTextObj::ImpCanConvTextToCurve() const
438 : : {
439 : 80 : return !IsOutlText();
440 : : }
441 : :
442 : 40 : SdrObject* SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPolygon, sal_Bool bClosed, sal_Bool bBezier, sal_Bool bNoSetAttr) const
443 : : {
444 [ + + ]: 40 : SdrObjKind ePathKind = bClosed ? OBJ_PATHFILL : OBJ_PATHLINE;
445 [ + - ]: 40 : basegfx::B2DPolyPolygon aB2DPolyPolygon(rPolyPolygon);
446 : :
447 : : // #i37011#
448 [ - + ]: 40 : if(!bBezier)
449 : : {
450 [ # # ][ # # ]: 0 : aB2DPolyPolygon = basegfx::tools::adaptiveSubdivideByAngle(aB2DPolyPolygon);
[ # # ]
451 [ # # ]: 0 : ePathKind = bClosed ? OBJ_POLY : OBJ_PLIN;
452 : : }
453 : :
454 [ + - ][ + - ]: 40 : SdrPathObj* pPathObj = new SdrPathObj(ePathKind, aB2DPolyPolygon);
455 : :
456 [ + - ]: 40 : if(bBezier)
457 : : {
458 : : // create bezier curves
459 [ + - ][ + - ]: 40 : pPathObj->SetPathPoly(basegfx::tools::expandToCurve(pPathObj->GetPathPoly()));
[ + - ]
460 : : }
461 : :
462 [ + - ]: 40 : if(pPathObj)
463 : : {
464 [ + - ]: 40 : pPathObj->ImpSetAnchorPos(aAnchor);
465 [ + - ][ + - ]: 40 : pPathObj->NbcSetLayer(SdrLayerID(GetLayer()));
466 : :
467 [ + - ]: 40 : if(pModel)
468 : : {
469 [ + - ]: 40 : pPathObj->SetModel(pModel);
470 : :
471 [ + - ]: 40 : if(!bNoSetAttr)
472 : : {
473 [ + - ]: 40 : sdr::properties::ItemChangeBroadcaster aC(*pPathObj);
474 : :
475 [ + - ]: 40 : pPathObj->ClearMergedItem();
476 [ + - ][ + - ]: 40 : pPathObj->SetMergedItemSet(GetObjectItemSet());
477 [ + - ][ + - ]: 40 : pPathObj->GetProperties().BroadcastItemChange(aC);
478 [ + - ][ + - ]: 40 : pPathObj->NbcSetStyleSheet(GetStyleSheet(), sal_True);
[ + - ]
479 : : }
480 : : }
481 : : }
482 : :
483 [ + - ]: 40 : return pPathObj;
484 : : }
485 : :
486 : 40 : SdrObject* SdrTextObj::ImpConvertAddText(SdrObject* pObj, bool bBezier) const
487 : : {
488 [ - + ]: 40 : if(!ImpCanConvTextToCurve())
489 : : {
490 : 0 : return pObj;
491 : : }
492 : :
493 : 40 : SdrObject* pText = ImpConvertContainedTextToSdrPathObjs(!bBezier);
494 : :
495 [ + - ]: 40 : if(!pText)
496 : : {
497 : 40 : return pObj;
498 : : }
499 : :
500 [ # # ]: 0 : if(!pObj)
501 : : {
502 : 0 : return pText;
503 : : }
504 : :
505 [ # # ]: 0 : if(pText->IsGroupObject())
506 : : {
507 : : // is already group object, add partial shape in front
508 : 0 : SdrObjList* pOL=pText->GetSubList();
509 : 0 : pOL->InsertObject(pObj,0);
510 : :
511 : 0 : return pText;
512 : : }
513 : : else
514 : : {
515 : : // not yet a group, create one and add partial and new shapes
516 [ # # ]: 0 : SdrObjGroup* pGrp=new SdrObjGroup;
517 : 0 : SdrObjList* pOL=pGrp->GetSubList();
518 : 0 : pOL->InsertObject(pObj);
519 : 0 : pOL->InsertObject(pText);
520 : :
521 : 40 : return pGrp;
522 : : }
523 : : }
524 : :
525 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|