LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdomeas.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 842 0.0 %
Date: 2012-08-25 Functions: 0 73 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1138 0.0 %

           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/svdomeas.hxx>
      31                 :            : #include <math.h>
      32                 :            : #include "svx/svditext.hxx" //
      33                 :            : #include <svx/xpoly.hxx>
      34                 :            : #include <svx/svdtrans.hxx>
      35                 :            : #include <svx/svdhdl.hxx>
      36                 :            : #include <svx/svdoutl.hxx>
      37                 :            : #include <svx/svddrag.hxx>
      38                 :            : #include <svx/svdpool.hxx>
      39                 :            : #include <svx/svdattrx.hxx>
      40                 :            : #include <svx/svdmodel.hxx>
      41                 :            : #include <svx/svdview.hxx>
      42                 :            : #include "svx/svdglob.hxx"   // StringCache
      43                 :            : #include "svx/svdstr.hrc"    // the object's name
      44                 :            : #include <svl/style.hxx>
      45                 :            : #include <svl/smplhint.hxx>
      46                 :            : #include <editeng/eeitem.hxx>
      47                 :            : #include <svx/xlnstit.hxx>
      48                 :            : #include <svx/xlnstwit.hxx>
      49                 :            : #include <svx/xlnedit.hxx>
      50                 :            : #include <svx/xlnwtit.hxx>
      51                 :            : #include <svx/xlnedwit.hxx>
      52                 :            : #include <svx/xlnstcit.hxx>
      53                 :            : #include <svx/xlnedcit.hxx>
      54                 :            : #include <editeng/outlobj.hxx>
      55                 :            : #include <editeng/outliner.hxx>
      56                 :            : #include <editeng/editobj.hxx>
      57                 :            : #include <editeng/measfld.hxx>
      58                 :            : #include <editeng/flditem.hxx>
      59                 :            : #include <svx/svdogrp.hxx>
      60                 :            : #include <svx/svdopath.hxx>
      61                 :            : #include <svx/svdpage.hxx>
      62                 :            : #include <unotools/syslocale.hxx>
      63                 :            : #include <svx/sdr/properties/measureproperties.hxx>
      64                 :            : #include <svx/sdr/contact/viewcontactofsdrmeasureobj.hxx>
      65                 :            : #include <basegfx/point/b2dpoint.hxx>
      66                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      67                 :            : #include <basegfx/polygon/b2dpolypolygon.hxx>
      68                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      69                 :            : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      70                 :            : #include "svdconv.hxx"
      71                 :            : 
      72                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
      73                 :            : 
      74                 :          0 : SdrMeasureObjGeoData::SdrMeasureObjGeoData() {}
      75         [ #  # ]:          0 : SdrMeasureObjGeoData::~SdrMeasureObjGeoData() {}
      76                 :            : 
      77                 :          0 : void SdrMeasureObj::TakeRepresentation( XubString& rStr, SdrMeasureFieldKind eMeasureFieldKind ) const
      78                 :            : {
      79         [ #  # ]:          0 :     rStr.Erase();
      80         [ #  # ]:          0 :     Fraction aMeasureScale(1, 1);
      81                 :          0 :     sal_Bool bTextRota90(sal_False);
      82                 :          0 :     sal_Bool bShowUnit(sal_False);
      83                 :          0 :     FieldUnit eMeasureUnit(FUNIT_NONE);
      84                 :          0 :     FieldUnit eModUIUnit(FUNIT_NONE);
      85                 :            : 
      86         [ #  # ]:          0 :     const SfxItemSet& rSet = GetMergedItemSet();
      87         [ #  # ]:          0 :     bTextRota90 = ((SdrMeasureTextRota90Item&)rSet.Get(SDRATTR_MEASURETEXTROTA90)).GetValue();
      88         [ #  # ]:          0 :     eMeasureUnit = ((SdrMeasureUnitItem&)rSet.Get(SDRATTR_MEASUREUNIT)).GetValue();
      89 [ #  # ][ #  # ]:          0 :     aMeasureScale = ((SdrMeasureScaleItem&)rSet.Get(SDRATTR_MEASURESCALE)).GetValue();
      90         [ #  # ]:          0 :     bShowUnit = ((SdrMeasureShowUnitItem&)rSet.Get(SDRATTR_MEASURESHOWUNIT)).GetValue();
      91         [ #  # ]:          0 :     sal_Int16 nNumDigits = ((SdrMeasureDecimalPlacesItem&)rSet.Get(SDRATTR_MEASUREDECIMALPLACES)).GetValue();
      92                 :            : 
      93   [ #  #  #  # ]:          0 :     switch(eMeasureFieldKind)
      94                 :            :     {
      95                 :            :         case SDRMEASUREFIELD_VALUE:
      96                 :            :         {
      97         [ #  # ]:          0 :             if(pModel)
      98                 :            :             {
      99                 :          0 :                 eModUIUnit = pModel->GetUIUnit();
     100                 :            : 
     101         [ #  # ]:          0 :                 if(eMeasureUnit == FUNIT_NONE)
     102                 :          0 :                     eMeasureUnit = eModUIUnit;
     103                 :            : 
     104         [ #  # ]:          0 :                 sal_Int32 nLen(GetLen(aPt2 - aPt1));
     105         [ #  # ]:          0 :                 Fraction aFact(1,1);
     106                 :            : 
     107         [ #  # ]:          0 :                 if(eMeasureUnit != eModUIUnit)
     108                 :            :                 {
     109                 :            :                     // for the unit conversion
     110 [ #  # ][ #  # ]:          0 :                     aFact *= GetMapFactor(eModUIUnit, eMeasureUnit).X();
     111                 :            :                 }
     112                 :            : 
     113         [ #  # ]:          0 :                 if(aMeasureScale.GetNumerator() != aMeasureScale.GetDenominator())
     114                 :            :                 {
     115         [ #  # ]:          0 :                     aFact *= aMeasureScale;
     116                 :            :                 }
     117                 :            : 
     118         [ #  # ]:          0 :                 if(aFact.GetNumerator() != aFact.GetDenominator())
     119                 :            :                 {
     120                 :            :                     // scale via BigInt, to avoid overruns
     121         [ #  # ]:          0 :                     nLen = BigMulDiv(nLen, aFact.GetNumerator(), aFact.GetDenominator());
     122                 :            :                 }
     123                 :            : 
     124                 :          0 :                 rtl::OUString aTmp;
     125         [ #  # ]:          0 :                 pModel->TakeMetricStr(nLen, aTmp, true, nNumDigits);
     126         [ #  # ]:          0 :                 rStr = aTmp;
     127                 :            : 
     128 [ #  # ][ #  # ]:          0 :                 if(!aFact.IsValid())
     129                 :            :                 {
     130 [ #  # ][ #  # ]:          0 :                     rStr = String();
                 [ #  # ]
     131         [ #  # ]:          0 :                     rStr += sal_Unicode('?');
     132                 :            :                 }
     133                 :            : 
     134 [ #  # ][ #  # ]:          0 :                 sal_Unicode cDec(SvtSysLocale().GetLocaleData().getNumDecimalSep()[0]);
         [ #  # ][ #  # ]
     135                 :            : 
     136 [ #  # ][ #  # ]:          0 :                 if(rStr.Search(cDec) != STRING_NOTFOUND)
     137                 :            :                 {
     138                 :          0 :                     xub_StrLen nLen2(rStr.Len() - 1);
     139                 :            : 
     140         [ #  # ]:          0 :                     while(rStr.GetChar(nLen2) == sal_Unicode('0'))
     141                 :            :                     {
     142         [ #  # ]:          0 :                         rStr.Erase(nLen2);
     143                 :          0 :                         nLen2--;
     144                 :            :                     }
     145                 :            : 
     146         [ #  # ]:          0 :                     if(rStr.GetChar(nLen2) == cDec)
     147                 :            :                     {
     148         [ #  # ]:          0 :                         rStr.Erase(nLen2);
     149                 :          0 :                         nLen2--;
     150                 :            :                     }
     151                 :            : 
     152         [ #  # ]:          0 :                     if(!rStr.Len())
     153         [ #  # ]:          0 :                         rStr += sal_Unicode('0');
     154                 :          0 :                 }
     155                 :            :             }
     156                 :            :             else
     157                 :            :             {
     158                 :            :                 // if there's no Model ... (e. g. preview in dialog)
     159 [ #  # ][ #  # ]:          0 :                 rStr = String();
                 [ #  # ]
     160         [ #  # ]:          0 :                 rStr.AppendAscii("4711");
     161                 :            :             }
     162                 :            : 
     163                 :          0 :             break;
     164                 :            :         }
     165                 :            :         case SDRMEASUREFIELD_UNIT:
     166                 :            :         {
     167         [ #  # ]:          0 :             if(bShowUnit)
     168                 :            :             {
     169         [ #  # ]:          0 :                 if(pModel)
     170                 :            :                 {
     171                 :          0 :                     eModUIUnit = pModel->GetUIUnit();
     172                 :            : 
     173         [ #  # ]:          0 :                     if(eMeasureUnit == FUNIT_NONE)
     174                 :          0 :                         eMeasureUnit = eModUIUnit;
     175                 :            : 
     176         [ #  # ]:          0 :                     if(bShowUnit)
     177         [ #  # ]:          0 :                         pModel->TakeUnitStr(eMeasureUnit, rStr);
     178                 :            :                 }
     179                 :            :             }
     180                 :            : 
     181                 :          0 :             break;
     182                 :            :         }
     183                 :            :         case SDRMEASUREFIELD_ROTA90BLANCS:
     184                 :            :         {
     185         [ #  # ]:          0 :             if(bTextRota90)
     186                 :            :             {
     187 [ #  # ][ #  # ]:          0 :                 rStr = String();
                 [ #  # ]
     188         [ #  # ]:          0 :                 rStr += sal_Unicode(' ');
     189                 :            :             }
     190                 :            : 
     191                 :          0 :             break;
     192                 :            :         }
     193                 :            :     }
     194                 :          0 : }
     195                 :            : 
     196                 :            : //////////////////////////////////////////////////////////////////////////////
     197                 :            : // BaseProperties section
     198                 :            : 
     199                 :          0 : sdr::properties::BaseProperties* SdrMeasureObj::CreateObjectSpecificProperties()
     200                 :            : {
     201         [ #  # ]:          0 :     return new sdr::properties::MeasureProperties(*this);
     202                 :            : }
     203                 :            : 
     204                 :            : //////////////////////////////////////////////////////////////////////////////
     205                 :            : // DrawContact section
     206                 :            : 
     207                 :          0 : sdr::contact::ViewContact* SdrMeasureObj::CreateObjectSpecificViewContact()
     208                 :            : {
     209         [ #  # ]:          0 :     return new sdr::contact::ViewContactOfSdrMeasureObj(*this);
     210                 :            : }
     211                 :            : 
     212                 :            : //////////////////////////////////////////////////////////////////////////////
     213                 :            : 
     214 [ #  # ][ #  # ]:          0 : TYPEINIT1(SdrMeasureObj,SdrTextObj);
     215                 :            : 
     216                 :          0 : SdrMeasureObj::SdrMeasureObj():
     217                 :          0 :     bTextDirty(sal_False)
     218                 :            : {
     219                 :            :     // #i25616#
     220                 :          0 :     mbSupportTextIndentingOnLineWidthChange = sal_False;
     221                 :          0 : }
     222                 :            : 
     223                 :          0 : SdrMeasureObj::SdrMeasureObj(const Point& rPt1, const Point& rPt2):
     224                 :            :     aPt1(rPt1),
     225                 :            :     aPt2(rPt2),
     226                 :          0 :     bTextDirty(sal_False)
     227                 :            : {
     228                 :            :     // #i25616#
     229                 :          0 :     mbSupportTextIndentingOnLineWidthChange = sal_False;
     230                 :          0 : }
     231                 :            : 
     232                 :          0 : SdrMeasureObj::~SdrMeasureObj()
     233                 :            : {
     234         [ #  # ]:          0 : }
     235                 :            : 
     236                 :          0 : void SdrMeasureObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
     237                 :            : {
     238                 :          0 :     rInfo.bSelectAllowed    =sal_True;
     239                 :          0 :     rInfo.bMoveAllowed      =sal_True;
     240                 :          0 :     rInfo.bResizeFreeAllowed=sal_True;
     241                 :          0 :     rInfo.bResizePropAllowed=sal_True;
     242                 :          0 :     rInfo.bRotateFreeAllowed=sal_True;
     243                 :          0 :     rInfo.bRotate90Allowed  =sal_True;
     244                 :          0 :     rInfo.bMirrorFreeAllowed=sal_True;
     245                 :          0 :     rInfo.bMirror45Allowed  =sal_True;
     246                 :          0 :     rInfo.bMirror90Allowed  =sal_True;
     247                 :          0 :     rInfo.bTransparenceAllowed = sal_False;
     248                 :          0 :     rInfo.bGradientAllowed = sal_False;
     249                 :          0 :     rInfo.bShearAllowed     =sal_True;
     250                 :          0 :     rInfo.bEdgeRadiusAllowed=sal_False;
     251                 :          0 :     rInfo.bNoOrthoDesired   =sal_True;
     252                 :          0 :     rInfo.bNoContortion     =sal_False;
     253                 :          0 :     rInfo.bCanConvToPath    =sal_False;
     254                 :          0 :     rInfo.bCanConvToPoly    =sal_True;
     255                 :          0 :     rInfo.bCanConvToPathLineToArea=sal_False;
     256                 :          0 :     rInfo.bCanConvToPolyLineToArea=sal_False;
     257 [ #  # ][ #  # ]:          0 :     rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
     258                 :          0 : }
     259                 :            : 
     260                 :          0 : sal_uInt16 SdrMeasureObj::GetObjIdentifier() const
     261                 :            : {
     262                 :          0 :     return (sal_uInt16)OBJ_MEASURE;
     263                 :            : }
     264                 :            : 
     265                 :          0 : struct ImpMeasureRec : public SdrDragStatUserData
     266                 :            : {
     267                 :            :     Point                       aPt1;
     268                 :            :     Point                       aPt2;
     269                 :            :     SdrMeasureKind              eKind;
     270                 :            :     SdrMeasureTextHPos          eWantTextHPos;
     271                 :            :     SdrMeasureTextVPos          eWantTextVPos;
     272                 :            :     long                        nLineDist;
     273                 :            :     long                        nHelplineOverhang;
     274                 :            :     long                        nHelplineDist;
     275                 :            :     long                        nHelpline1Len;
     276                 :            :     long                        nHelpline2Len;
     277                 :            :     bool                        bBelowRefEdge;
     278                 :            :     bool                        bTextRota90;
     279                 :            :     bool                        bTextUpsideDown;
     280                 :            :     long                        nMeasureOverhang;
     281                 :            :     FieldUnit                   eMeasureUnit;
     282                 :            :     Fraction                    aMeasureScale;
     283                 :            :     bool                        bShowUnit;
     284                 :            :     String                      aFormatString;
     285                 :            :     bool                        bTextAutoAngle;
     286                 :            :     long                        nTextAutoAngleView;
     287                 :            :     bool                        bTextIsFixedAngle;
     288                 :            :     long                        nTextFixedAngle;
     289                 :            : };
     290                 :            : 
     291                 :          0 : struct ImpLineRec
     292                 :            : {
     293                 :            :     Point                       aP1;
     294                 :            :     Point                       aP2;
     295                 :            : };
     296                 :            : 
     297                 :          0 : struct ImpMeasurePoly
     298                 :            : {
     299                 :            :     ImpLineRec                  aMainline1; // those with the 1st arrowhead
     300                 :            :     ImpLineRec                  aMainline2; // those with the 2nd arrowhead
     301                 :            :     ImpLineRec                  aMainline3; // those in between
     302                 :            :     ImpLineRec                  aHelpline1;
     303                 :            :     ImpLineRec                  aHelpline2;
     304                 :            :     Rectangle                   aTextRect;
     305                 :            :     Size                        aTextSize;
     306                 :            :     long                        nLineLen;
     307                 :            :     long                        nLineWink;
     308                 :            :     long                        nTextWink;
     309                 :            :     long                        nHlpWink;
     310                 :            :     double                      nLineSin;
     311                 :            :     double                      nLineCos;
     312                 :            :     double                      nHlpSin;
     313                 :            :     double                      nHlpCos;
     314                 :            :     sal_uInt16                      nMainlineAnz;
     315                 :            :     SdrMeasureTextHPos          eUsedTextHPos;
     316                 :            :     SdrMeasureTextVPos          eUsedTextVPos;
     317                 :            :     long                        nLineWdt2;  // half the line width
     318                 :            :     long                        nArrow1Len; // length of 1st arrowhead; for Center, use only half
     319                 :            :     long                        nArrow2Len; // length of 2nd arrowhead; for Center, use only half
     320                 :            :     long                        nArrow1Wdt; // width of 1st arrow
     321                 :            :     long                        nArrow2Wdt; // width of 2nd arrow
     322                 :            :     long                        nShortLineLen; // line length, if PfeileAussen (arrowheads on the outside)
     323                 :            :     bool                        bArrow1Center; // arrowhead 1 centered?
     324                 :            :     bool                        bArrow2Center; // arrowhead 2 centered?
     325                 :            :     bool                        bAutoUpsideDown; // UpsideDown via automation
     326                 :            :     bool                        bPfeileAussen; // arrowheads on the outside
     327                 :            :     bool                        bBreakedLine;
     328                 :            : };
     329                 :            : 
     330                 :          0 : void SdrMeasureObj::ImpTakeAttr(ImpMeasureRec& rRec) const
     331                 :            : {
     332                 :          0 :     rRec.aPt1 = aPt1;
     333                 :          0 :     rRec.aPt2 = aPt2;
     334                 :            : 
     335                 :          0 :     const SfxItemSet& rSet = GetObjectItemSet();
     336                 :          0 :     rRec.eKind            =((SdrMeasureKindItem&            )rSet.Get(SDRATTR_MEASUREKIND            )).GetValue();
     337                 :          0 :     rRec.eWantTextHPos    =((SdrMeasureTextHPosItem&        )rSet.Get(SDRATTR_MEASURETEXTHPOS        )).GetValue();
     338                 :          0 :     rRec.eWantTextVPos    =((SdrMeasureTextVPosItem&        )rSet.Get(SDRATTR_MEASURETEXTVPOS        )).GetValue();
     339                 :          0 :     rRec.nLineDist        =((SdrMeasureLineDistItem&        )rSet.Get(SDRATTR_MEASURELINEDIST        )).GetValue();
     340                 :          0 :     rRec.nHelplineOverhang=((SdrMeasureHelplineOverhangItem&)rSet.Get(SDRATTR_MEASUREHELPLINEOVERHANG)).GetValue();
     341                 :          0 :     rRec.nHelplineDist    =((SdrMeasureHelplineDistItem&    )rSet.Get(SDRATTR_MEASUREHELPLINEDIST    )).GetValue();
     342                 :          0 :     rRec.nHelpline1Len    =((SdrMeasureHelpline1LenItem&    )rSet.Get(SDRATTR_MEASUREHELPLINE1LEN    )).GetValue();
     343                 :          0 :     rRec.nHelpline2Len    =((SdrMeasureHelpline2LenItem&    )rSet.Get(SDRATTR_MEASUREHELPLINE2LEN    )).GetValue();
     344                 :          0 :     rRec.bBelowRefEdge    =((SdrMeasureBelowRefEdgeItem&    )rSet.Get(SDRATTR_MEASUREBELOWREFEDGE    )).GetValue();
     345                 :          0 :     rRec.bTextRota90      =((SdrMeasureTextRota90Item&      )rSet.Get(SDRATTR_MEASURETEXTROTA90      )).GetValue();
     346                 :          0 :     rRec.bTextUpsideDown  =((SdrMeasureTextUpsideDownItem&  )rSet.Get(SDRATTR_MEASURETEXTUPSIDEDOWN  )).GetValue();
     347                 :          0 :     rRec.nMeasureOverhang =((SdrMeasureOverhangItem&        )rSet.Get(SDRATTR_MEASUREOVERHANG        )).GetValue();
     348                 :          0 :     rRec.eMeasureUnit     =((SdrMeasureUnitItem&            )rSet.Get(SDRATTR_MEASUREUNIT            )).GetValue();
     349                 :          0 :     rRec.aMeasureScale    =((SdrMeasureScaleItem&           )rSet.Get(SDRATTR_MEASURESCALE           )).GetValue();
     350                 :          0 :     rRec.bShowUnit        =((SdrMeasureShowUnitItem&        )rSet.Get(SDRATTR_MEASURESHOWUNIT        )).GetValue();
     351                 :          0 :     rRec.aFormatString    =((SdrMeasureFormatStringItem&    )rSet.Get(SDRATTR_MEASUREFORMATSTRING    )).GetValue();
     352                 :          0 :     rRec.bTextAutoAngle    =((SdrMeasureTextAutoAngleItem&    )rSet.Get(SDRATTR_MEASURETEXTAUTOANGLE    )).GetValue();
     353                 :          0 :     rRec.nTextAutoAngleView=((SdrMeasureTextAutoAngleViewItem&)rSet.Get(SDRATTR_MEASURETEXTAUTOANGLEVIEW)).GetValue();
     354                 :          0 :     rRec.bTextIsFixedAngle =((SdrMeasureTextIsFixedAngleItem& )rSet.Get(SDRATTR_MEASURETEXTISFIXEDANGLE )).GetValue();
     355                 :          0 :     rRec.nTextFixedAngle   =((SdrMeasureTextFixedAngleItem&   )rSet.Get(SDRATTR_MEASURETEXTFIXEDANGLE   )).GetValue();
     356                 :          0 : }
     357                 :            : 
     358                 :          0 : long impGetLineStartEndDistance(const basegfx::B2DPolyPolygon& rPolyPolygon, long nNewWidth, bool bCenter)
     359                 :            : {
     360         [ #  # ]:          0 :     const basegfx::B2DRange aPolygonRange(rPolyPolygon.getB2DRange());
     361 [ #  # ][ #  # ]:          0 :     const double fOldWidth(aPolygonRange.getWidth() > 1.0 ? aPolygonRange.getWidth() : 1.0);
                 [ #  # ]
     362                 :          0 :     const double fScale((double)nNewWidth / fOldWidth);
     363         [ #  # ]:          0 :     long nHeight(basegfx::fround(aPolygonRange.getHeight() * fScale));
     364                 :            : 
     365         [ #  # ]:          0 :     if(bCenter)
     366                 :            :     {
     367                 :          0 :         nHeight /= 2L;
     368                 :            :     }
     369                 :            : 
     370                 :          0 :     return nHeight;
     371                 :            : }
     372                 :            : 
     373                 :          0 : void SdrMeasureObj::ImpCalcGeometrics(const ImpMeasureRec& rRec, ImpMeasurePoly& rPol) const
     374                 :            : {
     375                 :          0 :     Point aP1(rRec.aPt1);
     376                 :          0 :     Point aP2(rRec.aPt2);
     377                 :          0 :     Point aDelt(aP2); aDelt-=aP1;
     378                 :            : 
     379         [ #  # ]:          0 :     rPol.aTextSize=GetTextSize();
     380         [ #  # ]:          0 :     rPol.nLineLen=GetLen(aDelt);
     381                 :            : 
     382                 :          0 :     rPol.nLineWdt2=0;
     383                 :          0 :     long nArrow1Len=0; bool bArrow1Center=false;
     384                 :          0 :     long nArrow2Len=0; bool bArrow2Center=false;
     385                 :          0 :     long nArrow1Wdt=0;
     386                 :          0 :     long nArrow2Wdt=0;
     387                 :          0 :     rPol.nArrow1Wdt=0;
     388                 :          0 :     rPol.nArrow2Wdt=0;
     389                 :          0 :     long nArrowNeed=0;
     390                 :          0 :     long nShortLen=0;
     391                 :          0 :     bool bPfeileAussen = false;
     392                 :            : 
     393         [ #  # ]:          0 :     const SfxItemSet& rSet = GetObjectItemSet();
     394         [ #  # ]:          0 :     sal_Int32 nLineWdt = ((XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue(); // line width
     395                 :          0 :     rPol.nLineWdt2 = (nLineWdt + 1) / 2;
     396                 :            : 
     397         [ #  # ]:          0 :     nArrow1Wdt = ((const XLineStartWidthItem&)(rSet.Get(XATTR_LINESTARTWIDTH))).GetValue();
     398         [ #  # ]:          0 :     if(nArrow1Wdt < 0)
     399                 :          0 :         nArrow1Wdt = -nLineWdt * nArrow1Wdt / 100; // <0 = relativ
     400                 :            : 
     401         [ #  # ]:          0 :     nArrow2Wdt = ((const XLineEndWidthItem&)(rSet.Get(XATTR_LINEENDWIDTH))).GetValue();
     402         [ #  # ]:          0 :     if(nArrow2Wdt < 0)
     403                 :          0 :         nArrow2Wdt = -nLineWdt * nArrow2Wdt / 100; // <0 = relativ
     404                 :            : 
     405 [ #  # ][ #  # ]:          0 :     basegfx::B2DPolyPolygon aPol1(((const XLineStartItem&)(rSet.Get(XATTR_LINESTART))).GetLineStartValue());
     406 [ #  # ][ #  # ]:          0 :     basegfx::B2DPolyPolygon aPol2(((const XLineEndItem&)(rSet.Get(XATTR_LINEEND))).GetLineEndValue());
     407         [ #  # ]:          0 :     bArrow1Center = ((const XLineStartCenterItem&)(rSet.Get(XATTR_LINESTARTCENTER))).GetValue();
     408         [ #  # ]:          0 :     bArrow2Center = ((const XLineEndCenterItem&)(rSet.Get(XATTR_LINEENDCENTER))).GetValue();
     409         [ #  # ]:          0 :     nArrow1Len = impGetLineStartEndDistance(aPol1, nArrow1Wdt, bArrow1Center) - 1;
     410         [ #  # ]:          0 :     nArrow2Len = impGetLineStartEndDistance(aPol2, nArrow2Wdt, bArrow2Center) - 1;
     411                 :            : 
     412                 :            :     // nArrowLen is already halved at bCenter.
     413                 :            :     // In the case of 2 arrowheads each 4mm long, we can't go below 10mm.
     414                 :          0 :     nArrowNeed=nArrow1Len+nArrow2Len+(nArrow1Wdt+nArrow2Wdt)/2;
     415         [ #  # ]:          0 :     if (rPol.nLineLen<nArrowNeed) bPfeileAussen = true;
     416                 :          0 :     nShortLen=(nArrow1Len+nArrow1Wdt + nArrow2Len+nArrow2Wdt) /2;
     417                 :            : 
     418                 :          0 :     rPol.eUsedTextHPos=rRec.eWantTextHPos;
     419                 :          0 :     rPol.eUsedTextVPos=rRec.eWantTextVPos;
     420         [ #  # ]:          0 :     if (rPol.eUsedTextVPos==SDRMEASURE_TEXTVAUTO) rPol.eUsedTextVPos=SDRMEASURE_ABOVE;
     421                 :          0 :     bool bBrkLine=rPol.eUsedTextVPos==SDRMEASURETEXT_BREAKEDLINE;
     422         [ #  # ]:          0 :     if (rPol.eUsedTextVPos==SDRMEASURETEXT_VERTICALCENTERED)
     423                 :            :     {
     424         [ #  # ]:          0 :         OutlinerParaObject* pOutlinerParaObject = SdrTextObj::GetOutlinerParaObject();
     425 [ #  # ][ #  # ]:          0 :         if (pOutlinerParaObject!=NULL && pOutlinerParaObject->GetTextObject().GetParagraphCount()==1)
         [ #  # ][ #  # ]
                 [ #  # ]
     426                 :            :         {
     427                 :          0 :             bBrkLine=sal_True; // dashed line if there's only on paragraph.
     428                 :            :         }
     429                 :            :     }
     430                 :          0 :     rPol.bBreakedLine=bBrkLine;
     431         [ #  # ]:          0 :     if (rPol.eUsedTextHPos==SDRMEASURE_TEXTHAUTO) { // if text is too wide, push it outside
     432                 :          0 :         bool bOutside = false;
     433         [ #  # ]:          0 :         long nNeedSiz=!rRec.bTextRota90 ? rPol.aTextSize.Width() : rPol.aTextSize.Height();
     434         [ #  # ]:          0 :         if (nNeedSiz>rPol.nLineLen) bOutside = true; // text doesn't fit in between
     435         [ #  # ]:          0 :         if (bBrkLine) {
     436         [ #  # ]:          0 :             if (nNeedSiz+nArrowNeed>rPol.nLineLen) bPfeileAussen = true; // text fits in between, if arrowheads are on the outside
     437                 :            :         } else {
     438                 :          0 :             long nSmallNeed=nArrow1Len+nArrow2Len+(nArrow1Wdt+nArrow2Wdt)/2/4;
     439         [ #  # ]:          0 :             if (nNeedSiz+nSmallNeed>rPol.nLineLen) bPfeileAussen = true; // text fits in between, if arrowheads are on the outside
     440                 :            :         }
     441         [ #  # ]:          0 :         rPol.eUsedTextHPos=bOutside ? SDRMEASURE_TEXTLEFTOUTSIDE : SDRMEASURE_TEXTINSIDE;
     442                 :            :     }
     443         [ #  # ]:          0 :     if (rPol.eUsedTextHPos!=SDRMEASURE_TEXTINSIDE) bPfeileAussen = true;
     444                 :          0 :     rPol.nArrow1Wdt=nArrow1Wdt;
     445                 :          0 :     rPol.nArrow2Wdt=nArrow2Wdt;
     446                 :          0 :     rPol.nShortLineLen=nShortLen;
     447                 :          0 :     rPol.bPfeileAussen=bPfeileAussen;
     448                 :          0 :     rPol.nArrow1Len=nArrow1Len;
     449                 :          0 :     rPol.bArrow1Center=bArrow1Center;
     450                 :          0 :     rPol.nArrow2Len=nArrow2Len;
     451                 :          0 :     rPol.bArrow2Center=bArrow2Center;
     452                 :            : 
     453         [ #  # ]:          0 :     rPol.nLineWink=GetAngle(aDelt);
     454                 :          0 :     double a=rPol.nLineWink*nPi180;
     455                 :          0 :     double nLineSin=sin(a);
     456                 :          0 :     double nLineCos=cos(a);
     457                 :          0 :     rPol.nLineSin=nLineSin;
     458                 :          0 :     rPol.nLineCos=nLineCos;
     459                 :            : 
     460                 :          0 :     rPol.nTextWink=rPol.nLineWink;
     461         [ #  # ]:          0 :     if (rRec.bTextRota90) rPol.nTextWink+=9000;
     462                 :            : 
     463                 :          0 :     rPol.bAutoUpsideDown=sal_False;
     464         [ #  # ]:          0 :     if (rRec.bTextAutoAngle) {
     465         [ #  # ]:          0 :         long nTmpWink=NormAngle360(rPol.nTextWink-rRec.nTextAutoAngleView);
     466         [ #  # ]:          0 :         if (nTmpWink>=18000) {
     467                 :          0 :             rPol.nTextWink+=18000;
     468                 :          0 :             rPol.bAutoUpsideDown=sal_True;
     469                 :            :         }
     470                 :            :     }
     471                 :            : 
     472         [ #  # ]:          0 :     if (rRec.bTextUpsideDown) rPol.nTextWink+=18000;
     473         [ #  # ]:          0 :     rPol.nTextWink=NormAngle360(rPol.nTextWink);
     474                 :          0 :     rPol.nHlpWink=rPol.nLineWink+9000;
     475         [ #  # ]:          0 :     if (rRec.bBelowRefEdge) rPol.nHlpWink+=18000;
     476         [ #  # ]:          0 :     rPol.nHlpWink=NormAngle360(rPol.nHlpWink);
     477                 :          0 :     double nHlpSin=nLineCos;
     478                 :          0 :     double nHlpCos=-nLineSin;
     479         [ #  # ]:          0 :     if (rRec.bBelowRefEdge) {
     480                 :          0 :         nHlpSin=-nHlpSin;
     481                 :          0 :         nHlpCos=-nHlpCos;
     482                 :            :     }
     483                 :          0 :     rPol.nHlpSin=nHlpSin;
     484                 :          0 :     rPol.nHlpCos=nHlpCos;
     485                 :            : 
     486                 :          0 :     long nLineDist=rRec.nLineDist;
     487                 :          0 :     long nOverhang=rRec.nHelplineOverhang;
     488                 :          0 :     long nHelplineDist=rRec.nHelplineDist;
     489                 :            : 
     490                 :          0 :     long dx= Round(nLineDist*nHlpCos);
     491                 :          0 :     long dy=-Round(nLineDist*nHlpSin);
     492                 :          0 :     long dxh1a= Round((nHelplineDist-rRec.nHelpline1Len)*nHlpCos);
     493                 :          0 :     long dyh1a=-Round((nHelplineDist-rRec.nHelpline1Len)*nHlpSin);
     494                 :          0 :     long dxh1b= Round((nHelplineDist-rRec.nHelpline2Len)*nHlpCos);
     495                 :          0 :     long dyh1b=-Round((nHelplineDist-rRec.nHelpline2Len)*nHlpSin);
     496                 :          0 :     long dxh2= Round((nLineDist+nOverhang)*nHlpCos);
     497                 :          0 :     long dyh2=-Round((nLineDist+nOverhang)*nHlpSin);
     498                 :            : 
     499                 :            :     // extension line 1
     500                 :          0 :     rPol.aHelpline1.aP1=Point(aP1.X()+dxh1a,aP1.Y()+dyh1a);
     501                 :          0 :     rPol.aHelpline1.aP2=Point(aP1.X()+dxh2,aP1.Y()+dyh2);
     502                 :            : 
     503                 :            :     // extension line 2
     504                 :          0 :     rPol.aHelpline2.aP1=Point(aP2.X()+dxh1b,aP2.Y()+dyh1b);
     505                 :          0 :     rPol.aHelpline2.aP2=Point(aP2.X()+dxh2,aP2.Y()+dyh2);
     506                 :            : 
     507                 :            :     // dimension line
     508                 :          0 :     Point aMainlinePt1(aP1.X()+dx,aP1.Y()+dy);
     509                 :          0 :     Point aMainlinePt2(aP2.X()+dx,aP2.Y()+dy);
     510         [ #  # ]:          0 :     if (!bPfeileAussen) {
     511                 :          0 :         rPol.aMainline1.aP1=aMainlinePt1;
     512                 :          0 :         rPol.aMainline1.aP2=aMainlinePt2;
     513                 :          0 :         rPol.aMainline2=rPol.aMainline1;
     514                 :          0 :         rPol.aMainline3=rPol.aMainline1;
     515                 :          0 :         rPol.nMainlineAnz=1;
     516         [ #  # ]:          0 :         if (bBrkLine) {
     517         [ #  # ]:          0 :             long nNeedSiz=!rRec.bTextRota90 ? rPol.aTextSize.Width() : rPol.aTextSize.Height();
     518                 :          0 :             long nHalfLen=(rPol.nLineLen-nNeedSiz-nArrow1Wdt/4-nArrow2Wdt/4) /2;
     519                 :          0 :             rPol.nMainlineAnz=2;
     520                 :          0 :             rPol.aMainline1.aP2=aMainlinePt1;
     521                 :          0 :             rPol.aMainline1.aP2.X()+=nHalfLen;
     522                 :          0 :             RotatePoint(rPol.aMainline1.aP2,rPol.aMainline1.aP1,nLineSin,nLineCos);
     523                 :          0 :             rPol.aMainline2.aP1=aMainlinePt2;
     524                 :          0 :             rPol.aMainline2.aP1.X()-=nHalfLen;
     525                 :          0 :             RotatePoint(rPol.aMainline2.aP1,rPol.aMainline2.aP2,nLineSin,nLineCos);
     526                 :            :         }
     527                 :            :     } else {
     528                 :          0 :         long nLen1=nShortLen; // arrowhead's width as line length outside of the arrowhead
     529                 :          0 :         long nLen2=nShortLen;
     530         [ #  # ]:          0 :         long nTextWdt=rRec.bTextRota90 ? rPol.aTextSize.Height() : rPol.aTextSize.Width();
     531         [ #  # ]:          0 :         if (!bBrkLine) {
     532         [ #  # ]:          0 :             if (rPol.eUsedTextHPos==SDRMEASURE_TEXTLEFTOUTSIDE) nLen1=nArrow1Len+nTextWdt;
     533         [ #  # ]:          0 :             if (rPol.eUsedTextHPos==SDRMEASURE_TEXTRIGHTOUTSIDE) nLen2=nArrow2Len+nTextWdt;
     534                 :            :         }
     535                 :          0 :         rPol.aMainline1.aP1=aMainlinePt1;
     536                 :          0 :         rPol.aMainline1.aP2=aMainlinePt1; rPol.aMainline1.aP2.X()-=nLen1; RotatePoint(rPol.aMainline1.aP2,aMainlinePt1,nLineSin,nLineCos);
     537                 :          0 :         rPol.aMainline2.aP1=aMainlinePt2; rPol.aMainline2.aP1.X()+=nLen2; RotatePoint(rPol.aMainline2.aP1,aMainlinePt2,nLineSin,nLineCos);
     538                 :          0 :         rPol.aMainline2.aP2=aMainlinePt2;
     539                 :          0 :         rPol.aMainline3.aP1=aMainlinePt1;
     540                 :          0 :         rPol.aMainline3.aP2=aMainlinePt2;
     541                 :          0 :         rPol.nMainlineAnz=3;
     542 [ #  # ][ #  # ]:          0 :         if (bBrkLine && rPol.eUsedTextHPos==SDRMEASURE_TEXTINSIDE) rPol.nMainlineAnz=2;
     543 [ #  # ][ #  # ]:          0 :     }
     544                 :          0 : }
     545                 :            : 
     546                 :          0 : basegfx::B2DPolyPolygon SdrMeasureObj::ImpCalcXPoly(const ImpMeasurePoly& rPol) const
     547                 :            : {
     548         [ #  # ]:          0 :     basegfx::B2DPolyPolygon aRetval;
     549         [ #  # ]:          0 :     basegfx::B2DPolygon aPartPolyA;
     550         [ #  # ]:          0 :     aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline1.aP1.X(), rPol.aMainline1.aP1.Y()));
     551         [ #  # ]:          0 :     aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline1.aP2.X(), rPol.aMainline1.aP2.Y()));
     552         [ #  # ]:          0 :     aRetval.append(aPartPolyA);
     553                 :            : 
     554         [ #  # ]:          0 :     if(rPol.nMainlineAnz > 1)
     555                 :            :     {
     556         [ #  # ]:          0 :         aPartPolyA.clear();
     557         [ #  # ]:          0 :         aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline2.aP1.X(), rPol.aMainline2.aP1.Y()));
     558         [ #  # ]:          0 :         aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline2.aP2.X(), rPol.aMainline2.aP2.Y()));
     559         [ #  # ]:          0 :         aRetval.append(aPartPolyA);
     560                 :            :     }
     561                 :            : 
     562         [ #  # ]:          0 :     if(rPol.nMainlineAnz > 2)
     563                 :            :     {
     564         [ #  # ]:          0 :         aPartPolyA.clear();
     565         [ #  # ]:          0 :         aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline3.aP1.X(), rPol.aMainline3.aP1.Y()));
     566         [ #  # ]:          0 :         aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline3.aP2.X(), rPol.aMainline3.aP2.Y()));
     567         [ #  # ]:          0 :         aRetval.append(aPartPolyA);
     568                 :            :     }
     569                 :            : 
     570         [ #  # ]:          0 :     aPartPolyA.clear();
     571         [ #  # ]:          0 :     aPartPolyA.append(basegfx::B2DPoint(rPol.aHelpline1.aP1.X(), rPol.aHelpline1.aP1.Y()));
     572         [ #  # ]:          0 :     aPartPolyA.append(basegfx::B2DPoint(rPol.aHelpline1.aP2.X(), rPol.aHelpline1.aP2.Y()));
     573         [ #  # ]:          0 :     aRetval.append(aPartPolyA);
     574                 :            : 
     575         [ #  # ]:          0 :     aPartPolyA.clear();
     576         [ #  # ]:          0 :     aPartPolyA.append(basegfx::B2DPoint(rPol.aHelpline2.aP1.X(), rPol.aHelpline2.aP1.Y()));
     577         [ #  # ]:          0 :     aPartPolyA.append(basegfx::B2DPoint(rPol.aHelpline2.aP2.X(), rPol.aHelpline2.aP2.Y()));
     578         [ #  # ]:          0 :     aRetval.append(aPartPolyA);
     579                 :            : 
     580         [ #  # ]:          0 :     return aRetval;
     581                 :            : }
     582                 :            : 
     583                 :          0 : bool SdrMeasureObj::CalcFieldValue(const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos,
     584                 :            :     bool bEdit,
     585                 :            :     Color*& rpTxtColor, Color*& rpFldColor, XubString& rRet) const
     586                 :            : {
     587                 :          0 :     const SvxFieldData* pField=rField.GetField();
     588 [ #  # ][ #  # ]:          0 :     SdrMeasureField* pMeasureField=PTR_CAST(SdrMeasureField,pField);
     589         [ #  # ]:          0 :     if (pMeasureField!=NULL) {
     590                 :          0 :         TakeRepresentation(rRet, pMeasureField->GetMeasureFieldKind());
     591         [ #  # ]:          0 :         if (rpFldColor!=NULL) {
     592         [ #  # ]:          0 :             if (!bEdit)
     593                 :            :             {
     594                 :          0 :                 delete rpFldColor;
     595                 :          0 :                 rpFldColor=NULL;
     596                 :            :             }
     597                 :            :         }
     598                 :          0 :         return sal_True;
     599                 :            :     } else {
     600                 :          0 :         return SdrTextObj::CalcFieldValue(rField,nPara,nPos,bEdit,rpTxtColor,rpFldColor,rRet);
     601                 :            :     }
     602                 :            : }
     603                 :            : 
     604                 :          0 : void SdrMeasureObj::UndirtyText() const
     605                 :            : {
     606         [ #  # ]:          0 :     if (bTextDirty)
     607                 :            :     {
     608         [ #  # ]:          0 :         SdrOutliner& rOutliner=ImpGetDrawOutliner();
     609         [ #  # ]:          0 :         OutlinerParaObject* pOutlinerParaObject = SdrTextObj::GetOutlinerParaObject();
     610         [ #  # ]:          0 :         if(pOutlinerParaObject==NULL)
     611                 :            :         {
     612 [ #  # ][ #  # ]:          0 :             rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SDRMEASUREFIELD_ROTA90BLANCS), EE_FEATURE_FIELD), ESelection(0,0));
         [ #  # ][ #  # ]
                 [ #  # ]
     613 [ #  # ][ #  # ]:          0 :             rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SDRMEASUREFIELD_VALUE), EE_FEATURE_FIELD),ESelection(0,1));
         [ #  # ][ #  # ]
                 [ #  # ]
     614 [ #  # ][ #  # ]:          0 :             rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SDRMEASUREFIELD_UNIT), EE_FEATURE_FIELD),ESelection(0,2));
         [ #  # ][ #  # ]
                 [ #  # ]
     615 [ #  # ][ #  # ]:          0 :             rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SDRMEASUREFIELD_ROTA90BLANCS), EE_FEATURE_FIELD),ESelection(0,3));
         [ #  # ][ #  # ]
                 [ #  # ]
     616                 :            : 
     617 [ #  # ][ #  # ]:          0 :             if(GetStyleSheet())
     618 [ #  # ][ #  # ]:          0 :                 rOutliner.SetStyleSheet(0, GetStyleSheet());
     619                 :            : 
     620 [ #  # ][ #  # ]:          0 :             rOutliner.SetParaAttribs(0, GetObjectItemSet());
     621                 :            : 
     622                 :            :             // cast to nonconst
     623 [ #  # ][ #  # ]:          0 :             const_cast<SdrMeasureObj*>(this)->NbcSetOutlinerParaObject( rOutliner.CreateParaObject() );
     624                 :            :         }
     625                 :            :         else
     626                 :            :         {
     627         [ #  # ]:          0 :             rOutliner.SetText(*pOutlinerParaObject);
     628                 :            :         }
     629                 :            : 
     630         [ #  # ]:          0 :         rOutliner.SetUpdateMode(sal_True);
     631         [ #  # ]:          0 :         rOutliner.UpdateFields();
     632         [ #  # ]:          0 :         Size aSiz(rOutliner.CalcTextSize());
     633         [ #  # ]:          0 :         rOutliner.Clear();
     634                 :            :         // cast to nonconst three times
     635                 :          0 :         ((SdrMeasureObj*)this)->aTextSize=aSiz;
     636                 :          0 :         ((SdrMeasureObj*)this)->bTextSizeDirty=sal_False;
     637                 :          0 :         ((SdrMeasureObj*)this)->bTextDirty=sal_False;
     638                 :            :     }
     639                 :          0 : }
     640                 :            : 
     641                 :          0 : void SdrMeasureObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
     642                 :            : {
     643 [ #  # ][ #  # ]:          0 :     if (bTextDirty) UndirtyText();
     644         [ #  # ]:          0 :     ImpMeasureRec aRec;
     645         [ #  # ]:          0 :     ImpMeasurePoly aMPol;
     646         [ #  # ]:          0 :     ImpTakeAttr(aRec);
     647         [ #  # ]:          0 :     ImpCalcGeometrics(aRec,aMPol);
     648                 :            : 
     649                 :            :     // determine TextSize including text frame margins
     650                 :          0 :     Size aTextSize2(aMPol.aTextSize);
     651         [ #  # ]:          0 :     if (aTextSize2.Width()<1) aTextSize2.Width()=1;
     652         [ #  # ]:          0 :     if (aTextSize2.Height()<1) aTextSize2.Height()=1;
     653 [ #  # ][ #  # ]:          0 :     aTextSize2.Width()+=GetTextLeftDistance()+GetTextRightDistance();
     654 [ #  # ][ #  # ]:          0 :     aTextSize2.Height()+=GetTextUpperDistance()+GetTextLowerDistance();
     655                 :            : 
     656                 :          0 :     Point aPt1b(aMPol.aMainline1.aP1);
     657                 :          0 :     long nLen=aMPol.nLineLen;
     658                 :          0 :     long nLWdt=aMPol.nLineWdt2;
     659                 :          0 :     long nArr1Len=aMPol.nArrow1Len;
     660                 :          0 :     long nArr2Len=aMPol.nArrow2Len;
     661         [ #  # ]:          0 :     if (aMPol.bBreakedLine) {
     662                 :            :         // In the case of a dashed line and Outside, the text should be
     663                 :            :         // placed next to the line at the arrowhead instead of directly
     664                 :            :         // at the arrowhead.
     665                 :          0 :         nArr1Len=aMPol.nShortLineLen+aMPol.nArrow1Wdt/4;
     666                 :          0 :         nArr2Len=aMPol.nShortLineLen+aMPol.nArrow2Wdt/4;
     667                 :            :     }
     668                 :            : 
     669                 :          0 :     Point aTextPos;
     670                 :          0 :     bool bRota90=aRec.bTextRota90;
     671                 :          0 :     bool bUpsideDown=aRec.bTextUpsideDown!=aMPol.bAutoUpsideDown;
     672                 :          0 :     bool bBelowRefEdge=aRec.bBelowRefEdge;
     673                 :          0 :     SdrMeasureTextHPos eMH=aMPol.eUsedTextHPos;
     674                 :          0 :     SdrMeasureTextVPos eMV=aMPol.eUsedTextVPos;
     675         [ #  # ]:          0 :     if (!bRota90) {
     676      [ #  #  # ]:          0 :         switch (eMH) {
     677                 :          0 :             case SDRMEASURE_TEXTLEFTOUTSIDE: aTextPos.X()=aPt1b.X()-aTextSize2.Width()-nArr1Len-nLWdt; break;
     678                 :          0 :             case SDRMEASURE_TEXTRIGHTOUTSIDE: aTextPos.X()=aPt1b.X()+nLen+nArr2Len+nLWdt; break;
     679                 :          0 :             default: aTextPos.X()=aPt1b.X(); aTextSize2.Width()=nLen;
     680                 :            :         }
     681      [ #  #  # ]:          0 :         switch (eMV) {
     682                 :            :             case SDRMEASURETEXT_VERTICALCENTERED:
     683                 :          0 :             case SDRMEASURETEXT_BREAKEDLINE: aTextPos.Y()=aPt1b.Y()-aTextSize2.Height()/2; break;
     684                 :            :             case SDRMEASURE_BELOW: {
     685         [ #  # ]:          0 :                 if (!bUpsideDown) aTextPos.Y()=aPt1b.Y()+nLWdt;
     686                 :          0 :                 else aTextPos.Y()=aPt1b.Y()-aTextSize2.Height()-nLWdt;
     687                 :          0 :             } break;
     688                 :            :             default: {
     689         [ #  # ]:          0 :                 if (!bUpsideDown) aTextPos.Y()=aPt1b.Y()-aTextSize2.Height()-nLWdt;
     690                 :          0 :                 else aTextPos.Y()=aPt1b.Y()+nLWdt;
     691                 :            :             }
     692                 :            :         }
     693         [ #  # ]:          0 :         if (bUpsideDown) {
     694                 :          0 :             aTextPos.X()+=aTextSize2.Width();
     695                 :          0 :             aTextPos.Y()+=aTextSize2.Height();
     696                 :            :         }
     697                 :            :     } else { // also if bTextRota90==TRUE
     698      [ #  #  # ]:          0 :         switch (eMH) {
     699                 :          0 :             case SDRMEASURE_TEXTLEFTOUTSIDE: aTextPos.X()=aPt1b.X()-aTextSize2.Height()-nArr1Len; break;
     700                 :          0 :             case SDRMEASURE_TEXTRIGHTOUTSIDE: aTextPos.X()=aPt1b.X()+nLen+nArr2Len; break;
     701                 :          0 :             default: aTextPos.X()=aPt1b.X(); aTextSize2.Height()=nLen;
     702                 :            :         }
     703      [ #  #  # ]:          0 :         switch (eMV) {
     704                 :            :             case SDRMEASURETEXT_VERTICALCENTERED:
     705                 :          0 :             case SDRMEASURETEXT_BREAKEDLINE: aTextPos.Y()=aPt1b.Y()+aTextSize2.Width()/2; break;
     706                 :            :             case SDRMEASURE_BELOW: {
     707         [ #  # ]:          0 :                 if (!bBelowRefEdge) aTextPos.Y()=aPt1b.Y()+aTextSize2.Width()+nLWdt;
     708                 :          0 :                 else aTextPos.Y()=aPt1b.Y()-nLWdt;
     709                 :          0 :             } break;
     710                 :            :             default: {
     711         [ #  # ]:          0 :                 if (!bBelowRefEdge) aTextPos.Y()=aPt1b.Y()-nLWdt;
     712                 :          0 :                 else aTextPos.Y()=aPt1b.Y()+aTextSize2.Width()+nLWdt;
     713                 :            :             }
     714                 :            :         }
     715         [ #  # ]:          0 :         if (bUpsideDown) {
     716                 :          0 :             aTextPos.X()+=aTextSize2.Height();
     717                 :          0 :             aTextPos.Y()-=aTextSize2.Width();
     718                 :            :         }
     719                 :            :     }
     720         [ #  # ]:          0 :     if (aMPol.nTextWink!=aGeo.nDrehWink) {
     721                 :          0 :         ((SdrMeasureObj*)this)->aGeo.nDrehWink=aMPol.nTextWink;
     722         [ #  # ]:          0 :         ((SdrMeasureObj*)this)->aGeo.RecalcSinCos();
     723                 :            :     }
     724                 :          0 :     RotatePoint(aTextPos,aPt1b,aMPol.nLineSin,aMPol.nLineCos);
     725                 :          0 :     aTextSize2.Width()++; aTextSize2.Height()++; // because of the Rect-Ctor's odd behavior
     726         [ #  # ]:          0 :     rRect=Rectangle(aTextPos,aTextSize2);
     727         [ #  # ]:          0 :     rRect.Justify();
     728                 :          0 :     ((SdrMeasureObj*)this)->aRect=rRect;
     729                 :            : 
     730         [ #  # ]:          0 :     if (aMPol.nTextWink!=aGeo.nDrehWink) {
     731                 :          0 :         ((SdrMeasureObj*)this)->aGeo.nDrehWink=aMPol.nTextWink;
     732         [ #  # ]:          0 :         ((SdrMeasureObj*)this)->aGeo.RecalcSinCos();
     733         [ #  # ]:          0 :     }
     734                 :          0 : }
     735                 :            : 
     736                 :          0 : SdrMeasureObj* SdrMeasureObj::Clone() const
     737                 :            : {
     738                 :          0 :     return CloneHelper< SdrMeasureObj >();
     739                 :            : }
     740                 :            : 
     741                 :          0 : void SdrMeasureObj::TakeObjNameSingul(XubString& rName) const
     742                 :            : {
     743 [ #  # ][ #  # ]:          0 :     rName=ImpGetResStr(STR_ObjNameSingulMEASURE);
                 [ #  # ]
     744                 :            : 
     745 [ #  # ][ #  # ]:          0 :     String aName( GetName() );
     746         [ #  # ]:          0 :     if(aName.Len())
     747                 :            :     {
     748         [ #  # ]:          0 :         rName += sal_Unicode(' ');
     749         [ #  # ]:          0 :         rName += sal_Unicode('\'');
     750         [ #  # ]:          0 :         rName += aName;
     751         [ #  # ]:          0 :         rName += sal_Unicode('\'');
     752         [ #  # ]:          0 :     }
     753                 :          0 : }
     754                 :            : 
     755                 :          0 : void SdrMeasureObj::TakeObjNamePlural(XubString& rName) const
     756                 :            : {
     757         [ #  # ]:          0 :     rName=ImpGetResStr(STR_ObjNamePluralMEASURE);
     758                 :          0 : }
     759                 :            : 
     760                 :          0 : basegfx::B2DPolyPolygon SdrMeasureObj::TakeXorPoly() const
     761                 :            : {
     762         [ #  # ]:          0 :     ImpMeasureRec aRec;
     763         [ #  # ]:          0 :     ImpMeasurePoly aMPol;
     764         [ #  # ]:          0 :     ImpTakeAttr(aRec);
     765         [ #  # ]:          0 :     ImpCalcGeometrics(aRec,aMPol);
     766 [ #  # ][ #  # ]:          0 :     return ImpCalcXPoly(aMPol);
     767                 :            : }
     768                 :            : 
     769                 :          0 : sal_uInt32 SdrMeasureObj::GetHdlCount() const
     770                 :            : {
     771                 :          0 :     return 6L;
     772                 :            : }
     773                 :            : 
     774                 :          0 : SdrHdl* SdrMeasureObj::GetHdl(sal_uInt32 nHdlNum) const
     775                 :            : {
     776         [ #  # ]:          0 :     ImpMeasureRec aRec;
     777         [ #  # ]:          0 :     ImpMeasurePoly aMPol;
     778         [ #  # ]:          0 :     ImpTakeAttr(aRec);
     779                 :          0 :     aRec.nHelplineDist=0;
     780         [ #  # ]:          0 :     ImpCalcGeometrics(aRec,aMPol);
     781                 :          0 :     Point aPt;
     782                 :            : 
     783   [ #  #  #  #  :          0 :     switch (nHdlNum) {
                #  #  # ]
     784                 :          0 :         case 0: aPt=aMPol.aHelpline1.aP1; break;
     785                 :          0 :         case 1: aPt=aMPol.aHelpline2.aP1; break;
     786                 :          0 :         case 2: aPt=aPt1;       break;
     787                 :          0 :         case 3: aPt=aPt2;       break;
     788                 :          0 :         case 4: aPt=aMPol.aHelpline1.aP2; break;
     789                 :          0 :         case 5: aPt=aMPol.aHelpline2.aP2; break;
     790                 :            :     } // switch
     791 [ #  # ][ #  # ]:          0 :     SdrHdl* pHdl=new ImpMeasureHdl(aPt,HDL_USER);
     792                 :          0 :     pHdl->SetObjHdlNum(nHdlNum);
     793         [ #  # ]:          0 :     pHdl->SetDrehWink(aMPol.nLineWink);
     794         [ #  # ]:          0 :     return pHdl;
     795                 :            : }
     796                 :            : 
     797                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     798                 :            : 
     799                 :          0 : bool SdrMeasureObj::hasSpecialDrag() const
     800                 :            : {
     801                 :          0 :     return true;
     802                 :            : }
     803                 :            : 
     804                 :          0 : bool SdrMeasureObj::beginSpecialDrag(SdrDragStat& rDrag) const
     805                 :            : {
     806                 :          0 :     const SdrHdl* pHdl = rDrag.GetHdl();
     807                 :            : 
     808         [ #  # ]:          0 :     if(pHdl)
     809                 :            :     {
     810                 :          0 :         const sal_uInt32 nHdlNum(pHdl->GetObjHdlNum());
     811                 :            : 
     812 [ #  # ][ #  # ]:          0 :         if(nHdlNum != 2 && nHdlNum != 3)
     813                 :            :         {
     814                 :          0 :             rDrag.SetEndDragChangesAttributes(true);
     815                 :            :         }
     816                 :            : 
     817                 :          0 :         return true;
     818                 :            :     }
     819                 :            : 
     820                 :          0 :     return false;
     821                 :            : }
     822                 :            : 
     823                 :          0 : bool SdrMeasureObj::applySpecialDrag(SdrDragStat& rDrag)
     824                 :            : {
     825         [ #  # ]:          0 :     ImpMeasureRec aMeasureRec;
     826                 :          0 :     const SdrHdl* pHdl = rDrag.GetHdl();
     827                 :          0 :     const sal_uInt32 nHdlNum(pHdl->GetObjHdlNum());
     828                 :            : 
     829         [ #  # ]:          0 :     ImpTakeAttr(aMeasureRec);
     830         [ #  # ]:          0 :     ImpEvalDrag(aMeasureRec, rDrag);
     831                 :            : 
     832      [ #  #  # ]:          0 :     switch (nHdlNum)
     833                 :            :     {
     834                 :            :         case 2:
     835                 :            :         {
     836                 :          0 :             aPt1 = aMeasureRec.aPt1;
     837         [ #  # ]:          0 :             SetTextDirty();
     838                 :          0 :             break;
     839                 :            :         }
     840                 :            :         case 3:
     841                 :            :         {
     842                 :          0 :             aPt2 = aMeasureRec.aPt2;
     843         [ #  # ]:          0 :             SetTextDirty();
     844                 :          0 :             break;
     845                 :            :         }
     846                 :            :         default:
     847                 :            :         {
     848      [ #  #  # ]:          0 :             switch(nHdlNum)
     849                 :            :             {
     850                 :            :                 case 0:
     851                 :            :                 case 1:
     852                 :            :                 {
     853         [ #  # ]:          0 :                     ImpMeasureRec aOrigMeasureRec;
     854         [ #  # ]:          0 :                     ImpTakeAttr(aOrigMeasureRec);
     855                 :            : 
     856         [ #  # ]:          0 :                     if(aMeasureRec.nHelpline1Len != aOrigMeasureRec.nHelpline1Len)
     857                 :            :                     {
     858 [ #  # ][ #  # ]:          0 :                         SetObjectItem(SdrMeasureHelpline1LenItem(aMeasureRec.nHelpline1Len));
                 [ #  # ]
     859                 :            :                     }
     860                 :            : 
     861         [ #  # ]:          0 :                     if(aMeasureRec.nHelpline2Len != aOrigMeasureRec.nHelpline2Len)
     862                 :            :                     {
     863 [ #  # ][ #  # ]:          0 :                         SetObjectItem(SdrMeasureHelpline2LenItem(aMeasureRec.nHelpline2Len));
                 [ #  # ]
     864                 :            :                     }
     865                 :            : 
     866         [ #  # ]:          0 :                     break;
     867                 :            :                 }
     868                 :            : 
     869                 :            :                 case 4:
     870                 :            :                 case 5:
     871                 :            :                 {
     872         [ #  # ]:          0 :                     ImpMeasureRec aOrigMeasureRec;
     873         [ #  # ]:          0 :                     ImpTakeAttr(aOrigMeasureRec);
     874                 :            : 
     875         [ #  # ]:          0 :                     if(aMeasureRec.nLineDist != aOrigMeasureRec.nLineDist)
     876                 :            :                     {
     877 [ #  # ][ #  # ]:          0 :                         SetObjectItem(SdrMeasureLineDistItem(aMeasureRec.nLineDist));
                 [ #  # ]
     878                 :            :                     }
     879                 :            : 
     880         [ #  # ]:          0 :                     if(aMeasureRec.bBelowRefEdge != aOrigMeasureRec.bBelowRefEdge)
     881                 :            :                     {
     882 [ #  # ][ #  # ]:          0 :                         SetObjectItem(SdrMeasureBelowRefEdgeItem(aMeasureRec.bBelowRefEdge));
                 [ #  # ]
     883         [ #  # ]:          0 :                     }
     884                 :            :                 }
     885                 :            :             }
     886                 :            :         }
     887                 :            :     } // switch
     888                 :            : 
     889         [ #  # ]:          0 :     SetRectsDirty();
     890         [ #  # ]:          0 :     SetChanged();
     891                 :            : 
     892         [ #  # ]:          0 :     return true;
     893                 :            : }
     894                 :            : 
     895                 :          0 : String SdrMeasureObj::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const
     896                 :            : {
     897                 :          0 :     XubString aStr;
     898                 :          0 :     return aStr;
     899                 :            : }
     900                 :            : 
     901                 :          0 : void SdrMeasureObj::ImpEvalDrag(ImpMeasureRec& rRec, const SdrDragStat& rDrag) const
     902                 :            : {
     903         [ #  # ]:          0 :     long nLineWink=GetAngle(rRec.aPt2-rRec.aPt1);
     904                 :          0 :     double a=nLineWink*nPi180;
     905                 :          0 :     double nSin=sin(a);
     906                 :          0 :     double nCos=cos(a);
     907                 :            : 
     908                 :          0 :     const SdrHdl* pHdl=rDrag.GetHdl();
     909                 :          0 :     sal_uInt32 nHdlNum(pHdl->GetObjHdlNum());
     910 [ #  # ][ #  # ]:          0 :     bool bOrtho=rDrag.GetView()!=NULL && rDrag.GetView()->IsOrtho();
     911 [ #  # ][ #  # ]:          0 :     bool bBigOrtho=bOrtho && rDrag.GetView()->IsBigOrtho();
     912                 :          0 :     bool bBelow=rRec.bBelowRefEdge;
     913         [ #  # ]:          0 :     Point aPt(rDrag.GetNow());
     914                 :            : 
     915   [ #  #  #  #  :          0 :     switch (nHdlNum) {
                      # ]
     916                 :            :         case 0: {
     917                 :          0 :             RotatePoint(aPt,aPt1,nSin,-nCos);
     918                 :          0 :             rRec.nHelpline1Len=aPt1.Y()-aPt.Y();
     919         [ #  # ]:          0 :             if (bBelow) rRec.nHelpline1Len=-rRec.nHelpline1Len;
     920         [ #  # ]:          0 :             if (bOrtho) rRec.nHelpline2Len=rRec.nHelpline1Len;
     921                 :          0 :         } break;
     922                 :            :         case 1: {
     923                 :          0 :             RotatePoint(aPt,aPt2,nSin,-nCos);
     924                 :          0 :             rRec.nHelpline2Len=aPt2.Y()-aPt.Y();
     925         [ #  # ]:          0 :             if (bBelow) rRec.nHelpline2Len=-rRec.nHelpline2Len;
     926         [ #  # ]:          0 :             if (bOrtho) rRec.nHelpline1Len=rRec.nHelpline2Len;
     927                 :          0 :         } break;
     928                 :            :         case 2: case 3: {
     929                 :          0 :             bool bAnf=nHdlNum==2;
     930         [ #  # ]:          0 :             Point& rMov=bAnf ? rRec.aPt1 : rRec.aPt2;
     931                 :          0 :             Point aMov(rMov);
     932         [ #  # ]:          0 :             Point aFix(bAnf ? rRec.aPt2 : rRec.aPt1);
     933         [ #  # ]:          0 :             if (bOrtho) {
     934                 :          0 :                 long ndx0=aMov.X()-aFix.X();
     935                 :          0 :                 long ndy0=aMov.Y()-aFix.Y();
     936                 :          0 :                 bool bHLin=ndy0==0;
     937                 :          0 :                 bool bVLin=ndx0==0;
     938 [ #  # ][ #  # ]:          0 :                 if (!bHLin || !bVLin) { // else aPt1==aPt2
     939                 :          0 :                     long ndx=aPt.X()-aFix.X();
     940                 :          0 :                     long ndy=aPt.Y()-aFix.Y();
     941         [ #  # ]:          0 :                     double nXFact=0; if (!bVLin) nXFact=(double)ndx/(double)ndx0;
     942         [ #  # ]:          0 :                     double nYFact=0; if (!bHLin) nYFact=(double)ndy/(double)ndy0;
     943 [ #  # ][ #  # ]:          0 :                     bool bHor=bHLin || (!bVLin && (nXFact>nYFact) ==bBigOrtho);
                 [ #  # ]
     944 [ #  # ][ #  # ]:          0 :                     bool bVer=bVLin || (!bHLin && (nXFact<=nYFact)==bBigOrtho);
                 [ #  # ]
     945         [ #  # ]:          0 :                     if (bHor) ndy=long(ndy0*nXFact);
     946         [ #  # ]:          0 :                     if (bVer) ndx=long(ndx0*nYFact);
     947                 :          0 :                     aPt=aFix;
     948                 :          0 :                     aPt.X()+=ndx;
     949                 :          0 :                     aPt.Y()+=ndy;
     950                 :            :                 } // else Ortho8
     951                 :            :             }
     952                 :          0 :             rMov=aPt;
     953                 :          0 :         } break;
     954                 :            :         case 4: case 5: {
     955                 :          0 :             long nVal0=rRec.nLineDist;
     956         [ #  # ]:          0 :             RotatePoint(aPt,(nHdlNum==4 ? aPt1 : aPt2),nSin,-nCos);
     957         [ #  # ]:          0 :             rRec.nLineDist=aPt.Y()- (nHdlNum==4 ? aPt1.Y() : aPt2.Y());
     958         [ #  # ]:          0 :             if (bBelow) rRec.nLineDist=-rRec.nLineDist;
     959         [ #  # ]:          0 :             if (rRec.nLineDist<0) {
     960                 :          0 :                 rRec.nLineDist=-rRec.nLineDist;
     961                 :          0 :                 rRec.bBelowRefEdge=!bBelow;
     962                 :            :             }
     963                 :          0 :             rRec.nLineDist-=rRec.nHelplineOverhang;
     964         [ #  # ]:          0 :             if (bOrtho) rRec.nLineDist=nVal0;
     965                 :          0 :         } break;
     966                 :            :     } // switch
     967                 :          0 : }
     968                 :            : 
     969                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     970                 :            : 
     971                 :          0 : bool SdrMeasureObj::BegCreate(SdrDragStat& rStat)
     972                 :            : {
     973                 :          0 :     rStat.SetOrtho8Possible();
     974                 :          0 :     aPt1=rStat.GetStart();
     975                 :          0 :     aPt2=rStat.GetNow();
     976                 :          0 :     SetTextDirty();
     977                 :          0 :     return sal_True;
     978                 :            : }
     979                 :            : 
     980                 :          0 : bool SdrMeasureObj::MovCreate(SdrDragStat& rStat)
     981                 :            : {
     982                 :          0 :     SdrView* pView=rStat.GetView();
     983                 :          0 :     aPt1=rStat.GetStart();
     984                 :          0 :     aPt2=rStat.GetNow();
     985 [ #  # ][ #  # ]:          0 :     if (pView!=NULL && pView->IsCreate1stPointAsCenter()) {
                 [ #  # ]
     986                 :          0 :         aPt1+=aPt1;
     987                 :          0 :         aPt1-=rStat.Now();
     988                 :            :     }
     989                 :          0 :     SetTextDirty();
     990                 :          0 :     SetBoundRectDirty();
     991                 :          0 :     bSnapRectDirty=sal_True;
     992                 :          0 :     return sal_True;
     993                 :            : }
     994                 :            : 
     995                 :          0 : bool SdrMeasureObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
     996                 :            : {
     997                 :          0 :     SetTextDirty();
     998                 :          0 :     SetRectsDirty();
     999 [ #  # ][ #  # ]:          0 :     return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
    1000                 :            : }
    1001                 :            : 
    1002                 :          0 : bool SdrMeasureObj::BckCreate(SdrDragStat& /*rStat*/)
    1003                 :            : {
    1004                 :          0 :     return false;
    1005                 :            : }
    1006                 :            : 
    1007                 :          0 : void SdrMeasureObj::BrkCreate(SdrDragStat& /*rStat*/)
    1008                 :            : {
    1009                 :          0 : }
    1010                 :            : 
    1011                 :          0 : basegfx::B2DPolyPolygon SdrMeasureObj::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
    1012                 :            : {
    1013         [ #  # ]:          0 :     ImpMeasureRec aRec;
    1014         [ #  # ]:          0 :     ImpMeasurePoly aMPol;
    1015                 :            : 
    1016         [ #  # ]:          0 :     ImpTakeAttr(aRec);
    1017         [ #  # ]:          0 :     ImpCalcGeometrics(aRec, aMPol);
    1018                 :            : 
    1019 [ #  # ][ #  # ]:          0 :     return ImpCalcXPoly(aMPol);
    1020                 :            : }
    1021                 :            : 
    1022                 :          0 : Pointer SdrMeasureObj::GetCreatePointer() const
    1023                 :            : {
    1024                 :          0 :     return Pointer(POINTER_CROSS);
    1025                 :            : }
    1026                 :            : 
    1027                 :          0 : void SdrMeasureObj::NbcMove(const Size& rSiz)
    1028                 :            : {
    1029                 :          0 :     SdrTextObj::NbcMove(rSiz);
    1030                 :          0 :     MovePoint(aPt1,rSiz);
    1031                 :          0 :     MovePoint(aPt2,rSiz);
    1032                 :          0 : }
    1033                 :            : 
    1034                 :          0 : void SdrMeasureObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
    1035                 :            : {
    1036                 :          0 :     SdrTextObj::NbcResize(rRef,xFact,yFact);
    1037 [ #  # ][ #  # ]:          0 :     ResizePoint(aPt1,rRef,xFact,yFact);
    1038 [ #  # ][ #  # ]:          0 :     ResizePoint(aPt2,rRef,xFact,yFact);
    1039                 :          0 :     SetTextDirty();
    1040                 :          0 : }
    1041                 :            : 
    1042                 :          0 : void SdrMeasureObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
    1043                 :            : {
    1044                 :          0 :     SdrTextObj::NbcRotate(rRef,nWink,sn,cs);
    1045         [ #  # ]:          0 :     long nLen0=GetLen(aPt2-aPt1);
    1046                 :          0 :     RotatePoint(aPt1,rRef,sn,cs);
    1047                 :          0 :     RotatePoint(aPt2,rRef,sn,cs);
    1048         [ #  # ]:          0 :     long nLen1=GetLen(aPt2-aPt1);
    1049         [ #  # ]:          0 :     if (nLen1!=nLen0) { // rounding error!
    1050                 :          0 :         long dx=aPt2.X()-aPt1.X();
    1051                 :          0 :         long dy=aPt2.Y()-aPt1.Y();
    1052                 :          0 :         dx=BigMulDiv(dx,nLen0,nLen1);
    1053                 :          0 :         dy=BigMulDiv(dy,nLen0,nLen1);
    1054         [ #  # ]:          0 :         if (rRef==aPt2) {
    1055                 :          0 :             aPt1.X()=aPt2.X()-dx;
    1056                 :          0 :             aPt1.Y()=aPt2.Y()-dy;
    1057                 :            :         } else {
    1058                 :          0 :             aPt2.X()=aPt1.X()+dx;
    1059                 :          0 :             aPt2.Y()=aPt1.Y()+dy;
    1060                 :            :         }
    1061                 :            :     }
    1062                 :          0 :     SetRectsDirty();
    1063                 :          0 : }
    1064                 :            : 
    1065                 :          0 : void SdrMeasureObj::NbcMirror(const Point& rRef1, const Point& rRef2)
    1066                 :            : {
    1067                 :          0 :     SdrTextObj::NbcMirror(rRef1,rRef2);
    1068                 :          0 :     MirrorPoint(aPt1,rRef1,rRef2);
    1069                 :          0 :     MirrorPoint(aPt2,rRef1,rRef2);
    1070                 :          0 :     SetRectsDirty();
    1071                 :          0 : }
    1072                 :            : 
    1073                 :          0 : void SdrMeasureObj::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
    1074                 :            : {
    1075                 :          0 :     SdrTextObj::NbcShear(rRef,nWink,tn,bVShear);
    1076                 :          0 :     ShearPoint(aPt1,rRef,tn,bVShear);
    1077                 :          0 :     ShearPoint(aPt2,rRef,tn,bVShear);
    1078                 :          0 :     SetRectsDirty();
    1079                 :          0 :     SetTextDirty();
    1080                 :          0 : }
    1081                 :            : 
    1082                 :          0 : long SdrMeasureObj::GetRotateAngle() const
    1083                 :            : {
    1084         [ #  # ]:          0 :     return GetAngle(aPt2-aPt1);
    1085                 :            : }
    1086                 :            : 
    1087                 :          0 : void SdrMeasureObj::RecalcSnapRect()
    1088                 :            : {
    1089         [ #  # ]:          0 :     ImpMeasureRec aRec;
    1090         [ #  # ]:          0 :     ImpMeasurePoly aMPol;
    1091         [ #  # ]:          0 :     XPolyPolygon aXPP;
    1092                 :            : 
    1093         [ #  # ]:          0 :     ImpTakeAttr(aRec);
    1094         [ #  # ]:          0 :     ImpCalcGeometrics(aRec, aMPol);
    1095 [ #  # ][ #  # ]:          0 :     aXPP = XPolyPolygon(ImpCalcXPoly(aMPol));
         [ #  # ][ #  # ]
                 [ #  # ]
    1096 [ #  # ][ #  # ]:          0 :     maSnapRect = aXPP.GetBoundRect();
                 [ #  # ]
    1097                 :          0 : }
    1098                 :            : 
    1099                 :          0 : sal_uInt32 SdrMeasureObj::GetSnapPointCount() const
    1100                 :            : {
    1101                 :          0 :     return 2L;
    1102                 :            : }
    1103                 :            : 
    1104                 :          0 : Point SdrMeasureObj::GetSnapPoint(sal_uInt32 i) const
    1105                 :            : {
    1106         [ #  # ]:          0 :     if (i==0) return aPt1;
    1107                 :          0 :     else return aPt2;
    1108                 :            : }
    1109                 :            : 
    1110                 :          0 : sal_Bool SdrMeasureObj::IsPolyObj() const
    1111                 :            : {
    1112                 :          0 :     return sal_True;
    1113                 :            : }
    1114                 :            : 
    1115                 :          0 : sal_uInt32 SdrMeasureObj::GetPointCount() const
    1116                 :            : {
    1117                 :          0 :     return 2L;
    1118                 :            : }
    1119                 :            : 
    1120                 :          0 : Point SdrMeasureObj::GetPoint(sal_uInt32 i) const
    1121                 :            : {
    1122         [ #  # ]:          0 :      return (0L == i) ? aPt1 : aPt2;
    1123                 :            : }
    1124                 :            : 
    1125                 :          0 : void SdrMeasureObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)
    1126                 :            : {
    1127         [ #  # ]:          0 :     if (0L == i)
    1128                 :          0 :         aPt1=rPnt;
    1129         [ #  # ]:          0 :     if (1L == i)
    1130                 :          0 :         aPt2=rPnt;
    1131                 :          0 :     SetRectsDirty();
    1132                 :          0 :     SetTextDirty();
    1133                 :          0 : }
    1134                 :            : 
    1135                 :          0 : SdrObjGeoData* SdrMeasureObj::NewGeoData() const
    1136                 :            : {
    1137         [ #  # ]:          0 :     return new SdrMeasureObjGeoData;
    1138                 :            : }
    1139                 :            : 
    1140                 :          0 : void SdrMeasureObj::SaveGeoData(SdrObjGeoData& rGeo) const
    1141                 :            : {
    1142                 :          0 :     SdrTextObj::SaveGeoData(rGeo);
    1143                 :          0 :     SdrMeasureObjGeoData& rMGeo=(SdrMeasureObjGeoData&)rGeo;
    1144                 :          0 :     rMGeo.aPt1=aPt1;
    1145                 :          0 :     rMGeo.aPt2=aPt2;
    1146                 :          0 : }
    1147                 :            : 
    1148                 :          0 : void SdrMeasureObj::RestGeoData(const SdrObjGeoData& rGeo)
    1149                 :            : {
    1150                 :          0 :     SdrTextObj::RestGeoData(rGeo);
    1151                 :          0 :     SdrMeasureObjGeoData& rMGeo=(SdrMeasureObjGeoData&)rGeo;
    1152                 :          0 :     aPt1=rMGeo.aPt1;
    1153                 :          0 :     aPt2=rMGeo.aPt2;
    1154                 :          0 :     SetTextDirty();
    1155                 :          0 : }
    1156                 :            : 
    1157                 :          0 : SdrObject* SdrMeasureObj::DoConvertToPolyObj(sal_Bool bBezier) const
    1158                 :            : {
    1159                 :            :     // get XOR Poly as base
    1160 [ #  # ][ #  # ]:          0 :     XPolyPolygon aTmpPolyPolygon(TakeXorPoly());
                 [ #  # ]
    1161                 :            : 
    1162                 :            :     // get local ItemSet and StyleSheet
    1163 [ #  # ][ #  # ]:          0 :     SfxItemSet aSet(GetObjectItemSet());
    1164         [ #  # ]:          0 :     SfxStyleSheet* pStyleSheet = GetStyleSheet();
    1165                 :            : 
    1166                 :            :     // prepare group
    1167 [ #  # ][ #  # ]:          0 :     SdrObjGroup* pGroup = new SdrObjGroup;
    1168 [ #  # ][ #  # ]:          0 :     pGroup->SetModel(GetModel());
    1169                 :            : 
    1170                 :            :     // prepare parameters
    1171         [ #  # ]:          0 :     basegfx::B2DPolyPolygon aPolyPoly;
    1172                 :            :     SdrPathObj* pPath;
    1173         [ #  # ]:          0 :     sal_uInt16 nCount(aTmpPolyPolygon.Count());
    1174                 :          0 :     sal_uInt16 nLoopStart(0);
    1175                 :            : 
    1176         [ #  # ]:          0 :     if(nCount == 3)
    1177                 :            :     {
    1178                 :            :         // three lines, first one is the middle one
    1179         [ #  # ]:          0 :         aPolyPoly.clear();
    1180 [ #  # ][ #  # ]:          0 :         aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
         [ #  # ][ #  # ]
    1181                 :            : 
    1182 [ #  # ][ #  # ]:          0 :         pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
    1183 [ #  # ][ #  # ]:          0 :         pPath->SetModel(GetModel());
    1184         [ #  # ]:          0 :         pPath->SetMergedItemSet(aSet);
    1185         [ #  # ]:          0 :         pPath->SetStyleSheet(pStyleSheet, true);
    1186 [ #  # ][ #  # ]:          0 :         pGroup->GetSubList()->NbcInsertObject(pPath);
    1187 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineStartWidthItem(0L));
                 [ #  # ]
    1188 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineEndWidthItem(0L));
                 [ #  # ]
    1189                 :          0 :         nLoopStart = 1;
    1190                 :            :     }
    1191         [ #  # ]:          0 :     else if(nCount == 4)
    1192                 :            :     {
    1193                 :            :         // four lines, middle line with gap, so there are two lines used
    1194                 :            :         // which have one arrow each
    1195         [ #  # ]:          0 :         sal_Int32 nEndWidth = ((const XLineEndWidthItem&)(aSet.Get(XATTR_LINEENDWIDTH))).GetValue();
    1196 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineEndWidthItem(0L));
                 [ #  # ]
    1197                 :            : 
    1198         [ #  # ]:          0 :         aPolyPoly.clear();
    1199 [ #  # ][ #  # ]:          0 :         aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
         [ #  # ][ #  # ]
    1200 [ #  # ][ #  # ]:          0 :         pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
    1201 [ #  # ][ #  # ]:          0 :         pPath->SetModel(GetModel());
    1202         [ #  # ]:          0 :         pPath->SetMergedItemSet(aSet);
    1203         [ #  # ]:          0 :         pPath->SetStyleSheet(pStyleSheet, true);
    1204                 :            : 
    1205 [ #  # ][ #  # ]:          0 :         pGroup->GetSubList()->NbcInsertObject(pPath);
    1206                 :            : 
    1207 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineEndWidthItem(nEndWidth));
                 [ #  # ]
    1208 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineStartWidthItem(0L));
                 [ #  # ]
    1209                 :            : 
    1210         [ #  # ]:          0 :         aPolyPoly.clear();
    1211 [ #  # ][ #  # ]:          0 :         aPolyPoly.append(aTmpPolyPolygon[1].getB2DPolygon());
         [ #  # ][ #  # ]
    1212 [ #  # ][ #  # ]:          0 :         pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
    1213 [ #  # ][ #  # ]:          0 :         pPath->SetModel(GetModel());
    1214         [ #  # ]:          0 :         pPath->SetMergedItemSet(aSet);
    1215         [ #  # ]:          0 :         pPath->SetStyleSheet(pStyleSheet, true);
    1216                 :            : 
    1217 [ #  # ][ #  # ]:          0 :         pGroup->GetSubList()->NbcInsertObject(pPath);
    1218                 :            : 
    1219 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineEndWidthItem(0L));
                 [ #  # ]
    1220                 :          0 :         nLoopStart = 2;
    1221                 :            :     }
    1222         [ #  # ]:          0 :     else if(nCount == 5)
    1223                 :            :     {
    1224                 :            :         // five lines, first two are the outer ones
    1225         [ #  # ]:          0 :         sal_Int32 nEndWidth = ((const XLineEndWidthItem&)(aSet.Get(XATTR_LINEENDWIDTH))).GetValue();
    1226                 :            : 
    1227 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineEndWidthItem(0L));
                 [ #  # ]
    1228                 :            : 
    1229         [ #  # ]:          0 :         aPolyPoly.clear();
    1230 [ #  # ][ #  # ]:          0 :         aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
         [ #  # ][ #  # ]
    1231 [ #  # ][ #  # ]:          0 :         pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
    1232 [ #  # ][ #  # ]:          0 :         pPath->SetModel(GetModel());
    1233         [ #  # ]:          0 :         pPath->SetMergedItemSet(aSet);
    1234         [ #  # ]:          0 :         pPath->SetStyleSheet(pStyleSheet, true);
    1235                 :            : 
    1236 [ #  # ][ #  # ]:          0 :         pGroup->GetSubList()->NbcInsertObject(pPath);
    1237                 :            : 
    1238 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineEndWidthItem(nEndWidth));
                 [ #  # ]
    1239 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineStartWidthItem(0L));
                 [ #  # ]
    1240                 :            : 
    1241         [ #  # ]:          0 :         aPolyPoly.clear();
    1242 [ #  # ][ #  # ]:          0 :         aPolyPoly.append(aTmpPolyPolygon[1].getB2DPolygon());
         [ #  # ][ #  # ]
    1243 [ #  # ][ #  # ]:          0 :         pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
    1244 [ #  # ][ #  # ]:          0 :         pPath->SetModel(GetModel());
    1245         [ #  # ]:          0 :         pPath->SetMergedItemSet(aSet);
    1246         [ #  # ]:          0 :         pPath->SetStyleSheet(pStyleSheet, true);
    1247                 :            : 
    1248 [ #  # ][ #  # ]:          0 :         pGroup->GetSubList()->NbcInsertObject(pPath);
    1249                 :            : 
    1250 [ #  # ][ #  # ]:          0 :         aSet.Put(XLineEndWidthItem(0L));
                 [ #  # ]
    1251                 :          0 :         nLoopStart = 2;
    1252                 :            :     }
    1253                 :            : 
    1254         [ #  # ]:          0 :     for(;nLoopStart<nCount;nLoopStart++)
    1255                 :            :     {
    1256         [ #  # ]:          0 :         aPolyPoly.clear();
    1257 [ #  # ][ #  # ]:          0 :         aPolyPoly.append(aTmpPolyPolygon[nLoopStart].getB2DPolygon());
         [ #  # ][ #  # ]
    1258 [ #  # ][ #  # ]:          0 :         pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
    1259 [ #  # ][ #  # ]:          0 :         pPath->SetModel(GetModel());
    1260         [ #  # ]:          0 :         pPath->SetMergedItemSet(aSet);
    1261         [ #  # ]:          0 :         pPath->SetStyleSheet(pStyleSheet, true);
    1262                 :            : 
    1263 [ #  # ][ #  # ]:          0 :         pGroup->GetSubList()->NbcInsertObject(pPath);
    1264                 :            :     }
    1265                 :            : 
    1266 [ #  # ][ #  # ]:          0 :     return ImpConvertAddText(pGroup, bBezier);
         [ #  # ][ #  # ]
    1267                 :            : }
    1268                 :            : 
    1269                 :          0 : sal_Bool SdrMeasureObj::BegTextEdit(SdrOutliner& rOutl)
    1270                 :            : {
    1271                 :          0 :     UndirtyText();
    1272                 :          0 :     return SdrTextObj::BegTextEdit(rOutl);
    1273                 :            : }
    1274                 :            : 
    1275                 :          0 : const Size& SdrMeasureObj::GetTextSize() const
    1276                 :            : {
    1277         [ #  # ]:          0 :     if (bTextDirty) UndirtyText();
    1278                 :          0 :     return SdrTextObj::GetTextSize();
    1279                 :            : }
    1280                 :            : 
    1281                 :          0 : OutlinerParaObject* SdrMeasureObj::GetOutlinerParaObject() const
    1282                 :            : {
    1283         [ #  # ]:          0 :     if(bTextDirty)
    1284                 :          0 :         UndirtyText();
    1285                 :          0 :     return SdrTextObj::GetOutlinerParaObject();
    1286                 :            : }
    1287                 :            : 
    1288                 :          0 : void SdrMeasureObj::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject)
    1289                 :            : {
    1290                 :          0 :     SdrTextObj::NbcSetOutlinerParaObject(pTextObject);
    1291         [ #  # ]:          0 :     if(SdrTextObj::GetOutlinerParaObject())
    1292                 :          0 :         SetTextDirty(); // recalculate text
    1293                 :          0 : }
    1294                 :            : 
    1295                 :          0 : void SdrMeasureObj::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText,
    1296                 :            :     Rectangle* pAnchorRect, bool bLineWidth ) const
    1297                 :            : {
    1298         [ #  # ]:          0 :     if (bTextDirty) UndirtyText();
    1299                 :          0 :     SdrTextObj::TakeTextRect( rOutliner, rTextRect, bNoEditText, pAnchorRect, bLineWidth );
    1300                 :          0 : }
    1301                 :            : 
    1302                 :          0 : void SdrMeasureObj::TakeTextAnchorRect(Rectangle& rAnchorRect) const
    1303                 :            : {
    1304         [ #  # ]:          0 :     if (bTextDirty) UndirtyText();
    1305                 :          0 :     SdrTextObj::TakeTextAnchorRect(rAnchorRect);
    1306                 :          0 : }
    1307                 :            : 
    1308                 :          0 : void SdrMeasureObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const
    1309                 :            : {
    1310         [ #  # ]:          0 :     if (bTextDirty) UndirtyText();
    1311                 :          0 :     SdrTextObj::TakeTextEditArea(pPaperMin,pPaperMax,pViewInit,pViewMin);
    1312                 :          0 : }
    1313                 :            : 
    1314                 :          0 : sal_uInt16 SdrMeasureObj::GetOutlinerViewAnchorMode() const
    1315                 :            : {
    1316 [ #  # ][ #  # ]:          0 :     if (bTextDirty) UndirtyText();
    1317         [ #  # ]:          0 :     ImpMeasureRec aRec;
    1318         [ #  # ]:          0 :     ImpMeasurePoly aMPol;
    1319         [ #  # ]:          0 :     ImpTakeAttr(aRec);
    1320         [ #  # ]:          0 :     ImpCalcGeometrics(aRec,aMPol);
    1321                 :            : 
    1322         [ #  # ]:          0 :     SdrTextHorzAdjust eTH=GetTextHorizontalAdjust();
    1323         [ #  # ]:          0 :     SdrTextVertAdjust eTV=GetTextVerticalAdjust();
    1324                 :          0 :     SdrMeasureTextHPos eMH=aMPol.eUsedTextHPos;
    1325                 :          0 :     SdrMeasureTextVPos eMV=aMPol.eUsedTextVPos;
    1326                 :          0 :     bool bTextRota90=aRec.bTextRota90;
    1327                 :          0 :     bool bBelowRefEdge=aRec.bBelowRefEdge;
    1328                 :            : 
    1329                 :            :     // TODO: bTextUpsideDown should be interpreted here!
    1330         [ #  # ]:          0 :     if (!bTextRota90) {
    1331         [ #  # ]:          0 :         if (eMH==SDRMEASURE_TEXTLEFTOUTSIDE) eTH=SDRTEXTHORZADJUST_RIGHT;
    1332         [ #  # ]:          0 :         if (eMH==SDRMEASURE_TEXTRIGHTOUTSIDE) eTH=SDRTEXTHORZADJUST_LEFT;
    1333                 :            :         // at eMH==SDRMEASURE_TEXTINSIDE we can anchor horizontally
    1334         [ #  # ]:          0 :         if (eMV==SDRMEASURE_ABOVE) eTV=SDRTEXTVERTADJUST_BOTTOM;
    1335         [ #  # ]:          0 :         if (eMV==SDRMEASURE_BELOW) eTV=SDRTEXTVERTADJUST_TOP;
    1336 [ #  # ][ #  # ]:          0 :         if (eMV==SDRMEASURETEXT_BREAKEDLINE || eMV==SDRMEASURETEXT_VERTICALCENTERED) eTV=SDRTEXTVERTADJUST_CENTER;
    1337                 :            :     } else {
    1338         [ #  # ]:          0 :         if (eMH==SDRMEASURE_TEXTLEFTOUTSIDE) eTV=SDRTEXTVERTADJUST_BOTTOM;
    1339         [ #  # ]:          0 :         if (eMH==SDRMEASURE_TEXTRIGHTOUTSIDE) eTV=SDRTEXTVERTADJUST_TOP;
    1340                 :            :         // at eMH==SDRMEASURE_TEXTINSIDE we can anchor vertically
    1341         [ #  # ]:          0 :         if (!bBelowRefEdge) {
    1342         [ #  # ]:          0 :             if (eMV==SDRMEASURE_ABOVE) eTH=SDRTEXTHORZADJUST_LEFT;
    1343         [ #  # ]:          0 :             if (eMV==SDRMEASURE_BELOW) eTH=SDRTEXTHORZADJUST_RIGHT;
    1344                 :            :         } else {
    1345         [ #  # ]:          0 :             if (eMV==SDRMEASURE_ABOVE) eTH=SDRTEXTHORZADJUST_RIGHT;
    1346         [ #  # ]:          0 :             if (eMV==SDRMEASURE_BELOW) eTH=SDRTEXTHORZADJUST_LEFT;
    1347                 :            :         }
    1348 [ #  # ][ #  # ]:          0 :         if (eMV==SDRMEASURETEXT_BREAKEDLINE || eMV==SDRMEASURETEXT_VERTICALCENTERED) eTH=SDRTEXTHORZADJUST_CENTER;
    1349                 :            :     }
    1350                 :            : 
    1351                 :          0 :     EVAnchorMode eRet=ANCHOR_BOTTOM_HCENTER;
    1352         [ #  # ]:          0 :     if (eTH==SDRTEXTHORZADJUST_LEFT) {
    1353         [ #  # ]:          0 :         if (eTV==SDRTEXTVERTADJUST_TOP) eRet=ANCHOR_TOP_LEFT;
    1354         [ #  # ]:          0 :         else if (eTV==SDRTEXTVERTADJUST_BOTTOM) eRet=ANCHOR_BOTTOM_LEFT;
    1355                 :          0 :         else eRet=ANCHOR_VCENTER_LEFT;
    1356         [ #  # ]:          0 :     } else if (eTH==SDRTEXTHORZADJUST_RIGHT) {
    1357         [ #  # ]:          0 :         if (eTV==SDRTEXTVERTADJUST_TOP) eRet=ANCHOR_TOP_RIGHT;
    1358         [ #  # ]:          0 :         else if (eTV==SDRTEXTVERTADJUST_BOTTOM) eRet=ANCHOR_BOTTOM_RIGHT;
    1359                 :          0 :         else eRet=ANCHOR_VCENTER_RIGHT;
    1360                 :            :     } else {
    1361         [ #  # ]:          0 :         if (eTV==SDRTEXTVERTADJUST_TOP) eRet=ANCHOR_TOP_HCENTER;
    1362         [ #  # ]:          0 :         else if (eTV==SDRTEXTVERTADJUST_BOTTOM) eRet=ANCHOR_BOTTOM_HCENTER;
    1363                 :          0 :         else eRet=ANCHOR_VCENTER_HCENTER;
    1364                 :            :     }
    1365         [ #  # ]:          0 :     return (sal_uInt16)eRet;
    1366                 :            : }
    1367                 :            : 
    1368                 :            : //////////////////////////////////////////////////////////////////////////////
    1369                 :            : // #i97878#
    1370                 :            : // TRGetBaseGeometry/TRSetBaseGeometry needs to be based on two positions,
    1371                 :            : // same as line geometry in SdrPathObj. Thus needs to be overloaded and
    1372                 :            : // implemented since currently it is derived from SdrTextObj which uses
    1373                 :            : // a functionality based on SnapRect which is not useful here
    1374                 :            : 
    1375                 :          0 : sal_Bool SdrMeasureObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
    1376                 :            : {
    1377                 :            :     // handle the same as a simple line since the definition is based on two points
    1378         [ #  # ]:          0 :     const basegfx::B2DRange aRange(aPt1.X(), aPt1.Y(), aPt2.X(), aPt2.Y());
    1379         [ #  # ]:          0 :     basegfx::B2DTuple aScale(aRange.getRange());
    1380         [ #  # ]:          0 :     basegfx::B2DTuple aTranslate(aRange.getMinimum());
    1381                 :            : 
    1382                 :            :     // position maybe relative to anchor position, convert
    1383         [ #  # ]:          0 :     if( pModel->IsWriter() )
    1384                 :            :     {
    1385 [ #  # ][ #  # ]:          0 :         if(GetAnchorPos().X() || GetAnchorPos().Y())
         [ #  # ][ #  # ]
                 [ #  # ]
    1386                 :            :         {
    1387 [ #  # ][ #  # ]:          0 :             aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
    1388                 :            :         }
    1389                 :            :     }
    1390                 :            : 
    1391                 :            :     // force MapUnit to 100th mm
    1392         [ #  # ]:          0 :     SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
    1393         [ #  # ]:          0 :     if(eMapUnit != SFX_MAPUNIT_100TH_MM)
    1394                 :            :     {
    1395         [ #  # ]:          0 :         switch(eMapUnit)
    1396                 :            :         {
    1397                 :            :             case SFX_MAPUNIT_TWIP :
    1398                 :            :             {
    1399                 :            :                 // position
    1400                 :          0 :                 aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
    1401                 :          0 :                 aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
    1402                 :            : 
    1403                 :            :                 // size
    1404                 :          0 :                 aScale.setX(ImplTwipsToMM(aScale.getX()));
    1405                 :          0 :                 aScale.setY(ImplTwipsToMM(aScale.getY()));
    1406                 :            : 
    1407                 :          0 :                 break;
    1408                 :            :             }
    1409                 :            :             default:
    1410                 :            :             {
    1411                 :            :                 OSL_FAIL("TRGetBaseGeometry: Missing unit translation to 100th mm!");
    1412                 :            :             }
    1413                 :            :         }
    1414                 :            :     }
    1415                 :            : 
    1416                 :            :     // build return value matrix
    1417 [ #  # ][ #  # ]:          0 :     rMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aScale, aTranslate);
                 [ #  # ]
    1418                 :            : 
    1419                 :          0 :     return sal_True;
    1420                 :            : }
    1421                 :            : 
    1422                 :          0 : void SdrMeasureObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
    1423                 :            : {
    1424                 :            :     // use given transformation to derive the two defining points from unit line
    1425         [ #  # ]:          0 :     basegfx::B2DPoint aPosA(rMatrix * basegfx::B2DPoint(0.0, 0.0));
    1426         [ #  # ]:          0 :     basegfx::B2DPoint aPosB(rMatrix * basegfx::B2DPoint(1.0, 0.0));
    1427                 :            : 
    1428                 :            :     // force metric to pool metric
    1429         [ #  # ]:          0 :     SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
    1430         [ #  # ]:          0 :     if(eMapUnit != SFX_MAPUNIT_100TH_MM)
    1431                 :            :     {
    1432         [ #  # ]:          0 :         switch(eMapUnit)
    1433                 :            :         {
    1434                 :            :             case SFX_MAPUNIT_TWIP :
    1435                 :            :             {
    1436                 :            :                 // position
    1437                 :          0 :                 aPosA.setX(ImplMMToTwips(aPosA.getX()));
    1438                 :          0 :                 aPosA.setY(ImplMMToTwips(aPosA.getY()));
    1439                 :          0 :                 aPosB.setX(ImplMMToTwips(aPosB.getX()));
    1440                 :          0 :                 aPosB.setY(ImplMMToTwips(aPosB.getY()));
    1441                 :            : 
    1442                 :          0 :                 break;
    1443                 :            :             }
    1444                 :            :             default:
    1445                 :            :             {
    1446                 :            :                 OSL_FAIL("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
    1447                 :            :             }
    1448                 :            :         }
    1449                 :            :     }
    1450                 :            : 
    1451         [ #  # ]:          0 :     if( pModel->IsWriter() )
    1452                 :            :     {
    1453                 :            :         // if anchor is used, make position relative to it
    1454 [ #  # ][ #  # ]:          0 :         if(GetAnchorPos().X() || GetAnchorPos().Y())
         [ #  # ][ #  # ]
                 [ #  # ]
    1455                 :            :         {
    1456 [ #  # ][ #  # ]:          0 :             const basegfx::B2DVector aAnchorOffset(GetAnchorPos().X(), GetAnchorPos().Y());
    1457                 :            : 
    1458                 :          0 :             aPosA += aAnchorOffset;
    1459                 :          0 :             aPosB += aAnchorOffset;
    1460                 :            :         }
    1461                 :            :     }
    1462                 :            : 
    1463                 :            :     // derive new model data
    1464                 :          0 :     const Point aNewPt1(basegfx::fround(aPosA.getX()), basegfx::fround(aPosA.getY()));
    1465                 :          0 :     const Point aNewPt2(basegfx::fround(aPosB.getX()), basegfx::fround(aPosB.getY()));
    1466                 :            : 
    1467 [ #  # ][ #  # ]:          0 :     if(aNewPt1 != aPt1 || aNewPt2 != aPt2)
                 [ #  # ]
    1468                 :            :     {
    1469                 :            :         // set model values and broadcast
    1470 [ #  # ][ #  # ]:          0 :         Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
                 [ #  # ]
    1471                 :            : 
    1472                 :          0 :         aPt1 = aNewPt1;
    1473                 :          0 :         aPt2 = aNewPt2;
    1474                 :            : 
    1475         [ #  # ]:          0 :         SetTextDirty();
    1476         [ #  # ]:          0 :         ActionChanged();
    1477         [ #  # ]:          0 :         SetChanged();
    1478         [ #  # ]:          0 :         BroadcastObjectChange();
    1479         [ #  # ]:          0 :         SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
    1480                 :          0 :     }
    1481                 :          0 : }
    1482                 :            : 
    1483                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10