Kaydet (Commit) 26001f4f authored tarafından Regina Henschel's avatar Regina Henschel

tdf120965 Simplify SdrPathObj::AddToHdlList()

A polygon consists of line segments without controls and curve
segments with two controls. Where two segments meet, can only be
'line to line', 'line to curve' or 'curve to curve'. So for a
handle which marks a meeting point of two segments, there are 0
or 1 control before and 0 or 1 control after. Thus a loop is not
needed and makes the code harder to read. Therefore I have
removed the loop.

Change-Id: I48bcdbdf028542e08b3f5ed3f66907f2993e26bd
Reviewed-on: https://gerrit.libreoffice.org/63036
Tested-by: Jenkins
Reviewed-by: 's avatarRegina Henschel <rb.henschel@t-online.de>
üst 065edb4c
......@@ -2008,62 +2008,45 @@ void SdrPathObj::AddToHdlList(SdrHdlList& rHdlList) const
void SdrPathObj::AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const
{
// keep old stuff to be able to keep old SdrHdl stuff, too
const XPolyPolygon aOldPathPolygon(GetPathPoly());
sal_uInt16 nPnt = static_cast<sal_uInt16>(rHdl.GetPointNum());
// exclude some error situations
const XPolyPolygon aPathPolyPolygon(GetPathPoly());
sal_uInt16 nPolyNum = static_cast<sal_uInt16>(rHdl.GetPolyNum());
if (nPolyNum>=aOldPathPolygon.Count())
if (nPolyNum>=aPathPolyPolygon.Count())
return;
const XPolygon& rXPoly = aOldPathPolygon[nPolyNum];
sal_uInt16 nPntMax = rXPoly.GetPointCount();
const XPolygon& rXPoly = aPathPolyPolygon[nPolyNum];
sal_uInt16 nPntCount = rXPoly.GetPointCount();
if (nPntCount<=0)
return;
if (nPntMax<=0)
sal_uInt16 nPnt = static_cast<sal_uInt16>(rHdl.GetPointNum());
if (nPnt>=nPntCount)
return;
nPntMax--;
if (nPnt>nPntMax)
if (rXPoly.IsControl(nPnt))
return;
// calculate the number of plus points
sal_uInt16 nCnt = 0;
if (rXPoly.GetFlags(nPnt)!=PolyFlags::Control)
// segment before
if (nPnt==0 && IsClosed())
nPnt=nPntCount-1;
if (nPnt>0 && rXPoly.IsControl(nPnt-1))
{
if (nPnt==0 && IsClosed())
nPnt=nPntMax;
if (nPnt>0 && rXPoly.GetFlags(nPnt-1)==PolyFlags::Control)
nCnt++;
if (nPnt==nPntMax && IsClosed())
nPnt=0;
if (nPnt<nPntMax && rXPoly.GetFlags(nPnt+1)==PolyFlags::Control)
nCnt++;
std::unique_ptr<SdrHdl> pHdl(new SdrHdlBezWgt(&rHdl));
pHdl->SetPos(rXPoly[nPnt-1]);
pHdl->SetPointNum(nPnt-1);
pHdl->SetSourceHdlNum(rHdl.GetSourceHdlNum());
pHdl->SetPlusHdl(true);
rHdlList.AddHdl(std::move(pHdl));
}
// construct the plus points
for (sal_uInt32 nPlusNum = 0; nPlusNum < nCnt; ++nPlusNum)
// segment after
if (nPnt==nPntCount-1 && IsClosed())
nPnt=0;
if (nPnt<nPntCount-1 && rXPoly.IsControl(nPnt+1))
{
nPnt = static_cast<sal_uInt16>(rHdl.GetPointNum());
std::unique_ptr<SdrHdl> pHdl(new SdrHdlBezWgt(&rHdl));
pHdl->SetPolyNum(rHdl.GetPolyNum());
if (nPnt==0 && IsClosed())
nPnt=nPntMax;
if (nPnt>0 && rXPoly.GetFlags(nPnt-1)==PolyFlags::Control && nPlusNum==0)
{
pHdl->SetPos(rXPoly[nPnt-1]);
pHdl->SetPointNum(nPnt-1);
}
else
{
if (nPnt==nPntMax && IsClosed())
nPnt=0;
if (nPnt<rXPoly.GetPointCount()-1 && rXPoly.GetFlags(nPnt+1)==PolyFlags::Control)
{
pHdl->SetPos(rXPoly[nPnt+1]);
pHdl->SetPointNum(nPnt+1);
}
}
pHdl->SetPos(rXPoly[nPnt+1]);
pHdl->SetPointNum(nPnt+1);
pHdl->SetSourceHdlNum(rHdl.GetSourceHdlNum());
pHdl->SetPlusHdl(true);
rHdlList.AddHdl(std::move(pHdl));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment