LCOV - code coverage report
Current view: top level - sd/source/ui/func - fumorph.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 255 0.0 %
Date: 2014-04-14 Functions: 0 17 0.0 %
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             : #include "fumorph.hxx"
      21             : #include <svx/xfillit.hxx>
      22             : #include <svx/xlineit.hxx>
      23             : #include <vcl/msgbox.hxx>
      24             : #include <svx/svdpool.hxx>
      25             : #include <tools/poly.hxx>
      26             : #include <svx/svdopath.hxx>
      27             : #include <svx/svdogrp.hxx>
      28             : #include <editeng/eeitem.hxx>
      29             : 
      30             : #include "View.hxx"
      31             : #include "ViewShell.hxx"
      32             : #include "Window.hxx"
      33             : #include <basegfx/polygon/b2dpolygontools.hxx>
      34             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      35             : #include <basegfx/matrix/b2dhommatrix.hxx>
      36             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      37             : 
      38             : #include "strings.hrc"
      39             : #include "sdresid.hxx"
      40             : 
      41             : #include "sdabstdlg.hxx"
      42             : 
      43             : // #i48168#
      44             : #include <svx/svditer.hxx>
      45             : 
      46             : #include <basegfx/color/bcolor.hxx>
      47             : 
      48             : namespace sd {
      49             : 
      50             : #define  ITEMVALUE( ItemSet, Id, Cast ) ( ( (const Cast&) (ItemSet).Get( (Id) ) ).GetValue() )
      51           0 : TYPEINIT1( FuMorph, FuPoor );
      52             : 
      53             : 
      54           0 : FuMorph::FuMorph (
      55             :     ViewShell* pViewSh,
      56             :     ::sd::Window* pWin,
      57             :     ::sd::View* pView,
      58             :     SdDrawDocument* pDoc,
      59             :     SfxRequest& rReq )
      60           0 :     :   FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      61             : {
      62           0 : }
      63             : 
      64           0 : rtl::Reference<FuPoor> FuMorph::Create(
      65             :     ViewShell* pViewSh,
      66             :     ::sd::Window* pWin,
      67             :     ::sd::View* pView,
      68             :     SdDrawDocument* pDoc,
      69             :     SfxRequest& rReq
      70             : )
      71             : {
      72           0 :     rtl::Reference<FuPoor> xFunc( new FuMorph( pViewSh, pWin, pView, pDoc, rReq ) );
      73           0 :     xFunc->DoExecute(rReq);
      74           0 :     return xFunc;
      75             : }
      76             : 
      77           0 : void FuMorph::DoExecute( SfxRequest& )
      78             : {
      79           0 :     const SdrMarkList&  rMarkList = mpView->GetMarkedObjectList();
      80             : 
      81           0 :     if(rMarkList.GetMarkCount() == 2)
      82             :     {
      83             :         // create clones
      84           0 :         SdrObject*  pObj1 = rMarkList.GetMark(0)->GetMarkedSdrObj();
      85           0 :         SdrObject*  pObj2 = rMarkList.GetMark(1)->GetMarkedSdrObj();
      86           0 :         SdrObject*  pCloneObj1 = pObj1->Clone();
      87           0 :         SdrObject*  pCloneObj2 = pObj2->Clone();
      88             : 
      89             :         // delete text at clone, otherwise we do net get a correct PathObj
      90           0 :         pCloneObj1->SetOutlinerParaObject(NULL);
      91           0 :         pCloneObj2->SetOutlinerParaObject(NULL);
      92             : 
      93             :         // create path objects
      94           0 :         SdrObject*  pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false);
      95           0 :         SdrObject*  pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false);
      96           0 :         SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
      97           0 :         AbstractMorphDlg* pDlg = pFact ? pFact->CreateMorphDlg( static_cast< ::Window*>(mpWindow), pObj1, pObj2 ) : 0;
      98           0 :         if(pPolyObj1 && pPolyObj2 && pDlg && (pDlg->Execute() == RET_OK))
      99             :         {
     100           0 :             B2DPolyPolygonList_impl aPolyPolyList;
     101           0 :             ::basegfx::B2DPolyPolygon aPolyPoly1;
     102           0 :             ::basegfx::B2DPolyPolygon aPolyPoly2;
     103             : 
     104           0 :             pDlg->SaveSettings();
     105             : 
     106             :             // #i48168# Not always is the pPolyObj1/pPolyObj2 a SdrPathObj, it may also be a group object
     107             :             // containing SdrPathObjs. To get the polygons, i add two iters here
     108           0 :             SdrObjListIter aIter1(*pPolyObj1);
     109           0 :             SdrObjListIter aIter2(*pPolyObj2);
     110             : 
     111           0 :             while(aIter1.IsMore())
     112             :             {
     113           0 :                 SdrObject* pObj = aIter1.Next();
     114           0 :                 if(pObj && pObj->ISA(SdrPathObj))
     115           0 :                     aPolyPoly1.append(((SdrPathObj*)pObj)->GetPathPoly());
     116             :             }
     117             : 
     118           0 :             while(aIter2.IsMore())
     119             :             {
     120           0 :                 SdrObject* pObj = aIter2.Next();
     121           0 :                 if(pObj && pObj->ISA(SdrPathObj))
     122           0 :                     aPolyPoly2.append(((SdrPathObj*)pObj)->GetPathPoly());
     123             :             }
     124             : 
     125             :             // perform morphing
     126           0 :             if(aPolyPoly1.count() && aPolyPoly2.count())
     127             :             {
     128           0 :                 aPolyPoly1 = ::basegfx::tools::correctOrientations(aPolyPoly1);
     129           0 :                 aPolyPoly1.removeDoublePoints();
     130           0 :                 ::basegfx::B2VectorOrientation eIsClockwise1(::basegfx::tools::getOrientation(aPolyPoly1.getB2DPolygon(0L)));
     131             : 
     132           0 :                 aPolyPoly2 = ::basegfx::tools::correctOrientations(aPolyPoly2);
     133           0 :                 aPolyPoly2.removeDoublePoints();
     134           0 :                 ::basegfx::B2VectorOrientation eIsClockwise2(::basegfx::tools::getOrientation(aPolyPoly2.getB2DPolygon(0L)));
     135             : 
     136             :                 // set same orientation
     137           0 :                 if(eIsClockwise1 != eIsClockwise2)
     138           0 :                     aPolyPoly2.flip();
     139             : 
     140             :                 // force same poly count
     141           0 :                 if(aPolyPoly1.count() < aPolyPoly2.count())
     142           0 :                     ImpAddPolys(aPolyPoly1, aPolyPoly2);
     143           0 :                 else if(aPolyPoly2.count() < aPolyPoly1.count())
     144           0 :                     ImpAddPolys(aPolyPoly2, aPolyPoly1);
     145             : 
     146             :                 // use orientation flag from dialog
     147           0 :                 if(!pDlg->IsOrientationFade())
     148           0 :                     aPolyPoly2.flip();
     149             : 
     150             :                 // force same point counts
     151           0 :                 for( sal_uInt32 a(0L); a < aPolyPoly1.count(); a++ )
     152             :                 {
     153           0 :                     ::basegfx::B2DPolygon aSub1(aPolyPoly1.getB2DPolygon(a));
     154           0 :                     ::basegfx::B2DPolygon aSub2(aPolyPoly2.getB2DPolygon(a));
     155             : 
     156           0 :                     if(aSub1.count() < aSub2.count())
     157           0 :                         ImpEqualizePolyPointCount(aSub1, aSub2);
     158           0 :                     else if(aSub2.count() < aSub1.count())
     159           0 :                         ImpEqualizePolyPointCount(aSub2, aSub1);
     160             : 
     161           0 :                     aPolyPoly1.setB2DPolygon(a, aSub1);
     162           0 :                     aPolyPoly2.setB2DPolygon(a, aSub2);
     163           0 :                 }
     164             : 
     165           0 :                 if(ImpMorphPolygons(aPolyPoly1, aPolyPoly2, pDlg->GetFadeSteps(), aPolyPolyList))
     166             :                 {
     167           0 :                     OUString aString(mpView->GetDescriptionOfMarkedObjects());
     168           0 :                     aString += " " + SD_RESSTR(STR_UNDO_MORPHING);
     169             : 
     170           0 :                     mpView->BegUndo(aString);
     171           0 :                     ImpInsertPolygons(aPolyPolyList, pDlg->IsAttributeFade(), pObj1, pObj2);
     172           0 :                     mpView->EndUndo();
     173             :                 }
     174             : 
     175           0 :                 for( size_t i = 0, n = aPolyPolyList.size(); i < n; ++i ) {
     176           0 :                     delete aPolyPolyList[ i ];
     177             :                 }
     178           0 :             }
     179             :         }
     180           0 :         delete pDlg;
     181           0 :         SdrObject::Free( pCloneObj1 );
     182           0 :         SdrObject::Free( pCloneObj2 );
     183             : 
     184           0 :         SdrObject::Free( pPolyObj1 );
     185           0 :         SdrObject::Free( pPolyObj2 );
     186             :     }
     187           0 : }
     188             : 
     189           0 : ::basegfx::B2DPolygon ImpGetExpandedPolygon(
     190             :     const ::basegfx::B2DPolygon& rCandidate,
     191             :     sal_uInt32 nNum
     192             : )
     193             : {
     194           0 :     if(rCandidate.count() && nNum && rCandidate.count() != nNum)
     195             :     {
     196             :         // length of step in dest poly
     197           0 :         ::basegfx::B2DPolygon aRetval;
     198           0 :         const double fStep(::basegfx::tools::getLength(rCandidate) / (double)(rCandidate.isClosed() ? nNum : nNum - 1L));
     199           0 :         double fDestPos(0.0);
     200           0 :         double fSrcPos(0.0);
     201           0 :         sal_uInt32 nSrcPos(0L);
     202           0 :         sal_uInt32 nSrcPosNext((nSrcPos + 1L == rCandidate.count()) ? 0L : nSrcPos + 1L);
     203           0 :         double fNextSrcLen(::basegfx::B2DVector(rCandidate.getB2DPoint(nSrcPos) - rCandidate.getB2DPoint(nSrcPosNext)).getLength());
     204             : 
     205           0 :         for(sal_uInt32 b(0L); b < nNum; b++)
     206             :         {
     207             :             // calc fDestPos in source
     208           0 :             while(fSrcPos + fNextSrcLen < fDestPos)
     209             :             {
     210           0 :                 fSrcPos += fNextSrcLen;
     211           0 :                 nSrcPos++;
     212           0 :                 nSrcPosNext = (nSrcPos + 1L == rCandidate.count()) ? 0L : nSrcPos + 1L;
     213           0 :                 fNextSrcLen = ::basegfx::B2DVector(rCandidate.getB2DPoint(nSrcPos) - rCandidate.getB2DPoint(nSrcPosNext)).getLength();
     214             :             }
     215             : 
     216             :             // fDestPos is between fSrcPos and (fSrcPos + fNextSrcLen)
     217           0 :             const double fLenA((fDestPos - fSrcPos) / fNextSrcLen);
     218           0 :             const ::basegfx::B2DPoint aOld1(rCandidate.getB2DPoint(nSrcPos));
     219           0 :             const ::basegfx::B2DPoint aOld2(rCandidate.getB2DPoint(nSrcPosNext));
     220           0 :             ::basegfx::B2DPoint aNewPoint(basegfx::interpolate(aOld1, aOld2, fLenA));
     221           0 :             aRetval.append(aNewPoint);
     222             : 
     223             :             // next step
     224           0 :             fDestPos += fStep;
     225           0 :         }
     226             : 
     227           0 :         if(aRetval.count() >= 3L)
     228             :         {
     229           0 :             aRetval.setClosed(rCandidate.isClosed());
     230             :         }
     231             : 
     232           0 :         return aRetval;
     233             :     }
     234             :     else
     235             :     {
     236           0 :         return rCandidate;
     237             :     }
     238             : }
     239             : 
     240             : /**
     241             :  * make the point count of the polygons equal in adding points
     242             :  */
     243           0 : void FuMorph::ImpEqualizePolyPointCount(
     244             :     ::basegfx::B2DPolygon& rSmall,
     245             :     const ::basegfx::B2DPolygon& rBig
     246             : )
     247             : {
     248             :     // create poly with equal point count
     249           0 :     const sal_uInt32 nCnt(rBig.count());
     250           0 :     ::basegfx::B2DPolygon aPoly1(ImpGetExpandedPolygon(rSmall, nCnt));
     251             : 
     252             :     // create transformation for rBig to do the compare
     253           0 :     const ::basegfx::B2DRange aSrcSize(::basegfx::tools::getRange(rBig));
     254           0 :     const ::basegfx::B2DPoint aSrcPos(aSrcSize.getCenter());
     255           0 :     const ::basegfx::B2DRange aDstSize(::basegfx::tools::getRange(rSmall));
     256           0 :     const ::basegfx::B2DPoint aDstPos(aDstSize.getCenter());
     257             : 
     258           0 :     basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-aSrcPos.getX(), -aSrcPos.getY()));
     259           0 :     aTrans.scale(aDstSize.getWidth() / aSrcSize.getWidth(), aDstSize.getHeight() / aSrcSize.getHeight());
     260           0 :     aTrans.translate(aDstPos.getX(), aDstPos.getY());
     261             : 
     262             :     // transpose points to have smooth linear blending
     263           0 :     ::basegfx::B2DPolygon aPoly2;
     264           0 :     aPoly2.append(::basegfx::B2DPoint(), nCnt);
     265           0 :     sal_uInt32 nInd(ImpGetNearestIndex(aPoly1, aTrans * rBig.getB2DPoint(0L)));
     266             : 
     267           0 :     for(sal_uInt32 a(0L); a < nCnt; a++)
     268             :     {
     269           0 :         aPoly2.setB2DPoint((a + nCnt - nInd) % nCnt, aPoly1.getB2DPoint(a));
     270             :     }
     271             : 
     272           0 :     aPoly2.setClosed(rBig.isClosed());
     273           0 :     rSmall = aPoly2;
     274           0 : }
     275             : 
     276             : 
     277           0 : sal_uInt32 FuMorph::ImpGetNearestIndex(
     278             :     const ::basegfx::B2DPolygon& rPoly,
     279             :     const ::basegfx::B2DPoint& rPos
     280             : )
     281             : {
     282           0 :     double fMinDist = 0.0;
     283           0 :     sal_uInt32 nActInd = 0;
     284             : 
     285           0 :     for(sal_uInt32 a(0L); a < rPoly.count(); a++)
     286             :     {
     287           0 :         double fNewDist(::basegfx::B2DVector(rPoly.getB2DPoint(a) - rPos).getLength());
     288             : 
     289           0 :         if(!a || fNewDist < fMinDist)
     290             :         {
     291           0 :             fMinDist = fNewDist;
     292           0 :             nActInd = a;
     293             :         }
     294             :     }
     295             : 
     296           0 :     return nActInd;
     297             : }
     298             : 
     299             : /**
     300             :  * add to a point reduced polys until count is same
     301             :  */
     302           0 : void FuMorph::ImpAddPolys(
     303             :     ::basegfx::B2DPolyPolygon& rSmaller,
     304             :     const ::basegfx::B2DPolyPolygon& rBigger
     305             : )
     306             : {
     307           0 :     while(rSmaller.count() < rBigger.count())
     308             :     {
     309           0 :         const ::basegfx::B2DPolygon aToBeCopied(rBigger.getB2DPolygon(rSmaller.count()));
     310           0 :         const ::basegfx::B2DRange aToBeCopiedPolySize(::basegfx::tools::getRange(aToBeCopied));
     311           0 :         ::basegfx::B2DPoint aNewPoint(aToBeCopiedPolySize.getCenter());
     312           0 :         ::basegfx::B2DPolygon aNewPoly;
     313             : 
     314           0 :         const ::basegfx::B2DRange aSrcSize(::basegfx::tools::getRange(rBigger.getB2DPolygon(0L)));
     315           0 :         const ::basegfx::B2DPoint aSrcPos(aSrcSize.getCenter());
     316           0 :         const ::basegfx::B2DRange aDstSize(::basegfx::tools::getRange(rSmaller.getB2DPolygon(0L)));
     317           0 :         const ::basegfx::B2DPoint aDstPos(aDstSize.getCenter());
     318           0 :         aNewPoint = aNewPoint - aSrcPos + aDstPos;
     319             : 
     320           0 :         for(sal_uInt32 a(0L); a < aToBeCopied.count(); a++)
     321             :         {
     322           0 :             aNewPoly.append(aNewPoint);
     323             :         }
     324             : 
     325           0 :         rSmaller.append(aNewPoly);
     326           0 :     }
     327           0 : }
     328             : 
     329             : /**
     330             :  * create group object with morphed polygons
     331             :  */
     332           0 : void FuMorph::ImpInsertPolygons(
     333             :     B2DPolyPolygonList_impl& rPolyPolyList3D,
     334             :     sal_Bool bAttributeFade,
     335             :     const SdrObject* pObj1,
     336             :     const SdrObject* pObj2
     337             : )
     338             : {
     339           0 :     Color               aStartFillCol;
     340           0 :     Color               aEndFillCol;
     341           0 :     Color               aStartLineCol;
     342           0 :     Color               aEndLineCol;
     343           0 :     long                nStartLineWidth = 0;
     344           0 :     long                nEndLineWidth = 0;
     345           0 :     SdrPageView*        pPageView = mpView->GetSdrPageView();
     346           0 :     SfxItemPool*        pPool = pObj1->GetObjectItemPool();
     347           0 :     SfxItemSet          aSet1( *pPool,SDRATTR_START,SDRATTR_NOTPERSIST_FIRST-1,EE_ITEMS_START,EE_ITEMS_END,0 );
     348           0 :     SfxItemSet          aSet2( aSet1 );
     349           0 :     sal_Bool            bLineColor = sal_False;
     350           0 :     sal_Bool            bFillColor = sal_False;
     351           0 :     sal_Bool            bLineWidth = sal_False;
     352           0 :     sal_Bool            bIgnoreLine = sal_False;
     353           0 :     sal_Bool            bIgnoreFill = sal_False;
     354             : 
     355           0 :     aSet1.Put(pObj1->GetMergedItemSet());
     356           0 :     aSet2.Put(pObj2->GetMergedItemSet());
     357             : 
     358           0 :     const XLineStyle eLineStyle1 = ITEMVALUE( aSet1, XATTR_LINESTYLE, XLineStyleItem );
     359           0 :     const XLineStyle eLineStyle2 = ITEMVALUE( aSet2, XATTR_LINESTYLE, XLineStyleItem );
     360           0 :     const XFillStyle eFillStyle1 = ITEMVALUE( aSet1, XATTR_FILLSTYLE, XFillStyleItem );
     361           0 :     const XFillStyle eFillStyle2 = ITEMVALUE( aSet2, XATTR_FILLSTYLE, XFillStyleItem );
     362             : 
     363           0 :     if ( bAttributeFade )
     364             :     {
     365           0 :         if ( ( eLineStyle1 != XLINE_NONE ) && ( eLineStyle2 != XLINE_NONE ) )
     366             :         {
     367           0 :             bLineWidth = bLineColor = sal_True;
     368             : 
     369             :             aStartLineCol = static_cast< XLineColorItem const & >(
     370           0 :                 aSet1.Get(XATTR_LINECOLOR)).GetColorValue();
     371             :             aEndLineCol = static_cast< XLineColorItem const & >(
     372           0 :                 aSet2.Get(XATTR_LINECOLOR)).GetColorValue();
     373             : 
     374           0 :             nStartLineWidth = ITEMVALUE( aSet1, XATTR_LINEWIDTH, XLineWidthItem );
     375           0 :             nEndLineWidth = ITEMVALUE( aSet2, XATTR_LINEWIDTH, XLineWidthItem );
     376             :         }
     377           0 :         else if ( ( eLineStyle1 == XLINE_NONE ) && ( eLineStyle2 == XLINE_NONE ) )
     378           0 :             bIgnoreLine = sal_True;
     379             : 
     380           0 :         if ( ( eFillStyle1 == XFILL_SOLID ) && ( eFillStyle2 == XFILL_SOLID ) )
     381             :         {
     382           0 :             bFillColor = sal_True;
     383             :             aStartFillCol = static_cast< XFillColorItem const & >(
     384           0 :                 aSet1.Get(XATTR_FILLCOLOR)).GetColorValue();
     385             :             aEndFillCol = static_cast< XFillColorItem const & >(
     386           0 :                 aSet2.Get(XATTR_FILLCOLOR)).GetColorValue();
     387             :         }
     388           0 :         else if ( ( eFillStyle1 == XFILL_NONE ) && ( eFillStyle2 == XFILL_NONE ) )
     389           0 :             bIgnoreFill = sal_True;
     390             :     }
     391             : 
     392           0 :     if ( pPageView )
     393             :     {
     394           0 :         SfxItemSet      aSet( aSet1 );
     395           0 :         SdrObjGroup*    pObjGroup = new SdrObjGroup;
     396           0 :         SdrObjList*     pObjList = pObjGroup->GetSubList();
     397           0 :         const size_t    nCount = rPolyPolyList3D.size();
     398           0 :         const double    fStep = 1. / ( nCount + 1 );
     399           0 :         const double    fDelta = nEndLineWidth - nStartLineWidth;
     400           0 :         double          fFactor = fStep;
     401             : 
     402           0 :         aSet.Put( XLineStyleItem( XLINE_SOLID ) );
     403           0 :         aSet.Put( XFillStyleItem( XFILL_SOLID ) );
     404             : 
     405           0 :         for ( size_t i = 0; i < nCount; i++, fFactor += fStep )
     406             :         {
     407           0 :             const ::basegfx::B2DPolyPolygon& rPolyPoly3D = *rPolyPolyList3D[ i ];
     408           0 :             SdrPathObj* pNewObj = new SdrPathObj(OBJ_POLY, rPolyPoly3D);
     409             : 
     410             :             // line color
     411           0 :             if ( bLineColor )
     412             :             {
     413           0 :                 const basegfx::BColor aLineColor(basegfx::interpolate(aStartLineCol.getBColor(), aEndLineCol.getBColor(), fFactor));
     414           0 :                 aSet.Put( XLineColorItem( aEmptyStr, Color(aLineColor)));
     415             :             }
     416           0 :             else if ( bIgnoreLine )
     417           0 :                 aSet.Put( XLineStyleItem( XLINE_NONE ) );
     418             : 
     419             :             // fill color
     420           0 :             if ( bFillColor )
     421             :             {
     422           0 :                 const basegfx::BColor aFillColor(basegfx::interpolate(aStartFillCol.getBColor(), aEndFillCol.getBColor(), fFactor));
     423           0 :                 aSet.Put( XFillColorItem( aEmptyStr, Color(aFillColor)));
     424             :             }
     425           0 :             else if ( bIgnoreFill )
     426           0 :                 aSet.Put( XFillStyleItem( XFILL_NONE ) );
     427             : 
     428             :             // line width
     429           0 :             if ( bLineWidth )
     430           0 :                 aSet.Put( XLineWidthItem( nStartLineWidth + (long) ( fFactor * fDelta + 0.5 ) ) );
     431             : 
     432           0 :             pNewObj->SetMergedItemSetAndBroadcast(aSet);
     433             : 
     434           0 :             pObjList->InsertObject( pNewObj, CONTAINER_APPEND );
     435             :         }
     436             : 
     437           0 :         if ( nCount )
     438             :         {
     439           0 :             pObjList->InsertObject( pObj1->Clone(), 0 );
     440           0 :             pObjList->InsertObject( pObj2->Clone(), CONTAINER_APPEND );
     441           0 :             mpView->DeleteMarked();
     442           0 :             mpView->InsertObjectAtView( pObjGroup, *pPageView, SDRINSERT_SETDEFLAYER );
     443           0 :         }
     444           0 :     }
     445           0 : }
     446             : 
     447             : /**
     448             :  * create single morphed PolyPolygon
     449             :  */
     450           0 : ::basegfx::B2DPolyPolygon* FuMorph::ImpCreateMorphedPolygon(
     451             :     const ::basegfx::B2DPolyPolygon& rPolyPolyStart,
     452             :     const ::basegfx::B2DPolyPolygon& rPolyPolyEnd,
     453             :     double fMorphingFactor
     454             : )
     455             : {
     456           0 :     ::basegfx::B2DPolyPolygon* pNewPolyPolygon = new ::basegfx::B2DPolyPolygon();
     457           0 :     const double fFactor = 1.0 - fMorphingFactor;
     458             : 
     459           0 :     for(sal_uInt32 a(0L); a < rPolyPolyStart.count(); a++)
     460             :     {
     461           0 :         const ::basegfx::B2DPolygon aPolyStart(rPolyPolyStart.getB2DPolygon(a));
     462           0 :         const ::basegfx::B2DPolygon aPolyEnd(rPolyPolyEnd.getB2DPolygon(a));
     463           0 :         const sal_uInt32 nCount(aPolyStart.count());
     464           0 :         ::basegfx::B2DPolygon aNewPolygon;
     465             : 
     466           0 :         for(sal_uInt32 b(0L); b < nCount; b++)
     467             :         {
     468           0 :             const ::basegfx::B2DPoint& aPtStart(aPolyStart.getB2DPoint(b));
     469           0 :             const ::basegfx::B2DPoint& aPtEnd(aPolyEnd.getB2DPoint(b));
     470           0 :             aNewPolygon.append(aPtEnd + ((aPtStart - aPtEnd) * fFactor));
     471           0 :         }
     472             : 
     473           0 :         aNewPolygon.setClosed(aPolyStart.isClosed() && aPolyEnd.isClosed());
     474           0 :         pNewPolyPolygon->append(aNewPolygon);
     475           0 :     }
     476             : 
     477           0 :     return pNewPolyPolygon;
     478             : }
     479             : 
     480             : /**
     481             :  * create morphed PolyPolygons
     482             :  */
     483           0 : sal_Bool FuMorph::ImpMorphPolygons(
     484             :     const ::basegfx::B2DPolyPolygon& rPolyPoly1,
     485             :     const ::basegfx::B2DPolyPolygon& rPolyPoly2,
     486             :     const sal_uInt16 nSteps,
     487             :     B2DPolyPolygonList_impl& rPolyPolyList3D
     488             : )
     489             : {
     490           0 :     if(nSteps)
     491             :     {
     492           0 :         const ::basegfx::B2DRange aStartPolySize(::basegfx::tools::getRange(rPolyPoly1));
     493           0 :         const ::basegfx::B2DPoint aStartCenter(aStartPolySize.getCenter());
     494           0 :         const ::basegfx::B2DRange aEndPolySize(::basegfx::tools::getRange(rPolyPoly2));
     495           0 :         const ::basegfx::B2DPoint aEndCenter(aEndPolySize.getCenter());
     496           0 :         const ::basegfx::B2DPoint aDelta(aEndCenter - aStartCenter);
     497           0 :         const double fFactor(1.0 / (nSteps + 1));
     498           0 :         double fValue(0.0);
     499             : 
     500           0 :         for(sal_uInt16 i(0); i < nSteps; i++)
     501             :         {
     502           0 :             fValue += fFactor;
     503           0 :             ::basegfx::B2DPolyPolygon* pNewPolyPoly2D = ImpCreateMorphedPolygon(rPolyPoly1, rPolyPoly2, fValue);
     504             : 
     505           0 :             const ::basegfx::B2DRange aNewPolySize(::basegfx::tools::getRange(*pNewPolyPoly2D));
     506           0 :             const ::basegfx::B2DPoint aNewS(aNewPolySize.getCenter());
     507           0 :             const ::basegfx::B2DPoint aRealS(aStartCenter + (aDelta * fValue));
     508           0 :             const ::basegfx::B2DPoint aDiff(aRealS - aNewS);
     509             : 
     510           0 :             pNewPolyPoly2D->transform(basegfx::tools::createTranslateB2DHomMatrix(aDiff));
     511           0 :             rPolyPolyList3D.push_back( pNewPolyPoly2D );
     512           0 :         }
     513             :     }
     514           0 :     return sal_True;
     515             : }
     516             : 
     517           0 : } // end of namespace sd
     518             : 
     519             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10