45#include <com/sun/star/drawing/LineStyle.hpp>
57 :
FuPoor(pViewSh, pWin, pView, pDoc, rReq)
70 xFunc->DoExecute(rReq);
88 pCloneObj1->SetOutlinerParaObject(std::nullopt);
89 pCloneObj2->SetOutlinerParaObject(std::nullopt);
96 if(pPolyObj1 && pPolyObj2 && (pDlg->Execute() ==
RET_OK))
102 pDlg->SaveSettings();
112 if(
auto pPathObj =
dynamic_cast< SdrPathObj *
>( pObj ))
113 aPolyPoly1.
append(pPathObj->GetPathPoly());
119 if(
auto pPathObj =
dynamic_cast< SdrPathObj *
>( pObj ))
120 aPolyPoly2.
append(pPathObj->GetPathPoly());
126 aPolyPoly1 = ::basegfx::utils::correctOrientations(aPolyPoly1);
130 aPolyPoly2 = ::basegfx::utils::correctOrientations(aPolyPoly2);
135 if(eIsClockwise1 != eIsClockwise2)
141 else if(aPolyPoly2.
count() < aPolyPoly1.
count())
145 if(!pDlg->IsOrientationFade())
149 for( sal_uInt32
a(0);
a < aPolyPoly1.
count();
a++ )
163 ImpMorphPolygons(aPolyPoly1, aPolyPoly2, pDlg->GetFadeSteps(), aPolyPolyList);
166 " " +
SdResId(STR_UNDO_MORPHING);
176 const ::basegfx::B2DPolygon& rCandidate,
180 if(rCandidate.count() && nNum && rCandidate.count() != nNum)
184 const double fStep(::basegfx::utils::getLength(rCandidate) /
static_cast<double>(rCandidate.isClosed() ? nNum : nNum - 1));
185 double fDestPos(0.0);
187 sal_uInt32 nSrcPos(0);
188 sal_uInt32 nSrcPosNext((nSrcPos + 1 == rCandidate.count()) ? 0 : nSrcPos + 1);
191 for(sal_uInt32 b(0); b < nNum; b++)
194 while(fSrcPos + fNextSrcLen < fDestPos)
196 fSrcPos += fNextSrcLen;
198 nSrcPosNext = (nSrcPos + 1 == rCandidate.count()) ? 0 : nSrcPos + 1;
203 const double fLenA((fDestPos - fSrcPos) / fNextSrcLen);
204 const ::basegfx::B2DPoint aOld1(rCandidate.getB2DPoint(nSrcPos));
205 const ::basegfx::B2DPoint aOld2(rCandidate.getB2DPoint(nSrcPosNext));
207 aRetval.
append(aNewPoint);
213 if(aRetval.
count() >= 3)
215 aRetval.
setClosed(rCandidate.isClosed());
231 const ::basegfx::B2DPolygon& rBig
235 const sal_uInt32 nCnt(rBig.count());
239 const ::basegfx::B2DRange aSrcSize(::basegfx::utils::getRange(rBig));
240 const ::basegfx::B2DPoint aSrcPos(aSrcSize.getCenter());
241 const ::basegfx::B2DRange aDstSize(::basegfx::utils::getRange(rSmall));
242 const ::basegfx::B2DPoint aDstPos(aDstSize.getCenter());
245 aTrans.
scale(aDstSize.getWidth() / aSrcSize.getWidth(), aDstSize.getHeight() / aSrcSize.getHeight());
246 aTrans.
translate(aDstPos.getX(), aDstPos.getY());
253 for(sal_uInt32
a(0);
a < nCnt;
a++)
263 const ::basegfx::B2DPolygon& rPoly,
264 const ::basegfx::B2DPoint& rPos
267 double fMinDist = 0.0;
268 sal_uInt32 nActInd = 0;
270 for(sal_uInt32
a(0);
a < rPoly.count();
a++)
274 if(!
a || fNewDist < fMinDist)
289 const ::basegfx::B2DPolyPolygon& rBigger
292 while(rSmaller.
count() < rBigger.count())
294 const ::basegfx::B2DPolygon& aToBeCopied(rBigger.getB2DPolygon(rSmaller.
count()));
295 const ::basegfx::B2DRange aToBeCopiedPolySize(::basegfx::utils::getRange(aToBeCopied));
299 const ::basegfx::B2DRange aSrcSize(::basegfx::utils::getRange(rBigger.getB2DPolygon(0)));
300 const ::basegfx::B2DPoint aSrcPos(aSrcSize.getCenter());
301 const ::basegfx::B2DRange aDstSize(::basegfx::utils::getRange(rSmaller.
getB2DPolygon(0)));
302 const ::basegfx::B2DPoint aDstPos(aDstSize.getCenter());
303 aNewPoint = aNewPoint - aSrcPos + aDstPos;
305 for(sal_uInt32
a(0);
a < aToBeCopied.count();
a++)
307 aNewPoly.
append(aNewPoint);
310 rSmaller.
append(aNewPoly);
334 bool bLineColor =
false;
335 bool bFillColor =
false;
336 bool bLineWidth =
false;
337 bool bIgnoreLine =
false;
338 bool bIgnoreFill =
false;
343 const drawing::LineStyle eLineStyle1 = aSet1.Get(
XATTR_LINESTYLE).GetValue();
345 const drawing::FillStyle eFillStyle1 = aSet1.Get(
XATTR_FILLSTYLE).GetValue();
348 if ( bAttributeFade )
350 if ( ( eLineStyle1 != drawing::LineStyle_NONE ) && ( eLineStyle2 != drawing::LineStyle_NONE ) )
352 bLineWidth = bLineColor =
true;
360 else if ( ( eLineStyle1 == drawing::LineStyle_NONE ) && ( eLineStyle2 == drawing::LineStyle_NONE ) )
363 if ( ( eFillStyle1 == drawing::FillStyle_SOLID ) && ( eFillStyle2 == drawing::FillStyle_SOLID ) )
369 else if ( ( eFillStyle1 == drawing::FillStyle_NONE ) && ( eFillStyle2 == drawing::FillStyle_NONE ) )
378 SdrObjList* pObjList = xObjGroup->GetSubList();
379 const size_t nCount = rPolyPolyList3D.size();
380 const double fStep = 1. / (
nCount + 1 );
381 const double fDelta = nEndLineWidth - nStartLineWidth;
382 double fFactor = fStep;
387 for (
size_t i = 0;
i <
nCount;
i++, fFactor += fStep )
389 const ::basegfx::B2DPolyPolygon& rPolyPoly3D = rPolyPolyList3D[
i ];
401 else if ( bIgnoreLine )
410 else if ( bIgnoreFill )
417 pNewObj->SetMergedItemSetAndBroadcast(aSet);
439 const ::basegfx::B2DPolyPolygon& rPolyPolyStart,
440 const ::basegfx::B2DPolyPolygon& rPolyPolyEnd,
441 double fMorphingFactor
445 const double fFactor = 1.0 - fMorphingFactor;
447 for(sal_uInt32
a(0);
a < rPolyPolyStart.count();
a++)
449 const ::basegfx::B2DPolygon& aPolyStart(rPolyPolyStart.getB2DPolygon(
a));
450 const ::basegfx::B2DPolygon& aPolyEnd(rPolyPolyEnd.getB2DPolygon(
a));
451 const sal_uInt32
nCount(aPolyStart.count());
454 for(sal_uInt32 b(0); b <
nCount; b++)
456 const ::basegfx::B2DPoint& aPtStart(aPolyStart.getB2DPoint(b));
457 const ::basegfx::B2DPoint& aPtEnd(aPolyEnd.getB2DPoint(b));
458 aNewPolygon.
append(aPtEnd + ((aPtStart - aPtEnd) * fFactor));
461 aNewPolygon.
setClosed(aPolyStart.isClosed() && aPolyEnd.isClosed());
462 aNewPolyPolygon.
append(aNewPolygon);
465 return aNewPolyPolygon;
472 const ::basegfx::B2DPolyPolygon& rPolyPoly1,
473 const ::basegfx::B2DPolyPolygon& rPolyPoly2,
474 const sal_uInt16 nSteps,
481 const ::basegfx::B2DRange aStartPolySize(::basegfx::utils::getRange(rPolyPoly1));
482 const ::basegfx::B2DPoint aStartCenter(aStartPolySize.getCenter());
483 const ::basegfx::B2DRange aEndPolySize(::basegfx::utils::getRange(rPolyPoly2));
484 const ::basegfx::B2DPoint aEndCenter(aEndPolySize.getCenter());
485 const ::basegfx::B2DPoint aDelta(aEndCenter - aStartCenter);
486 const double fFactor(1.0 / (nSteps + 1));
489 for(sal_uInt16
i(0);
i < nSteps;
i++)
494 const ::basegfx::B2DRange aNewPolySize(::basegfx::utils::getRange(aNewPolyPoly2D));
495 const ::basegfx::B2DPoint aNewS(aNewPolySize.getCenter());
496 const ::basegfx::B2DPoint aRealS(aStartCenter + (aDelta * fValue));
497 const ::basegfx::B2DPoint aDiff(aRealS - aNewS);
500 rPolyPolyList3D.push_back( std::move(aNewPolyPoly2D) );
basegfx::BColor getBColor() const
virtual VclPtr< AbstractMorphDlg > CreateMorphDlg(weld::Window *pParent, const SdrObject *pObj1, const SdrObject *pObj2)=0
static SD_DLLPUBLIC SdAbstractDialogFactory * Create()
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
OUString const & GetDescriptionOfMarkedObjects() const
SdrObject * GetMarkedSdrObj() const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
SfxItemPool & GetObjectItemPool() const
SdrModel & getSdrModelFromSdrObject() const
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const=0
const SfxItemSet & GetMergedItemSet() const
SdrModel & getSdrModelFromSdrView() const
SdrPageView * GetSdrPageView() const
virtual void DeleteMarked()
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void translate(double fX, double fY)
void scale(double fX, double fY)
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
void removeDoublePoints()
void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon &rPolygon)
void transform(const basegfx::B2DHomMatrix &rMatrix)
void setB2DPoint(sal_uInt32 nIndex, const basegfx::B2DPoint &rValue)
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void setClosed(bool bNew)
static void ImpMorphPolygons(const ::basegfx::B2DPolyPolygon &rPolyPoly1, const ::basegfx::B2DPolyPolygon &rPolyPoly2, const sal_uInt16 nSteps, B2DPolyPolygonList_impl &rPolyPolyList3D)
create morphed PolyPolygons
static void ImpEqualizePolyPointCount(::basegfx::B2DPolygon &rSmall, const ::basegfx::B2DPolygon &rBig)
make the point count of the polygons equal in adding points
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
void ImpInsertPolygons(B2DPolyPolygonList_impl &rPolyPolyList3D, bool bAttributeFade, const SdrObject *pObj1, const SdrObject *pObj2)
create group object with morphed polygons
::basegfx::B2DPolyPolygon ImpCreateMorphedPolygon(const ::basegfx::B2DPolyPolygon &rPolyPolyStart, const ::basegfx::B2DPolyPolygon &rPolyPolyEnd, double fMorphingFactor)
create single morphed PolyPolygon
FuMorph(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
static sal_uInt32 ImpGetNearestIndex(const ::basegfx::B2DPolygon &rPoly, const ::basegfx::B2DPoint &rPos)
virtual void DoExecute(SfxRequest &rReq) override
::std::vector< ::basegfx::B2DPolyPolygon > B2DPolyPolygonList_impl
static void ImpAddPolys(::basegfx::B2DPolyPolygon &rSmaller, const ::basegfx::B2DPolyPolygon &rBigger)
add to a point reduced polys until count is same
Base class for all functions.
VclPtr< ::sd::Window > mpWindow
Base class of the stacked shell hierarchy.
An SdWindow contains the actual working area of ViewShell.
constexpr sal_uInt16 EE_ITEMS_END(EE_FEATURE_END)
constexpr sal_uInt16 EE_ITEMS_START(OWN_ATTR_VALUE_END+1)
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
B2DTuple interpolate(const B2DTuple &rOld1, const B2DTuple &rOld2, double t)
::basegfx::B2DPolygon ImpGetExpandedPolygon(const ::basegfx::B2DPolygon &rCandidate, sal_uInt32 nNum)
OUString SdResId(TranslateId aId)
constexpr sal_uInt16 SDRATTR_START(XATTR_START)
constexpr sal_uInt16 SDRATTR_NOTPERSIST_FIRST(SDRATTR_CIRC_LAST+1)
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
constexpr TypedWhichId< XLineColorItem > XATTR_LINECOLOR(XATTR_LINE_FIRST+3)
constexpr TypedWhichId< XLineWidthItem > XATTR_LINEWIDTH(XATTR_LINE_FIRST+2)
constexpr TypedWhichId< XLineStyleItem > XATTR_LINESTYLE(XATTR_LINE_FIRST)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)