LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdorect.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 196 313 62.6 %
Date: 2012-08-25 Functions: 33 48 68.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 126 403 31.3 %

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

Generated by: LCOV version 1.10