summaryrefslogtreecommitdiff
path: root/cppcanvas/source/mtfrenderer
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2018-11-01 20:40:23 +0800
committerMark Hung <marklh9@gmail.com>2018-11-05 12:20:41 +0100
commitb0da1ca2d7a426ff13f39b21362fbcd5c0580c24 (patch)
tree910583016804ce48ba8a2ec1316d87b0fa34a5cb /cppcanvas/source/mtfrenderer
parent9709061a570a4867a4c5898ffed936b4b47ce90f (diff)
tdf#37636 create underlines, overlines, strikeout separately
and expose a new cppcanvas::tools::createTextLinesPolyPolygon interace to fetch them in order to fill each of them with their own color later. Change-Id: I26e99a9af87a69d9cb71cda6a4c03c4ba42158dc Reviewed-on: https://gerrit.libreoffice.org/62830 Tested-by: Jenkins Reviewed-by: Mark Hung <marklh9@gmail.com>
Diffstat (limited to 'cppcanvas/source/mtfrenderer')
-rw-r--r--cppcanvas/source/mtfrenderer/mtftools.cxx446
-rw-r--r--cppcanvas/source/mtfrenderer/mtftools.hxx8
2 files changed, 249 insertions, 205 deletions
diff --git a/cppcanvas/source/mtfrenderer/mtftools.cxx b/cppcanvas/source/mtfrenderer/mtftools.cxx
index 0680e05f3ca8..1d60ed157927 100644
--- a/cppcanvas/source/mtfrenderer/mtftools.cxx
+++ b/cppcanvas/source/mtfrenderer/mtftools.cxx
@@ -406,222 +406,244 @@ namespace cppcanvas
}
return true;
}
- }
-
- // create line actions for text such as underline and
- // strikeout
- ::basegfx::B2DPolyPolygon createTextLinesPolyPolygon( const ::basegfx::B2DPoint& rStartPos,
- const double& rLineWidth,
- const TextLineInfo& rTextLineInfo )
- {
- // fill the polypolygon with all text lines
- ::basegfx::B2DPolyPolygon aTextLinesPolyPoly;
- switch( rTextLineInfo.mnOverlineStyle )
+ // create line actions for text such as underline and
+ // strikeout
+ void createOverlinePolyPolygon(::basegfx::B2DPolyPolygon& rTextLinesPolyPoly,
+ const ::basegfx::B2DPoint& rStartPos,
+ const double& rLineWidth,
+ const TextLineInfo& rTextLineInfo)
{
- case LINESTYLE_NONE: // nothing to do
- // FALLTHROUGH intended
- case LINESTYLE_DONTKNOW:
- break;
-
- case LINESTYLE_DOUBLEWAVE:
- // FALLTHROUGH intended
- case LINESTYLE_SMALLWAVE:
- // FALLTHROUGH intended
- case LINESTYLE_BOLDWAVE:
- // FALLTHROUGH intended
- case LINESTYLE_WAVE:
- appendWaveline(
- aTextLinesPolyPoly,
- rStartPos,
- rTextLineInfo.mnOverlineOffset,
- rLineWidth,
- rTextLineInfo.mnOverlineHeight,
- rTextLineInfo.mnOverlineStyle);
-
- break;
- case LINESTYLE_SINGLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnOverlineOffset,
- rLineWidth,
- rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight );
- break;
- case LINESTYLE_BOLD:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnOverlineOffset - rTextLineInfo.mnOverlineHeight,
- rLineWidth,
- rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight );
- break;
-
- case LINESTYLE_DOUBLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnOverlineOffset - rTextLineInfo.mnOverlineHeight * 2.0 ,
- rLineWidth,
- rTextLineInfo.mnOverlineOffset - rTextLineInfo.mnOverlineHeight );
-
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight,
- rLineWidth,
- rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight * 2.0 );
- break;
-
- default:
- if (!appendDashes(
- aTextLinesPolyPoly,
- rStartPos.getX(),
- rStartPos.getY() + rTextLineInfo.mnOverlineOffset,
- rLineWidth,
- rTextLineInfo.mnOverlineHeight,
- rTextLineInfo.mnOverlineStyle,
- true))
- {
- ENSURE_OR_THROW( false,
- "::cppcanvas::internal::createTextLinesPolyPolygon(): Unexpected overline case" );
- }
+ switch( rTextLineInfo.mnOverlineStyle )
+ {
+ case LINESTYLE_NONE: // nothing to do
+ // FALLTHROUGH intended
+ case LINESTYLE_DONTKNOW:
+ break;
+
+ case LINESTYLE_DOUBLEWAVE:
+ // FALLTHROUGH intended
+ case LINESTYLE_SMALLWAVE:
+ // FALLTHROUGH intended
+ case LINESTYLE_BOLDWAVE:
+ // FALLTHROUGH intended
+ case LINESTYLE_WAVE:
+ appendWaveline(
+ rTextLinesPolyPoly,
+ rStartPos,
+ rTextLineInfo.mnOverlineOffset,
+ rLineWidth,
+ rTextLineInfo.mnOverlineHeight,
+ rTextLineInfo.mnOverlineStyle);
+
+ break;
+ case LINESTYLE_SINGLE:
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnOverlineOffset,
+ rLineWidth,
+ rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight );
+ break;
+ case LINESTYLE_BOLD:
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnOverlineOffset - rTextLineInfo.mnOverlineHeight,
+ rLineWidth,
+ rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight );
+ break;
+
+ case LINESTYLE_DOUBLE:
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnOverlineOffset - rTextLineInfo.mnOverlineHeight * 2.0 ,
+ rLineWidth,
+ rTextLineInfo.mnOverlineOffset - rTextLineInfo.mnOverlineHeight );
+
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight,
+ rLineWidth,
+ rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight * 2.0 );
+ break;
+
+ default:
+ if (!appendDashes(
+ rTextLinesPolyPoly,
+ rStartPos.getX(),
+ rStartPos.getY() + rTextLineInfo.mnOverlineOffset,
+ rLineWidth,
+ rTextLineInfo.mnOverlineHeight,
+ rTextLineInfo.mnOverlineStyle,
+ true))
+ {
+ ENSURE_OR_THROW( false,
+ "::cppcanvas::internal::createTextLinesPolyPolygon(): Unexpected overline case" );
+ }
+ }
}
- switch( rTextLineInfo.mnUnderlineStyle )
+ void createUnderlinePolyPolygon(::basegfx::B2DPolyPolygon& rTextLinesPolyPoly,
+ const ::basegfx::B2DPoint& rStartPos,
+ const double& rLineWidth,
+ const TextLineInfo& rTextLineInfo )
{
- case LINESTYLE_NONE: // nothing to do
- // FALLTHROUGH intended
- case LINESTYLE_DONTKNOW:
- break;
-
- case LINESTYLE_DOUBLEWAVE:
- // FALLTHROUGH intended
- case LINESTYLE_SMALLWAVE:
- // FALLTHROUGH intended
- case LINESTYLE_BOLDWAVE:
- // FALLTHROUGH intended
- case LINESTYLE_WAVE:
- appendWaveline(
- aTextLinesPolyPoly,
- rStartPos,
- rTextLineInfo.mnUnderlineOffset,
- rLineWidth,
- rTextLineInfo.mnLineHeight,
- rTextLineInfo.mnUnderlineStyle);
- break;
- case LINESTYLE_SINGLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnUnderlineOffset,
- rLineWidth,
- rTextLineInfo.mnUnderlineOffset + rTextLineInfo.mnLineHeight );
- break;
-
- case LINESTYLE_BOLD:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnUnderlineOffset,
- rLineWidth,
- rTextLineInfo.mnUnderlineOffset + 2*rTextLineInfo.mnLineHeight );
- break;
-
- case LINESTYLE_DOUBLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnUnderlineOffset - rTextLineInfo.mnLineHeight,
- rLineWidth,
- rTextLineInfo.mnUnderlineOffset );
-
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnUnderlineOffset + 2*rTextLineInfo.mnLineHeight,
- rLineWidth,
- rTextLineInfo.mnUnderlineOffset + 3*rTextLineInfo.mnLineHeight );
- break;
- default:
- if (!appendDashes(
- aTextLinesPolyPoly,
- rStartPos.getX(),
- rStartPos.getY() + rTextLineInfo.mnUnderlineOffset,
- rLineWidth,
- rTextLineInfo.mnLineHeight,
- rTextLineInfo.mnUnderlineStyle,
- false))
- {
- ENSURE_OR_THROW( false,
- "::cppcanvas::internal::createTextLinesPolyPolygon(): Unexpected underline case" );
- }
+ switch( rTextLineInfo.mnUnderlineStyle )
+ {
+ case LINESTYLE_NONE: // nothing to do
+ // FALLTHROUGH intended
+ case LINESTYLE_DONTKNOW:
+ break;
+
+ case LINESTYLE_DOUBLEWAVE:
+ // FALLTHROUGH intended
+ case LINESTYLE_SMALLWAVE:
+ // FALLTHROUGH intended
+ case LINESTYLE_BOLDWAVE:
+ // FALLTHROUGH intended
+ case LINESTYLE_WAVE:
+ appendWaveline(
+ rTextLinesPolyPoly,
+ rStartPos,
+ rTextLineInfo.mnUnderlineOffset,
+ rLineWidth,
+ rTextLineInfo.mnLineHeight,
+ rTextLineInfo.mnUnderlineStyle);
+ break;
+ case LINESTYLE_SINGLE:
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnUnderlineOffset,
+ rLineWidth,
+ rTextLineInfo.mnUnderlineOffset + rTextLineInfo.mnLineHeight );
+ break;
+
+ case LINESTYLE_BOLD:
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnUnderlineOffset,
+ rLineWidth,
+ rTextLineInfo.mnUnderlineOffset + 2*rTextLineInfo.mnLineHeight );
+ break;
+
+ case LINESTYLE_DOUBLE:
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnUnderlineOffset - rTextLineInfo.mnLineHeight,
+ rLineWidth,
+ rTextLineInfo.mnUnderlineOffset );
+
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnUnderlineOffset + 2*rTextLineInfo.mnLineHeight,
+ rLineWidth,
+ rTextLineInfo.mnUnderlineOffset + 3*rTextLineInfo.mnLineHeight );
+ break;
+
+ default:
+ if (!appendDashes(
+ rTextLinesPolyPoly,
+ rStartPos.getX(),
+ rStartPos.getY() + rTextLineInfo.mnUnderlineOffset,
+ rLineWidth,
+ rTextLineInfo.mnLineHeight,
+ rTextLineInfo.mnUnderlineStyle,
+ false))
+ {
+ ENSURE_OR_THROW( false,
+ "::cppcanvas::internal::createTextLinesPolyPolygon(): Unexpected underline case" );
+ }
+ }
}
- switch( rTextLineInfo.mnStrikeoutStyle )
+ void createStrikeoutPolyPolygon(::basegfx::B2DPolyPolygon& rTextLinesPolyPoly,
+ const ::basegfx::B2DPoint& rStartPos,
+ const double& rLineWidth,
+ const TextLineInfo& rTextLineInfo)
{
- case STRIKEOUT_NONE: // nothing to do
- // FALLTHROUGH intended
- case STRIKEOUT_DONTKNOW:
- break;
-
- case STRIKEOUT_SLASH: // TODO(Q1): we should handle this in the text layer
- // FALLTHROUGH intended
- case STRIKEOUT_X:
- break;
-
- case STRIKEOUT_SINGLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnStrikeoutOffset,
- rLineWidth,
- rTextLineInfo.mnStrikeoutOffset + rTextLineInfo.mnLineHeight );
- break;
-
- case STRIKEOUT_BOLD:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnStrikeoutOffset,
- rLineWidth,
- rTextLineInfo.mnStrikeoutOffset + 2*rTextLineInfo.mnLineHeight );
- break;
-
- case STRIKEOUT_DOUBLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnStrikeoutOffset - rTextLineInfo.mnLineHeight,
- rLineWidth,
- rTextLineInfo.mnStrikeoutOffset );
-
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnStrikeoutOffset + 2*rTextLineInfo.mnLineHeight,
- rLineWidth,
- rTextLineInfo.mnStrikeoutOffset + 3*rTextLineInfo.mnLineHeight );
- break;
-
- default:
- ENSURE_OR_THROW( false,
- "::cppcanvas::internal::createTextLinesPolyPolygon(): Unexpected strikeout case" );
+ switch( rTextLineInfo.mnStrikeoutStyle )
+ {
+ case STRIKEOUT_NONE: // nothing to do
+ // FALLTHROUGH intended
+ case STRIKEOUT_DONTKNOW:
+ break;
+
+ case STRIKEOUT_SLASH: // TODO(Q1): we should handle this in the text layer
+ // FALLTHROUGH intended
+ case STRIKEOUT_X:
+ break;
+
+ case STRIKEOUT_SINGLE:
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnStrikeoutOffset,
+ rLineWidth,
+ rTextLineInfo.mnStrikeoutOffset + rTextLineInfo.mnLineHeight );
+ break;
+
+ case STRIKEOUT_BOLD:
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnStrikeoutOffset,
+ rLineWidth,
+ rTextLineInfo.mnStrikeoutOffset + 2*rTextLineInfo.mnLineHeight );
+ break;
+
+ case STRIKEOUT_DOUBLE:
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnStrikeoutOffset - rTextLineInfo.mnLineHeight,
+ rLineWidth,
+ rTextLineInfo.mnStrikeoutOffset );
+
+ appendRect(
+ rTextLinesPolyPoly,
+ rStartPos,
+ 0,
+ rTextLineInfo.mnStrikeoutOffset + 2*rTextLineInfo.mnLineHeight,
+ rLineWidth,
+ rTextLineInfo.mnStrikeoutOffset + 3*rTextLineInfo.mnLineHeight );
+ break;
+
+ default:
+ ENSURE_OR_THROW( false,
+ "::cppcanvas::internal::createTextLinesPolyPolygon(): Unexpected strikeout case" );
+ }
}
+ }
+ ::basegfx::B2DPolyPolygon createTextLinesPolyPolygon( const ::basegfx::B2DPoint& rStartPos,
+ const double& rLineWidth,
+ const TextLineInfo& rTextLineInfo )
+ {
+ // fill the polypolygon with all text lines
+ ::basegfx::B2DPolyPolygon aTextLinesPolyPoly;
+
+ createOverlinePolyPolygon(aTextLinesPolyPoly, rStartPos, rLineWidth, rTextLineInfo);
+ createUnderlinePolyPolygon(aTextLinesPolyPoly, rStartPos, rLineWidth, rTextLineInfo);
+ createStrikeoutPolyPolygon(aTextLinesPolyPoly, rStartPos, rLineWidth, rTextLineInfo);
return aTextLinesPolyPoly;
}
@@ -652,6 +674,20 @@ namespace cppcanvas
rLineWidth,
rTextLineInfo );
}
+
+ void createTextLinesPolyPolygon( const double& rStartOffset,
+ const double& rLineWidth,
+ const TextLineInfo& rTextLineInfo,
+ ::basegfx::B2DPolyPolygon& rOverlinePolyPoly,
+ ::basegfx::B2DPolyPolygon& rUnderlinePolyPoly,
+ ::basegfx::B2DPolyPolygon& rStrikeoutPolyPoly )
+ {
+ ::basegfx::B2DPoint aStartPos(rStartOffset, 0.0);
+
+ createOverlinePolyPolygon(rOverlinePolyPoly, aStartPos, rLineWidth, rTextLineInfo);
+ createUnderlinePolyPolygon(rUnderlinePolyPoly, aStartPos, rLineWidth, rTextLineInfo);
+ createStrikeoutPolyPolygon(rStrikeoutPolyPoly, aStartPos, rLineWidth, rTextLineInfo);
+ }
}
}
diff --git a/cppcanvas/source/mtfrenderer/mtftools.hxx b/cppcanvas/source/mtfrenderer/mtftools.hxx
index 2deeb883ac85..3d438e3e2934 100644
--- a/cppcanvas/source/mtfrenderer/mtftools.hxx
+++ b/cppcanvas/source/mtfrenderer/mtftools.hxx
@@ -199,6 +199,14 @@ namespace cppcanvas
::basegfx::B2DPolyPolygon createTextLinesPolyPolygon( const ::basegfx::B2DPoint& rStartPos,
const double& rLineWidth,
const TextLineInfo& rTextLineInfo );
+
+ void createTextLinesPolyPolygon( const double& rStartOffset,
+ const double& rLineWidth,
+ const TextLineInfo& rTextLineInfo,
+ ::basegfx::B2DPolyPolygon& rOverlinePolyPoly,
+ ::basegfx::B2DPolyPolygon& rUnderlinePolyPoly,
+ ::basegfx::B2DPolyPolygon& rStrikeoutPolyPoly );
+
}
}