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 10cdf0e10cSrcweir * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 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/svdorect.hxx> 28cdf0e10cSrcweir #include <math.h> 29cdf0e10cSrcweir #include <stdlib.h> 30cdf0e10cSrcweir #include <svx/xpool.hxx> 31cdf0e10cSrcweir #include <svx/xpoly.hxx> 32cdf0e10cSrcweir #include <svx/svdattr.hxx> 33cdf0e10cSrcweir #include <svx/svdpool.hxx> 34cdf0e10cSrcweir #include <svx/svdtrans.hxx> 35cdf0e10cSrcweir #include <svx/svdetc.hxx> 36cdf0e10cSrcweir #include <svx/svddrag.hxx> 37cdf0e10cSrcweir #include <svx/svdmodel.hxx> 38cdf0e10cSrcweir #include <svx/svdpage.hxx> 39cdf0e10cSrcweir #include <svx/svdocapt.hxx> // fuer Import von SdrFileVersion 2 40cdf0e10cSrcweir #include <svx/svdpagv.hxx> // fuer 41cdf0e10cSrcweir #include <svx/svdview.hxx> // das 42cdf0e10cSrcweir #include <svx/svdundo.hxx> // Macro-Beispiel 43cdf0e10cSrcweir #include <svx/svdopath.hxx> 44cdf0e10cSrcweir #include "svx/svdglob.hxx" // Stringcache 45cdf0e10cSrcweir #include "svx/svdstr.hrc" // Objektname 46cdf0e10cSrcweir #include <svx/xflclit.hxx> 47cdf0e10cSrcweir #include <svx/xlnclit.hxx> 48cdf0e10cSrcweir #include <svx/xlnwtit.hxx> 49cdf0e10cSrcweir #include "svdoimp.hxx" 50cdf0e10cSrcweir #include <svx/sdr/properties/rectangleproperties.hxx> 51cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrrectobj.hxx> 52cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 53cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 54cdf0e10cSrcweir 55cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 56cdf0e10cSrcweir // BaseProperties section 57cdf0e10cSrcweir 58cdf0e10cSrcweir sdr::properties::BaseProperties* SdrRectObj::CreateObjectSpecificProperties() 59cdf0e10cSrcweir { 60cdf0e10cSrcweir return new sdr::properties::RectangleProperties(*this); 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 64cdf0e10cSrcweir // DrawContact section 65cdf0e10cSrcweir 66cdf0e10cSrcweir sdr::contact::ViewContact* SdrRectObj::CreateObjectSpecificViewContact() 67cdf0e10cSrcweir { 68cdf0e10cSrcweir return new sdr::contact::ViewContactOfSdrRectObj(*this); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 72cdf0e10cSrcweir 73cdf0e10cSrcweir TYPEINIT1(SdrRectObj,SdrTextObj); 74cdf0e10cSrcweir 75cdf0e10cSrcweir SdrRectObj::SdrRectObj() 76cdf0e10cSrcweir : mpXPoly(0L) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir bClosedObj=sal_True; 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir SdrRectObj::SdrRectObj(const Rectangle& rRect) 82cdf0e10cSrcweir : SdrTextObj(rRect), 83cdf0e10cSrcweir mpXPoly(NULL) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir bClosedObj=sal_True; 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind) 89cdf0e10cSrcweir : SdrTextObj(eNewTextKind), 90cdf0e10cSrcweir mpXPoly(NULL) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT || 93cdf0e10cSrcweir eTextKind==OBJ_OUTLINETEXT || eTextKind==OBJ_TITLETEXT, 94cdf0e10cSrcweir "SdrRectObj::SdrRectObj(SdrObjKind) ist nur fuer Textrahmen gedacht"); 95cdf0e10cSrcweir bClosedObj=sal_True; 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind, const Rectangle& rRect) 99cdf0e10cSrcweir : SdrTextObj(eNewTextKind,rRect), 100cdf0e10cSrcweir mpXPoly(NULL) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT || 103cdf0e10cSrcweir eTextKind==OBJ_OUTLINETEXT || eTextKind==OBJ_TITLETEXT, 104cdf0e10cSrcweir "SdrRectObj::SdrRectObj(SdrObjKind,...) ist nur fuer Textrahmen gedacht"); 105cdf0e10cSrcweir bClosedObj=sal_True; 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind, const Rectangle& rNewRect, SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat) 109cdf0e10cSrcweir : SdrTextObj(eNewTextKind,rNewRect,rInput,rBaseURL,eFormat), 110cdf0e10cSrcweir mpXPoly(NULL) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT || 113cdf0e10cSrcweir eTextKind==OBJ_OUTLINETEXT || eTextKind==OBJ_TITLETEXT, 114cdf0e10cSrcweir "SdrRectObj::SdrRectObj(SdrObjKind,...) ist nur fuer Textrahmen gedacht"); 115cdf0e10cSrcweir bClosedObj=sal_True; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir SdrRectObj::~SdrRectObj() 119cdf0e10cSrcweir { 120cdf0e10cSrcweir if(mpXPoly) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir delete mpXPoly; 123cdf0e10cSrcweir } 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir void SdrRectObj::SetXPolyDirty() 127cdf0e10cSrcweir { 128cdf0e10cSrcweir if(mpXPoly) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir delete mpXPoly; 131cdf0e10cSrcweir mpXPoly = 0L; 132cdf0e10cSrcweir } 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir FASTBOOL SdrRectObj::PaintNeedsXPoly(long nEckRad) const 136cdf0e10cSrcweir { 137cdf0e10cSrcweir FASTBOOL bNeed=aGeo.nDrehWink!=0 || aGeo.nShearWink!=0 || nEckRad!=0; 138cdf0e10cSrcweir return bNeed; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir XPolygon SdrRectObj::ImpCalcXPoly(const Rectangle& rRect1, long nRad1) const 142cdf0e10cSrcweir { 143cdf0e10cSrcweir XPolygon aXPoly(rRect1,nRad1,nRad1); 144cdf0e10cSrcweir const sal_uInt16 nPointAnz(aXPoly.GetPointCount()); 145cdf0e10cSrcweir XPolygon aNeuPoly(nPointAnz+1); 146cdf0e10cSrcweir sal_uInt16 nShift=nPointAnz-2; 147cdf0e10cSrcweir if (nRad1!=0) nShift=nPointAnz-5; 148cdf0e10cSrcweir sal_uInt16 j=nShift; 149cdf0e10cSrcweir for (sal_uInt16 i=1; i<nPointAnz; i++) { 150cdf0e10cSrcweir aNeuPoly[i]=aXPoly[j]; 151cdf0e10cSrcweir aNeuPoly.SetFlags(i,aXPoly.GetFlags(j)); 152cdf0e10cSrcweir j++; 153cdf0e10cSrcweir if (j>=nPointAnz) j=1; 154cdf0e10cSrcweir } 155cdf0e10cSrcweir aNeuPoly[0]=rRect1.BottomCenter(); 156cdf0e10cSrcweir aNeuPoly[nPointAnz]=aNeuPoly[0]; 157cdf0e10cSrcweir aXPoly=aNeuPoly; 158cdf0e10cSrcweir 159cdf0e10cSrcweir // Die Winkelangaben beziehen sich immer auf die linke obere Ecke von !aRect! 160cdf0e10cSrcweir if (aGeo.nShearWink!=0) ShearXPoly(aXPoly,aRect.TopLeft(),aGeo.nTan); 161cdf0e10cSrcweir if (aGeo.nDrehWink!=0) RotateXPoly(aXPoly,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); 162cdf0e10cSrcweir return aXPoly; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir void SdrRectObj::RecalcXPoly() 166cdf0e10cSrcweir { 167cdf0e10cSrcweir mpXPoly = new XPolygon(ImpCalcXPoly(aRect,GetEckenradius())); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir const XPolygon& SdrRectObj::GetXPoly() const 171cdf0e10cSrcweir { 172cdf0e10cSrcweir if(!mpXPoly) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir ((SdrRectObj*)this)->RecalcXPoly(); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir return *mpXPoly; 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir void SdrRectObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const 181cdf0e10cSrcweir { 182cdf0e10cSrcweir FASTBOOL bNoTextFrame=!IsTextFrame(); 183cdf0e10cSrcweir rInfo.bResizeFreeAllowed=bNoTextFrame || aGeo.nDrehWink%9000==0; 184cdf0e10cSrcweir rInfo.bResizePropAllowed=sal_True; 185cdf0e10cSrcweir rInfo.bRotateFreeAllowed=sal_True; 186cdf0e10cSrcweir rInfo.bRotate90Allowed =sal_True; 187cdf0e10cSrcweir rInfo.bMirrorFreeAllowed=bNoTextFrame; 188cdf0e10cSrcweir rInfo.bMirror45Allowed =bNoTextFrame; 189cdf0e10cSrcweir rInfo.bMirror90Allowed =bNoTextFrame; 190cdf0e10cSrcweir 191cdf0e10cSrcweir // allow transparence 192cdf0e10cSrcweir rInfo.bTransparenceAllowed = sal_True; 193cdf0e10cSrcweir 194cdf0e10cSrcweir // gradient depends on fillstyle 195cdf0e10cSrcweir XFillStyle eFillStyle = ((XFillStyleItem&)(GetObjectItem(XATTR_FILLSTYLE))).GetValue(); 196cdf0e10cSrcweir rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT); 197cdf0e10cSrcweir 198cdf0e10cSrcweir rInfo.bShearAllowed =bNoTextFrame; 199cdf0e10cSrcweir rInfo.bEdgeRadiusAllowed=sal_True; 200cdf0e10cSrcweir 201cdf0e10cSrcweir FASTBOOL bCanConv=!HasText() || ImpCanConvTextToCurve(); 202cdf0e10cSrcweir if (bCanConv && !bNoTextFrame && !HasText()) { 203cdf0e10cSrcweir bCanConv=HasFill() || HasLine(); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir rInfo.bCanConvToPath =bCanConv; 206cdf0e10cSrcweir rInfo.bCanConvToPoly =bCanConv; 207cdf0e10cSrcweir rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary()); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir sal_uInt16 SdrRectObj::GetObjIdentifier() const 211cdf0e10cSrcweir { 212cdf0e10cSrcweir if (IsTextFrame()) return sal_uInt16(eTextKind); 213cdf0e10cSrcweir else return sal_uInt16(OBJ_RECT); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir void SdrRectObj::TakeUnrotatedSnapRect(Rectangle& rRect) const 217cdf0e10cSrcweir { 218cdf0e10cSrcweir rRect=aRect; 219cdf0e10cSrcweir if (aGeo.nShearWink!=0) { 220cdf0e10cSrcweir long nDst=Round((aRect.Bottom()-aRect.Top())*aGeo.nTan); 221cdf0e10cSrcweir if (aGeo.nShearWink>0) { 222cdf0e10cSrcweir Point aRef(rRect.TopLeft()); 223cdf0e10cSrcweir rRect.Left()-=nDst; 224cdf0e10cSrcweir Point aTmpPt(rRect.TopLeft()); 225cdf0e10cSrcweir RotatePoint(aTmpPt,aRef,aGeo.nSin,aGeo.nCos); 226cdf0e10cSrcweir aTmpPt-=rRect.TopLeft(); 227cdf0e10cSrcweir rRect.Move(aTmpPt.X(),aTmpPt.Y()); 228cdf0e10cSrcweir } else { 229cdf0e10cSrcweir rRect.Right()-=nDst; 230cdf0e10cSrcweir } 231cdf0e10cSrcweir } 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir void SdrRectObj::TakeObjNameSingul(XubString& rName) const 235cdf0e10cSrcweir { 236cdf0e10cSrcweir if (IsTextFrame()) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir SdrTextObj::TakeObjNameSingul(rName); 239cdf0e10cSrcweir } 240cdf0e10cSrcweir else 241cdf0e10cSrcweir { 242cdf0e10cSrcweir sal_uInt16 nResId=STR_ObjNameSingulRECT; 243cdf0e10cSrcweir if (aGeo.nShearWink!=0) { 244cdf0e10cSrcweir nResId+=4; // Parallelogramm oder Raute 245cdf0e10cSrcweir // Raute ist nicht, weil Shear die vertikalen Kanten verlaengert! 246cdf0e10cSrcweir // Wenn Zeit ist, werde ich das mal berechnen. 247cdf0e10cSrcweir } else { 248cdf0e10cSrcweir if (aRect.GetWidth()==aRect.GetHeight()) nResId+=2; // Quadrat 249cdf0e10cSrcweir } 250cdf0e10cSrcweir if (GetEckenradius()!=0) nResId+=8; // abgerundet 251cdf0e10cSrcweir rName=ImpGetResStr(nResId); 252cdf0e10cSrcweir 253cdf0e10cSrcweir String aName( GetName() ); 254cdf0e10cSrcweir if(aName.Len()) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir rName += sal_Unicode(' '); 257cdf0e10cSrcweir rName += sal_Unicode('\''); 258cdf0e10cSrcweir rName += aName; 259cdf0e10cSrcweir rName += sal_Unicode('\''); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir } 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir void SdrRectObj::TakeObjNamePlural(XubString& rName) const 265cdf0e10cSrcweir { 266cdf0e10cSrcweir if (IsTextFrame()) SdrTextObj::TakeObjNamePlural(rName); 267cdf0e10cSrcweir else { 268cdf0e10cSrcweir sal_uInt16 nResId=STR_ObjNamePluralRECT; 269cdf0e10cSrcweir if (aGeo.nShearWink!=0) { 270cdf0e10cSrcweir nResId+=4; // Parallelogramm oder Raute 271cdf0e10cSrcweir } else { 272cdf0e10cSrcweir if (aRect.GetWidth()==aRect.GetHeight()) nResId+=2; // Quadrat 273cdf0e10cSrcweir } 274cdf0e10cSrcweir if (GetEckenradius()!=0) nResId+=8; // abgerundet 275cdf0e10cSrcweir rName=ImpGetResStr(nResId); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir } 278cdf0e10cSrcweir 279cdf0e10cSrcweir void SdrRectObj::operator=(const SdrObject& rObj) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir SdrTextObj::operator=(rObj); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir 284cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrRectObj::TakeXorPoly() const 285cdf0e10cSrcweir { 286cdf0e10cSrcweir XPolyPolygon aXPP; 287cdf0e10cSrcweir aXPP.Insert(ImpCalcXPoly(aRect,GetEckenradius())); 288cdf0e10cSrcweir return aXPP.getB2DPolyPolygon(); 289cdf0e10cSrcweir } 290cdf0e10cSrcweir 291cdf0e10cSrcweir void SdrRectObj::RecalcSnapRect() 292cdf0e10cSrcweir { 293cdf0e10cSrcweir long nEckRad=GetEckenradius(); 294cdf0e10cSrcweir if ((aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) && nEckRad!=0) { 295cdf0e10cSrcweir maSnapRect=GetXPoly().GetBoundRect(); 296cdf0e10cSrcweir } else { 297cdf0e10cSrcweir SdrTextObj::RecalcSnapRect(); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir void SdrRectObj::NbcSetSnapRect(const Rectangle& rRect) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir SdrTextObj::NbcSetSnapRect(rRect); 304cdf0e10cSrcweir SetXPolyDirty(); 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir void SdrRectObj::NbcSetLogicRect(const Rectangle& rRect) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir SdrTextObj::NbcSetLogicRect(rRect); 310cdf0e10cSrcweir SetXPolyDirty(); 311cdf0e10cSrcweir } 312cdf0e10cSrcweir 313cdf0e10cSrcweir sal_uInt32 SdrRectObj::GetHdlCount() const 314cdf0e10cSrcweir { 315cdf0e10cSrcweir return IsTextFrame() ? 10 : 9; 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir SdrHdl* SdrRectObj::GetHdl(sal_uInt32 nHdlNum) const 319cdf0e10cSrcweir { 320cdf0e10cSrcweir SdrHdl* pH = NULL; 321cdf0e10cSrcweir Point aPnt; 322cdf0e10cSrcweir SdrHdlKind eKind = HDL_MOVE; 323cdf0e10cSrcweir 324cdf0e10cSrcweir if(!IsTextFrame()) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir nHdlNum++; 327cdf0e10cSrcweir } 328cdf0e10cSrcweir 329cdf0e10cSrcweir switch(nHdlNum) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir case 0: 332cdf0e10cSrcweir { 333*d8a41635SArmin Le Grand OSL_ENSURE(!IsTextEditActive(), "Do not use a ImpTextframeHdl for hilighting text in active text edit, this will collide with EditEngine paints (!)"); 334cdf0e10cSrcweir pH = new ImpTextframeHdl(aRect); 335cdf0e10cSrcweir pH->SetObj((SdrObject*)this); 336cdf0e10cSrcweir pH->SetDrehWink(aGeo.nDrehWink); 337cdf0e10cSrcweir break; 338cdf0e10cSrcweir } 339cdf0e10cSrcweir case 1: 340cdf0e10cSrcweir { 341cdf0e10cSrcweir long a = GetEckenradius(); 342cdf0e10cSrcweir long b = Max(aRect.GetWidth(),aRect.GetHeight())/2; // Wird aufgerundet, da GetWidth() eins draufaddiert 343cdf0e10cSrcweir if (a>b) a=b; 344cdf0e10cSrcweir if (a<0) a=0; 345cdf0e10cSrcweir aPnt=aRect.TopLeft(); 346cdf0e10cSrcweir aPnt.X()+=a; 347cdf0e10cSrcweir eKind = HDL_CIRC; 348cdf0e10cSrcweir break; 349cdf0e10cSrcweir } 350cdf0e10cSrcweir case 2: aPnt=aRect.TopLeft(); eKind = HDL_UPLFT; break; // Oben links 351cdf0e10cSrcweir case 3: aPnt=aRect.TopCenter(); eKind = HDL_UPPER; break; // Oben 352cdf0e10cSrcweir case 4: aPnt=aRect.TopRight(); eKind = HDL_UPRGT; break; // Oben rechts 353cdf0e10cSrcweir case 5: aPnt=aRect.LeftCenter(); eKind = HDL_LEFT ; break; // Links 354cdf0e10cSrcweir case 6: aPnt=aRect.RightCenter(); eKind = HDL_RIGHT; break; // Rechts 355cdf0e10cSrcweir case 7: aPnt=aRect.BottomLeft(); eKind = HDL_LWLFT; break; // Unten links 356cdf0e10cSrcweir case 8: aPnt=aRect.BottomCenter(); eKind = HDL_LOWER; break; // Unten 357cdf0e10cSrcweir case 9: aPnt=aRect.BottomRight(); eKind = HDL_LWRGT; break; // Unten rechts 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir if(!pH) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir if(aGeo.nShearWink) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir ShearPoint(aPnt,aRect.TopLeft(),aGeo.nTan); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir if(aGeo.nDrehWink) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir RotatePoint(aPnt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir pH = new SdrHdl(aPnt,eKind); 373cdf0e10cSrcweir pH->SetObj((SdrObject*)this); 374cdf0e10cSrcweir pH->SetDrehWink(aGeo.nDrehWink); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir 377cdf0e10cSrcweir return pH; 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 381cdf0e10cSrcweir 382cdf0e10cSrcweir bool SdrRectObj::hasSpecialDrag() const 383cdf0e10cSrcweir { 384cdf0e10cSrcweir return true; 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir bool SdrRectObj::beginSpecialDrag(SdrDragStat& rDrag) const 388cdf0e10cSrcweir { 389cdf0e10cSrcweir const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); 390cdf0e10cSrcweir 391cdf0e10cSrcweir if(bRad) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir rDrag.SetEndDragChangesAttributes(true); 394cdf0e10cSrcweir 395cdf0e10cSrcweir return true; 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir return SdrTextObj::beginSpecialDrag(rDrag); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir bool SdrRectObj::applySpecialDrag(SdrDragStat& rDrag) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); 404cdf0e10cSrcweir 405cdf0e10cSrcweir if (bRad) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir Rectangle aBoundRect0; 408cdf0e10cSrcweir Point aPt(rDrag.GetNow()); 409cdf0e10cSrcweir 410cdf0e10cSrcweir if(aGeo.nDrehWink) 411cdf0e10cSrcweir RotatePoint(aPt,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos); 412cdf0e10cSrcweir 413cdf0e10cSrcweir sal_Int32 nRad(aPt.X() - aRect.Left()); 414cdf0e10cSrcweir 415cdf0e10cSrcweir if (nRad < 0) 416cdf0e10cSrcweir nRad = 0; 417cdf0e10cSrcweir 418cdf0e10cSrcweir if(nRad != GetEckenradius()) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir NbcSetEckenradius(nRad); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir return true; 424cdf0e10cSrcweir } 425cdf0e10cSrcweir else 426cdf0e10cSrcweir { 427cdf0e10cSrcweir return SdrTextObj::applySpecialDrag(rDrag); 428cdf0e10cSrcweir } 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir String SdrRectObj::getSpecialDragComment(const SdrDragStat& rDrag) const 432cdf0e10cSrcweir { 433cdf0e10cSrcweir const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj()); 434cdf0e10cSrcweir 435cdf0e10cSrcweir if(bCreateComment) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir return String(); 438cdf0e10cSrcweir } 439cdf0e10cSrcweir else 440cdf0e10cSrcweir { 441cdf0e10cSrcweir const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); 442cdf0e10cSrcweir 443cdf0e10cSrcweir if(bRad) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir Point aPt(rDrag.GetNow()); 446cdf0e10cSrcweir 447cdf0e10cSrcweir // -sin fuer Umkehrung 448cdf0e10cSrcweir if(aGeo.nDrehWink) 449cdf0e10cSrcweir RotatePoint(aPt, aRect.TopLeft(), -aGeo.nSin, aGeo.nCos); 450cdf0e10cSrcweir 451cdf0e10cSrcweir sal_Int32 nRad(aPt.X() - aRect.Left()); 452cdf0e10cSrcweir 453cdf0e10cSrcweir if(nRad < 0) 454cdf0e10cSrcweir nRad = 0; 455cdf0e10cSrcweir 456cdf0e10cSrcweir XubString aStr; 457cdf0e10cSrcweir 458cdf0e10cSrcweir ImpTakeDescriptionStr(STR_DragRectEckRad, aStr); 459cdf0e10cSrcweir aStr.AppendAscii(" ("); 460cdf0e10cSrcweir aStr += GetMetrStr(nRad); 461cdf0e10cSrcweir aStr += sal_Unicode(')'); 462cdf0e10cSrcweir 463cdf0e10cSrcweir return aStr; 464cdf0e10cSrcweir } 465cdf0e10cSrcweir else 466cdf0e10cSrcweir { 467cdf0e10cSrcweir return SdrTextObj::getSpecialDragComment(rDrag); 468cdf0e10cSrcweir } 469cdf0e10cSrcweir } 470cdf0e10cSrcweir } 471cdf0e10cSrcweir 472cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 473cdf0e10cSrcweir 474cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrRectObj::TakeCreatePoly(const SdrDragStat& rDrag) const 475cdf0e10cSrcweir { 476cdf0e10cSrcweir Rectangle aRect1; 477cdf0e10cSrcweir rDrag.TakeCreateRect(aRect1); 478cdf0e10cSrcweir aRect1.Justify(); 479cdf0e10cSrcweir 480cdf0e10cSrcweir basegfx::B2DPolyPolygon aRetval; 481cdf0e10cSrcweir aRetval.append(ImpCalcXPoly(aRect1,GetEckenradius()).getB2DPolygon()); 482cdf0e10cSrcweir return aRetval; 483cdf0e10cSrcweir } 484cdf0e10cSrcweir 485cdf0e10cSrcweir Pointer SdrRectObj::GetCreatePointer() const 486cdf0e10cSrcweir { 487cdf0e10cSrcweir if (IsTextFrame()) return Pointer(POINTER_DRAW_TEXT); 488cdf0e10cSrcweir return Pointer(POINTER_DRAW_RECT); 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir void SdrRectObj::NbcMove(const Size& rSiz) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir SdrTextObj::NbcMove(rSiz); 494cdf0e10cSrcweir SetXPolyDirty(); 495cdf0e10cSrcweir } 496cdf0e10cSrcweir 497cdf0e10cSrcweir void SdrRectObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) 498cdf0e10cSrcweir { 499cdf0e10cSrcweir SdrTextObj::NbcResize(rRef,xFact,yFact); 500cdf0e10cSrcweir SetXPolyDirty(); 501cdf0e10cSrcweir } 502cdf0e10cSrcweir 503cdf0e10cSrcweir void SdrRectObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs) 504cdf0e10cSrcweir { 505cdf0e10cSrcweir SdrTextObj::NbcRotate(rRef,nWink,sn,cs); 506cdf0e10cSrcweir SetXPolyDirty(); 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir void SdrRectObj::NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir SdrTextObj::NbcShear(rRef,nWink,tn,bVShear); 512cdf0e10cSrcweir SetXPolyDirty(); 513cdf0e10cSrcweir } 514cdf0e10cSrcweir 515cdf0e10cSrcweir void SdrRectObj::NbcMirror(const Point& rRef1, const Point& rRef2) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir SdrTextObj::NbcMirror(rRef1,rRef2); 518cdf0e10cSrcweir SetXPolyDirty(); 519cdf0e10cSrcweir } 520cdf0e10cSrcweir 521cdf0e10cSrcweir FASTBOOL SdrRectObj::DoMacro(const SdrObjMacroHitRec& rRec) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir return SdrTextObj::DoMacro(rRec); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir XubString SdrRectObj::GetMacroPopupComment(const SdrObjMacroHitRec& rRec) const 527cdf0e10cSrcweir { 528cdf0e10cSrcweir return SdrTextObj::GetMacroPopupComment(rRec); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir 531cdf0e10cSrcweir SdrGluePoint SdrRectObj::GetVertexGluePoint(sal_uInt16 nPosNum) const 532cdf0e10cSrcweir { 533cdf0e10cSrcweir sal_Int32 nWdt = ImpGetLineWdt(); // #i25616# ((XLineWidthItem&)(GetObjectItem(XATTR_LINEWIDTH))).GetValue(); 534cdf0e10cSrcweir 535cdf0e10cSrcweir // #i25616# 536cdf0e10cSrcweir if(!LineIsOutsideGeometry()) 537cdf0e10cSrcweir { 538cdf0e10cSrcweir nWdt++; 539cdf0e10cSrcweir nWdt /= 2; 540cdf0e10cSrcweir } 541cdf0e10cSrcweir 542cdf0e10cSrcweir Point aPt; 543cdf0e10cSrcweir switch (nPosNum) { 544cdf0e10cSrcweir case 0: aPt=aRect.TopCenter(); aPt.Y()-=nWdt; break; 545cdf0e10cSrcweir case 1: aPt=aRect.RightCenter(); aPt.X()+=nWdt; break; 546cdf0e10cSrcweir case 2: aPt=aRect.BottomCenter(); aPt.Y()+=nWdt; break; 547cdf0e10cSrcweir case 3: aPt=aRect.LeftCenter(); aPt.X()-=nWdt; break; 548cdf0e10cSrcweir } 549cdf0e10cSrcweir if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),aGeo.nTan); 550cdf0e10cSrcweir if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); 551cdf0e10cSrcweir aPt-=GetSnapRect().Center(); 552cdf0e10cSrcweir SdrGluePoint aGP(aPt); 553cdf0e10cSrcweir aGP.SetPercent(sal_False); 554cdf0e10cSrcweir return aGP; 555cdf0e10cSrcweir } 556cdf0e10cSrcweir 557cdf0e10cSrcweir SdrGluePoint SdrRectObj::GetCornerGluePoint(sal_uInt16 nPosNum) const 558cdf0e10cSrcweir { 559cdf0e10cSrcweir sal_Int32 nWdt = ImpGetLineWdt(); // #i25616# ((XLineWidthItem&)(GetObjectItem(XATTR_LINEWIDTH))).GetValue(); 560cdf0e10cSrcweir 561cdf0e10cSrcweir // #i25616# 562cdf0e10cSrcweir if(!LineIsOutsideGeometry()) 563cdf0e10cSrcweir { 564cdf0e10cSrcweir nWdt++; 565cdf0e10cSrcweir nWdt /= 2; 566cdf0e10cSrcweir } 567cdf0e10cSrcweir 568cdf0e10cSrcweir Point aPt; 569cdf0e10cSrcweir switch (nPosNum) { 570cdf0e10cSrcweir case 0: aPt=aRect.TopLeft(); aPt.X()-=nWdt; aPt.Y()-=nWdt; break; 571cdf0e10cSrcweir case 1: aPt=aRect.TopRight(); aPt.X()+=nWdt; aPt.Y()-=nWdt; break; 572cdf0e10cSrcweir case 2: aPt=aRect.BottomRight(); aPt.X()+=nWdt; aPt.Y()+=nWdt; break; 573cdf0e10cSrcweir case 3: aPt=aRect.BottomLeft(); aPt.X()-=nWdt; aPt.Y()+=nWdt; break; 574cdf0e10cSrcweir } 575cdf0e10cSrcweir if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),aGeo.nTan); 576cdf0e10cSrcweir if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); 577cdf0e10cSrcweir aPt-=GetSnapRect().Center(); 578cdf0e10cSrcweir SdrGluePoint aGP(aPt); 579cdf0e10cSrcweir aGP.SetPercent(sal_False); 580cdf0e10cSrcweir return aGP; 581cdf0e10cSrcweir } 582cdf0e10cSrcweir 583a5258243SPedro Giffuni SdrObject* SdrRectObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const 584cdf0e10cSrcweir { 585cdf0e10cSrcweir XPolygon aXP(ImpCalcXPoly(aRect,GetEckenradius())); 586cdf0e10cSrcweir { // #40608# Nur Uebergangsweise bis zum neuen TakeContour() 587cdf0e10cSrcweir aXP.Remove(0,1); 588cdf0e10cSrcweir aXP[aXP.GetPointCount()-1]=aXP[0]; 589cdf0e10cSrcweir } 590cdf0e10cSrcweir 591cdf0e10cSrcweir basegfx::B2DPolyPolygon aPolyPolygon(aXP.getB2DPolygon()); 592cdf0e10cSrcweir aPolyPolygon.removeDoublePoints(); 593cdf0e10cSrcweir SdrObject* pRet = 0L; 594cdf0e10cSrcweir 595ddde725dSArmin Le Grand // small correction: Do not create something when no fill and no line. To 596ddde725dSArmin Le Grand // be sure to not damage something with non-text frames, do this only 597ddde725dSArmin Le Grand // when used with bAddText==false from other converters 598ddde725dSArmin Le Grand if((bAddText && !IsTextFrame()) || HasFill() || HasLine()) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir pRet = ImpConvertMakeObj(aPolyPolygon, sal_True, bBezier); 601cdf0e10cSrcweir } 602cdf0e10cSrcweir 603a5258243SPedro Giffuni if(bAddText) 604a5258243SPedro Giffuni { 605cdf0e10cSrcweir pRet = ImpConvertAddText(pRet, bBezier); 606a5258243SPedro Giffuni } 607cdf0e10cSrcweir 608cdf0e10cSrcweir return pRet; 609cdf0e10cSrcweir } 610cdf0e10cSrcweir 611cdf0e10cSrcweir void SdrRectObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) 612cdf0e10cSrcweir { 613cdf0e10cSrcweir SdrTextObj::Notify(rBC,rHint); 614cdf0e10cSrcweir SetXPolyDirty(); // wg. Eckenradius 615cdf0e10cSrcweir } 616cdf0e10cSrcweir 617cdf0e10cSrcweir void SdrRectObj::RestGeoData(const SdrObjGeoData& rGeo) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir SdrTextObj::RestGeoData(rGeo); 620cdf0e10cSrcweir SetXPolyDirty(); 621cdf0e10cSrcweir } 622cdf0e10cSrcweir 623cdf0e10cSrcweir // eof 624