summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2018-08-10 18:33:20 +0800
committerMark Hung <marklh9@gmail.com>2018-08-14 16:25:29 +0200
commita85565653d770418f1f5a8bbfd13dfbe890ac7bb (patch)
tree626fb53b0b7e281d5d9d76bbabe3c15dfad7e4cc
parent99e545dda9198bfcb4c63a2c7f1ba7fc4ded2a49 (diff)
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: Mark Hung <marklh9@gmail.com>
-rw-r--r--basegfx/source/inc/stringconversiontools.hxx5
-rw-r--r--basegfx/source/polygon/b2dsvgpolypolygon.cxx62
-rw-r--r--basegfx/source/tools/stringconversiontools.cxx20
3 files changed, 40 insertions, 47 deletions
diff --git a/basegfx/source/inc/stringconversiontools.hxx b/basegfx/source/inc/stringconversiontools.hxx
index 27ae7310d2f9..d4600617bb4b 100644
--- a/basegfx/source/inc/stringconversiontools.hxx
+++ b/basegfx/source/inc/stringconversiontools.hxx
@@ -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
diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
index 049354621975..a0ff38155a26 100644
--- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
@@ -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;
}
}
diff --git a/basegfx/source/tools/stringconversiontools.cxx b/basegfx/source/tools/stringconversiontools.cxx
index c657d4687bcf..b14fce0fb557 100644
--- a/basegfx/source/tools/stringconversiontools.cxx
+++ b/basegfx/source/tools/stringconversiontools.cxx
@@ -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
}