Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <svx/svdorect.hxx>
21 : #include <math.h>
22 : #include <stdlib.h>
23 : #include <svx/xpool.hxx>
24 : #include <svx/xpoly.hxx>
25 : #include <svx/svdattr.hxx>
26 : #include <svx/svdpool.hxx>
27 : #include <svx/svdtrans.hxx>
28 : #include <svx/svdetc.hxx>
29 : #include <svx/svddrag.hxx>
30 : #include <svx/svdmodel.hxx>
31 : #include <svx/svdpage.hxx>
32 : #include <svx/svdocapt.hxx>
33 : #include <svx/svdpagv.hxx>
34 : #include <svx/svdview.hxx>
35 : #include <svx/svdundo.hxx>
36 : #include <svx/svdopath.hxx>
37 : #include "svx/svdglob.hxx"
38 : #include "svx/svdstr.hrc"
39 : #include <svx/xflclit.hxx>
40 : #include <svx/xlnclit.hxx>
41 : #include <svx/xlnwtit.hxx>
42 : #include <svx/sdr/properties/rectangleproperties.hxx>
43 : #include <svx/sdr/contact/viewcontactofsdrrectobj.hxx>
44 : #include <basegfx/polygon/b2dpolygon.hxx>
45 : #include <basegfx/polygon/b2dpolygontools.hxx>
46 :
47 :
48 : // BaseProperties section
49 :
50 23522 : sdr::properties::BaseProperties* SdrRectObj::CreateObjectSpecificProperties()
51 : {
52 23522 : return new sdr::properties::RectangleProperties(*this);
53 : }
54 :
55 :
56 : // DrawContact section
57 :
58 23207 : sdr::contact::ViewContact* SdrRectObj::CreateObjectSpecificViewContact()
59 : {
60 23207 : return new sdr::contact::ViewContactOfSdrRectObj(*this);
61 : }
62 :
63 :
64 :
65 2368402 : TYPEINIT1(SdrRectObj,SdrTextObj);
66 :
67 8397 : SdrRectObj::SdrRectObj()
68 8397 : : mpXPoly(0L)
69 : {
70 8397 : bClosedObj=true;
71 8397 : }
72 :
73 108 : SdrRectObj::SdrRectObj(const Rectangle& rRect)
74 : : SdrTextObj(rRect),
75 108 : mpXPoly(NULL)
76 : {
77 108 : bClosedObj=true;
78 108 : }
79 :
80 15946 : SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind)
81 : : SdrTextObj(eNewTextKind),
82 15946 : mpXPoly(NULL)
83 : {
84 : DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT ||
85 : eTextKind==OBJ_OUTLINETEXT || eTextKind==OBJ_TITLETEXT,
86 : "SdrRectObj::SdrRectObj(SdrObjKind) can only be applied to text frames.");
87 15946 : bClosedObj=true;
88 15946 : }
89 :
90 98 : SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind, const Rectangle& rRect)
91 : : SdrTextObj(eNewTextKind,rRect),
92 98 : mpXPoly(NULL)
93 : {
94 : DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT ||
95 : eTextKind==OBJ_OUTLINETEXT || eTextKind==OBJ_TITLETEXT,
96 : "SdrRectObj::SdrRectObj(SdrObjKind,...) can only be applied to text frames.");
97 98 : bClosedObj=true;
98 98 : }
99 :
100 63033 : SdrRectObj::~SdrRectObj()
101 : {
102 21386 : delete mpXPoly;
103 41647 : }
104 :
105 34 : SdrRectObj& SdrRectObj::operator=(const SdrRectObj& rCopy)
106 : {
107 34 : if ( this == &rCopy )
108 0 : return *this;
109 :
110 34 : SdrTextObj::operator=( rCopy );
111 :
112 34 : delete mpXPoly;
113 :
114 34 : if ( rCopy.mpXPoly )
115 2 : mpXPoly = new XPolygon( *rCopy.mpXPoly );
116 : else
117 32 : mpXPoly = NULL;
118 :
119 34 : return *this;
120 : }
121 :
122 361621 : void SdrRectObj::SetXPolyDirty()
123 : {
124 361621 : delete mpXPoly;
125 361621 : mpXPoly = 0L;
126 361621 : }
127 :
128 6 : XPolygon SdrRectObj::ImpCalcXPoly(const Rectangle& rRect1, long nRad1) const
129 : {
130 6 : XPolygon aXPoly(rRect1,nRad1,nRad1);
131 6 : const sal_uInt16 nPointAnz(aXPoly.GetPointCount());
132 12 : XPolygon aNeuPoly(nPointAnz+1);
133 6 : sal_uInt16 nShift=nPointAnz-2;
134 6 : if (nRad1!=0) nShift=nPointAnz-5;
135 6 : sal_uInt16 j=nShift;
136 54 : for (sal_uInt16 i=1; i<nPointAnz; i++) {
137 48 : aNeuPoly[i]=aXPoly[j];
138 48 : aNeuPoly.SetFlags(i,aXPoly.GetFlags(j));
139 48 : j++;
140 48 : if (j>=nPointAnz) j=1;
141 : }
142 6 : aNeuPoly[0]=rRect1.BottomCenter();
143 6 : aNeuPoly[nPointAnz]=aNeuPoly[0];
144 6 : aXPoly=aNeuPoly;
145 :
146 : // these angles always relate to the top left corner of aRect
147 6 : if (aGeo.nShearWink!=0) ShearXPoly(aXPoly,aRect.TopLeft(),aGeo.nTan);
148 6 : if (aGeo.nDrehWink!=0) RotateXPoly(aXPoly,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
149 12 : return aXPoly;
150 : }
151 :
152 2 : void SdrRectObj::RecalcXPoly()
153 : {
154 2 : delete mpXPoly;
155 2 : mpXPoly = new XPolygon(ImpCalcXPoly(aRect,GetEckenradius()));
156 2 : }
157 :
158 14 : const XPolygon& SdrRectObj::GetXPoly() const
159 : {
160 14 : if(!mpXPoly)
161 : {
162 13 : ((SdrRectObj*)this)->RecalcXPoly();
163 : }
164 :
165 14 : return *mpXPoly;
166 : }
167 :
168 7 : void SdrRectObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
169 : {
170 7 : bool bNoTextFrame=!IsTextFrame();
171 7 : rInfo.bResizeFreeAllowed=bNoTextFrame || aGeo.nDrehWink%9000==0;
172 7 : rInfo.bResizePropAllowed=true;
173 7 : rInfo.bRotateFreeAllowed=true;
174 7 : rInfo.bRotate90Allowed =true;
175 7 : rInfo.bMirrorFreeAllowed=bNoTextFrame;
176 7 : rInfo.bMirror45Allowed =bNoTextFrame;
177 7 : rInfo.bMirror90Allowed =bNoTextFrame;
178 :
179 : // allow transparency
180 7 : rInfo.bTransparenceAllowed = true;
181 :
182 : // gradient depends on fillstyle
183 7 : XFillStyle eFillStyle = ((XFillStyleItem&)(GetObjectItem(XATTR_FILLSTYLE))).GetValue();
184 7 : rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT);
185 :
186 7 : rInfo.bShearAllowed =bNoTextFrame;
187 7 : rInfo.bEdgeRadiusAllowed=true;
188 :
189 7 : bool bCanConv=!HasText() || ImpCanConvTextToCurve();
190 7 : if (bCanConv && !bNoTextFrame && !HasText()) {
191 0 : bCanConv=HasFill() || HasLine();
192 : }
193 7 : rInfo.bCanConvToPath =bCanConv;
194 7 : rInfo.bCanConvToPoly =bCanConv;
195 7 : rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
196 7 : }
197 :
198 316773 : sal_uInt16 SdrRectObj::GetObjIdentifier() const
199 : {
200 316773 : if (IsTextFrame()) return sal_uInt16(eTextKind);
201 95369 : else return sal_uInt16(OBJ_RECT);
202 : }
203 :
204 0 : void SdrRectObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
205 : {
206 0 : rRect=aRect;
207 0 : if (aGeo.nShearWink!=0) {
208 0 : long nDst=Round((aRect.Bottom()-aRect.Top())*aGeo.nTan);
209 0 : if (aGeo.nShearWink>0) {
210 0 : Point aRef(rRect.TopLeft());
211 0 : rRect.Left()-=nDst;
212 0 : Point aTmpPt(rRect.TopLeft());
213 0 : RotatePoint(aTmpPt,aRef,aGeo.nSin,aGeo.nCos);
214 0 : aTmpPt-=rRect.TopLeft();
215 0 : rRect.Move(aTmpPt.X(),aTmpPt.Y());
216 : } else {
217 0 : rRect.Right()-=nDst;
218 : }
219 : }
220 0 : }
221 :
222 200 : OUString SdrRectObj::TakeObjNameSingul() const
223 : {
224 200 : if (IsTextFrame())
225 : {
226 194 : return SdrTextObj::TakeObjNameSingul();
227 : }
228 :
229 6 : OUStringBuffer sName;
230 :
231 6 : sal_uInt16 nResId=STR_ObjNameSingulRECT;
232 6 : if (aGeo.nShearWink!=0) {
233 0 : nResId+=4; // parallelogram or, maybe, rhombus
234 : } else {
235 6 : if (aRect.GetWidth()==aRect.GetHeight()) nResId+=2; // square
236 : }
237 6 : if (GetEckenradius()!=0) nResId+=8; // rounded down
238 6 : sName.append(ImpGetResStr(nResId));
239 :
240 12 : OUString aName(GetName());
241 6 : if (!aName.isEmpty())
242 : {
243 0 : sName.append(' ');
244 0 : sName.append('\'');
245 0 : sName.append(aName);
246 0 : sName.append('\'');
247 : }
248 :
249 12 : return sName.makeStringAndClear();
250 : }
251 :
252 4 : OUString SdrRectObj::TakeObjNamePlural() const
253 : {
254 4 : if (IsTextFrame())
255 : {
256 0 : return SdrTextObj::TakeObjNamePlural();
257 : }
258 :
259 4 : sal_uInt16 nResId=STR_ObjNamePluralRECT;
260 :
261 4 : if (aGeo.nShearWink!=0)
262 : {
263 0 : nResId+=4; // parallelogram or rhombus
264 : }
265 : else
266 : {
267 4 : if (aRect.GetWidth()==aRect.GetHeight())
268 0 : nResId+=2; // square
269 : }
270 :
271 4 : if (GetEckenradius()!=0)
272 0 : nResId+=8; // rounded down
273 :
274 4 : return ImpGetResStr(nResId);
275 : }
276 :
277 3 : SdrRectObj* SdrRectObj::Clone() const
278 : {
279 3 : return CloneHelper< SdrRectObj >();
280 : }
281 :
282 0 : basegfx::B2DPolyPolygon SdrRectObj::TakeXorPoly() const
283 : {
284 0 : XPolyPolygon aXPP;
285 0 : aXPP.Insert(ImpCalcXPoly(aRect,GetEckenradius()));
286 0 : return aXPP.getB2DPolyPolygon();
287 : }
288 :
289 29926 : void SdrRectObj::RecalcSnapRect()
290 : {
291 29926 : long nEckRad=GetEckenradius();
292 29926 : if ((aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) && nEckRad!=0) {
293 2 : maSnapRect=GetXPoly().GetBoundRect();
294 : } else {
295 29924 : SdrTextObj::RecalcSnapRect();
296 : }
297 29926 : }
298 :
299 40840 : void SdrRectObj::NbcSetSnapRect(const Rectangle& rRect)
300 : {
301 40840 : SdrTextObj::NbcSetSnapRect(rRect);
302 40840 : SetXPolyDirty();
303 40840 : }
304 :
305 36945 : void SdrRectObj::NbcSetLogicRect(const Rectangle& rRect)
306 : {
307 36945 : SdrTextObj::NbcSetLogicRect(rRect);
308 36945 : SetXPolyDirty();
309 36945 : }
310 :
311 12 : sal_uInt32 SdrRectObj::GetHdlCount() const
312 : {
313 12 : return IsTextFrame() ? 10 : 9;
314 : }
315 :
316 108 : SdrHdl* SdrRectObj::GetHdl(sal_uInt32 nHdlNum) const
317 : {
318 108 : SdrHdl* pH = NULL;
319 108 : Point aPnt;
320 108 : SdrHdlKind eKind = HDL_MOVE;
321 :
322 108 : if(!IsTextFrame())
323 : {
324 108 : nHdlNum++;
325 : }
326 :
327 108 : switch(nHdlNum)
328 : {
329 : case 0:
330 : {
331 : OSL_ENSURE(!IsTextEditActive(), "Do not use a ImpTextframeHdl for hilighting text in active text edit, this will collide with EditEngine paints (!)");
332 : // hack for calc grid sync to ensure the hatched area
333 : // for a textbox is displayed at correct position
334 0 : pH = new ImpTextframeHdl(aRect + GetGridOffset() );
335 0 : pH->SetObj((SdrObject*)this);
336 0 : pH->SetDrehWink(aGeo.nDrehWink);
337 0 : break;
338 : }
339 : case 1:
340 : {
341 12 : long a = GetEckenradius();
342 12 : long b = std::max(aRect.GetWidth(),aRect.GetHeight())/2; // rounded up, because GetWidth() adds 1
343 12 : if (a>b) a=b;
344 12 : if (a<0) a=0;
345 12 : aPnt=aRect.TopLeft();
346 12 : aPnt.X()+=a;
347 12 : eKind = HDL_CIRC;
348 12 : break;
349 : }
350 12 : case 2: aPnt=aRect.TopLeft(); eKind = HDL_UPLFT; break;
351 12 : case 3: aPnt=aRect.TopCenter(); eKind = HDL_UPPER; break;
352 12 : case 4: aPnt=aRect.TopRight(); eKind = HDL_UPRGT; break;
353 12 : case 5: aPnt=aRect.LeftCenter(); eKind = HDL_LEFT ; break;
354 12 : case 6: aPnt=aRect.RightCenter(); eKind = HDL_RIGHT; break;
355 12 : case 7: aPnt=aRect.BottomLeft(); eKind = HDL_LWLFT; break;
356 12 : case 8: aPnt=aRect.BottomCenter(); eKind = HDL_LOWER; break;
357 12 : case 9: aPnt=aRect.BottomRight(); eKind = HDL_LWRGT; break;
358 : }
359 :
360 108 : if(!pH)
361 : {
362 108 : if(aGeo.nShearWink)
363 : {
364 0 : ShearPoint(aPnt,aRect.TopLeft(),aGeo.nTan);
365 : }
366 :
367 108 : if(aGeo.nDrehWink)
368 : {
369 0 : RotatePoint(aPnt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
370 : }
371 :
372 108 : pH = new SdrHdl(aPnt,eKind);
373 108 : pH->SetObj((SdrObject*)this);
374 108 : pH->SetDrehWink(aGeo.nDrehWink);
375 : }
376 :
377 108 : return pH;
378 : }
379 :
380 :
381 :
382 113 : bool SdrRectObj::hasSpecialDrag() const
383 : {
384 113 : return true;
385 : }
386 :
387 0 : bool SdrRectObj::beginSpecialDrag(SdrDragStat& rDrag) const
388 : {
389 0 : const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind());
390 :
391 0 : if(bRad)
392 : {
393 0 : rDrag.SetEndDragChangesAttributes(true);
394 :
395 0 : return true;
396 : }
397 :
398 0 : return SdrTextObj::beginSpecialDrag(rDrag);
399 : }
400 :
401 0 : bool SdrRectObj::applySpecialDrag(SdrDragStat& rDrag)
402 : {
403 0 : const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind());
404 :
405 0 : if (bRad)
406 : {
407 0 : Point aPt(rDrag.GetNow());
408 :
409 0 : if(aGeo.nDrehWink)
410 0 : RotatePoint(aPt,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos);
411 :
412 0 : sal_Int32 nRad(aPt.X() - aRect.Left());
413 :
414 0 : if (nRad < 0)
415 0 : nRad = 0;
416 :
417 0 : if(nRad != GetEckenradius())
418 : {
419 0 : NbcSetEckenradius(nRad);
420 : }
421 :
422 0 : return true;
423 : }
424 : else
425 : {
426 0 : return SdrTextObj::applySpecialDrag(rDrag);
427 : }
428 : }
429 :
430 0 : OUString SdrRectObj::getSpecialDragComment(const SdrDragStat& rDrag) const
431 : {
432 0 : const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj());
433 :
434 0 : if(bCreateComment)
435 : {
436 0 : return OUString();
437 : }
438 : else
439 : {
440 0 : const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind());
441 :
442 0 : if(bRad)
443 : {
444 0 : Point aPt(rDrag.GetNow());
445 :
446 : // -sin for reversal
447 0 : if(aGeo.nDrehWink)
448 0 : RotatePoint(aPt, aRect.TopLeft(), -aGeo.nSin, aGeo.nCos);
449 :
450 0 : sal_Int32 nRad(aPt.X() - aRect.Left());
451 :
452 0 : if(nRad < 0)
453 0 : nRad = 0;
454 :
455 0 : OUString aStr;
456 0 : ImpTakeDescriptionStr(STR_DragRectEckRad, aStr);
457 0 : OUStringBuffer aBuf(aStr);
458 0 : aBuf.appendAscii(" (");
459 0 : aBuf.append(GetMetrStr(nRad));
460 0 : aBuf.append(')');
461 :
462 0 : return aBuf.makeStringAndClear();
463 : }
464 : else
465 : {
466 0 : return SdrTextObj::getSpecialDragComment(rDrag);
467 : }
468 : }
469 : }
470 :
471 :
472 :
473 0 : basegfx::B2DPolyPolygon SdrRectObj::TakeCreatePoly(const SdrDragStat& rDrag) const
474 : {
475 0 : Rectangle aRect1;
476 0 : rDrag.TakeCreateRect(aRect1);
477 0 : aRect1.Justify();
478 :
479 0 : basegfx::B2DPolyPolygon aRetval;
480 0 : aRetval.append(ImpCalcXPoly(aRect1,GetEckenradius()).getB2DPolygon());
481 0 : return aRetval;
482 : }
483 :
484 357 : Pointer SdrRectObj::GetCreatePointer() const
485 : {
486 357 : if (IsTextFrame()) return Pointer(POINTER_DRAW_TEXT);
487 357 : return Pointer(POINTER_DRAW_RECT);
488 : }
489 :
490 36922 : void SdrRectObj::NbcMove(const Size& rSiz)
491 : {
492 36922 : SdrTextObj::NbcMove(rSiz);
493 36922 : SetXPolyDirty();
494 36922 : }
495 :
496 24 : void SdrRectObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
497 : {
498 24 : SdrTextObj::NbcResize(rRef,xFact,yFact);
499 24 : SetXPolyDirty();
500 24 : }
501 :
502 480 : void SdrRectObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
503 : {
504 480 : SdrTextObj::NbcRotate(rRef,nWink,sn,cs);
505 480 : SetXPolyDirty();
506 480 : }
507 :
508 0 : void SdrRectObj::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
509 : {
510 0 : SdrTextObj::NbcShear(rRef,nWink,tn,bVShear);
511 0 : SetXPolyDirty();
512 0 : }
513 :
514 2 : void SdrRectObj::NbcMirror(const Point& rRef1, const Point& rRef2)
515 : {
516 2 : SdrTextObj::NbcMirror(rRef1,rRef2);
517 2 : SetXPolyDirty();
518 2 : }
519 :
520 0 : bool SdrRectObj::DoMacro(const SdrObjMacroHitRec& rRec)
521 : {
522 0 : return SdrTextObj::DoMacro(rRec);
523 : }
524 :
525 0 : OUString SdrRectObj::GetMacroPopupComment(const SdrObjMacroHitRec& rRec) const
526 : {
527 0 : return SdrTextObj::GetMacroPopupComment(rRec);
528 : }
529 :
530 224 : SdrGluePoint SdrRectObj::GetVertexGluePoint(sal_uInt16 nPosNum) const
531 : {
532 224 : sal_Int32 nWdt = ImpGetLineWdt(); // #i25616#
533 :
534 : // #i25616#
535 224 : if(!LineIsOutsideGeometry())
536 : {
537 220 : nWdt++;
538 220 : nWdt /= 2;
539 : }
540 :
541 224 : Point aPt;
542 224 : switch (nPosNum) {
543 56 : case 0: aPt=aRect.TopCenter(); aPt.Y()-=nWdt; break;
544 56 : case 1: aPt=aRect.RightCenter(); aPt.X()+=nWdt; break;
545 56 : case 2: aPt=aRect.BottomCenter(); aPt.Y()+=nWdt; break;
546 56 : case 3: aPt=aRect.LeftCenter(); aPt.X()-=nWdt; break;
547 : }
548 224 : if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),aGeo.nTan);
549 224 : if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
550 224 : aPt-=GetSnapRect().Center();
551 224 : SdrGluePoint aGP(aPt);
552 224 : aGP.SetPercent(false);
553 224 : return aGP;
554 : }
555 :
556 0 : SdrGluePoint SdrRectObj::GetCornerGluePoint(sal_uInt16 nPosNum) const
557 : {
558 0 : sal_Int32 nWdt = ImpGetLineWdt(); // #i25616#
559 :
560 : // #i25616#
561 0 : if(!LineIsOutsideGeometry())
562 : {
563 0 : nWdt++;
564 0 : nWdt /= 2;
565 : }
566 :
567 0 : Point aPt;
568 0 : switch (nPosNum) {
569 0 : case 0: aPt=aRect.TopLeft(); aPt.X()-=nWdt; aPt.Y()-=nWdt; break;
570 0 : case 1: aPt=aRect.TopRight(); aPt.X()+=nWdt; aPt.Y()-=nWdt; break;
571 0 : case 2: aPt=aRect.BottomRight(); aPt.X()+=nWdt; aPt.Y()+=nWdt; break;
572 0 : case 3: aPt=aRect.BottomLeft(); aPt.X()-=nWdt; aPt.Y()+=nWdt; break;
573 : }
574 0 : if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),aGeo.nTan);
575 0 : if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
576 0 : aPt-=GetSnapRect().Center();
577 0 : SdrGluePoint aGP(aPt);
578 0 : aGP.SetPercent(false);
579 0 : return aGP;
580 : }
581 :
582 4 : SdrObject* SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
583 : {
584 4 : XPolygon aXP(ImpCalcXPoly(aRect,GetEckenradius()));
585 : { // TODO: this is only for the moment, until we have the new TakeContour()
586 4 : aXP.Remove(0,1);
587 4 : aXP[aXP.GetPointCount()-1]=aXP[0];
588 : }
589 :
590 8 : basegfx::B2DPolyPolygon aPolyPolygon(aXP.getB2DPolygon());
591 4 : aPolyPolygon.removeDoublePoints();
592 4 : SdrObject* pRet = 0L;
593 :
594 : // small correction: Do not create something when no fill and no line. To
595 : // be sure to not damage something with non-text frames, do this only
596 : // when used with bAddText==false from other converters
597 4 : if((bAddText && !IsTextFrame()) || HasFill() || HasLine())
598 : {
599 4 : pRet = ImpConvertMakeObj(aPolyPolygon, true, bBezier);
600 : }
601 :
602 4 : if(bAddText)
603 : {
604 4 : pRet = ImpConvertAddText(pRet, bBezier);
605 : }
606 :
607 8 : return pRet;
608 : }
609 :
610 45172 : void SdrRectObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
611 : {
612 45172 : SdrTextObj::Notify(rBC,rHint);
613 45172 : SetXPolyDirty(); // because of the corner radius
614 45172 : }
615 :
616 0 : void SdrRectObj::RestGeoData(const SdrObjGeoData& rGeo)
617 : {
618 0 : SdrTextObj::RestGeoData(rGeo);
619 0 : SetXPolyDirty();
620 0 : }
621 :
622 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|