1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir #include <tools/bigint.hxx> 27cdf0e10cSrcweir #include <svx/xlnwtit.hxx> 28cdf0e10cSrcweir #include <svl/style.hxx> 29cdf0e10cSrcweir #include <svx/svdocapt.hxx> 30cdf0e10cSrcweir #include <svx/xpool.hxx> 31cdf0e10cSrcweir #include <svx/xpoly.hxx> 32cdf0e10cSrcweir #include <svx/svdattrx.hxx> 33cdf0e10cSrcweir #include <svx/svdpool.hxx> 34cdf0e10cSrcweir #include <svx/svdetc.hxx> 35cdf0e10cSrcweir #include <svx/svdtrans.hxx> 36cdf0e10cSrcweir #include <svx/svdhdl.hxx> 37cdf0e10cSrcweir #include <svx/svddrag.hxx> 38cdf0e10cSrcweir #include <svx/svdmodel.hxx> 39cdf0e10cSrcweir #include <svx/svdview.hxx> // fuer RectSnap 40cdf0e10cSrcweir #include "svx/svdglob.hxx" // StringCache 41cdf0e10cSrcweir #include "svx/svdstr.hrc" // Objektname 42cdf0e10cSrcweir #include <svx/svdogrp.hxx> 43cdf0e10cSrcweir #include <svx/svdpage.hxx> 44cdf0e10cSrcweir #include <svx/xflhtit.hxx> 45cdf0e10cSrcweir #include <svx/xflclit.hxx> 46cdf0e10cSrcweir #include <svx/xfltrit.hxx> 47cdf0e10cSrcweir #include <editeng/eeitem.hxx> 48cdf0e10cSrcweir #include <svx/sdr/properties/captionproperties.hxx> 49cdf0e10cSrcweir #include <vcl/salbtype.hxx> // FRound 50cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrcaptionobj.hxx> 51cdf0e10cSrcweir #include <basegfx/tuple/b2dtuple.hxx> 52cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 53cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 54cdf0e10cSrcweir #include <basegfx/range/b2drange.hxx> 55cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 56cdf0e10cSrcweir #include <svx/sdrhittesthelper.hxx> 57cdf0e10cSrcweir 58cdf0e10cSrcweir // #i32599# 59cdf0e10cSrcweir inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); } 60cdf0e10cSrcweir inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); } 61cdf0e10cSrcweir 62cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 63cdf0e10cSrcweir 64cdf0e10cSrcweir enum EscDir {LKS,RTS,OBN,UNT}; 65cdf0e10cSrcweir 66cdf0e10cSrcweir class ImpCaptParams 67cdf0e10cSrcweir { 68cdf0e10cSrcweir public: 69cdf0e10cSrcweir SdrCaptionType eType; 70cdf0e10cSrcweir long nAngle; 71cdf0e10cSrcweir long nGap; 72cdf0e10cSrcweir long nEscRel; 73cdf0e10cSrcweir long nEscAbs; 74cdf0e10cSrcweir long nLineLen; 75cdf0e10cSrcweir SdrCaptionEscDir eEscDir; 76cdf0e10cSrcweir FASTBOOL bFitLineLen; 77cdf0e10cSrcweir FASTBOOL bEscRel; 78cdf0e10cSrcweir FASTBOOL bFixedAngle; 79cdf0e10cSrcweir 80cdf0e10cSrcweir public: 81cdf0e10cSrcweir ImpCaptParams() 82cdf0e10cSrcweir { 83cdf0e10cSrcweir eType =SDRCAPT_TYPE3; 84cdf0e10cSrcweir bFixedAngle=sal_False; 85cdf0e10cSrcweir nAngle =4500; 86cdf0e10cSrcweir nGap =0; 87cdf0e10cSrcweir eEscDir =SDRCAPT_ESCHORIZONTAL; 88cdf0e10cSrcweir bEscRel =sal_True; 89cdf0e10cSrcweir nEscRel =5000; 90cdf0e10cSrcweir nEscAbs =0; 91cdf0e10cSrcweir nLineLen =0; 92cdf0e10cSrcweir bFitLineLen=sal_True; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir void CalcEscPos(const Point& rTail, const Rectangle& rRect, Point& rPt, EscDir& rDir) const; 95cdf0e10cSrcweir }; 96cdf0e10cSrcweir 97cdf0e10cSrcweir void ImpCaptParams::CalcEscPos(const Point& rTailPt, const Rectangle& rRect, Point& rPt, EscDir& rDir) const 98cdf0e10cSrcweir { 99cdf0e10cSrcweir Point aTl(rTailPt); // lokal kopieren wg. Performance 100cdf0e10cSrcweir long nX,nY; 101cdf0e10cSrcweir if (bEscRel) { 102cdf0e10cSrcweir nX=rRect.Right()-rRect.Left(); 103cdf0e10cSrcweir nX=BigMulDiv(nX,nEscRel,10000); 104cdf0e10cSrcweir nY=rRect.Bottom()-rRect.Top(); 105cdf0e10cSrcweir nY=BigMulDiv(nY,nEscRel,10000); 106cdf0e10cSrcweir } else { 107cdf0e10cSrcweir nX=nEscAbs; 108cdf0e10cSrcweir nY=nEscAbs; 109cdf0e10cSrcweir } 110cdf0e10cSrcweir nX+=rRect.Left(); 111cdf0e10cSrcweir nY+=rRect.Top(); 112cdf0e10cSrcweir Point aBestPt; 113cdf0e10cSrcweir EscDir eBestDir=LKS; 114cdf0e10cSrcweir FASTBOOL bTryH=eEscDir==SDRCAPT_ESCBESTFIT; 115cdf0e10cSrcweir if (!bTryH) { 116cdf0e10cSrcweir if (eType!=SDRCAPT_TYPE1) { 117cdf0e10cSrcweir bTryH=eEscDir==SDRCAPT_ESCHORIZONTAL; 118cdf0e10cSrcweir } else { 119cdf0e10cSrcweir bTryH=eEscDir==SDRCAPT_ESCVERTICAL; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir } 122cdf0e10cSrcweir FASTBOOL bTryV=eEscDir==SDRCAPT_ESCBESTFIT; 123cdf0e10cSrcweir if (!bTryV) { 124cdf0e10cSrcweir if (eType!=SDRCAPT_TYPE1) { 125cdf0e10cSrcweir bTryV=eEscDir==SDRCAPT_ESCVERTICAL; 126cdf0e10cSrcweir } else { 127cdf0e10cSrcweir bTryV=eEscDir==SDRCAPT_ESCHORIZONTAL; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir if (bTryH) { 132cdf0e10cSrcweir Point aLft(rRect.Left()-nGap,nY); 133cdf0e10cSrcweir Point aRgt(rRect.Right()+nGap,nY); 134cdf0e10cSrcweir FASTBOOL bLft=(aTl.X()-aLft.X()<aRgt.X()-aTl.X()); 135cdf0e10cSrcweir if (bLft) { 136cdf0e10cSrcweir eBestDir=LKS; 137cdf0e10cSrcweir aBestPt=aLft; 138cdf0e10cSrcweir } else { 139cdf0e10cSrcweir eBestDir=RTS; 140cdf0e10cSrcweir aBestPt=aRgt; 141cdf0e10cSrcweir } 142cdf0e10cSrcweir } 143cdf0e10cSrcweir if (bTryV) { 144cdf0e10cSrcweir Point aTop(nX,rRect.Top()-nGap); 145cdf0e10cSrcweir Point aBtm(nX,rRect.Bottom()+nGap); 146cdf0e10cSrcweir FASTBOOL bTop=(aTl.Y()-aTop.Y()<aBtm.Y()-aTl.Y()); 147cdf0e10cSrcweir Point aBest2; 148cdf0e10cSrcweir EscDir eBest2; 149cdf0e10cSrcweir if (bTop) { 150cdf0e10cSrcweir eBest2=OBN; 151cdf0e10cSrcweir aBest2=aTop; 152cdf0e10cSrcweir } else { 153cdf0e10cSrcweir eBest2=UNT; 154cdf0e10cSrcweir aBest2=aBtm; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir FASTBOOL bTakeIt=eEscDir!=SDRCAPT_ESCBESTFIT; 157cdf0e10cSrcweir if (!bTakeIt) { 158cdf0e10cSrcweir BigInt aHorX(aBestPt.X()-aTl.X()); aHorX*=aHorX; 159cdf0e10cSrcweir BigInt aHorY(aBestPt.Y()-aTl.Y()); aHorY*=aHorY; 160cdf0e10cSrcweir BigInt aVerX(aBest2.X()-aTl.X()); aVerX*=aVerX; 161cdf0e10cSrcweir BigInt aVerY(aBest2.Y()-aTl.Y()); aVerY*=aVerY; 162cdf0e10cSrcweir if (eType!=SDRCAPT_TYPE1) { 163cdf0e10cSrcweir bTakeIt=aVerX+aVerY<aHorX+aHorY; 164cdf0e10cSrcweir } else { 165cdf0e10cSrcweir bTakeIt=aVerX+aVerY>=aHorX+aHorY; 166cdf0e10cSrcweir } 167cdf0e10cSrcweir } 168cdf0e10cSrcweir if (bTakeIt) { 169cdf0e10cSrcweir aBestPt=aBest2; 170cdf0e10cSrcweir eBestDir=eBest2; 171cdf0e10cSrcweir } 172cdf0e10cSrcweir } 173cdf0e10cSrcweir rPt=aBestPt; 174cdf0e10cSrcweir rDir=eBestDir; 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 178cdf0e10cSrcweir // BaseProperties section 179cdf0e10cSrcweir 180cdf0e10cSrcweir sdr::properties::BaseProperties* SdrCaptionObj::CreateObjectSpecificProperties() 181cdf0e10cSrcweir { 182cdf0e10cSrcweir return new sdr::properties::CaptionProperties(*this); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 186cdf0e10cSrcweir // DrawContact section 187cdf0e10cSrcweir 188cdf0e10cSrcweir sdr::contact::ViewContact* SdrCaptionObj::CreateObjectSpecificViewContact() 189cdf0e10cSrcweir { 190cdf0e10cSrcweir return new sdr::contact::ViewContactOfSdrCaptionObj(*this); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 194cdf0e10cSrcweir 195cdf0e10cSrcweir TYPEINIT1(SdrCaptionObj,SdrRectObj); 196cdf0e10cSrcweir 197cdf0e10cSrcweir SdrCaptionObj::SdrCaptionObj(): 198cdf0e10cSrcweir SdrRectObj(OBJ_TEXT), 199cdf0e10cSrcweir aTailPoly(3), // Default Groesse: 3 Punkte = 2 Linien 200cdf0e10cSrcweir mbSpecialTextBoxShadow(sal_False), 201cdf0e10cSrcweir mbFixedTail(sal_False) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir SdrCaptionObj::SdrCaptionObj(const Rectangle& rRect): 206cdf0e10cSrcweir SdrRectObj(OBJ_TEXT,rRect), 207cdf0e10cSrcweir aTailPoly(3), // Default Groesse: 3 Punkte = 2 Linien 208cdf0e10cSrcweir mbSpecialTextBoxShadow(sal_False), 209cdf0e10cSrcweir mbFixedTail(sal_False) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir SdrCaptionObj::SdrCaptionObj(const Rectangle& rRect, const Point& rTail): 214cdf0e10cSrcweir SdrRectObj(OBJ_TEXT,rRect), 215cdf0e10cSrcweir aTailPoly(3), // Default Groesse: 3 Punkte = 2 Linien 216cdf0e10cSrcweir mbSpecialTextBoxShadow(sal_False), 217cdf0e10cSrcweir mbFixedTail(sal_False) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir aTailPoly[0]=maFixedTailPos=rTail; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir SdrCaptionObj::~SdrCaptionObj() 223cdf0e10cSrcweir { 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir void SdrCaptionObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const 227cdf0e10cSrcweir { 228cdf0e10cSrcweir rInfo.bRotateFreeAllowed=sal_False; 229cdf0e10cSrcweir rInfo.bRotate90Allowed =sal_False; 230cdf0e10cSrcweir rInfo.bMirrorFreeAllowed=sal_False; 231cdf0e10cSrcweir rInfo.bMirror45Allowed =sal_False; 232cdf0e10cSrcweir rInfo.bMirror90Allowed =sal_False; 233cdf0e10cSrcweir rInfo.bTransparenceAllowed = sal_False; 234cdf0e10cSrcweir rInfo.bGradientAllowed = sal_False; 235cdf0e10cSrcweir rInfo.bShearAllowed =sal_False; 236cdf0e10cSrcweir rInfo.bEdgeRadiusAllowed=sal_False; 237cdf0e10cSrcweir rInfo.bCanConvToPath =sal_True; 238cdf0e10cSrcweir rInfo.bCanConvToPoly =sal_True; 239cdf0e10cSrcweir rInfo.bCanConvToPathLineToArea=sal_False; 240cdf0e10cSrcweir rInfo.bCanConvToPolyLineToArea=sal_False; 241cdf0e10cSrcweir rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary()); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir sal_uInt16 SdrCaptionObj::GetObjIdentifier() const 245cdf0e10cSrcweir { 246cdf0e10cSrcweir return sal_uInt16(OBJ_CAPTION); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 249cdf0e10cSrcweir void SdrCaptionObj::operator=(const SdrObject& rObj) 250cdf0e10cSrcweir { 251cdf0e10cSrcweir SdrRectObj::operator=(rObj); 252cdf0e10cSrcweir aTailPoly=((SdrCaptionObj&)rObj).aTailPoly; 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir void SdrCaptionObj::TakeObjNameSingul(XubString& rName) const 256cdf0e10cSrcweir { 257cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNameSingulCAPTION); 258cdf0e10cSrcweir 259cdf0e10cSrcweir String aName( GetName() ); 260cdf0e10cSrcweir if(aName.Len()) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir rName += sal_Unicode(' '); 263cdf0e10cSrcweir rName += sal_Unicode('\''); 264cdf0e10cSrcweir rName += aName; 265cdf0e10cSrcweir rName += sal_Unicode('\''); 266cdf0e10cSrcweir } 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir void SdrCaptionObj::TakeObjNamePlural(XubString& rName) const 270cdf0e10cSrcweir { 271cdf0e10cSrcweir rName=ImpGetResStr(STR_ObjNamePluralCAPTION); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrCaptionObj::TakeXorPoly() const 275cdf0e10cSrcweir { 276cdf0e10cSrcweir basegfx::B2DPolyPolygon aPolyPoly(SdrRectObj::TakeXorPoly()); 277cdf0e10cSrcweir aPolyPoly.append(aTailPoly.getB2DPolygon()); 278cdf0e10cSrcweir 279cdf0e10cSrcweir return aPolyPoly; 280cdf0e10cSrcweir } 281cdf0e10cSrcweir 282cdf0e10cSrcweir sal_uInt32 SdrCaptionObj::GetHdlCount() const 283cdf0e10cSrcweir { 284cdf0e10cSrcweir sal_uInt32 nAnz1(SdrRectObj::GetHdlCount()); 285cdf0e10cSrcweir // sal_uInt32 nAnz2(aTailPoly.GetSize()); 286cdf0e10cSrcweir // Derzeit ist nur das Draggen des Schwanzendes implementiert 287cdf0e10cSrcweir return nAnz1 + 1L; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir SdrHdl* SdrCaptionObj::GetHdl(sal_uInt32 nHdlNum) const 291cdf0e10cSrcweir { 292cdf0e10cSrcweir const sal_uInt32 nRectHdlAnz(SdrRectObj::GetHdlCount()); 293cdf0e10cSrcweir 294cdf0e10cSrcweir if(nHdlNum < nRectHdlAnz) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir return SdrRectObj::GetHdl(nHdlNum); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir else 299cdf0e10cSrcweir { 300cdf0e10cSrcweir sal_uInt32 nPntNum(nHdlNum); 301cdf0e10cSrcweir nPntNum -= nRectHdlAnz; 302cdf0e10cSrcweir 303cdf0e10cSrcweir if(nPntNum < aTailPoly.GetSize()) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir SdrHdl* pHdl = new SdrHdl(aTailPoly.GetPoint((sal_uInt16)nPntNum), HDL_POLY); 306cdf0e10cSrcweir pHdl->SetPolyNum(1L); 307cdf0e10cSrcweir pHdl->SetPointNum(nPntNum); 308cdf0e10cSrcweir return pHdl; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir else 311cdf0e10cSrcweir { 312cdf0e10cSrcweir return 0L; 313cdf0e10cSrcweir } 314cdf0e10cSrcweir } 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 318cdf0e10cSrcweir 319cdf0e10cSrcweir bool SdrCaptionObj::hasSpecialDrag() const 320cdf0e10cSrcweir { 321cdf0e10cSrcweir return true; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir bool SdrCaptionObj::beginSpecialDrag(SdrDragStat& rDrag) const 325cdf0e10cSrcweir { 326cdf0e10cSrcweir const SdrHdl* pHdl = rDrag.GetHdl(); 327cdf0e10cSrcweir rDrag.SetEndDragChangesAttributes(true); 328cdf0e10cSrcweir rDrag.SetEndDragChangesGeoAndAttributes(true); 329cdf0e10cSrcweir 330cdf0e10cSrcweir if(pHdl && 0 == pHdl->GetPolyNum()) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir return SdrRectObj::beginSpecialDrag(rDrag); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir else 335cdf0e10cSrcweir { 336cdf0e10cSrcweir rDrag.SetOrtho8Possible(true); 337cdf0e10cSrcweir 338cdf0e10cSrcweir if(!pHdl) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir if (bMovProt) 341cdf0e10cSrcweir return 0; 342cdf0e10cSrcweir 343cdf0e10cSrcweir rDrag.SetNoSnap(true); 344cdf0e10cSrcweir rDrag.SetActionRect(aRect); 345cdf0e10cSrcweir 346cdf0e10cSrcweir Point aHit(rDrag.GetStart()); 347cdf0e10cSrcweir 348cdf0e10cSrcweir if(rDrag.GetPageView() && SdrObjectPrimitiveHit(*this, aHit, 0, *rDrag.GetPageView(), 0, false)) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir return true; 351cdf0e10cSrcweir } 352cdf0e10cSrcweir } 353cdf0e10cSrcweir else 354cdf0e10cSrcweir { 355cdf0e10cSrcweir if((1 == pHdl->GetPolyNum()) && (0 == pHdl->GetPointNum())) 356cdf0e10cSrcweir return true; 357cdf0e10cSrcweir } 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir return false; 361cdf0e10cSrcweir } 362cdf0e10cSrcweir 363cdf0e10cSrcweir bool SdrCaptionObj::applySpecialDrag(SdrDragStat& rDrag) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir const SdrHdl* pHdl = rDrag.GetHdl(); 366cdf0e10cSrcweir 367cdf0e10cSrcweir if(pHdl && 0 == pHdl->GetPolyNum()) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir const bool bRet(SdrRectObj::applySpecialDrag(rDrag)); 370cdf0e10cSrcweir ImpRecalcTail(); 371cdf0e10cSrcweir ActionChanged(); 372cdf0e10cSrcweir 373cdf0e10cSrcweir return bRet; 374cdf0e10cSrcweir } 375cdf0e10cSrcweir else 376cdf0e10cSrcweir { 377cdf0e10cSrcweir Point aDelt(rDrag.GetNow()-rDrag.GetStart()); 378cdf0e10cSrcweir 379cdf0e10cSrcweir if(!pHdl) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir aRect.Move(aDelt.X(),aDelt.Y()); 382cdf0e10cSrcweir } 383cdf0e10cSrcweir else 384cdf0e10cSrcweir { 385cdf0e10cSrcweir aTailPoly[0] += aDelt; 386cdf0e10cSrcweir } 387cdf0e10cSrcweir 388cdf0e10cSrcweir ImpRecalcTail(); 389cdf0e10cSrcweir ActionChanged(); 390cdf0e10cSrcweir 391cdf0e10cSrcweir return true; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir } 394cdf0e10cSrcweir 395cdf0e10cSrcweir String SdrCaptionObj::getSpecialDragComment(const SdrDragStat& rDrag) const 396cdf0e10cSrcweir { 397cdf0e10cSrcweir const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj()); 398cdf0e10cSrcweir 399cdf0e10cSrcweir if(bCreateComment) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir return String(); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir else 404cdf0e10cSrcweir { 405cdf0e10cSrcweir const SdrHdl* pHdl = rDrag.GetHdl(); 406cdf0e10cSrcweir 407cdf0e10cSrcweir if(pHdl && 0 == pHdl->GetPolyNum()) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir return SdrRectObj::getSpecialDragComment(rDrag); 410cdf0e10cSrcweir } 411cdf0e10cSrcweir else 412cdf0e10cSrcweir { 413cdf0e10cSrcweir XubString aStr; 414cdf0e10cSrcweir 415cdf0e10cSrcweir if(!pHdl) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir ImpTakeDescriptionStr(STR_DragCaptFram, aStr); 418cdf0e10cSrcweir } 419cdf0e10cSrcweir else 420cdf0e10cSrcweir { 421cdf0e10cSrcweir ImpTakeDescriptionStr(STR_DragCaptTail, aStr); 422cdf0e10cSrcweir } 423cdf0e10cSrcweir 424cdf0e10cSrcweir return aStr; 425cdf0e10cSrcweir } 426cdf0e10cSrcweir } 427cdf0e10cSrcweir } 428cdf0e10cSrcweir 429cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 430cdf0e10cSrcweir 431cdf0e10cSrcweir void SdrCaptionObj::ImpGetCaptParams(ImpCaptParams& rPara) const 432cdf0e10cSrcweir { 433cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet(); 434cdf0e10cSrcweir rPara.eType =((SdrCaptionTypeItem&) (rSet.Get(SDRATTR_CAPTIONTYPE ))).GetValue(); 435cdf0e10cSrcweir rPara.bFixedAngle=((SdrCaptionFixedAngleItem&)(rSet.Get(SDRATTR_CAPTIONANGLE ))).GetValue(); 436cdf0e10cSrcweir rPara.nAngle =((SdrCaptionAngleItem&) (rSet.Get(SDRATTR_CAPTIONFIXEDANGLE))).GetValue(); 437cdf0e10cSrcweir rPara.nGap =((SdrCaptionGapItem&) (rSet.Get(SDRATTR_CAPTIONGAP ))).GetValue(); 438cdf0e10cSrcweir rPara.eEscDir =((SdrCaptionEscDirItem&) (rSet.Get(SDRATTR_CAPTIONESCDIR ))).GetValue(); 439cdf0e10cSrcweir rPara.bEscRel =((SdrCaptionEscIsRelItem&) (rSet.Get(SDRATTR_CAPTIONESCISREL ))).GetValue(); 440cdf0e10cSrcweir rPara.nEscRel =((SdrCaptionEscRelItem&) (rSet.Get(SDRATTR_CAPTIONESCREL ))).GetValue(); 441cdf0e10cSrcweir rPara.nEscAbs =((SdrCaptionEscAbsItem&) (rSet.Get(SDRATTR_CAPTIONESCABS ))).GetValue(); 442cdf0e10cSrcweir rPara.nLineLen =((SdrCaptionLineLenItem&) (rSet.Get(SDRATTR_CAPTIONLINELEN ))).GetValue(); 443cdf0e10cSrcweir rPara.bFitLineLen=((SdrCaptionFitLineLenItem&)(rSet.Get(SDRATTR_CAPTIONFITLINELEN))).GetValue(); 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir void SdrCaptionObj::ImpRecalcTail() 447cdf0e10cSrcweir { 448cdf0e10cSrcweir ImpCaptParams aPara; 449cdf0e10cSrcweir ImpGetCaptParams(aPara); 450cdf0e10cSrcweir ImpCalcTail(aPara,aTailPoly,aRect); 451cdf0e10cSrcweir SetRectsDirty(); 452cdf0e10cSrcweir SetXPolyDirty(); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir // #i35971# 456cdf0e10cSrcweir // SdrCaptionObj::ImpCalcTail1 does move the object(!). What a hack. 457cdf0e10cSrcweir // I really wonder why this had not triggered problems before. I am 458cdf0e10cSrcweir // sure there are some places where SetTailPos() is called at least 459cdf0e10cSrcweir // twice or SetSnapRect after it again just to work around this. 460cdf0e10cSrcweir // Changed this method to not do that. 461cdf0e10cSrcweir // Also found why this has been done: For interactive dragging of the 462cdf0e10cSrcweir // tail end pos for SDRCAPT_TYPE1. This sure was the simplest method 463cdf0e10cSrcweir // to achieve this, for the cost to make a whole group of const methods 464cdf0e10cSrcweir // of this object implicitly chainging the object's position. 465cdf0e10cSrcweir void SdrCaptionObj::ImpCalcTail1(const ImpCaptParams& rPara, Polygon& rPoly, Rectangle& rRect) const 466cdf0e10cSrcweir { 467cdf0e10cSrcweir Polygon aPol(2); 468cdf0e10cSrcweir Point aTl(rPoly[0]); 469cdf0e10cSrcweir 470cdf0e10cSrcweir aPol[0] = aTl; 471cdf0e10cSrcweir aPol[1] = aTl; 472cdf0e10cSrcweir 473cdf0e10cSrcweir EscDir eEscDir; 474cdf0e10cSrcweir Point aEscPos; 475cdf0e10cSrcweir 476cdf0e10cSrcweir rPara.CalcEscPos(aTl, rRect, aEscPos, eEscDir); 477cdf0e10cSrcweir aPol[1] = aEscPos; 478cdf0e10cSrcweir 479cdf0e10cSrcweir if(eEscDir==LKS || eEscDir==RTS) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir aPol[0].X() = aEscPos.X(); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir else 484cdf0e10cSrcweir { 485cdf0e10cSrcweir aPol[0].Y() = aEscPos.Y(); 486cdf0e10cSrcweir } 487cdf0e10cSrcweir 488cdf0e10cSrcweir rPoly = aPol; 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir void SdrCaptionObj::ImpCalcTail2(const ImpCaptParams& rPara, Polygon& rPoly, Rectangle& rRect) const 492cdf0e10cSrcweir { // Gap/EscDir/EscPos/Angle 493cdf0e10cSrcweir Polygon aPol(2); 494cdf0e10cSrcweir Point aTl(rPoly[0]); 495cdf0e10cSrcweir aPol[0]=aTl; 496cdf0e10cSrcweir 497cdf0e10cSrcweir EscDir eEscDir; 498cdf0e10cSrcweir Point aEscPos; 499cdf0e10cSrcweir rPara.CalcEscPos(aTl,rRect,aEscPos,eEscDir); 500cdf0e10cSrcweir aPol[1]=aEscPos; 501cdf0e10cSrcweir 502cdf0e10cSrcweir if (!rPara.bFixedAngle) { 503cdf0e10cSrcweir // fehlende Implementation 504cdf0e10cSrcweir } 505cdf0e10cSrcweir rPoly=aPol; 506cdf0e10cSrcweir } 507cdf0e10cSrcweir 508cdf0e10cSrcweir void SdrCaptionObj::ImpCalcTail3(const ImpCaptParams& rPara, Polygon& rPoly, Rectangle& rRect) const 509cdf0e10cSrcweir { // Gap/EscDir/EscPos/Angle/LineLen 510cdf0e10cSrcweir Polygon aPol(3); 511cdf0e10cSrcweir Point aTl(rPoly[0]); 512cdf0e10cSrcweir aPol[0]=aTl; 513cdf0e10cSrcweir 514cdf0e10cSrcweir EscDir eEscDir; 515cdf0e10cSrcweir Point aEscPos; 516cdf0e10cSrcweir rPara.CalcEscPos(aTl,rRect,aEscPos,eEscDir); 517cdf0e10cSrcweir aPol[1]=aEscPos; 518cdf0e10cSrcweir aPol[2]=aEscPos; 519cdf0e10cSrcweir 520cdf0e10cSrcweir if (eEscDir==LKS || eEscDir==RTS) { 521cdf0e10cSrcweir if (rPara.bFitLineLen) { 522cdf0e10cSrcweir aPol[1].X()=(aTl.X()+aEscPos.X())/2; 523cdf0e10cSrcweir } else { 524cdf0e10cSrcweir if (eEscDir==LKS) aPol[1].X()-=rPara.nLineLen; 525cdf0e10cSrcweir else aPol[1].X()+=rPara.nLineLen; 526cdf0e10cSrcweir } 527cdf0e10cSrcweir } else { 528cdf0e10cSrcweir if (rPara.bFitLineLen) { 529cdf0e10cSrcweir aPol[1].Y()=(aTl.Y()+aEscPos.Y())/2; 530cdf0e10cSrcweir } else { 531cdf0e10cSrcweir if (eEscDir==OBN) aPol[1].Y()-=rPara.nLineLen; 532cdf0e10cSrcweir else aPol[1].Y()+=rPara.nLineLen; 533cdf0e10cSrcweir } 534cdf0e10cSrcweir } 535cdf0e10cSrcweir if (!rPara.bFixedAngle) { 536cdf0e10cSrcweir // fehlende Implementation 537cdf0e10cSrcweir } 538cdf0e10cSrcweir rPoly=aPol; 539cdf0e10cSrcweir } 540cdf0e10cSrcweir 541cdf0e10cSrcweir void SdrCaptionObj::ImpCalcTail4(const ImpCaptParams& rPara, Polygon& rPoly, Rectangle& rRect) const 542cdf0e10cSrcweir { 543cdf0e10cSrcweir ImpCalcTail3(rPara,rPoly,rRect); 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir void SdrCaptionObj::ImpCalcTail(const ImpCaptParams& rPara, Polygon& rPoly, Rectangle& rRect) const 547cdf0e10cSrcweir { 548cdf0e10cSrcweir switch (rPara.eType) { 549cdf0e10cSrcweir case SDRCAPT_TYPE1: ImpCalcTail1(rPara,rPoly,rRect); break; 550cdf0e10cSrcweir case SDRCAPT_TYPE2: ImpCalcTail2(rPara,rPoly,rRect); break; 551cdf0e10cSrcweir case SDRCAPT_TYPE3: ImpCalcTail3(rPara,rPoly,rRect); break; 552cdf0e10cSrcweir case SDRCAPT_TYPE4: ImpCalcTail4(rPara,rPoly,rRect); break; 553cdf0e10cSrcweir } 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir FASTBOOL SdrCaptionObj::BegCreate(SdrDragStat& rStat) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir if (aRect.IsEmpty()) return sal_False; // Create z.Zt. nur mit vorgegebenen Rect 559cdf0e10cSrcweir 560cdf0e10cSrcweir ImpCaptParams aPara; 561cdf0e10cSrcweir ImpGetCaptParams(aPara); 562cdf0e10cSrcweir aRect.SetPos(rStat.GetNow()); 563cdf0e10cSrcweir aTailPoly[0]=rStat.GetStart(); 564cdf0e10cSrcweir ImpCalcTail(aPara,aTailPoly,aRect); 565cdf0e10cSrcweir rStat.SetActionRect(aRect); 566cdf0e10cSrcweir return sal_True; 567cdf0e10cSrcweir } 568cdf0e10cSrcweir 569cdf0e10cSrcweir FASTBOOL SdrCaptionObj::MovCreate(SdrDragStat& rStat) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir ImpCaptParams aPara; 572cdf0e10cSrcweir ImpGetCaptParams(aPara); 573cdf0e10cSrcweir aRect.SetPos(rStat.GetNow()); 574cdf0e10cSrcweir ImpCalcTail(aPara,aTailPoly,aRect); 575cdf0e10cSrcweir rStat.SetActionRect(aRect); 576cdf0e10cSrcweir SetBoundRectDirty(); 577cdf0e10cSrcweir bSnapRectDirty=sal_True; 578cdf0e10cSrcweir return sal_True; 579cdf0e10cSrcweir } 580cdf0e10cSrcweir 581cdf0e10cSrcweir FASTBOOL SdrCaptionObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir ImpCaptParams aPara; 584cdf0e10cSrcweir ImpGetCaptParams(aPara); 585cdf0e10cSrcweir aRect.SetPos(rStat.GetNow()); 586cdf0e10cSrcweir ImpCalcTail(aPara,aTailPoly,aRect); 587cdf0e10cSrcweir SetRectsDirty(); 588cdf0e10cSrcweir return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2); 589cdf0e10cSrcweir } 590cdf0e10cSrcweir 591cdf0e10cSrcweir FASTBOOL SdrCaptionObj::BckCreate(SdrDragStat& /*rStat*/) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir return sal_False; 594cdf0e10cSrcweir } 595cdf0e10cSrcweir 596cdf0e10cSrcweir void SdrCaptionObj::BrkCreate(SdrDragStat& /*rStat*/) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir } 599cdf0e10cSrcweir 600cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrCaptionObj::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const 601cdf0e10cSrcweir { 602cdf0e10cSrcweir basegfx::B2DPolyPolygon aRetval; 603cdf0e10cSrcweir const basegfx::B2DRange aRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom()); 604cdf0e10cSrcweir aRetval.append(basegfx::tools::createPolygonFromRect(aRange)); 605cdf0e10cSrcweir aRetval.append(aTailPoly.getB2DPolygon()); 606cdf0e10cSrcweir return aRetval; 607cdf0e10cSrcweir } 608cdf0e10cSrcweir 609cdf0e10cSrcweir Pointer SdrCaptionObj::GetCreatePointer() const 610cdf0e10cSrcweir { 611cdf0e10cSrcweir return Pointer(POINTER_DRAW_CAPTION); 612cdf0e10cSrcweir } 613cdf0e10cSrcweir 614cdf0e10cSrcweir void SdrCaptionObj::NbcMove(const Size& rSiz) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir SdrRectObj::NbcMove(rSiz); 617cdf0e10cSrcweir MovePoly(aTailPoly,rSiz); 618cdf0e10cSrcweir if(mbFixedTail) 619cdf0e10cSrcweir SetTailPos(GetFixedTailPos()); 620cdf0e10cSrcweir } 621cdf0e10cSrcweir 622cdf0e10cSrcweir void SdrCaptionObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) 623cdf0e10cSrcweir { 624cdf0e10cSrcweir SdrRectObj::NbcResize(rRef,xFact,yFact); 625cdf0e10cSrcweir ResizePoly(aTailPoly,rRef,xFact,yFact); 626cdf0e10cSrcweir ImpRecalcTail(); 627cdf0e10cSrcweir if(mbFixedTail) 628cdf0e10cSrcweir SetTailPos(GetFixedTailPos()); 629cdf0e10cSrcweir } 630cdf0e10cSrcweir 631cdf0e10cSrcweir void SdrCaptionObj::NbcSetRelativePos(const Point& rPnt) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir Point aRelPos0(aTailPoly.GetPoint(0)-aAnchor); 634cdf0e10cSrcweir Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y()); 635cdf0e10cSrcweir NbcMove(aSiz); // Der ruft auch das SetRectsDirty() 636cdf0e10cSrcweir } 637cdf0e10cSrcweir 638cdf0e10cSrcweir Point SdrCaptionObj::GetRelativePos() const 639cdf0e10cSrcweir { 640cdf0e10cSrcweir return aTailPoly.GetPoint(0)-aAnchor; 641cdf0e10cSrcweir } 642cdf0e10cSrcweir 643cdf0e10cSrcweir void SdrCaptionObj::NbcSetAnchorPos(const Point& rPnt) 644cdf0e10cSrcweir { 645cdf0e10cSrcweir SdrRectObj::NbcSetAnchorPos(rPnt); 646cdf0e10cSrcweir // !!!!! fehlende Impl. 647cdf0e10cSrcweir } 648cdf0e10cSrcweir 649cdf0e10cSrcweir const Point& SdrCaptionObj::GetAnchorPos() const 650cdf0e10cSrcweir { 651cdf0e10cSrcweir // !!!!! fehlende Impl. 652cdf0e10cSrcweir return SdrRectObj::GetAnchorPos(); 653cdf0e10cSrcweir } 654cdf0e10cSrcweir 655cdf0e10cSrcweir void SdrCaptionObj::RecalcSnapRect() 656cdf0e10cSrcweir { 657cdf0e10cSrcweir SdrRectObj::RecalcSnapRect(); 658cdf0e10cSrcweir // #i32599# 659cdf0e10cSrcweir // maSnapRect.Union(aTailPoly.GetBoundRect()); 660cdf0e10cSrcweir // !!!!! fehlende Impl. 661cdf0e10cSrcweir } 662cdf0e10cSrcweir 663cdf0e10cSrcweir const Rectangle& SdrCaptionObj::GetSnapRect() const 664cdf0e10cSrcweir { 665cdf0e10cSrcweir return SdrRectObj::GetSnapRect(); 666cdf0e10cSrcweir } 667cdf0e10cSrcweir 668cdf0e10cSrcweir void SdrCaptionObj::NbcSetSnapRect(const Rectangle& rRect) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir // #i32599# 671cdf0e10cSrcweir // Move back to see the rectangle of the underlying SdrRectObj 672cdf0e10cSrcweir // as the SnapRect, without the TailPos. That simplifies SnapRect 673cdf0e10cSrcweir // handling again, if not allows it at all... 674cdf0e10cSrcweir SdrRectObj::NbcSetSnapRect(rRect); 675cdf0e10cSrcweir } 676cdf0e10cSrcweir 677cdf0e10cSrcweir const Rectangle& SdrCaptionObj::GetLogicRect() const 678cdf0e10cSrcweir { 679cdf0e10cSrcweir return aRect; 680cdf0e10cSrcweir } 681cdf0e10cSrcweir 682cdf0e10cSrcweir void SdrCaptionObj::NbcSetLogicRect(const Rectangle& rRect) 683cdf0e10cSrcweir { 684cdf0e10cSrcweir SdrRectObj::NbcSetLogicRect(rRect); 685cdf0e10cSrcweir ImpRecalcTail(); 686cdf0e10cSrcweir } 687cdf0e10cSrcweir 688cdf0e10cSrcweir const Point& SdrCaptionObj::GetTailPos() const 689cdf0e10cSrcweir { 690cdf0e10cSrcweir return aTailPoly[0]; 691cdf0e10cSrcweir } 692cdf0e10cSrcweir 693cdf0e10cSrcweir void SdrCaptionObj::SetTailPos(const Point& rPos) 694cdf0e10cSrcweir { 695cdf0e10cSrcweir if (aTailPoly.GetSize()==0 || aTailPoly[0]!=rPos) { 696cdf0e10cSrcweir Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); 697cdf0e10cSrcweir // #110094#-14 SendRepaintBroadcast(); 698cdf0e10cSrcweir NbcSetTailPos(rPos); 699cdf0e10cSrcweir SetChanged(); 700cdf0e10cSrcweir BroadcastObjectChange(); 701cdf0e10cSrcweir SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 702cdf0e10cSrcweir } 703cdf0e10cSrcweir } 704cdf0e10cSrcweir 705cdf0e10cSrcweir void SdrCaptionObj::NbcSetTailPos(const Point& rPos) 706cdf0e10cSrcweir { 707cdf0e10cSrcweir aTailPoly[0]=rPos; 708cdf0e10cSrcweir ImpRecalcTail(); 709cdf0e10cSrcweir } 710cdf0e10cSrcweir 711cdf0e10cSrcweir sal_uInt32 SdrCaptionObj::GetSnapPointCount() const 712cdf0e10cSrcweir { 713cdf0e10cSrcweir // !!!!! fehlende Impl. 714cdf0e10cSrcweir return 0L; 715cdf0e10cSrcweir } 716cdf0e10cSrcweir 717cdf0e10cSrcweir Point SdrCaptionObj::GetSnapPoint(sal_uInt32 /*i*/) const 718cdf0e10cSrcweir { 719cdf0e10cSrcweir // !!!!! fehlende Impl. 720cdf0e10cSrcweir return Point(0,0); 721cdf0e10cSrcweir } 722cdf0e10cSrcweir 723cdf0e10cSrcweir void SdrCaptionObj::SetModel(SdrModel* pNewModel) 724cdf0e10cSrcweir { 725cdf0e10cSrcweir SdrRectObj::SetModel(pNewModel); 726cdf0e10cSrcweir ImpRecalcTail(); 727cdf0e10cSrcweir } 728cdf0e10cSrcweir 729cdf0e10cSrcweir void SdrCaptionObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) 730cdf0e10cSrcweir { 731cdf0e10cSrcweir SdrRectObj::Notify(rBC,rHint); 732cdf0e10cSrcweir ImpRecalcTail(); 733cdf0e10cSrcweir } 734cdf0e10cSrcweir 735cdf0e10cSrcweir SdrObjGeoData* SdrCaptionObj::NewGeoData() const 736cdf0e10cSrcweir { 737cdf0e10cSrcweir return new SdrCaptObjGeoData; 738cdf0e10cSrcweir } 739cdf0e10cSrcweir 740cdf0e10cSrcweir void SdrCaptionObj::SaveGeoData(SdrObjGeoData& rGeo) const 741cdf0e10cSrcweir { 742cdf0e10cSrcweir SdrRectObj::SaveGeoData(rGeo); 743cdf0e10cSrcweir SdrCaptObjGeoData& rCGeo=(SdrCaptObjGeoData&)rGeo; 744cdf0e10cSrcweir rCGeo.aTailPoly=aTailPoly; 745cdf0e10cSrcweir } 746cdf0e10cSrcweir 747cdf0e10cSrcweir void SdrCaptionObj::RestGeoData(const SdrObjGeoData& rGeo) 748cdf0e10cSrcweir { 749cdf0e10cSrcweir SdrRectObj::RestGeoData(rGeo); 750cdf0e10cSrcweir SdrCaptObjGeoData& rCGeo=(SdrCaptObjGeoData&)rGeo; 751cdf0e10cSrcweir aTailPoly=rCGeo.aTailPoly; 752cdf0e10cSrcweir } 753cdf0e10cSrcweir 754a5258243SPedro Giffuni SdrObject* SdrCaptionObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const 755cdf0e10cSrcweir { // #42334# - Convert implementiert 756a5258243SPedro Giffuni SdrObject* pRect=SdrRectObj::DoConvertToPolyObj(bBezier, bAddText); 757cdf0e10cSrcweir SdrObject* pTail = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aTailPoly.getB2DPolygon()), sal_False, bBezier); 758cdf0e10cSrcweir SdrObject* pRet=(pTail!=NULL) ? pTail : pRect; 759cdf0e10cSrcweir if (pTail!=NULL && pRect!=NULL) { 760cdf0e10cSrcweir FASTBOOL bInsRect=sal_True; 761cdf0e10cSrcweir FASTBOOL bInsTail=sal_True; 762cdf0e10cSrcweir SdrObjList* pOL=pTail->GetSubList(); 763cdf0e10cSrcweir if (pOL!=NULL) { pRet=pRect; bInsTail=sal_False; } 764cdf0e10cSrcweir if (pOL==NULL) pOL=pRect->GetSubList(); 765cdf0e10cSrcweir if (pOL!=NULL) { pRet=pRect; bInsRect=sal_False; } 766cdf0e10cSrcweir if (pOL==NULL) { 767cdf0e10cSrcweir SdrObjGroup* pGrp=new SdrObjGroup; 768cdf0e10cSrcweir pOL=pGrp->GetSubList(); 769cdf0e10cSrcweir pRet=pGrp; 770cdf0e10cSrcweir } 771cdf0e10cSrcweir if (bInsRect) pOL->NbcInsertObject(pRect); 772cdf0e10cSrcweir if (bInsTail) pOL->NbcInsertObject(pTail,0); 773cdf0e10cSrcweir } 774cdf0e10cSrcweir return pRet; 775cdf0e10cSrcweir } 776cdf0e10cSrcweir 777cdf0e10cSrcweir // #i32599# 778cdf0e10cSrcweir // Add own implementation for TRSetBaseGeometry to handle TailPos over changes. 779cdf0e10cSrcweir void SdrCaptionObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir // break up matrix 782cdf0e10cSrcweir basegfx::B2DTuple aScale; 783cdf0e10cSrcweir basegfx::B2DTuple aTranslate; 784cdf0e10cSrcweir double fRotate, fShearX; 785cdf0e10cSrcweir rMatrix.decompose(aScale, aTranslate, fRotate, fShearX); 786cdf0e10cSrcweir 787cdf0e10cSrcweir // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings 788cdf0e10cSrcweir // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly 789cdf0e10cSrcweir if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0)) 790cdf0e10cSrcweir { 791cdf0e10cSrcweir aScale.setX(fabs(aScale.getX())); 792cdf0e10cSrcweir aScale.setY(fabs(aScale.getY())); 793cdf0e10cSrcweir fRotate = fmod(fRotate + F_PI, F_2PI); 794cdf0e10cSrcweir } 795cdf0e10cSrcweir 796cdf0e10cSrcweir // force metric to pool metric 797cdf0e10cSrcweir SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); 798cdf0e10cSrcweir if(eMapUnit != SFX_MAPUNIT_100TH_MM) 799cdf0e10cSrcweir { 800cdf0e10cSrcweir switch(eMapUnit) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir case SFX_MAPUNIT_TWIP : 803cdf0e10cSrcweir { 804cdf0e10cSrcweir // position 805cdf0e10cSrcweir aTranslate.setX(ImplMMToTwips(aTranslate.getX())); 806cdf0e10cSrcweir aTranslate.setY(ImplMMToTwips(aTranslate.getY())); 807cdf0e10cSrcweir 808cdf0e10cSrcweir // size 809cdf0e10cSrcweir aScale.setX(ImplMMToTwips(aScale.getX())); 810cdf0e10cSrcweir aScale.setY(ImplMMToTwips(aScale.getY())); 811cdf0e10cSrcweir 812cdf0e10cSrcweir break; 813cdf0e10cSrcweir } 814cdf0e10cSrcweir default: 815cdf0e10cSrcweir { 816cdf0e10cSrcweir DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!"); 817cdf0e10cSrcweir } 818cdf0e10cSrcweir } 819cdf0e10cSrcweir } 820cdf0e10cSrcweir 821cdf0e10cSrcweir // if anchor is used, make position relative to it 822cdf0e10cSrcweir if( pModel->IsWriter() ) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir if(GetAnchorPos().X() || GetAnchorPos().Y()) 825cdf0e10cSrcweir { 826cdf0e10cSrcweir aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y()); 827cdf0e10cSrcweir } 828cdf0e10cSrcweir } 829cdf0e10cSrcweir 830cdf0e10cSrcweir // build BaseRect 831cdf0e10cSrcweir Point aPoint(FRound(aTranslate.getX()), FRound(aTranslate.getY())); 832cdf0e10cSrcweir Rectangle aBaseRect(aPoint, Size(FRound(aScale.getX()), FRound(aScale.getY()))); 833cdf0e10cSrcweir 834cdf0e10cSrcweir // set BaseRect, but rescue TailPos over this call 835cdf0e10cSrcweir const Point aTailPoint = GetTailPos(); 836cdf0e10cSrcweir SetSnapRect(aBaseRect); 837cdf0e10cSrcweir SetTailPos(aTailPoint); 838cdf0e10cSrcweir ImpRecalcTail(); 839cdf0e10cSrcweir } 840cdf0e10cSrcweir 841cdf0e10cSrcweir // geometry access 842cdf0e10cSrcweir basegfx::B2DPolygon SdrCaptionObj::getTailPolygon() const 843cdf0e10cSrcweir { 844cdf0e10cSrcweir return aTailPoly.getB2DPolygon(); 845cdf0e10cSrcweir } 846cdf0e10cSrcweir 847cdf0e10cSrcweir // eof 848