LCOV - code coverage report
Current view: top level - sd/source/ui/func - fumorph.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 254 0.4 %
Date: 2014-11-03 Functions: 2 17 11.8 %
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             : #include <svx/svditer.hxx>
      44             : 
      45             : #include <basegfx/color/bcolor.hxx>
      46             : #include <boost/scoped_ptr.hpp>
      47             : 
      48             : using namespace com::sun::star;
      49             : 
      50             : namespace sd {
      51             : 
      52             : #define  ITEMVALUE( ItemSet, Id, Cast ) ( ( (const Cast&) (ItemSet).Get( (Id) ) ).GetValue() )
      53           0 : TYPEINIT1( FuMorph, FuPoor );
      54             : 
      55           0 : FuMorph::FuMorph (
      56             :     ViewShell* pViewSh,
      57             :     ::sd::Window* pWin,
      58             :     ::sd::View* pView,
      59             :     SdDrawDocument* pDoc,
      60             :     SfxRequest& rReq )
      61           0 :     :   FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      62             : {
      63           0 : }
      64             : 
      65           0 : rtl::Reference<FuPoor> FuMorph::Create(
      66             :     ViewShell* pViewSh,
      67             :     ::sd::Window* pWin,
      68             :     ::sd::View* pView,
      69             :     SdDrawDocument* pDoc,
      70             :     SfxRequest& rReq
      71             : )
      72             : {
      73           0 :     rtl::Reference<FuPoor> xFunc( new FuMorph( pViewSh, pWin, pView, pDoc, rReq ) );
      74           0 :     xFunc->DoExecute(rReq);
      75           0 :     return xFunc;
      76             : }
      77             : 
      78           0 : void FuMorph::DoExecute( SfxRequest& )
      79             : {
      80           0 :     const SdrMarkList&  rMarkList = mpView->GetMarkedObjectList();
      81             : 
      82           0 :     if(rMarkList.GetMarkCount() == 2)
      83             :     {
      84             :         // create clones
      85           0 :         SdrObject*  pObj1 = rMarkList.GetMark(0)->GetMarkedSdrObj();
      86           0 :         SdrObject*  pObj2 = rMarkList.GetMark(1)->GetMarkedSdrObj();
      87           0 :         SdrObject*  pCloneObj1 = pObj1->Clone();
      88           0 :         SdrObject*  pCloneObj2 = pObj2->Clone();
      89             : 
      90             :         // delete text at clone, otherwise we do net get a correct PathObj
      91           0 :         pCloneObj1->SetOutlinerParaObject(NULL);
      92           0 :         pCloneObj2->SetOutlinerParaObject(NULL);
      93             : 
      94             :         // create path objects
      95           0 :         SdrObject*  pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false);
      96           0 :         SdrObject*  pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false);
      97           0 :         SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
      98           0 :         boost::scoped_ptr<AbstractMorphDlg> pDlg(pFact ? pFact->CreateMorphDlg( static_cast< vcl::Window*>(mpWindow), pObj1, pObj2 ) : 0);
      99           0 :         if(pPolyObj1 && pPolyObj2 && pDlg && (pDlg->Execute() == RET_OK))
     100             :         {
     101           0 :             B2DPolyPolygonList_impl aPolyPolyList;
     102           0 :             ::basegfx::B2DPolyPolygon aPolyPoly1;
     103           0 :             ::basegfx::B2DPolyPolygon aPolyPoly2;
     104             : 
     105           0 :             pDlg->SaveSettings();
     106             : 
     107             :             // #i48168# Not always is the pPolyObj1/pPolyObj2 a SdrPathObj, it may also be a group object
     108             :             // containing SdrPathObjs. To get the polygons, i add two iters here
     109           0 :             SdrObjListIter aIter1(*pPolyObj1);
     110           0 :             SdrObjListIter aIter2(*pPolyObj2);
     111             : 
     112           0 :             while(aIter1.IsMore())
     113             :             {
     114           0 :                 SdrObject* pObj = aIter1.Next();
     115           0 :                 if(pObj && pObj->ISA(SdrPathObj))
     116           0 :                     aPolyPoly1.append(((SdrPathObj*)pObj)->GetPathPoly());
     117             :             }
     118             : 
     119           0 :             while(aIter2.IsMore())
     120             :             {
     121           0 :                 SdrObject* pObj = aIter2.Next();
     122           0 :                 if(pObj && pObj->ISA(SdrPathObj))
     123           0 :                     aPolyPoly2.append(((SdrPathObj*)pObj)->GetPathPoly());
     124             :             }
     125             : 
     126             :             // perform morphing
     127           0 :             if(aPolyPoly1.count() && aPolyPoly2.count())
     128             :             {
     129           0 :                 aPolyPoly1 = ::basegfx::tools::correctOrientations(aPolyPoly1);
     130           0 :                 aPolyPoly1.removeDoublePoints();
     131           0 :                 ::basegfx::B2VectorOrientation eIsClockwise1(::basegfx::tools::getOrientation(aPolyPoly1.getB2DPolygon(0L)));
     132             : 
     133           0 :                 aPolyPoly2 = ::basegfx::tools::correctOrientations(aPolyPoly2);
     134           0 :                 aPolyPoly2.removeDoublePoints();
     135           0 :                 ::basegfx::B2VectorOrientation eIsClockwise2(::basegfx::tools::getOrientation(aPolyPoly2.getB2DPolygon(0L)));
     136             : 
     137             :                 // set same orientation
     138           0 :                 if(eIsClockwise1 != eIsClockwise2)
     139           0 :                     aPolyPoly2.flip();
     140             : 
     141             :                 // force same poly count
     142           0 :                 if(aPolyPoly1.count() < aPolyPoly2.count())
     143           0 :                     ImpAddPolys(aPolyPoly1, aPolyPoly2);
     144           0 :                 else if(aPolyPoly2.count() < aPolyPoly1.count())
     145           0 :                     ImpAddPolys(aPolyPoly2, aPolyPoly1);
     146             : 
     147             :                 // use orientation flag from dialog
     148           0 :                 if(!pDlg->IsOrientationFade())
     149           0 :                     aPolyPoly2.flip();
     150             : 
     151             :                 // force same point counts
     152           0 :                 for( sal_uInt32 a(0L); a < aPolyPoly1.count(); a++ )
     153             :                 {
     154           0 :                     ::basegfx::B2DPolygon aSub1(aPolyPoly1.getB2DPolygon(a));
     155           0 :                     ::basegfx::B2DPolygon aSub2(aPolyPoly2.getB2DPolygon(a));
     156             : 
     157           0 :                     if(aSub1.count() < aSub2.count())
     158           0 :                         ImpEqualizePolyPointCount(aSub1, aSub2);
     159           0 :                     else if(aSub2.count() < aSub1.count())
     160           0 :                         ImpEqualizePolyPointCount(aSub2, aSub1);
     161             : 
     162           0 :                     aPolyPoly1.setB2DPolygon(a, aSub1);
     163           0 :                     aPolyPoly2.setB2DPolygon(a, aSub2);
     164           0 :                 }
     165             : 
     166           0 :                 if(ImpMorphPolygons(aPolyPoly1, aPolyPoly2, pDlg->GetFadeSteps(), aPolyPolyList))
     167             :                 {
     168           0 :                     OUString aString(mpView->GetDescriptionOfMarkedObjects());
     169           0 :                     aString += " " + SD_RESSTR(STR_UNDO_MORPHING);
     170             : 
     171           0 :                     mpView->BegUndo(aString);
     172           0 :                     ImpInsertPolygons(aPolyPolyList, pDlg->IsAttributeFade(), pObj1, pObj2);
     173           0 :                     mpView->EndUndo();
     174             :                 }
     175             : 
     176           0 :                 for( size_t i = 0, n = aPolyPolyList.size(); i < n; ++i ) {
     177           0 :                     delete aPolyPolyList[ i ];
     178             :                 }
     179           0 :             }
     180             :         }
     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           0 : sal_uInt32 FuMorph::ImpGetNearestIndex(
     277             :     const ::basegfx::B2DPolygon& rPoly,
     278             :     const ::basegfx::B2DPoint& rPos
     279             : )
     280             : {
     281           0 :     double fMinDist = 0.0;
     282           0 :     sal_uInt32 nActInd = 0;
     283             : 
     284           0 :     for(sal_uInt32 a(0L); a < rPoly.count(); a++)
     285             :     {
     286           0 :         double fNewDist(::basegfx::B2DVector(rPoly.getB2DPoint(a) - rPos).getLength());
     287             : 
     288           0 :         if(!a || fNewDist < fMinDist)
     289             :         {
     290           0 :             fMinDist = fNewDist;
     291           0 :             nActInd = a;
     292             :         }
     293             :     }
     294             : 
     295           0 :     return nActInd;
     296             : }
     297             : 
     298             : /**
     299             :  * add to a point reduced polys until count is same
     300             :  */
     301           0 : void FuMorph::ImpAddPolys(
     302             :     ::basegfx::B2DPolyPolygon& rSmaller,
     303             :     const ::basegfx::B2DPolyPolygon& rBigger
     304             : )
     305             : {
     306           0 :     while(rSmaller.count() < rBigger.count())
     307             :     {
     308           0 :         const ::basegfx::B2DPolygon aToBeCopied(rBigger.getB2DPolygon(rSmaller.count()));
     309           0 :         const ::basegfx::B2DRange aToBeCopiedPolySize(::basegfx::tools::getRange(aToBeCopied));
     310           0 :         ::basegfx::B2DPoint aNewPoint(aToBeCopiedPolySize.getCenter());
     311           0 :         ::basegfx::B2DPolygon aNewPoly;
     312             : 
     313           0 :         const ::basegfx::B2DRange aSrcSize(::basegfx::tools::getRange(rBigger.getB2DPolygon(0L)));
     314           0 :         const ::basegfx::B2DPoint aSrcPos(aSrcSize.getCenter());
     315           0 :         const ::basegfx::B2DRange aDstSize(::basegfx::tools::getRange(rSmaller.getB2DPolygon(0L)));
     316           0 :         const ::basegfx::B2DPoint aDstPos(aDstSize.getCenter());
     317           0 :         aNewPoint = aNewPoint - aSrcPos + aDstPos;
     318             : 
     319           0 :         for(sal_uInt32 a(0L); a < aToBeCopied.count(); a++)
     320             :         {
     321           0 :             aNewPoly.append(aNewPoint);
     322             :         }
     323             : 
     324           0 :         rSmaller.append(aNewPoly);
     325           0 :     }
     326           0 : }
     327             : 
     328             : /**
     329             :  * create group object with morphed polygons
     330             :  */
     331           0 : void FuMorph::ImpInsertPolygons(
     332             :     B2DPolyPolygonList_impl& rPolyPolyList3D,
     333             :     bool bAttributeFade,
     334             :     const SdrObject* pObj1,
     335             :     const SdrObject* pObj2
     336             : )
     337             : {
     338           0 :     Color               aStartFillCol;
     339           0 :     Color               aEndFillCol;
     340           0 :     Color               aStartLineCol;
     341           0 :     Color               aEndLineCol;
     342           0 :     long                nStartLineWidth = 0;
     343           0 :     long                nEndLineWidth = 0;
     344           0 :     SdrPageView*        pPageView = mpView->GetSdrPageView();
     345           0 :     SfxItemPool &       pPool = pObj1->GetObjectItemPool();
     346           0 :     SfxItemSet          aSet1( pPool,SDRATTR_START,SDRATTR_NOTPERSIST_FIRST-1,EE_ITEMS_START,EE_ITEMS_END,0 );
     347           0 :     SfxItemSet          aSet2( aSet1 );
     348           0 :     bool            bLineColor = false;
     349           0 :     bool            bFillColor = false;
     350           0 :     bool            bLineWidth = false;
     351           0 :     bool            bIgnoreLine = false;
     352           0 :     bool            bIgnoreFill = false;
     353             : 
     354           0 :     aSet1.Put(pObj1->GetMergedItemSet());
     355           0 :     aSet2.Put(pObj2->GetMergedItemSet());
     356             : 
     357           0 :     const XLineStyle eLineStyle1 = ITEMVALUE( aSet1, XATTR_LINESTYLE, XLineStyleItem );
     358           0 :     const XLineStyle eLineStyle2 = ITEMVALUE( aSet2, XATTR_LINESTYLE, XLineStyleItem );
     359           0 :     const drawing::FillStyle eFillStyle1 = ITEMVALUE( aSet1, XATTR_FILLSTYLE, XFillStyleItem );
     360           0 :     const drawing::FillStyle eFillStyle2 = ITEMVALUE( aSet2, XATTR_FILLSTYLE, XFillStyleItem );
     361             : 
     362           0 :     if ( bAttributeFade )
     363             :     {
     364           0 :         if ( ( eLineStyle1 != XLINE_NONE ) && ( eLineStyle2 != XLINE_NONE ) )
     365             :         {
     366           0 :             bLineWidth = bLineColor = true;
     367             : 
     368             :             aStartLineCol = static_cast< XLineColorItem const & >(
     369           0 :                 aSet1.Get(XATTR_LINECOLOR)).GetColorValue();
     370             :             aEndLineCol = static_cast< XLineColorItem const & >(
     371           0 :                 aSet2.Get(XATTR_LINECOLOR)).GetColorValue();
     372             : 
     373           0 :             nStartLineWidth = ITEMVALUE( aSet1, XATTR_LINEWIDTH, XLineWidthItem );
     374           0 :             nEndLineWidth = ITEMVALUE( aSet2, XATTR_LINEWIDTH, XLineWidthItem );
     375             :         }
     376           0 :         else if ( ( eLineStyle1 == XLINE_NONE ) && ( eLineStyle2 == XLINE_NONE ) )
     377           0 :             bIgnoreLine = true;
     378             : 
     379           0 :         if ( ( eFillStyle1 == drawing::FillStyle_SOLID ) && ( eFillStyle2 == drawing::FillStyle_SOLID ) )
     380             :         {
     381           0 :             bFillColor = true;
     382             :             aStartFillCol = static_cast< XFillColorItem const & >(
     383           0 :                 aSet1.Get(XATTR_FILLCOLOR)).GetColorValue();
     384             :             aEndFillCol = static_cast< XFillColorItem const & >(
     385           0 :                 aSet2.Get(XATTR_FILLCOLOR)).GetColorValue();
     386             :         }
     387           0 :         else if ( ( eFillStyle1 == drawing::FillStyle_NONE ) && ( eFillStyle2 == drawing::FillStyle_NONE ) )
     388           0 :             bIgnoreFill = true;
     389             :     }
     390             : 
     391           0 :     if ( pPageView )
     392             :     {
     393           0 :         SfxItemSet      aSet( aSet1 );
     394           0 :         SdrObjGroup*    pObjGroup = new SdrObjGroup;
     395           0 :         SdrObjList*     pObjList = pObjGroup->GetSubList();
     396           0 :         const size_t    nCount = rPolyPolyList3D.size();
     397           0 :         const double    fStep = 1. / ( nCount + 1 );
     398           0 :         const double    fDelta = nEndLineWidth - nStartLineWidth;
     399           0 :         double          fFactor = fStep;
     400             : 
     401           0 :         aSet.Put( XLineStyleItem( XLINE_SOLID ) );
     402           0 :         aSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
     403             : 
     404           0 :         for ( size_t i = 0; i < nCount; i++, fFactor += fStep )
     405             :         {
     406           0 :             const ::basegfx::B2DPolyPolygon& rPolyPoly3D = *rPolyPolyList3D[ i ];
     407           0 :             SdrPathObj* pNewObj = new SdrPathObj(OBJ_POLY, rPolyPoly3D);
     408             : 
     409             :             // line color
     410           0 :             if ( bLineColor )
     411             :             {
     412           0 :                 const basegfx::BColor aLineColor(basegfx::interpolate(aStartLineCol.getBColor(), aEndLineCol.getBColor(), fFactor));
     413           0 :                 aSet.Put( XLineColorItem( aEmptyStr, Color(aLineColor)));
     414             :             }
     415           0 :             else if ( bIgnoreLine )
     416           0 :                 aSet.Put( XLineStyleItem( XLINE_NONE ) );
     417             : 
     418             :             // fill color
     419           0 :             if ( bFillColor )
     420             :             {
     421           0 :                 const basegfx::BColor aFillColor(basegfx::interpolate(aStartFillCol.getBColor(), aEndFillCol.getBColor(), fFactor));
     422           0 :                 aSet.Put( XFillColorItem( aEmptyStr, Color(aFillColor)));
     423             :             }
     424           0 :             else if ( bIgnoreFill )
     425           0 :                 aSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
     426             : 
     427             :             // line width
     428           0 :             if ( bLineWidth )
     429           0 :                 aSet.Put( XLineWidthItem( nStartLineWidth + (long) ( fFactor * fDelta + 0.5 ) ) );
     430             : 
     431           0 :             pNewObj->SetMergedItemSetAndBroadcast(aSet);
     432             : 
     433           0 :             pObjList->InsertObject( pNewObj );
     434             :         }
     435             : 
     436           0 :         if ( nCount )
     437             :         {
     438           0 :             pObjList->InsertObject( pObj1->Clone(), 0 );
     439           0 :             pObjList->InsertObject( pObj2->Clone() );
     440           0 :             mpView->DeleteMarked();
     441           0 :             mpView->InsertObjectAtView( pObjGroup, *pPageView, SDRINSERT_SETDEFLAYER );
     442           0 :         }
     443           0 :     }
     444           0 : }
     445             : 
     446             : /**
     447             :  * create single morphed PolyPolygon
     448             :  */
     449           0 : ::basegfx::B2DPolyPolygon* FuMorph::ImpCreateMorphedPolygon(
     450             :     const ::basegfx::B2DPolyPolygon& rPolyPolyStart,
     451             :     const ::basegfx::B2DPolyPolygon& rPolyPolyEnd,
     452             :     double fMorphingFactor
     453             : )
     454             : {
     455           0 :     ::basegfx::B2DPolyPolygon* pNewPolyPolygon = new ::basegfx::B2DPolyPolygon();
     456           0 :     const double fFactor = 1.0 - fMorphingFactor;
     457             : 
     458           0 :     for(sal_uInt32 a(0L); a < rPolyPolyStart.count(); a++)
     459             :     {
     460           0 :         const ::basegfx::B2DPolygon aPolyStart(rPolyPolyStart.getB2DPolygon(a));
     461           0 :         const ::basegfx::B2DPolygon aPolyEnd(rPolyPolyEnd.getB2DPolygon(a));
     462           0 :         const sal_uInt32 nCount(aPolyStart.count());
     463           0 :         ::basegfx::B2DPolygon aNewPolygon;
     464             : 
     465           0 :         for(sal_uInt32 b(0L); b < nCount; b++)
     466             :         {
     467           0 :             const ::basegfx::B2DPoint& aPtStart(aPolyStart.getB2DPoint(b));
     468           0 :             const ::basegfx::B2DPoint& aPtEnd(aPolyEnd.getB2DPoint(b));
     469           0 :             aNewPolygon.append(aPtEnd + ((aPtStart - aPtEnd) * fFactor));
     470           0 :         }
     471             : 
     472           0 :         aNewPolygon.setClosed(aPolyStart.isClosed() && aPolyEnd.isClosed());
     473           0 :         pNewPolyPolygon->append(aNewPolygon);
     474           0 :     }
     475             : 
     476           0 :     return pNewPolyPolygon;
     477             : }
     478             : 
     479             : /**
     480             :  * create morphed PolyPolygons
     481             :  */
     482           0 : bool FuMorph::ImpMorphPolygons(
     483             :     const ::basegfx::B2DPolyPolygon& rPolyPoly1,
     484             :     const ::basegfx::B2DPolyPolygon& rPolyPoly2,
     485             :     const sal_uInt16 nSteps,
     486             :     B2DPolyPolygonList_impl& rPolyPolyList3D
     487             : )
     488             : {
     489           0 :     if(nSteps)
     490             :     {
     491           0 :         const ::basegfx::B2DRange aStartPolySize(::basegfx::tools::getRange(rPolyPoly1));
     492           0 :         const ::basegfx::B2DPoint aStartCenter(aStartPolySize.getCenter());
     493           0 :         const ::basegfx::B2DRange aEndPolySize(::basegfx::tools::getRange(rPolyPoly2));
     494           0 :         const ::basegfx::B2DPoint aEndCenter(aEndPolySize.getCenter());
     495           0 :         const ::basegfx::B2DPoint aDelta(aEndCenter - aStartCenter);
     496           0 :         const double fFactor(1.0 / (nSteps + 1));
     497           0 :         double fValue(0.0);
     498             : 
     499           0 :         for(sal_uInt16 i(0); i < nSteps; i++)
     500             :         {
     501           0 :             fValue += fFactor;
     502           0 :             ::basegfx::B2DPolyPolygon* pNewPolyPoly2D = ImpCreateMorphedPolygon(rPolyPoly1, rPolyPoly2, fValue);
     503             : 
     504           0 :             const ::basegfx::B2DRange aNewPolySize(::basegfx::tools::getRange(*pNewPolyPoly2D));
     505           0 :             const ::basegfx::B2DPoint aNewS(aNewPolySize.getCenter());
     506           0 :             const ::basegfx::B2DPoint aRealS(aStartCenter + (aDelta * fValue));
     507           0 :             const ::basegfx::B2DPoint aDiff(aRealS - aNewS);
     508             : 
     509           0 :             pNewPolyPoly2D->transform(basegfx::tools::createTranslateB2DHomMatrix(aDiff));
     510           0 :             rPolyPolyList3D.push_back( pNewPolyPoly2D );
     511           0 :         }
     512             :     }
     513           0 :     return true;
     514             : }
     515             : 
     516         114 : } // end of namespace sd
     517             : 
     518             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10