LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/func - fumorph.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 256 0.4 %
Date: 2013-07-09 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             : // #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 : FunctionReference FuMorph::Create(
      65             :     ViewShell* pViewSh,
      66             :     ::sd::Window* pWin,
      67             :     ::sd::View* pView,
      68             :     SdDrawDocument* pDoc,
      69             :     SfxRequest& rReq
      70             : )
      71             : {
      72           0 :     FunctionReference 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(sal_False, sal_False);
      95           0 :         SdrObject*  pPolyObj2 = pCloneObj2->ConvertToPolyObj(sal_False, sal_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 :                     String aString(mpView->GetDescriptionOfMarkedObjects());
     168             : 
     169           0 :                     aString.Append(sal_Unicode(' '));
     170           0 :                     aString.Append(String(SdResId(STR_UNDO_MORPHING)));
     171             : 
     172           0 :                     mpView->BegUndo(aString);
     173           0 :                     ImpInsertPolygons(aPolyPolyList, pDlg->IsAttributeFade(), pObj1, pObj2);
     174           0 :                     mpView->EndUndo();
     175             :                 }
     176             : 
     177           0 :                 for( size_t i = 0, n = aPolyPolyList.size(); i < n; ++i ) {
     178           0 :                     delete aPolyPolyList[ i ];
     179             :                 }
     180           0 :             }
     181             :         }
     182           0 :         delete pDlg;
     183           0 :         SdrObject::Free( pCloneObj1 );
     184           0 :         SdrObject::Free( pCloneObj2 );
     185             : 
     186           0 :         SdrObject::Free( pPolyObj1 );
     187           0 :         SdrObject::Free( pPolyObj2 );
     188             :     }
     189           0 : }
     190             : 
     191           0 : ::basegfx::B2DPolygon ImpGetExpandedPolygon(
     192             :     const ::basegfx::B2DPolygon& rCandidate,
     193             :     sal_uInt32 nNum
     194             : )
     195             : {
     196           0 :     if(rCandidate.count() && nNum && rCandidate.count() != nNum)
     197             :     {
     198             :         // length of step in dest poly
     199           0 :         ::basegfx::B2DPolygon aRetval;
     200           0 :         const double fStep(::basegfx::tools::getLength(rCandidate) / (double)(rCandidate.isClosed() ? nNum : nNum - 1L));
     201           0 :         double fDestPos(0.0);
     202           0 :         double fSrcPos(0.0);
     203           0 :         sal_uInt32 nSrcPos(0L);
     204           0 :         sal_uInt32 nSrcPosNext((nSrcPos + 1L == rCandidate.count()) ? 0L : nSrcPos + 1L);
     205           0 :         double fNextSrcLen(::basegfx::B2DVector(rCandidate.getB2DPoint(nSrcPos) - rCandidate.getB2DPoint(nSrcPosNext)).getLength());
     206             : 
     207           0 :         for(sal_uInt32 b(0L); b < nNum; b++)
     208             :         {
     209             :             // calc fDestPos in source
     210           0 :             while(fSrcPos + fNextSrcLen < fDestPos)
     211             :             {
     212           0 :                 fSrcPos += fNextSrcLen;
     213           0 :                 nSrcPos++;
     214           0 :                 nSrcPosNext = (nSrcPos + 1L == rCandidate.count()) ? 0L : nSrcPos + 1L;
     215           0 :                 fNextSrcLen = ::basegfx::B2DVector(rCandidate.getB2DPoint(nSrcPos) - rCandidate.getB2DPoint(nSrcPosNext)).getLength();
     216             :             }
     217             : 
     218             :             // fDestPos is between fSrcPos and (fSrcPos + fNextSrcLen)
     219           0 :             const double fLenA((fDestPos - fSrcPos) / fNextSrcLen);
     220           0 :             const ::basegfx::B2DPoint aOld1(rCandidate.getB2DPoint(nSrcPos));
     221           0 :             const ::basegfx::B2DPoint aOld2(rCandidate.getB2DPoint(nSrcPosNext));
     222           0 :             ::basegfx::B2DPoint aNewPoint(basegfx::interpolate(aOld1, aOld2, fLenA));
     223           0 :             aRetval.append(aNewPoint);
     224             : 
     225             :             // next step
     226           0 :             fDestPos += fStep;
     227           0 :         }
     228             : 
     229           0 :         if(aRetval.count() >= 3L)
     230             :         {
     231           0 :             aRetval.setClosed(rCandidate.isClosed());
     232             :         }
     233             : 
     234           0 :         return aRetval;
     235             :     }
     236             :     else
     237             :     {
     238           0 :         return rCandidate;
     239             :     }
     240             : }
     241             : 
     242             : /**
     243             :  * make the point count of the polygons equal in adding points
     244             :  */
     245           0 : void FuMorph::ImpEqualizePolyPointCount(
     246             :     ::basegfx::B2DPolygon& rSmall,
     247             :     const ::basegfx::B2DPolygon& rBig
     248             : )
     249             : {
     250             :     // create poly with equal point count
     251           0 :     const sal_uInt32 nCnt(rBig.count());
     252           0 :     ::basegfx::B2DPolygon aPoly1(ImpGetExpandedPolygon(rSmall, nCnt));
     253             : 
     254             :     // create transformation for rBig to do the compare
     255           0 :     const ::basegfx::B2DRange aSrcSize(::basegfx::tools::getRange(rBig));
     256           0 :     const ::basegfx::B2DPoint aSrcPos(aSrcSize.getCenter());
     257           0 :     const ::basegfx::B2DRange aDstSize(::basegfx::tools::getRange(rSmall));
     258           0 :     const ::basegfx::B2DPoint aDstPos(aDstSize.getCenter());
     259             : 
     260           0 :     basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-aSrcPos.getX(), -aSrcPos.getY()));
     261           0 :     aTrans.scale(aDstSize.getWidth() / aSrcSize.getWidth(), aDstSize.getHeight() / aSrcSize.getHeight());
     262           0 :     aTrans.translate(aDstPos.getX(), aDstPos.getY());
     263             : 
     264             :     // transpose points to have smooth linear blending
     265           0 :     ::basegfx::B2DPolygon aPoly2;
     266           0 :     aPoly2.append(::basegfx::B2DPoint(), nCnt);
     267           0 :     sal_uInt32 nInd(ImpGetNearestIndex(aPoly1, aTrans * rBig.getB2DPoint(0L)));
     268             : 
     269           0 :     for(sal_uInt32 a(0L); a < nCnt; a++)
     270             :     {
     271           0 :         aPoly2.setB2DPoint((a + nCnt - nInd) % nCnt, aPoly1.getB2DPoint(a));
     272             :     }
     273             : 
     274           0 :     aPoly2.setClosed(rBig.isClosed());
     275           0 :     rSmall = aPoly2;
     276           0 : }
     277             : 
     278             : 
     279           0 : sal_uInt32 FuMorph::ImpGetNearestIndex(
     280             :     const ::basegfx::B2DPolygon& rPoly,
     281             :     const ::basegfx::B2DPoint& rPos
     282             : )
     283             : {
     284           0 :     double fMinDist = 0.0;
     285           0 :     sal_uInt32 nActInd = 0;
     286             : 
     287           0 :     for(sal_uInt32 a(0L); a < rPoly.count(); a++)
     288             :     {
     289           0 :         double fNewDist(::basegfx::B2DVector(rPoly.getB2DPoint(a) - rPos).getLength());
     290             : 
     291           0 :         if(!a || fNewDist < fMinDist)
     292             :         {
     293           0 :             fMinDist = fNewDist;
     294           0 :             nActInd = a;
     295             :         }
     296             :     }
     297             : 
     298           0 :     return nActInd;
     299             : }
     300             : 
     301             : /**
     302             :  * add to a point reduced polys until count is same
     303             :  */
     304           0 : void FuMorph::ImpAddPolys(
     305             :     ::basegfx::B2DPolyPolygon& rSmaller,
     306             :     const ::basegfx::B2DPolyPolygon& rBigger
     307             : )
     308             : {
     309           0 :     while(rSmaller.count() < rBigger.count())
     310             :     {
     311           0 :         const ::basegfx::B2DPolygon aToBeCopied(rBigger.getB2DPolygon(rSmaller.count()));
     312           0 :         const ::basegfx::B2DRange aToBeCopiedPolySize(::basegfx::tools::getRange(aToBeCopied));
     313           0 :         ::basegfx::B2DPoint aNewPoint(aToBeCopiedPolySize.getCenter());
     314           0 :         ::basegfx::B2DPolygon aNewPoly;
     315             : 
     316           0 :         const ::basegfx::B2DRange aSrcSize(::basegfx::tools::getRange(rBigger.getB2DPolygon(0L)));
     317           0 :         const ::basegfx::B2DPoint aSrcPos(aSrcSize.getCenter());
     318           0 :         const ::basegfx::B2DRange aDstSize(::basegfx::tools::getRange(rSmaller.getB2DPolygon(0L)));
     319           0 :         const ::basegfx::B2DPoint aDstPos(aDstSize.getCenter());
     320           0 :         aNewPoint = aNewPoint - aSrcPos + aDstPos;
     321             : 
     322           0 :         for(sal_uInt32 a(0L); a < aToBeCopied.count(); a++)
     323             :         {
     324           0 :             aNewPoly.append(aNewPoint);
     325             :         }
     326             : 
     327           0 :         rSmaller.append(aNewPoly);
     328           0 :     }
     329           0 : }
     330             : 
     331             : /**
     332             :  * create group object with morphed polygons
     333             :  */
     334           0 : void FuMorph::ImpInsertPolygons(
     335             :     B2DPolyPolygonList_impl& rPolyPolyList3D,
     336             :     sal_Bool bAttributeFade,
     337             :     const SdrObject* pObj1,
     338             :     const SdrObject* pObj2
     339             : )
     340             : {
     341           0 :     Color               aStartFillCol;
     342           0 :     Color               aEndFillCol;
     343           0 :     Color               aStartLineCol;
     344           0 :     Color               aEndLineCol;
     345           0 :     long                nStartLineWidth = 0;
     346           0 :     long                nEndLineWidth = 0;
     347           0 :     SdrPageView*        pPageView = mpView->GetSdrPageView();
     348           0 :     SfxItemPool*        pPool = pObj1->GetObjectItemPool();
     349           0 :     SfxItemSet          aSet1( *pPool,SDRATTR_START,SDRATTR_NOTPERSIST_FIRST-1,EE_ITEMS_START,EE_ITEMS_END,0 );
     350           0 :     SfxItemSet          aSet2( aSet1 );
     351           0 :     sal_Bool            bLineColor = sal_False;
     352           0 :     sal_Bool            bFillColor = sal_False;
     353           0 :     sal_Bool            bLineWidth = sal_False;
     354           0 :     sal_Bool            bIgnoreLine = sal_False;
     355           0 :     sal_Bool            bIgnoreFill = sal_False;
     356             : 
     357           0 :     aSet1.Put(pObj1->GetMergedItemSet());
     358           0 :     aSet2.Put(pObj2->GetMergedItemSet());
     359             : 
     360           0 :     const XLineStyle eLineStyle1 = ITEMVALUE( aSet1, XATTR_LINESTYLE, XLineStyleItem );
     361           0 :     const XLineStyle eLineStyle2 = ITEMVALUE( aSet2, XATTR_LINESTYLE, XLineStyleItem );
     362           0 :     const XFillStyle eFillStyle1 = ITEMVALUE( aSet1, XATTR_FILLSTYLE, XFillStyleItem );
     363           0 :     const XFillStyle eFillStyle2 = ITEMVALUE( aSet2, XATTR_FILLSTYLE, XFillStyleItem );
     364             : 
     365           0 :     if ( bAttributeFade )
     366             :     {
     367           0 :         if ( ( eLineStyle1 != XLINE_NONE ) && ( eLineStyle2 != XLINE_NONE ) )
     368             :         {
     369           0 :             bLineWidth = bLineColor = sal_True;
     370             : 
     371             :             aStartLineCol = static_cast< XLineColorItem const & >(
     372           0 :                 aSet1.Get(XATTR_LINECOLOR)).GetColorValue();
     373             :             aEndLineCol = static_cast< XLineColorItem const & >(
     374           0 :                 aSet2.Get(XATTR_LINECOLOR)).GetColorValue();
     375             : 
     376           0 :             nStartLineWidth = ITEMVALUE( aSet1, XATTR_LINEWIDTH, XLineWidthItem );
     377           0 :             nEndLineWidth = ITEMVALUE( aSet2, XATTR_LINEWIDTH, XLineWidthItem );
     378             :         }
     379           0 :         else if ( ( eLineStyle1 == XLINE_NONE ) && ( eLineStyle2 == XLINE_NONE ) )
     380           0 :             bIgnoreLine = sal_True;
     381             : 
     382           0 :         if ( ( eFillStyle1 == XFILL_SOLID ) && ( eFillStyle2 == XFILL_SOLID ) )
     383             :         {
     384           0 :             bFillColor = sal_True;
     385             :             aStartFillCol = static_cast< XFillColorItem const & >(
     386           0 :                 aSet1.Get(XATTR_FILLCOLOR)).GetColorValue();
     387             :             aEndFillCol = static_cast< XFillColorItem const & >(
     388           0 :                 aSet2.Get(XATTR_FILLCOLOR)).GetColorValue();
     389             :         }
     390           0 :         else if ( ( eFillStyle1 == XFILL_NONE ) && ( eFillStyle2 == XFILL_NONE ) )
     391           0 :             bIgnoreFill = sal_True;
     392             :     }
     393             : 
     394           0 :     if ( pPageView )
     395             :     {
     396           0 :         SfxItemSet      aSet( aSet1 );
     397           0 :         SdrObjGroup*    pObjGroup = new SdrObjGroup;
     398           0 :         SdrObjList*     pObjList = pObjGroup->GetSubList();
     399           0 :         const size_t    nCount = rPolyPolyList3D.size();
     400           0 :         const double    fStep = 1. / ( nCount + 1 );
     401           0 :         const double    fDelta = nEndLineWidth - nStartLineWidth;
     402           0 :         double          fFactor = fStep;
     403             : 
     404           0 :         aSet.Put( XLineStyleItem( XLINE_SOLID ) );
     405           0 :         aSet.Put( XFillStyleItem( XFILL_SOLID ) );
     406             : 
     407           0 :         for ( size_t i = 0; i < nCount; i++, fFactor += fStep )
     408             :         {
     409           0 :             const ::basegfx::B2DPolyPolygon& rPolyPoly3D = *rPolyPolyList3D[ i ];
     410           0 :             SdrPathObj* pNewObj = new SdrPathObj(OBJ_POLY, rPolyPoly3D);
     411             : 
     412             :             // line color
     413           0 :             if ( bLineColor )
     414             :             {
     415           0 :                 const basegfx::BColor aLineColor(basegfx::interpolate(aStartLineCol.getBColor(), aEndLineCol.getBColor(), fFactor));
     416           0 :                 aSet.Put( XLineColorItem( aEmptyStr, Color(aLineColor)));
     417             :             }
     418           0 :             else if ( bIgnoreLine )
     419           0 :                 aSet.Put( XLineStyleItem( XLINE_NONE ) );
     420             : 
     421             :             // fill color
     422           0 :             if ( bFillColor )
     423             :             {
     424           0 :                 const basegfx::BColor aFillColor(basegfx::interpolate(aStartFillCol.getBColor(), aEndFillCol.getBColor(), fFactor));
     425           0 :                 aSet.Put( XFillColorItem( aEmptyStr, Color(aFillColor)));
     426             :             }
     427           0 :             else if ( bIgnoreFill )
     428           0 :                 aSet.Put( XFillStyleItem( XFILL_NONE ) );
     429             : 
     430             :             // line width
     431           0 :             if ( bLineWidth )
     432           0 :                 aSet.Put( XLineWidthItem( nStartLineWidth + (long) ( fFactor * fDelta + 0.5 ) ) );
     433             : 
     434           0 :             pNewObj->SetMergedItemSetAndBroadcast(aSet);
     435             : 
     436           0 :             pObjList->InsertObject( pNewObj, LIST_APPEND );
     437             :         }
     438             : 
     439           0 :         if ( nCount )
     440             :         {
     441           0 :             pObjList->InsertObject( pObj1->Clone(), 0 );
     442           0 :             pObjList->InsertObject( pObj2->Clone(), LIST_APPEND );
     443           0 :             mpView->DeleteMarked();
     444           0 :             mpView->InsertObjectAtView( pObjGroup, *pPageView, SDRINSERT_SETDEFLAYER );
     445           0 :         }
     446           0 :     }
     447           0 : }
     448             : 
     449             : /**
     450             :  * create single morphed PolyPolygon
     451             :  */
     452           0 : ::basegfx::B2DPolyPolygon* FuMorph::ImpCreateMorphedPolygon(
     453             :     const ::basegfx::B2DPolyPolygon& rPolyPolyStart,
     454             :     const ::basegfx::B2DPolyPolygon& rPolyPolyEnd,
     455             :     double fMorphingFactor
     456             : )
     457             : {
     458           0 :     ::basegfx::B2DPolyPolygon* pNewPolyPolygon = new ::basegfx::B2DPolyPolygon();
     459           0 :     const double fFactor = 1.0 - fMorphingFactor;
     460             : 
     461           0 :     for(sal_uInt32 a(0L); a < rPolyPolyStart.count(); a++)
     462             :     {
     463           0 :         const ::basegfx::B2DPolygon aPolyStart(rPolyPolyStart.getB2DPolygon(a));
     464           0 :         const ::basegfx::B2DPolygon aPolyEnd(rPolyPolyEnd.getB2DPolygon(a));
     465           0 :         const sal_uInt32 nCount(aPolyStart.count());
     466           0 :         ::basegfx::B2DPolygon aNewPolygon;
     467             : 
     468           0 :         for(sal_uInt32 b(0L); b < nCount; b++)
     469             :         {
     470           0 :             const ::basegfx::B2DPoint& aPtStart(aPolyStart.getB2DPoint(b));
     471           0 :             const ::basegfx::B2DPoint& aPtEnd(aPolyEnd.getB2DPoint(b));
     472           0 :             aNewPolygon.append(aPtEnd + ((aPtStart - aPtEnd) * fFactor));
     473           0 :         }
     474             : 
     475           0 :         aNewPolygon.setClosed(aPolyStart.isClosed() && aPolyEnd.isClosed());
     476           0 :         pNewPolyPolygon->append(aNewPolygon);
     477           0 :     }
     478             : 
     479           0 :     return pNewPolyPolygon;
     480             : }
     481             : 
     482             : /**
     483             :  * create morphed PolyPolygons
     484             :  */
     485           0 : sal_Bool FuMorph::ImpMorphPolygons(
     486             :     const ::basegfx::B2DPolyPolygon& rPolyPoly1,
     487             :     const ::basegfx::B2DPolyPolygon& rPolyPoly2,
     488             :     const sal_uInt16 nSteps,
     489             :     B2DPolyPolygonList_impl& rPolyPolyList3D
     490             : )
     491             : {
     492           0 :     if(nSteps)
     493             :     {
     494           0 :         const ::basegfx::B2DRange aStartPolySize(::basegfx::tools::getRange(rPolyPoly1));
     495           0 :         const ::basegfx::B2DPoint aStartCenter(aStartPolySize.getCenter());
     496           0 :         const ::basegfx::B2DRange aEndPolySize(::basegfx::tools::getRange(rPolyPoly2));
     497           0 :         const ::basegfx::B2DPoint aEndCenter(aEndPolySize.getCenter());
     498           0 :         const ::basegfx::B2DPoint aDelta(aEndCenter - aStartCenter);
     499           0 :         const double fFactor(1.0 / (nSteps + 1));
     500           0 :         double fValue(0.0);
     501             : 
     502           0 :         for(sal_uInt16 i(0); i < nSteps; i++)
     503             :         {
     504           0 :             fValue += fFactor;
     505           0 :             ::basegfx::B2DPolyPolygon* pNewPolyPoly2D = ImpCreateMorphedPolygon(rPolyPoly1, rPolyPoly2, fValue);
     506             : 
     507           0 :             const ::basegfx::B2DRange aNewPolySize(::basegfx::tools::getRange(*pNewPolyPoly2D));
     508           0 :             const ::basegfx::B2DPoint aNewS(aNewPolySize.getCenter());
     509           0 :             const ::basegfx::B2DPoint aRealS(aStartCenter + (aDelta * fValue));
     510           0 :             const ::basegfx::B2DPoint aDiff(aRealS - aNewS);
     511             : 
     512           0 :             pNewPolyPoly2D->transform(basegfx::tools::createTranslateB2DHomMatrix(aDiff));
     513           0 :             rPolyPolyList3D.push_back( pNewPolyPoly2D );
     514           0 :         }
     515             :     }
     516           0 :     return sal_True;
     517             : }
     518             : 
     519          33 : } // end of namespace sd
     520             : 
     521             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10