LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdtrans.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 173 661 26.2 %
Date: 2014-04-11 Functions: 17 44 38.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <svx/svdtrans.hxx>
      22             : #include <math.h>
      23             : #include <svx/xpoly.hxx>
      24             : 
      25             : #include <vcl/virdev.hxx>
      26             : #include <tools/bigint.hxx>
      27             : #include <tools/debug.hxx>
      28             : #include <unotools/syslocale.hxx>
      29             : 
      30           0 : void MoveXPoly(XPolygon& rPoly, const Size& S)
      31             : {
      32           0 :     rPoly.Move(S.Width(),S.Height());
      33           0 : }
      34             : 
      35       54198 : void ResizeRect(Rectangle& rRect, const Point& rRef, const Fraction& rxFact, const Fraction& ryFact, bool bNoJustify)
      36             : {
      37       54198 :     Fraction xFact(rxFact);
      38       54198 :     Fraction yFact(ryFact);
      39             : 
      40             :     {
      41       54198 :         if (xFact.GetDenominator()==0) {
      42           6 :             long nWdt=rRect.Right()-rRect.Left();
      43           6 :             if (xFact.GetNumerator()>=0) { // catch divisions by zero
      44           6 :                 xFact=Fraction(xFact.GetNumerator(),1);
      45           6 :                 if (nWdt==0) rRect.Right()++;
      46             :             } else {
      47           0 :                 xFact=Fraction(xFact.GetNumerator(),-1);
      48           0 :                 if (nWdt==0) rRect.Left()--;
      49             :             }
      50             :         }
      51       54198 :         rRect.Left()  =rRef.X()+Round(((double)(rRect.Left()  -rRef.X())*xFact.GetNumerator())/xFact.GetDenominator());
      52       54198 :         rRect.Right() =rRef.X()+Round(((double)(rRect.Right() -rRef.X())*xFact.GetNumerator())/xFact.GetDenominator());
      53             :     }
      54             :     {
      55       54198 :         if (yFact.GetDenominator()==0) {
      56           6 :             long nHgt=rRect.Bottom()-rRect.Top();
      57           6 :             if (yFact.GetNumerator()>=0) { // catch divisions by zero
      58           6 :                 yFact=Fraction(yFact.GetNumerator(),1);
      59           6 :                 if (nHgt==0) rRect.Bottom()++;
      60             :             } else {
      61           0 :                 yFact=Fraction(yFact.GetNumerator(),-1);
      62           0 :                 if (nHgt==0) rRect.Top()--;
      63             :             }
      64             : 
      65           6 :             yFact=Fraction(yFact.GetNumerator(),1); // catch divisions by zero
      66             :         }
      67       54198 :         rRect.Top()   =rRef.Y()+Round(((double)(rRect.Top()   -rRef.Y())*yFact.GetNumerator())/yFact.GetDenominator());
      68       54198 :         rRect.Bottom()=rRef.Y()+Round(((double)(rRect.Bottom()-rRef.Y())*yFact.GetNumerator())/yFact.GetDenominator());
      69             :     }
      70       54198 :     if (!bNoJustify) rRect.Justify();
      71       54198 : }
      72             : 
      73             : 
      74           0 : void ResizePoly(Polygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact)
      75             : {
      76           0 :     sal_uInt16 nAnz=rPoly.GetSize();
      77           0 :     for (sal_uInt16 i=0; i<nAnz; i++) {
      78           0 :         ResizePoint(rPoly[i],rRef,xFact,yFact);
      79             :     }
      80           0 : }
      81             : 
      82           0 : void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact)
      83             : {
      84           0 :     sal_uInt16 nAnz=rPoly.GetPointCount();
      85           0 :     for (sal_uInt16 i=0; i<nAnz; i++) {
      86           0 :         ResizePoint(rPoly[i],rRef,xFact,yFact);
      87             :     }
      88           0 : }
      89             : 
      90       12351 : void RotatePoly(Polygon& rPoly, const Point& rRef, double sn, double cs)
      91             : {
      92       12351 :     sal_uInt16 nAnz=rPoly.GetSize();
      93       73686 :     for (sal_uInt16 i=0; i<nAnz; i++) {
      94       61335 :         RotatePoint(rPoly[i],rRef,sn,cs);
      95             :     }
      96       12351 : }
      97             : 
      98           2 : void RotateXPoly(XPolygon& rPoly, const Point& rRef, double sn, double cs)
      99             : {
     100           2 :     sal_uInt16 nAnz=rPoly.GetPointCount();
     101          38 :     for (sal_uInt16 i=0; i<nAnz; i++) {
     102          36 :         RotatePoint(rPoly[i],rRef,sn,cs);
     103             :     }
     104           2 : }
     105             : 
     106           0 : void RotateXPoly(XPolyPolygon& rPoly, const Point& rRef, double sn, double cs)
     107             : {
     108           0 :     sal_uInt16 nAnz=rPoly.Count();
     109           0 :     for (sal_uInt16 i=0; i<nAnz; i++) {
     110           0 :         RotateXPoly(rPoly[i],rRef,sn,cs);
     111             :     }
     112           0 : }
     113             : 
     114        1955 : void MirrorPoint(Point& rPnt, const Point& rRef1, const Point& rRef2)
     115             : {
     116        1955 :     long mx=rRef2.X()-rRef1.X();
     117        1955 :     long my=rRef2.Y()-rRef1.Y();
     118        1955 :     if (mx==0) { // vertical axis
     119         325 :         long dx=rRef1.X()-rPnt.X();
     120         325 :         rPnt.X()+=2*dx;
     121        1630 :     } else if (my==0) { // horizontal axis
     122        1630 :         long dy=rRef1.Y()-rPnt.Y();
     123        1630 :         rPnt.Y()+=2*dy;
     124           0 :     } else if (mx==my) { // diagonal axis '\'
     125           0 :         long dx1=rPnt.X()-rRef1.X();
     126           0 :         long dy1=rPnt.Y()-rRef1.Y();
     127           0 :         rPnt.X()=rRef1.X()+dy1;
     128           0 :         rPnt.Y()=rRef1.Y()+dx1;
     129           0 :     } else if (mx==-my) { // diagonal axis '/'
     130           0 :         long dx1=rPnt.X()-rRef1.X();
     131           0 :         long dy1=rPnt.Y()-rRef1.Y();
     132           0 :         rPnt.X()=rRef1.X()-dy1;
     133           0 :         rPnt.Y()=rRef1.Y()-dx1;
     134             :     } else { // arbitrary axis
     135             :         // TODO: Optimize this! Raise perpendicular on the mirroring axis..?
     136           0 :         long nRefWink=GetAngle(rRef2-rRef1);
     137           0 :         rPnt-=rRef1;
     138           0 :         long nPntWink=GetAngle(rPnt);
     139           0 :         long nWink=2*(nRefWink-nPntWink);
     140           0 :         double a=nWink*nPi180;
     141           0 :         double nSin=sin(a);
     142           0 :         double nCos=cos(a);
     143           0 :         RotatePoint(rPnt,Point(),nSin,nCos);
     144           0 :         rPnt+=rRef1;
     145             :     }
     146        1955 : }
     147             : 
     148           0 : void MirrorPoly(Polygon& rPoly, const Point& rRef1, const Point& rRef2)
     149             : {
     150           0 :     sal_uInt16 nAnz=rPoly.GetSize();
     151           0 :     for (sal_uInt16 i=0; i<nAnz; i++) {
     152           0 :         MirrorPoint(rPoly[i],rRef1,rRef2);
     153             :     }
     154           0 : }
     155             : 
     156           0 : void MirrorXPoly(XPolygon& rPoly, const Point& rRef1, const Point& rRef2)
     157             : {
     158           0 :     sal_uInt16 nAnz=rPoly.GetPointCount();
     159           0 :     for (sal_uInt16 i=0; i<nAnz; i++) {
     160           0 :         MirrorPoint(rPoly[i],rRef1,rRef2);
     161             :     }
     162           0 : }
     163             : 
     164           8 : void ShearPoly(Polygon& rPoly, const Point& rRef, double tn, bool bVShear)
     165             : {
     166           8 :     sal_uInt16 nAnz=rPoly.GetSize();
     167          48 :     for (sal_uInt16 i=0; i<nAnz; i++) {
     168          40 :         ShearPoint(rPoly[i],rRef,tn,bVShear);
     169             :     }
     170           8 : }
     171             : 
     172           0 : void ShearXPoly(XPolygon& rPoly, const Point& rRef, double tn, bool bVShear)
     173             : {
     174           0 :     sal_uInt16 nAnz=rPoly.GetPointCount();
     175           0 :     for (sal_uInt16 i=0; i<nAnz; i++) {
     176           0 :         ShearPoint(rPoly[i],rRef,tn,bVShear);
     177             :     }
     178           0 : }
     179             : 
     180           0 : double CrookRotateXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCenter,
     181             :                          const Point& rRad, double& rSin, double& rCos, bool bVert)
     182             : {
     183           0 :     bool bC1=pC1!=NULL;
     184           0 :     bool bC2=pC2!=NULL;
     185           0 :     long x0=rPnt.X();
     186           0 :     long y0=rPnt.Y();
     187           0 :     long cx=rCenter.X();
     188           0 :     long cy=rCenter.Y();
     189           0 :     double nWink=GetCrookAngle(rPnt,rCenter,rRad,bVert);
     190           0 :     double sn=sin(nWink);
     191           0 :     double cs=cos(nWink);
     192           0 :     RotatePoint(rPnt,rCenter,sn,cs);
     193           0 :     if (bC1) {
     194           0 :         if (bVert) {
     195             :             // move into the direction of the center, as a basic position for the rotation
     196           0 :             pC1->Y()-=y0;
     197             :             // resize, account for the distance from the center
     198           0 :             pC1->Y()=Round(((double)pC1->Y()) /rRad.X()*(cx-pC1->X()));
     199           0 :             pC1->Y()+=cy;
     200             :         } else {
     201             :             // move into the direction of the center, as a basic position for the rotation
     202           0 :             pC1->X()-=x0;
     203             :             // resize, account for the distance from the center
     204           0 :             long nPntRad=cy-pC1->Y();
     205           0 :             double nFact=(double)nPntRad/(double)rRad.Y();
     206           0 :             pC1->X()=Round((double)pC1->X()*nFact);
     207           0 :             pC1->X()+=cx;
     208             :         }
     209           0 :         RotatePoint(*pC1,rCenter,sn,cs);
     210             :     }
     211           0 :     if (bC2) {
     212           0 :         if (bVert) {
     213             :             // move into the direction of the center, as a basic position for the rotation
     214           0 :             pC2->Y()-=y0;
     215             :             // resize, account for the distance from the center
     216           0 :             pC2->Y()=Round(((double)pC2->Y()) /rRad.X()*(rCenter.X()-pC2->X()));
     217           0 :             pC2->Y()+=cy;
     218             :         } else {
     219             :             // move into the direction of the center, as a basic position for the rotation
     220           0 :             pC2->X()-=x0;
     221             :             // resize, account for the distance from the center
     222           0 :             long nPntRad=rCenter.Y()-pC2->Y();
     223           0 :             double nFact=(double)nPntRad/(double)rRad.Y();
     224           0 :             pC2->X()=Round((double)pC2->X()*nFact);
     225           0 :             pC2->X()+=cx;
     226             :         }
     227           0 :         RotatePoint(*pC2,rCenter,sn,cs);
     228             :     }
     229           0 :     rSin=sn;
     230           0 :     rCos=cs;
     231           0 :     return nWink;
     232             : }
     233             : 
     234           0 : double CrookSlantXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCenter,
     235             :                         const Point& rRad, double& rSin, double& rCos, bool bVert)
     236             : {
     237           0 :     bool bC1=pC1!=NULL;
     238           0 :     bool bC2=pC2!=NULL;
     239           0 :     long x0=rPnt.X();
     240           0 :     long y0=rPnt.Y();
     241           0 :     long dx1=0,dy1=0;
     242           0 :     long dxC1=0,dyC1=0;
     243           0 :     long dxC2=0,dyC2=0;
     244           0 :     if (bVert) {
     245           0 :         long nStart=rCenter.X()-rRad.X();
     246           0 :         dx1=rPnt.X()-nStart;
     247           0 :         rPnt.X()=nStart;
     248           0 :         if (bC1) {
     249           0 :             dxC1=pC1->X()-nStart;
     250           0 :             pC1->X()=nStart;
     251             :         }
     252           0 :         if (bC2) {
     253           0 :             dxC2=pC2->X()-nStart;
     254           0 :             pC2->X()=nStart;
     255             :         }
     256             :     } else {
     257           0 :         long nStart=rCenter.Y()-rRad.Y();
     258           0 :         dy1=rPnt.Y()-nStart;
     259           0 :         rPnt.Y()=nStart;
     260           0 :         if (bC1) {
     261           0 :             dyC1=pC1->Y()-nStart;
     262           0 :             pC1->Y()=nStart;
     263             :         }
     264           0 :         if (bC2) {
     265           0 :             dyC2=pC2->Y()-nStart;
     266           0 :             pC2->Y()=nStart;
     267             :         }
     268             :     }
     269           0 :     double nWink=GetCrookAngle(rPnt,rCenter,rRad,bVert);
     270           0 :     double sn=sin(nWink);
     271           0 :     double cs=cos(nWink);
     272           0 :     RotatePoint(rPnt,rCenter,sn,cs);
     273           0 :     if (bC1) { if (bVert) pC1->Y()-=y0-rCenter.Y(); else pC1->X()-=x0-rCenter.X(); RotatePoint(*pC1,rCenter,sn,cs); }
     274           0 :     if (bC2) { if (bVert) pC2->Y()-=y0-rCenter.Y(); else pC2->X()-=x0-rCenter.X(); RotatePoint(*pC2,rCenter,sn,cs); }
     275           0 :     if (bVert) {
     276           0 :         rPnt.X()+=dx1;
     277           0 :         if (bC1) pC1->X()+=dxC1;
     278           0 :         if (bC2) pC2->X()+=dxC2;
     279             :     } else {
     280           0 :         rPnt.Y()+=dy1;
     281           0 :         if (bC1) pC1->Y()+=dyC1;
     282           0 :         if (bC2) pC2->Y()+=dyC2;
     283             :     }
     284           0 :     rSin=sn;
     285           0 :     rCos=cs;
     286           0 :     return nWink;
     287             : }
     288             : 
     289           0 : double CrookStretchXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCenter,
     290             :                           const Point& rRad, double& rSin, double& rCos, bool bVert,
     291             :                           const Rectangle rRefRect)
     292             : {
     293           0 :     long y0=rPnt.Y();
     294           0 :     CrookSlantXPoint(rPnt,pC1,pC2,rCenter,rRad,rSin,rCos,bVert);
     295           0 :     if (bVert) {
     296             :     } else {
     297           0 :         long nTop=rRefRect.Top();
     298           0 :         long nBtm=rRefRect.Bottom();
     299           0 :         long nHgt=nBtm-nTop;
     300           0 :         long dy=rPnt.Y()-y0;
     301           0 :         double a=((double)(y0-nTop))/nHgt;
     302           0 :         a*=dy;
     303           0 :         rPnt.Y()=y0+Round(a);
     304           0 :     } return 0.0;
     305             : }
     306             : 
     307             : 
     308             : 
     309           0 : void CrookRotatePoly(XPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert)
     310             : {
     311             :     double nSin,nCos;
     312           0 :     sal_uInt16 nPointAnz=rPoly.GetPointCount();
     313           0 :     sal_uInt16 i=0;
     314           0 :     while (i<nPointAnz) {
     315           0 :         Point* pPnt=&rPoly[i];
     316           0 :         Point* pC1=NULL;
     317           0 :         Point* pC2=NULL;
     318           0 :         if (i+1<nPointAnz && rPoly.IsControl(i)) { // control point to the left
     319           0 :             pC1=pPnt;
     320           0 :             i++;
     321           0 :             pPnt=&rPoly[i];
     322             :         }
     323           0 :         i++;
     324           0 :         if (i<nPointAnz && rPoly.IsControl(i)) { // control point to the right
     325           0 :             pC2=&rPoly[i];
     326           0 :             i++;
     327             :         }
     328           0 :         CrookRotateXPoint(*pPnt,pC1,pC2,rCenter,rRad,nSin,nCos,bVert);
     329             :     }
     330           0 : }
     331             : 
     332           0 : void CrookSlantPoly(XPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert)
     333             : {
     334             :     double nSin,nCos;
     335           0 :     sal_uInt16 nPointAnz=rPoly.GetPointCount();
     336           0 :     sal_uInt16 i=0;
     337           0 :     while (i<nPointAnz) {
     338           0 :         Point* pPnt=&rPoly[i];
     339           0 :         Point* pC1=NULL;
     340           0 :         Point* pC2=NULL;
     341           0 :         if (i+1<nPointAnz && rPoly.IsControl(i)) { // control point to the left
     342           0 :             pC1=pPnt;
     343           0 :             i++;
     344           0 :             pPnt=&rPoly[i];
     345             :         }
     346           0 :         i++;
     347           0 :         if (i<nPointAnz && rPoly.IsControl(i)) { // control point to the right
     348           0 :             pC2=&rPoly[i];
     349           0 :             i++;
     350             :         }
     351           0 :         CrookSlantXPoint(*pPnt,pC1,pC2,rCenter,rRad,nSin,nCos,bVert);
     352             :     }
     353           0 : }
     354             : 
     355           0 : void CrookStretchPoly(XPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert, const Rectangle rRefRect)
     356             : {
     357             :     double nSin,nCos;
     358           0 :     sal_uInt16 nPointAnz=rPoly.GetPointCount();
     359           0 :     sal_uInt16 i=0;
     360           0 :     while (i<nPointAnz) {
     361           0 :         Point* pPnt=&rPoly[i];
     362           0 :         Point* pC1=NULL;
     363           0 :         Point* pC2=NULL;
     364           0 :         if (i+1<nPointAnz && rPoly.IsControl(i)) { //  control point to the left
     365           0 :             pC1=pPnt;
     366           0 :             i++;
     367           0 :             pPnt=&rPoly[i];
     368             :         }
     369           0 :         i++;
     370           0 :         if (i<nPointAnz && rPoly.IsControl(i)) { // control point to the right
     371           0 :             pC2=&rPoly[i];
     372           0 :             i++;
     373             :         }
     374           0 :         CrookStretchXPoint(*pPnt,pC1,pC2,rCenter,rRad,nSin,nCos,bVert,rRefRect);
     375             :     }
     376           0 : }
     377             : 
     378             : 
     379             : 
     380           0 : void CrookRotatePoly(XPolyPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert)
     381             : {
     382           0 :     sal_uInt16 nPolyAnz=rPoly.Count();
     383           0 :     for (sal_uInt16 nPolyNum=0; nPolyNum<nPolyAnz; nPolyNum++) {
     384           0 :         CrookRotatePoly(rPoly[nPolyNum],rCenter,rRad,bVert);
     385             :     }
     386           0 : }
     387             : 
     388           0 : void CrookSlantPoly(XPolyPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert)
     389             : {
     390           0 :     sal_uInt16 nPolyAnz=rPoly.Count();
     391           0 :     for (sal_uInt16 nPolyNum=0; nPolyNum<nPolyAnz; nPolyNum++) {
     392           0 :         CrookSlantPoly(rPoly[nPolyNum],rCenter,rRad,bVert);
     393             :     }
     394           0 : }
     395             : 
     396           0 : void CrookStretchPoly(XPolyPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert, const Rectangle rRefRect)
     397             : {
     398           0 :     sal_uInt16 nPolyAnz=rPoly.Count();
     399           0 :     for (sal_uInt16 nPolyNum=0; nPolyNum<nPolyAnz; nPolyNum++) {
     400           0 :         CrookStretchPoly(rPoly[nPolyNum],rCenter,rRad,bVert,rRefRect);
     401             :     }
     402           0 : }
     403             : 
     404             : 
     405             : 
     406       26535 : long GetAngle(const Point& rPnt)
     407             : {
     408       26535 :     long a=0;
     409       26535 :     if (rPnt.Y()==0) {
     410       23803 :         if (rPnt.X()<0) a=-18000;
     411        2732 :     } else if (rPnt.X()==0) {
     412        1846 :         if (rPnt.Y()>0) a=-9000;
     413         747 :         else a=9000;
     414             :     } else {
     415         886 :         a=Round((atan2((double)-rPnt.Y(),(double)rPnt.X())/nPi180));
     416             :     }
     417       26535 :     return a;
     418             : }
     419             : 
     420       12110 : long NormAngle180(long a)
     421             : {
     422       12110 :     while (a<18000) a+=36000;
     423       12110 :     while (a>=18000) a-=36000;
     424       12110 :     return a;
     425             : }
     426             : 
     427       13949 : long NormAngle360(long a)
     428             : {
     429       13949 :     while (a<0) a+=36000;
     430       13949 :     while (a>=36000) a-=36000;
     431       13949 :     return a;
     432             : }
     433             : 
     434           0 : sal_uInt16 GetAngleSector(long nWink)
     435             : {
     436           0 :     while (nWink<0) nWink+=36000;
     437           0 :     while (nWink>=36000) nWink-=36000;
     438           0 :     if (nWink< 9000) return 0;
     439           0 :     if (nWink<18000) return 1;
     440           0 :     if (nWink<27000) return 2;
     441           0 :     return 3;
     442             : }
     443             : 
     444          24 : long GetLen(const Point& rPnt)
     445             : {
     446          24 :     long x=std::abs(rPnt.X());
     447          24 :     long y=std::abs(rPnt.Y());
     448          24 :     if (x+y<0x8000) { // because 7FFF * 7FFF * 2 = 7FFE0002
     449          24 :         x*=x;
     450          24 :         y*=y;
     451          24 :         x+=y;
     452          24 :         x=Round(sqrt((double)x));
     453          24 :         return x;
     454             :     } else {
     455           0 :         double nx=x;
     456           0 :         double ny=y;
     457           0 :         nx*=nx;
     458           0 :         ny*=ny;
     459           0 :         nx+=ny;
     460           0 :         nx=sqrt(nx);
     461           0 :         if (nx>0x7FFFFFFF) {
     462           0 :             return 0x7FFFFFFF; // we can't go any further, for fear of an overrun!
     463             :         } else {
     464           0 :             return Round(nx);
     465             :         }
     466             :     }
     467             : }
     468             : 
     469             : 
     470             : 
     471       59080 : void GeoStat::RecalcSinCos()
     472             : {
     473       59080 :     if (nDrehWink==0) {
     474       45315 :         nSin=0.0;
     475       45315 :         nCos=1.0;
     476             :     } else {
     477       13765 :         double a=nDrehWink*nPi180;
     478       13765 :         nSin=sin(a);
     479       13765 :         nCos=cos(a);
     480             :     }
     481       59080 : }
     482             : 
     483       58047 : void GeoStat::RecalcTan()
     484             : {
     485       58047 :     if (nShearWink==0) {
     486       46802 :         nTan=0.0;
     487             :     } else {
     488       11245 :         double a=nShearWink*nPi180;
     489       11245 :         nTan=tan(a);
     490             :     }
     491       58047 : }
     492             : 
     493             : 
     494             : 
     495       12110 : Polygon Rect2Poly(const Rectangle& rRect, const GeoStat& rGeo)
     496             : {
     497       12110 :     Polygon aPol(5);
     498       12110 :     aPol[0]=rRect.TopLeft();
     499       12110 :     aPol[1]=rRect.TopRight();
     500       12110 :     aPol[2]=rRect.BottomRight();
     501       12110 :     aPol[3]=rRect.BottomLeft();
     502       12110 :     aPol[4]=rRect.TopLeft();
     503       12110 :     if (rGeo.nShearWink!=0) ShearPoly(aPol,rRect.TopLeft(),rGeo.nTan);
     504       12110 :     if (rGeo.nDrehWink!=0) RotatePoly(aPol,rRect.TopLeft(),rGeo.nSin,rGeo.nCos);
     505       12110 :     return aPol;
     506             : }
     507             : 
     508       12110 : void Poly2Rect(const Polygon& rPol, Rectangle& rRect, GeoStat& rGeo)
     509             : {
     510       12110 :     rGeo.nDrehWink=GetAngle(rPol[1]-rPol[0]);
     511       12110 :     rGeo.nDrehWink=NormAngle360(rGeo.nDrehWink);
     512             :     // rotation successful
     513       12110 :     rGeo.RecalcSinCos();
     514             : 
     515       12110 :     Point aPt1(rPol[1]-rPol[0]);
     516       12110 :     if (rGeo.nDrehWink!=0) RotatePoint(aPt1,Point(0,0),-rGeo.nSin,rGeo.nCos); // -Sin to reverse rotation
     517       12110 :     long nWdt=aPt1.X();
     518             : 
     519       12110 :     Point aPt0(rPol[0]);
     520       12110 :     Point aPt3(rPol[3]-rPol[0]);
     521       12110 :     if (rGeo.nDrehWink!=0) RotatePoint(aPt3,Point(0,0),-rGeo.nSin,rGeo.nCos); // -Sin to reverse rotation
     522       12110 :     long nHgt=aPt3.Y();
     523             : 
     524             : 
     525       12110 :     long nShW=GetAngle(aPt3);
     526       12110 :     nShW-=27000; // ShearWink is measured against a vertical line
     527       12110 :     nShW=-nShW;  // Negieren, denn '+' ist Rechtskursivierung
     528             : 
     529       12110 :     bool bMirr=aPt3.Y()<0;
     530       12110 :     if (bMirr) { // "exchange of points" when mirroring
     531          60 :         nHgt=-nHgt;
     532          60 :         nShW+=18000;
     533          60 :         aPt0=rPol[3];
     534             :     }
     535       12110 :     nShW=NormAngle180(nShW);
     536       12110 :     if (nShW<-9000 || nShW>9000) {
     537           0 :         nShW=NormAngle180(nShW+18000);
     538             :     }
     539       12110 :     if (nShW<-SDRMAXSHEAR) nShW=-SDRMAXSHEAR; // limit ShearWinkel (shear angle) to +/- 89.00 deg
     540       12110 :     if (nShW>SDRMAXSHEAR)  nShW=SDRMAXSHEAR;
     541       12110 :     rGeo.nShearWink=nShW;
     542       12110 :     rGeo.RecalcTan();
     543       12110 :     Point aRU(aPt0);
     544       12110 :     aRU.X()+=nWdt;
     545       12110 :     aRU.Y()+=nHgt;
     546       12110 :     rRect=Rectangle(aPt0,aRU);
     547       12110 : }
     548             : 
     549             : 
     550             : 
     551           0 : void OrthoDistance8(const Point& rPt0, Point& rPt, bool bBigOrtho)
     552             : {
     553           0 :     long dx=rPt.X()-rPt0.X();
     554           0 :     long dy=rPt.Y()-rPt0.Y();
     555           0 :     long dxa=std::abs(dx);
     556           0 :     long dya=std::abs(dy);
     557           0 :     if (dx==0 || dy==0 || dxa==dya) return;
     558           0 :     if (dxa>=dya*2) { rPt.Y()=rPt0.Y(); return; }
     559           0 :     if (dya>=dxa*2) { rPt.X()=rPt0.X(); return; }
     560           0 :     if ((dxa<dya) != bBigOrtho) {
     561           0 :         rPt.Y()=rPt0.Y()+(dxa* (dy>=0 ? 1 : -1) );
     562             :     } else {
     563           0 :         rPt.X()=rPt0.X()+(dya* (dx>=0 ? 1 : -1) );
     564             :     }
     565             : }
     566             : 
     567           0 : void OrthoDistance4(const Point& rPt0, Point& rPt, bool bBigOrtho)
     568             : {
     569           0 :     long dx=rPt.X()-rPt0.X();
     570           0 :     long dy=rPt.Y()-rPt0.Y();
     571           0 :     long dxa=std::abs(dx);
     572           0 :     long dya=std::abs(dy);
     573           0 :     if ((dxa<dya) != bBigOrtho) {
     574           0 :         rPt.Y()=rPt0.Y()+(dxa* (dy>=0 ? 1 : -1) );
     575             :     } else {
     576           0 :         rPt.X()=rPt0.X()+(dya* (dx>=0 ? 1 : -1) );
     577             :     }
     578           0 : }
     579             : 
     580             : 
     581             : 
     582       15163 : long BigMulDiv(long nVal, long nMul, long nDiv)
     583             : {
     584       15163 :     BigInt aVal(nVal);
     585       15163 :     aVal*=nMul;
     586       15163 :     if (aVal.IsNeg()!=(nDiv<0)) {
     587          63 :         aVal-=nDiv/2; // to round correctly
     588             :     } else {
     589       15100 :         aVal+=nDiv/2; // to round correctly
     590             :     }
     591       15163 :     if(nDiv)
     592             :     {
     593       15163 :         aVal/=nDiv;
     594       15163 :         return long(aVal);
     595             :     }
     596           0 :     return 0x7fffffff;
     597             : }
     598             : 
     599         148 : void Kuerzen(Fraction& rF, unsigned nDigits)
     600             : {
     601         148 :     sal_Int32 nMul=rF.GetNumerator();
     602         148 :     sal_Int32 nDiv=rF.GetDenominator();
     603         148 :     bool bNeg = false;
     604         148 :     if (nMul<0) { nMul=-nMul; bNeg=!bNeg; }
     605         148 :     if (nDiv<0) { nDiv=-nDiv; bNeg=!bNeg; }
     606         254 :     if (nMul==0 || nDiv==0) return;
     607             :     sal_uInt32 a;
     608          42 :     a=sal_uInt32(nMul); unsigned nMulZ=0; // count leading zeros
     609          42 :     while (a<0x00800000) { nMulZ+=8; a<<=8; }
     610          42 :     while (a<0x80000000) { nMulZ++; a<<=1; }
     611          42 :     a=sal_uInt32(nDiv); unsigned nDivZ=0; // count leading zeros
     612          42 :     while (a<0x00800000) { nDivZ+=8; a<<=8; }
     613          42 :     while (a<0x80000000) { nDivZ++; a<<=1; }
     614             :     // count the number of digits
     615          42 :     int nMulDigits=32-nMulZ;
     616          42 :     int nDivDigits=32-nDivZ;
     617             :     // count how many decimal places can be removed
     618          42 :     int nMulWeg=nMulDigits-nDigits; if (nMulWeg<0) nMulWeg=0;
     619          42 :     int nDivWeg=nDivDigits-nDigits; if (nDivWeg<0) nDivWeg=0;
     620          42 :     int nWeg=std::min(nMulWeg,nDivWeg);
     621          42 :     nMul>>=nWeg;
     622          42 :     nDiv>>=nWeg;
     623          42 :     if (nMul==0 || nDiv==0) {
     624             :         DBG_WARNING("Math error after canceling decimal places.");
     625           0 :         return;
     626             :     }
     627          42 :     if (bNeg) nMul=-nMul;
     628          42 :     rF=Fraction(nMul,nDiv);
     629             : }
     630             : 
     631             : 
     632             : // How many eU units fit into a mm, respectively an inch?
     633             : // Or: How many mm, respectively inches, are there in an eU (and then give me the inverse)
     634             : 
     635        1448 : FrPair GetInchOrMM(MapUnit eU)
     636             : {
     637        1448 :     switch (eU) {
     638           0 :         case MAP_1000TH_INCH: return FrPair(1000,1);
     639           0 :         case MAP_100TH_INCH : return FrPair( 100,1);
     640           0 :         case MAP_10TH_INCH  : return FrPair(  10,1);
     641         340 :         case MAP_INCH       : return FrPair(   1,1);
     642         340 :         case MAP_POINT      : return FrPair(  72,1);
     643         124 :         case MAP_TWIP       : return FrPair(1440,1);
     644         644 :         case MAP_100TH_MM   : return FrPair( 100,1);
     645           0 :         case MAP_10TH_MM    : return FrPair(  10,1);
     646           0 :         case MAP_MM         : return FrPair(   1,1);
     647           0 :         case MAP_CM         : return FrPair(   1,10);
     648             :         case MAP_PIXEL      : {
     649           0 :             VirtualDevice aVD;
     650           0 :             aVD.SetMapMode(MapMode(MAP_100TH_MM));
     651           0 :             Point aP(aVD.PixelToLogic(Point(64,64))); // 64 pixels for more accuracy
     652           0 :             return FrPair(6400,aP.X(),6400,aP.Y());
     653             :         }
     654             :         case MAP_APPFONT: case MAP_SYSFONT: {
     655           0 :             VirtualDevice aVD;
     656           0 :             aVD.SetMapMode(MapMode(eU));
     657           0 :             Point aP(aVD.LogicToPixel(Point(32,32))); // 32 units for more accuracy
     658           0 :             aVD.SetMapMode(MapMode(MAP_100TH_MM));
     659           0 :             aP=aVD.PixelToLogic(aP);
     660           0 :             return FrPair(3200,aP.X(),3200,aP.Y());
     661             :         }
     662           0 :         default: break;
     663             :     }
     664           0 :     return Fraction(1,1);
     665             : }
     666             : 
     667           0 : FrPair GetInchOrMM(FieldUnit eU)
     668             : {
     669           0 :     switch (eU) {
     670           0 :         case FUNIT_INCH       : return FrPair(   1,1);
     671           0 :         case FUNIT_POINT      : return FrPair(  72,1);
     672           0 :         case FUNIT_TWIP       : return FrPair(1440,1);
     673           0 :         case FUNIT_100TH_MM   : return FrPair( 100,1);
     674           0 :         case FUNIT_MM         : return FrPair(   1,1);
     675           0 :         case FUNIT_CM         : return FrPair(   1,10);
     676           0 :         case FUNIT_M          : return FrPair(   1,1000);
     677           0 :         case FUNIT_KM         : return FrPair(   1,1000000);
     678           0 :         case FUNIT_PICA       : return FrPair(   6,1);
     679           0 :         case FUNIT_FOOT       : return FrPair(   1,12);
     680           0 :         case FUNIT_MILE       : return FrPair(   1,63360);
     681           0 :         default: break;
     682             :     }
     683           0 :     return Fraction(1,1);
     684             : }
     685             : 
     686             : // Calculate the factor that we need to convert units from eS to eD.
     687             : // e. g. GetMapFactor(UNIT_MM,UNIT_100TH_MM) => 100.
     688             : 
     689        1024 : FrPair GetMapFactor(MapUnit eS, MapUnit eD)
     690             : {
     691        1024 :     if (eS==eD) return FrPair(1,1,1,1);
     692         724 :     FrPair aS(GetInchOrMM(eS));
     693         724 :     FrPair aD(GetInchOrMM(eD));
     694         724 :     bool bSInch=IsInch(eS);
     695         724 :     bool bDInch=IsInch(eD);
     696         724 :     FrPair aRet(aD.X()/aS.X(),aD.Y()/aS.Y());
     697         724 :     if (bSInch && !bDInch) { aRet.X()*=Fraction(127,5); aRet.Y()*=Fraction(127,5); }
     698         724 :     if (!bSInch && bDInch) { aRet.X()*=Fraction(5,127); aRet.Y()*=Fraction(5,127); }
     699         724 :     return aRet;
     700             : };
     701             : 
     702           0 : FrPair GetMapFactor(FieldUnit eS, FieldUnit eD)
     703             : {
     704           0 :     if (eS==eD) return FrPair(1,1,1,1);
     705           0 :     FrPair aS(GetInchOrMM(eS));
     706           0 :     FrPair aD(GetInchOrMM(eD));
     707           0 :     bool bSInch=IsInch(eS);
     708           0 :     bool bDInch=IsInch(eD);
     709           0 :     FrPair aRet(aD.X()/aS.X(),aD.Y()/aS.Y());
     710           0 :     if (bSInch && !bDInch) { aRet.X()*=Fraction(127,5); aRet.Y()*=Fraction(127,5); }
     711           0 :     if (!bSInch && bDInch) { aRet.X()*=Fraction(5,127); aRet.Y()*=Fraction(5,127); }
     712           0 :     return aRet;
     713             : };
     714             : 
     715             : 
     716             : 
     717             :     // 1 mile    =  8 furlong = 63.360" = 1.609.344,0mm
     718             :     // 1 furlong = 10 chains  =  7.920" =   201.168,0mm
     719             :     // 1 chain   =  4 poles   =    792" =    20.116,8mm
     720             :     // 1 pole    =  5 1/2 yd  =    198" =     5.029,2mm
     721             :     // 1 yd      =  3 ft      =     36" =       914,4mm
     722             :     // 1 ft      = 12 "       =      1" =       304,8mm
     723             : 
     724           0 : void GetMeterOrInch(MapUnit eMU, short& rnKomma, long& rnMul, long& rnDiv, bool& rbMetr, bool& rbInch)
     725             : {
     726           0 :     rnMul=1; rnDiv=1;
     727           0 :     short nKomma=0;
     728           0 :     bool bMetr = false, bInch = false;
     729           0 :     switch (eMU) {
     730             :         // Metrisch
     731           0 :         case MAP_100TH_MM   : bMetr = true; nKomma=5; break;
     732           0 :         case MAP_10TH_MM    : bMetr = true; nKomma=4; break;
     733           0 :         case MAP_MM         : bMetr = true; nKomma=3; break;
     734           0 :         case MAP_CM         : bMetr = true; nKomma=2; break;
     735             :         // Inch
     736           0 :         case MAP_1000TH_INCH: bInch = true; nKomma=3; break;
     737           0 :         case MAP_100TH_INCH : bInch = true; nKomma=2; break;
     738           0 :         case MAP_10TH_INCH  : bInch = true; nKomma=1; break;
     739           0 :         case MAP_INCH       : bInch = true; nKomma=0; break;
     740           0 :         case MAP_POINT      : bInch = true; rnDiv=72;  break;          // 1Pt   = 1/72"
     741           0 :         case MAP_TWIP       : bInch = true; rnDiv=144; nKomma=1; break; // 1Twip = 1/1440"
     742             :         // Sonstiges
     743           0 :         case MAP_PIXEL      : break;
     744           0 :         case MAP_SYSFONT    : break;
     745           0 :         case MAP_APPFONT    : break;
     746           0 :         case MAP_RELATIVE   : break;
     747           0 :         default: break;
     748             :     } // switch
     749           0 :     rnKomma=nKomma;
     750           0 :     rbMetr=bMetr;
     751           0 :     rbInch=bInch;
     752           0 : }
     753             : 
     754           0 : void GetMeterOrInch(FieldUnit eFU, short& rnKomma, long& rnMul, long& rnDiv, bool& rbMetr, bool& rbInch)
     755             : {
     756           0 :     rnMul=1; rnDiv=1;
     757           0 :     short nKomma=0;
     758           0 :     bool bMetr = false, bInch = false;
     759           0 :     switch (eFU) {
     760           0 :         case FUNIT_NONE     : break;
     761             :         // metrically
     762           0 :         case FUNIT_100TH_MM : bMetr = true; nKomma=5; break;
     763           0 :         case FUNIT_MM       : bMetr = true; nKomma=3; break;
     764           0 :         case FUNIT_CM       : bMetr = true; nKomma=2; break;
     765           0 :         case FUNIT_M        : bMetr = true; nKomma=0; break;
     766           0 :         case FUNIT_KM       : bMetr = true; nKomma=-3; break;
     767             :         // Inch
     768           0 :         case FUNIT_TWIP     : bInch = true; rnDiv=144; nKomma=1; break;  // 1Twip = 1/1440"
     769           0 :         case FUNIT_POINT    : bInch = true; rnDiv=72; break;   // 1Pt   = 1/72"
     770           0 :         case FUNIT_PICA     : bInch = true; rnDiv=6; break;    // 1Pica = 1/6"  ?
     771           0 :         case FUNIT_INCH     : bInch = true; break;             // 1"    = 1"
     772           0 :         case FUNIT_FOOT     : bInch = true; rnMul=12; break;   // 1Ft   = 12"
     773           0 :         case FUNIT_MILE     : bInch = true; rnMul=6336; nKomma=-1; break; // 1mile = 63360"
     774             :         // others
     775           0 :         case FUNIT_CUSTOM   : break;
     776           0 :         case FUNIT_PERCENT  : nKomma=2; break;
     777             :         // TODO: Add code to handle the following (added to remove warning)
     778           0 :         case FUNIT_CHAR     : break;
     779           0 :         case FUNIT_LINE     : break;
     780           0 :         case FUNIT_PIXEL    : break;
     781           0 :         case FUNIT_DEGREE   : break;
     782           0 :         case FUNIT_SECOND   : break;
     783           0 :         case FUNIT_MILLISECOND   : break;
     784             :     } // switch
     785           0 :     rnKomma=nKomma;
     786           0 :     rbMetr=bMetr;
     787           0 :     rbInch=bInch;
     788           0 : }
     789             : 
     790           0 : void SdrFormatter::Undirty()
     791             : {
     792           0 :     if (aScale.GetNumerator()==0 || aScale.GetDenominator()==0) aScale=Fraction(1,1);
     793             :     bool bSrcMetr,bSrcInch,bDstMetr,bDstInch;
     794             :     long nMul1,nDiv1,nMul2,nDiv2;
     795             :     short nKomma1,nKomma2;
     796             :     // first: normalize to m or in
     797           0 :     if (!bSrcFU) {
     798           0 :         GetMeterOrInch(eSrcMU,nKomma1,nMul1,nDiv1,bSrcMetr,bSrcInch);
     799             :     } else {
     800           0 :         GetMeterOrInch(eSrcFU,nKomma1,nMul1,nDiv1,bSrcMetr,bSrcInch);
     801             :     }
     802           0 :     if (!bDstFU) {
     803           0 :         GetMeterOrInch(eDstMU,nKomma2,nMul2,nDiv2,bDstMetr,bDstInch);
     804             :     } else {
     805           0 :         GetMeterOrInch(eDstFU,nKomma2,nMul2,nDiv2,bDstMetr,bDstInch);
     806             :     }
     807           0 :     nMul1*=nDiv2;
     808           0 :     nDiv1*=nMul2;
     809           0 :     nKomma1=nKomma1-nKomma2;
     810             : 
     811           0 :     if (bSrcInch && bDstMetr) {
     812           0 :         nKomma1+=4;
     813           0 :         nMul1*=254;
     814             :     }
     815           0 :     if (bSrcMetr && bDstInch) {
     816           0 :         nKomma1-=4;
     817           0 :         nDiv1*=254;
     818             :     }
     819             : 
     820             :     // temporary fraction for canceling
     821           0 :     Fraction aTempFract(nMul1,nDiv1);
     822           0 :     nMul1=aTempFract.GetNumerator();
     823           0 :     nDiv1=aTempFract.GetDenominator();
     824             : 
     825           0 :     nMul_=nMul1;
     826           0 :     nDiv_=nDiv1;
     827           0 :     nKomma_=nKomma1;
     828           0 :     bDirty=false;
     829           0 : }
     830             : 
     831             : 
     832           0 : void SdrFormatter::TakeStr(long nVal, OUString& rStr) const
     833             : {
     834           0 :     OUString aNullCode("0");
     835             : 
     836           0 :     if(!nVal)
     837             :     {
     838           0 :         rStr = aNullCode;
     839           0 :         return;
     840             :     }
     841             : 
     842             :     // we may lose some decimal places here, because of MulDiv instead of Real
     843           0 :     bool bNeg(nVal < 0);
     844           0 :     SvtSysLocale aSysLoc;
     845           0 :     const LocaleDataWrapper& rLoc = aSysLoc.GetLocaleData();
     846             : 
     847           0 :     ForceUndirty();
     848             : 
     849           0 :     sal_Int16 nC(nKomma_);
     850             : 
     851           0 :     if(bNeg)
     852           0 :         nVal = -nVal;
     853             : 
     854           0 :     while(nC <= -3)
     855             :     {
     856           0 :         nVal *= 1000;
     857           0 :         nC += 3;
     858             :     }
     859             : 
     860           0 :     while(nC <= -1)
     861             :     {
     862           0 :         nVal *= 10;
     863           0 :         nC++;
     864             :     }
     865             : 
     866           0 :     if(nMul_ != nDiv_)
     867           0 :         nVal = BigMulDiv(nVal, nMul_, nDiv_);
     868             : 
     869           0 :     OUStringBuffer aStr = OUString::number(nVal);
     870             : 
     871           0 :     if(nC > 0 && aStr.getLength() <= nC )
     872             :     {
     873             :         // decimal separator necessary
     874           0 :         sal_Int32 nAnz(nC - aStr.getLength());
     875             : 
     876           0 :         if(nAnz >= 0 && rLoc.isNumLeadingZero())
     877           0 :             nAnz++;
     878             : 
     879           0 :         for(sal_Int32  i=0; i<nAnz; i++)
     880           0 :             aStr.insert(0, aNullCode);
     881             : 
     882             :         // remove superfluous decimal points
     883           0 :         sal_Int32 nNumDigits(rLoc.getNumDigits());
     884           0 :         sal_Int32 nWeg(nC - nNumDigits);
     885             : 
     886           0 :         if(nWeg > 0)
     887             :         {
     888             :             // TODO: we should round here
     889           0 :             aStr.remove(aStr.getLength() - nWeg, nWeg);
     890           0 :             nC = nNumDigits;
     891             :         }
     892             :     }
     893             : 
     894             :     // remember everything before the decimal separator for later
     895           0 :     sal_Int32 nForComma(aStr.getLength() - nC);
     896             : 
     897           0 :     if(nC > 0)
     898             :     {
     899             :         // insert comma char (decimal separator)
     900             :         // remove trailing zeros
     901           0 :         while(nC > 0 && aStr[aStr.getLength() - 1] == aNullCode[0])
     902             :         {
     903           0 :             aStr.remove(aStr.getLength() - 1, 1);
     904           0 :             nC--;
     905             :         }
     906             : 
     907           0 :         if(nC > 0)
     908             :         {
     909             :             // do we still have decimal places?
     910           0 :             sal_Unicode cDec(rLoc.getNumDecimalSep()[0]);
     911           0 :             aStr.insert(nForComma, cDec);
     912             :         }
     913             :     }
     914             : 
     915             :     // add in thousands separator (if necessary)
     916           0 :     if( nForComma > 3 )
     917             :     {
     918           0 :         OUString aThoSep( rLoc.getNumThousandSep() );
     919           0 :         if ( aThoSep.getLength() > 0 )
     920             :         {
     921           0 :             sal_Unicode cTho( aThoSep[0] );
     922           0 :             sal_Int32 i(nForComma - 3);
     923             : 
     924           0 :             while(i > 0)
     925             :             {
     926           0 :                 aStr.insert(i, cTho);
     927           0 :                 i -= 3;
     928             :             }
     929           0 :         }
     930             :     }
     931             : 
     932           0 :     if(aStr.isEmpty())
     933           0 :         aStr.insert(aStr.getLength(), aNullCode);
     934             : 
     935           0 :     if(bNeg && (aStr.getLength() > 1 || aStr[0] != aNullCode[0]))
     936             :     {
     937           0 :         aStr.insert(0, "-");
     938             :     }
     939             : 
     940           0 :     rStr = aStr.makeStringAndClear();
     941             : }
     942             : 
     943           0 : void SdrFormatter::TakeUnitStr(MapUnit eUnit, OUString& rStr)
     944             : {
     945           0 :     switch(eUnit)
     946             :     {
     947             :         // metrically
     948             :         case MAP_100TH_MM   :
     949             :         {
     950           0 :             rStr = "/100mm";
     951           0 :             break;
     952             :         }
     953             :         case MAP_10TH_MM    :
     954             :         {
     955           0 :             rStr = "/10mm";
     956           0 :             break;
     957             :         }
     958             :         case MAP_MM         :
     959             :         {
     960           0 :             rStr = "mm";
     961           0 :             break;
     962             :         }
     963             :         case MAP_CM         :
     964             :         {
     965           0 :             rStr = "cm";
     966           0 :             break;
     967             :         }
     968             : 
     969             :         // Inch
     970             :         case MAP_1000TH_INCH:
     971             :         {
     972           0 :             rStr = "/1000\"";
     973           0 :             break;
     974             :         }
     975             :         case MAP_100TH_INCH :
     976             :         {
     977           0 :             rStr = "/100\"";
     978           0 :             break;
     979             :         }
     980             :         case MAP_10TH_INCH  :
     981             :         {
     982           0 :             rStr = "/10\"";
     983           0 :             break;
     984             :         }
     985             :         case MAP_INCH       :
     986             :         {
     987           0 :             rStr = "\"";
     988           0 :             break;
     989             :         }
     990             :         case MAP_POINT      :
     991             :         {
     992           0 :             rStr = "pt";
     993           0 :             break;
     994             :         }
     995             :         case MAP_TWIP       :
     996             :         {
     997           0 :             rStr = "twip";
     998           0 :             break;
     999             :         }
    1000             : 
    1001             :         // others
    1002             :         case MAP_PIXEL      :
    1003             :         {
    1004           0 :             rStr = "pixel";
    1005           0 :             break;
    1006             :         }
    1007             :         case MAP_SYSFONT    :
    1008             :         {
    1009           0 :             rStr = "sysfont";
    1010           0 :             break;
    1011             :         }
    1012             :         case MAP_APPFONT    :
    1013             :         {
    1014           0 :             rStr = "appfont";
    1015           0 :             break;
    1016             :         }
    1017             :         case MAP_RELATIVE   :
    1018             :         {
    1019           0 :             rStr = "%";
    1020           0 :             break;
    1021             :         }
    1022           0 :         default: break;
    1023             :     }
    1024           0 : }
    1025             : 
    1026           0 : void SdrFormatter::TakeUnitStr(FieldUnit eUnit, OUString& rStr)
    1027             : {
    1028           0 :     switch(eUnit)
    1029             :     {
    1030             :         default             :
    1031             :         case FUNIT_NONE     :
    1032             :         case FUNIT_CUSTOM   :
    1033             :         {
    1034           0 :             rStr = OUString();
    1035           0 :             break;
    1036             :         }
    1037             : 
    1038             :         // metrically
    1039             :         case FUNIT_100TH_MM:
    1040             :         {
    1041           0 :             rStr = "/100mm";
    1042           0 :             break;
    1043             :         }
    1044             :         case FUNIT_MM     :
    1045             :         {
    1046           0 :             rStr = "mm";
    1047           0 :             break;
    1048             :         }
    1049             :         case FUNIT_CM     :
    1050             :         {
    1051           0 :             rStr = "cm";
    1052           0 :             break;
    1053             :         }
    1054             :         case FUNIT_M      :
    1055             :         {
    1056           0 :             rStr = "m";
    1057           0 :             break;
    1058             :         }
    1059             :         case FUNIT_KM     :
    1060             :         {
    1061           0 :             rStr = "km";
    1062           0 :             break;
    1063             :         }
    1064             : 
    1065             :         // Inch
    1066             :         case FUNIT_TWIP   :
    1067             :         {
    1068           0 :             rStr = "twip";
    1069           0 :             break;
    1070             :         }
    1071             :         case FUNIT_POINT  :
    1072             :         {
    1073           0 :             rStr = "pt";
    1074           0 :             break;
    1075             :         }
    1076             :         case FUNIT_PICA   :
    1077             :         {
    1078           0 :             rStr = "pica";
    1079           0 :             break;
    1080             :         }
    1081             :         case FUNIT_INCH   :
    1082             :         {
    1083           0 :             rStr = "\"";
    1084           0 :             break;
    1085             :         }
    1086             :         case FUNIT_FOOT   :
    1087             :         {
    1088           0 :             rStr = "ft";
    1089           0 :             break;
    1090             :         }
    1091             :         case FUNIT_MILE   :
    1092             :         {
    1093           0 :             rStr = "mile(s)";
    1094           0 :             break;
    1095             :         }
    1096             : 
    1097             :         // others
    1098             :         case FUNIT_PERCENT:
    1099             :         {
    1100           0 :             rStr = "%";
    1101           0 :             break;
    1102             :         }
    1103             :     }
    1104           0 : }
    1105             : 
    1106             : 
    1107             : 
    1108             : 
    1109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10