Kaydet (Commit) a8556565 authored tarafından Mark Hung's avatar Mark Hung

tdf#118825 move basegfx::internal::putNumberCharWithSpace

to anonymous namespace.

While basegfx::internal::putNumberCharWithSpace is only used in
exportToSvgD, move it into the anonymous in the same file for
later enhancement.

Change-Id: I6534ac39b2095ed2ba12acc114c75737ad8dacb6
Reviewed-on: https://gerrit.libreoffice.org/58847
Tested-by: Jenkins
Reviewed-by: 's avatarMark Hung <marklh9@gmail.com>
üst 99e545dd
......@@ -58,11 +58,6 @@ namespace basegfx
const OUString& rStr,
const sal_Int32 nLen);
void putNumberCharWithSpace(OUStringBuffer& rStr,
double fValue,
double fOldValue,
bool bUseRelativeCoordinates);
} // namespace internal
} // namespace basegfx
......
......@@ -43,6 +43,24 @@ void putCommandChar(OUStringBuffer& rBuffer,sal_Unicode& rLastSVGCommand, sal_Un
}
}
void putNumberChar(OUStringBuffer& rStr,double fValue, double fOldValue, bool bUseRelativeCoordinates)
{
if (bUseRelativeCoordinates)
fValue -= fOldValue;
const sal_Int32 aLen(rStr.getLength());
if (aLen)
{
if (basegfx::internal::isOnNumberChar(rStr[aLen - 1], false) &&
fValue >= 0.0 )
{
rStr.append(' ');
}
}
rStr.append(fValue);
}
}
namespace basegfx
......@@ -741,8 +759,8 @@ namespace basegfx
// Write 'moveto' and the 1st coordinates, set aLastSVGCommand to 'lineto'
putCommandChar(aResult, aLastSVGCommand, 'M', bUseRelativeCoordinatesForFirstPoint);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeStart.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinatesForFirstPoint);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeStart.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinatesForFirstPoint);
putNumberChar(aResult, aEdgeStart.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinatesForFirstPoint);
putNumberChar(aResult, aEdgeStart.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinatesForFirstPoint);
aLastSVGCommand = bUseRelativeCoordinatesForFirstPoint ? 'l' : 'L';
aCurrentSVGPosition = aEdgeStart;
......@@ -799,18 +817,18 @@ namespace basegfx
{
putCommandChar(aResult, aLastSVGCommand, 'T', bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
aCurrentSVGPosition = aEdgeEnd;
}
else
{
putCommandChar(aResult, aLastSVGCommand, 'Q', bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aLeft.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aLeft.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
putNumberChar(aResult, aLeft.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
putNumberChar(aResult, aLeft.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
aCurrentSVGPosition = aEdgeEnd;
}
}
......@@ -821,22 +839,22 @@ namespace basegfx
{
putCommandChar(aResult, aLastSVGCommand, 'S', bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aControlEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aControlEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
putNumberChar(aResult, aControlEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
putNumberChar(aResult, aControlEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
aCurrentSVGPosition = aEdgeEnd;
}
else
{
putCommandChar(aResult, aLastSVGCommand, 'C', bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aControlEdgeStart.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aControlEdgeStart.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aControlEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aControlEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
putNumberChar(aResult, aControlEdgeStart.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
putNumberChar(aResult, aControlEdgeStart.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
putNumberChar(aResult, aControlEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
putNumberChar(aResult, aControlEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
aCurrentSVGPosition = aEdgeEnd;
}
}
......@@ -863,7 +881,7 @@ namespace basegfx
// export as vertical line
putCommandChar(aResult, aLastSVGCommand, 'V', bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
aCurrentSVGPosition = aEdgeEnd;
}
else if(bYEqual)
......@@ -871,7 +889,7 @@ namespace basegfx
// export as horizontal line
putCommandChar(aResult, aLastSVGCommand, 'H', bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
aCurrentSVGPosition = aEdgeEnd;
}
else
......@@ -879,8 +897,8 @@ namespace basegfx
// export as line
putCommandChar(aResult, aLastSVGCommand, 'L', bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
basegfx::internal::putNumberCharWithSpace(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
putNumberChar(aResult, aEdgeEnd.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
aCurrentSVGPosition = aEdgeEnd;
}
}
......
......@@ -159,26 +159,6 @@ namespace basegfx
return true;
}
void putNumberCharWithSpace(OUStringBuffer& rStr,
double fValue,
double fOldValue,
bool bUseRelativeCoordinates )
{
if( bUseRelativeCoordinates )
fValue -= fOldValue;
const sal_Int32 aLen( rStr.getLength() );
if(aLen)
{
if( isOnNumberChar(rStr[aLen - 1], false) &&
fValue >= 0.0 )
{
rStr.append( ' ' );
}
}
rStr.append(fValue);
}
} // namespace internal
}
......
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