From 84fd42edf49efd3af6966efb4e326c6fbb37d56f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Mon, 11 Jun 2018 09:00:46 +0100
Subject: [PATCH] rhbz#1589029 impress not showing text highlight in
presentation mode
the text hightlighting feature was implemented backed on to the vcl
TextFillColor feature. TextFillColor fills the background of the bounds
of the text with that color
Likely either the same problem or similar as tdf#93789
Change-Id: Iace62cedc49e5f5844ac35d3caa23249b6cb4bc1
---
cppcanvas/source/mtfrenderer/emfplus.cxx | 2 +
cppcanvas/source/mtfrenderer/implrenderer.cxx | 6 +
cppcanvas/source/mtfrenderer/textaction.cxx | 131 +++++++++++++++---
cppcanvas/source/mtfrenderer/textaction.hxx | 1 +
4 files changed, 119 insertions(+), 21 deletions(-)
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 1da733bd9f73..9b5fae31d584 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -1318,6 +1318,7 @@ namespace cppcanvas
::Color(),
::Size(),
::Color(),
+ ::Color(),
text,
0,
stringLength,
@@ -1633,6 +1634,7 @@ namespace cppcanvas
::Color(),
::Size(),
::Color(),
+ ::Color(),
text,
0,
glyphsCount,
diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx
index ad9098defc69..38694caec091 100644
--- a/cppcanvas/source/mtfrenderer/implrenderer.cxx
+++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx
@@ -876,6 +876,7 @@ namespace cppcanvas
// TODO(F2): implement all text effects
// if( rState.textAlignment ); // TODO(F2): NYI
+ ::Color aTextFillColor( COL_AUTO );
::Color aShadowColor( COL_AUTO );
::Color aReliefColor( COL_AUTO );
::Size aShadowOffset;
@@ -941,6 +942,9 @@ namespace cppcanvas
aReliefColor.SetTransparency( aTextColor.GetTransparency() );
}
+ if (rState.isTextFillColorSet)
+ aTextFillColor = vcl::unotools::doubleSequenceToColor(rState.textFillColor, xColorSpace);
+
// create the actual text action
ActionSharedPtr pTextAction(
TextActionFactory::createTextAction(
@@ -949,6 +953,7 @@ namespace cppcanvas
aReliefColor,
aShadowOffset,
aShadowColor,
+ aTextFillColor,
rString,
nIndex,
nLength,
@@ -1015,6 +1020,7 @@ namespace cppcanvas
aReliefColor,
aShadowOffset,
aShadowColor,
+ aTextFillColor,
aStrikeoutText,
nStartPos,
aStrikeoutText.getLength(),
diff --git a/cppcanvas/source/mtfrenderer/textaction.cxx b/cppcanvas/source/mtfrenderer/textaction.cxx
index 51554a2e3595..0c5ef91354e3 100644
--- a/cppcanvas/source/mtfrenderer/textaction.cxx
+++ b/cppcanvas/source/mtfrenderer/textaction.cxx
@@ -472,7 +472,7 @@ namespace cppcanvas
virtual ~TextRenderer() {}
/// Render text with given RenderState
- virtual bool operator()( const rendering::RenderState& rRenderState ) const = 0;
+ virtual bool operator()( const rendering::RenderState& rRenderState, const ::Color& rTextFillColor ) const = 0;
};
/** Render effect text.
@@ -489,7 +489,8 @@ namespace cppcanvas
const ::Color& rShadowColor,
const ::basegfx::B2DSize& rShadowOffset,
const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rReliefOffset )
+ const ::basegfx::B2DSize& rReliefOffset,
+ const ::Color& rTextFillColor )
{
::Color aEmptyColor( COL_AUTO );
uno::Reference<rendering::XColorSpace> xColorSpace(
@@ -510,7 +511,7 @@ namespace cppcanvas
vcl::unotools::colorToDoubleSequence( rShadowColor,
xColorSpace );
- rRenderer( aShadowState );
+ rRenderer( aShadowState, rTextFillColor );
}
// draw relief text, if enabled
@@ -528,11 +529,11 @@ namespace cppcanvas
vcl::unotools::colorToDoubleSequence( rReliefColor,
xColorSpace );
- rRenderer( aReliefState );
+ rRenderer( aReliefState, rTextFillColor );
}
// draw normal text
- rRenderer( rRenderState );
+ rRenderer( rRenderState, rTextFillColor );
return true;
}
@@ -803,7 +804,10 @@ namespace cppcanvas
private:
/// Interface TextRenderer
- virtual bool operator()( const rendering::RenderState& rRenderState ) const override;
+ virtual bool operator()( const rendering::RenderState& rRenderState, const ::Color& rTextFillColor ) const override;
+
+ geometry::RealRectangle2D queryTextBounds() const;
+ css::uno::Reference<css::rendering::XPolyPolygon2D> queryTextBounds(const uno::Reference<rendering::XCanvas>& rCanvas) const;
// TODO(P2): This is potentially a real mass object
// (every character might be a separate TextAction),
@@ -824,6 +828,7 @@ namespace cppcanvas
const ::Color maReliefColor;
const ::basegfx::B2DSize maShadowOffset;
const ::Color maShadowColor;
+ const ::Color maTextFillColor;
const sal_Int8 maTextDirection;
};
@@ -906,7 +911,7 @@ namespace cppcanvas
"::cppcanvas::internal::EffectTextAction(): Invalid font or lines" );
}
- bool EffectTextAction::operator()( const rendering::RenderState& rRenderState ) const
+ bool EffectTextAction::operator()( const rendering::RenderState& rRenderState, const ::Color& rTextFillColor ) const
{
const rendering::ViewState& rViewState( mpCanvas->getViewState() );
const uno::Reference< rendering::XCanvas >& rCanvas( mpCanvas->getUNOCanvas() );
@@ -915,6 +920,18 @@ namespace cppcanvas
rViewState,
rRenderState );
+ //rhbz#1589029 non-transparent text fill background support
+ ::Color aEmptyColor( COL_AUTO );
+ if (rTextFillColor != aEmptyColor)
+ {
+ rendering::RenderState aLocalState( rRenderState );
+ aLocalState.DeviceColor = vcl::unotools::colorToDoubleSequence(
+ rTextFillColor, rCanvas->getDevice()->getDeviceColorSpace());
+ auto xTextBounds = queryTextBounds(rCanvas);
+ // background of text
+ rCanvas->fillPolyPolygon(xTextBounds, rViewState, aLocalState);
+ }
+
rCanvas->drawText( maStringContext, mxFont,
rViewState,
rRenderState,
@@ -938,7 +955,8 @@ namespace cppcanvas
maShadowColor,
maShadowOffset,
maReliefColor,
- maReliefOffset );
+ maReliefOffset,
+ maTextFillColor);
}
bool EffectTextAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
@@ -953,7 +971,7 @@ namespace cppcanvas
return render( rTransformation );
}
- ::basegfx::B2DRange EffectTextAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
+ geometry::RealRectangle2D EffectTextAction::queryTextBounds() const
{
// create XTextLayout, to have the
// XTextLayout::queryTextBounds() method available
@@ -963,11 +981,24 @@ namespace cppcanvas
maTextDirection,
0 ) );
+ return xTextLayout->queryTextBounds();
+ }
+
+ css::uno::Reference<css::rendering::XPolyPolygon2D> EffectTextAction::queryTextBounds(const uno::Reference<rendering::XCanvas>& rCanvas) const
+ {
+ auto aTextBounds = queryTextBounds();
+ auto aB2DBounds = ::basegfx::unotools::b2DRectangleFromRealRectangle2D(aTextBounds);
+ auto aTextBoundsPoly = ::basegfx::tools::createPolygonFromRect(aB2DBounds);
+ return ::basegfx::unotools::xPolyPolygonFromB2DPolygon(rCanvas->getDevice(), aTextBoundsPoly);
+ }
+
+ ::basegfx::B2DRange EffectTextAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
+ {
rendering::RenderState aLocalState( maState );
::canvas::tools::prependToRenderState(aLocalState, rTransformation);
return calcEffectTextBounds( ::basegfx::unotools::b2DRectangleFromRealRectangle2D(
- xTextLayout->queryTextBounds() ),
+ queryTextBounds() ),
::basegfx::B2DRange( 0,0,
maLinesOverallSize.getX(),
maLinesOverallSize.getY() ),
@@ -1188,6 +1219,7 @@ namespace cppcanvas
const ::Color& rReliefColor,
const ::basegfx::B2DSize& rShadowOffset,
const ::Color& rShadowColor,
+ const ::Color& rTextFillColor,
const OUString& rText,
sal_Int32 nStartPos,
sal_Int32 nLen,
@@ -1200,6 +1232,7 @@ namespace cppcanvas
const ::Color& rReliefColor,
const ::basegfx::B2DSize& rShadowOffset,
const ::Color& rShadowColor,
+ const ::Color& rTextFillColor,
const OUString& rText,
sal_Int32 nStartPos,
sal_Int32 nLen,
@@ -1224,7 +1257,9 @@ namespace cppcanvas
private:
// TextRenderer interface
- virtual bool operator()( const rendering::RenderState& rRenderState ) const override;
+ virtual bool operator()( const rendering::RenderState& rRenderState, const ::Color& rTextFillColor ) const override;
+
+ css::uno::Reference<css::rendering::XPolyPolygon2D> queryTextBounds(const uno::Reference<rendering::XCanvas>& rCanvas) const;
// TODO(P2): This is potentially a real mass object
// (every character might be a separate TextAction),
@@ -1243,6 +1278,7 @@ namespace cppcanvas
const ::Color maReliefColor;
const ::basegfx::B2DSize maShadowOffset;
const ::Color maShadowColor;
+ const ::Color maTextFillColor;
};
EffectTextArrayAction::EffectTextArrayAction( const ::basegfx::B2DPoint& rStartPoint,
@@ -1250,6 +1286,7 @@ namespace cppcanvas
const ::Color& rReliefColor,
const ::basegfx::B2DSize& rShadowOffset,
const ::Color& rShadowColor,
+ const ::Color& rTextFillColor,
const OUString& rText,
sal_Int32 nStartPos,
sal_Int32 nLen,
@@ -1266,7 +1303,8 @@ namespace cppcanvas
maReliefOffset( rReliefOffset ),
maReliefColor( rReliefColor ),
maShadowOffset( rShadowOffset ),
- maShadowColor( rShadowColor )
+ maShadowColor( rShadowColor ),
+ maTextFillColor( rTextFillColor )
{
initEffectLinePolyPolygon( maLinesOverallSize,
mxTextLines,
@@ -1290,6 +1328,7 @@ namespace cppcanvas
const ::Color& rReliefColor,
const ::basegfx::B2DSize& rShadowOffset,
const ::Color& rShadowColor,
+ const ::Color& rTextFillColor,
const OUString& rText,
sal_Int32 nStartPos,
sal_Int32 nLen,
@@ -1307,7 +1346,8 @@ namespace cppcanvas
maReliefOffset( rReliefOffset ),
maReliefColor( rReliefColor ),
maShadowOffset( rShadowOffset ),
- maShadowColor( rShadowColor )
+ maShadowColor( rShadowColor ),
+ maTextFillColor( rTextFillColor )
{
initEffectLinePolyPolygon( maLinesOverallSize,
mxTextLines,
@@ -1327,7 +1367,15 @@ namespace cppcanvas
&rTextTransform );
}
- bool EffectTextArrayAction::operator()( const rendering::RenderState& rRenderState ) const
+ css::uno::Reference<css::rendering::XPolyPolygon2D> EffectTextArrayAction::queryTextBounds(const uno::Reference<rendering::XCanvas>& rCanvas) const
+ {
+ const geometry::RealRectangle2D aTextBounds(mxTextLayout->queryTextBounds());
+ auto aB2DBounds = ::basegfx::unotools::b2DRectangleFromRealRectangle2D(aTextBounds);
+ auto aTextBoundsPoly = ::basegfx::tools::createPolygonFromRect(aB2DBounds);
+ return ::basegfx::unotools::xPolyPolygonFromB2DPolygon(rCanvas->getDevice(), aTextBoundsPoly);
+ }
+
+ bool EffectTextArrayAction::operator()( const rendering::RenderState& rRenderState, const ::Color& rTextFillColor ) const
{
const rendering::ViewState& rViewState( mpCanvas->getViewState() );
const uno::Reference< rendering::XCanvas >& rCanvas( mpCanvas->getUNOCanvas() );
@@ -1336,6 +1384,18 @@ namespace cppcanvas
rViewState,
rRenderState );
+ //rhbz#1589029 non-transparent text fill background support
+ ::Color aEmptyColor( COL_AUTO );
+ if (rTextFillColor != aEmptyColor)
+ {
+ rendering::RenderState aLocalState(rRenderState);
+ aLocalState.DeviceColor = vcl::unotools::colorToDoubleSequence(
+ rTextFillColor, rCanvas->getDevice()->getDeviceColorSpace());
+ auto xTextBounds = queryTextBounds(rCanvas);
+ // background of text
+ rCanvas->fillPolyPolygon(xTextBounds, rViewState, aLocalState);
+ }
+
rCanvas->drawTextLayout( mxTextLayout,
rViewState,
rRenderState );
@@ -1358,7 +1418,8 @@ namespace cppcanvas
maShadowColor,
maShadowOffset,
maReliefColor,
- maReliefOffset );
+ maReliefOffset,
+ maTextFillColor);
}
class EffectTextArrayRenderHelper : public TextRenderer
@@ -1376,12 +1437,24 @@ namespace cppcanvas
}
// TextRenderer interface
- virtual bool operator()( const rendering::RenderState& rRenderState ) const override
+ virtual bool operator()( const rendering::RenderState& rRenderState, const ::Color& rTextFillColor ) const override
{
mrCanvas->fillPolyPolygon( mrLinePolygon,
mrViewState,
rRenderState );
+ //rhbz#1589029 non-transparent text fill background support
+ ::Color aEmptyColor( COL_AUTO );
+ if (rTextFillColor != aEmptyColor)
+ {
+ rendering::RenderState aLocalState(rRenderState);
+ aLocalState.DeviceColor = vcl::unotools::colorToDoubleSequence(
+ rTextFillColor, mrCanvas->getDevice()->getDeviceColorSpace());
+ auto xTextBounds = queryTextBounds();
+ // background of text
+ mrCanvas->fillPolyPolygon(xTextBounds, mrViewState, aLocalState);
+ }
+
mrCanvas->drawTextLayout( mrTextLayout,
mrViewState,
rRenderState );
@@ -1390,6 +1463,15 @@ namespace cppcanvas
}
private:
+
+ css::uno::Reference<css::rendering::XPolyPolygon2D> queryTextBounds() const
+ {
+ const geometry::RealRectangle2D aTextBounds(mrTextLayout->queryTextBounds());
+ auto aB2DBounds = ::basegfx::unotools::b2DRectangleFromRealRectangle2D(aTextBounds);
+ auto aTextBoundsPoly = ::basegfx::tools::createPolygonFromRect(aB2DBounds);
+ return ::basegfx::unotools::xPolyPolygonFromB2DPolygon(mrCanvas->getDevice(), aTextBoundsPoly);
+ }
+
const uno::Reference< rendering::XCanvas >& mrCanvas;
const uno::Reference< rendering::XTextLayout >& mrTextLayout;
const uno::Reference< rendering::XPolyPolygon2D >& mrLinePolygon;
@@ -1448,7 +1530,8 @@ namespace cppcanvas
maShadowColor,
maShadowOffset,
maReliefColor,
- maReliefOffset );
+ maReliefOffset,
+ maTextFillColor);
}
::basegfx::B2DRange EffectTextArrayAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
@@ -1560,7 +1643,7 @@ namespace cppcanvas
private:
// TextRenderer interface
- virtual bool operator()( const rendering::RenderState& rRenderState ) const override;
+ virtual bool operator()( const rendering::RenderState& rRenderState, const ::Color& rTextFillColor ) const override;
// TODO(P2): This is potentially a real mass object
// (every character might be a separate TextAction),
@@ -1584,6 +1667,7 @@ namespace cppcanvas
const ::Color maReliefColor;
const ::basegfx::B2DSize maShadowOffset;
const ::Color maShadowColor;
+ const ::Color maTextFillColor;
};
double calcOutlineWidth( const OutDevState& rState,
@@ -1682,7 +1766,7 @@ namespace cppcanvas
rTextTransform );
}
- bool OutlineAction::operator()( const rendering::RenderState& rRenderState ) const
+ bool OutlineAction::operator()( const rendering::RenderState& rRenderState, const ::Color& /*rTextFillColor*/ ) const
{
const rendering::ViewState& rViewState( mpCanvas->getViewState() );
const uno::Reference< rendering::XCanvas >& rCanvas( mpCanvas->getUNOCanvas() );
@@ -1739,7 +1823,8 @@ namespace cppcanvas
maShadowColor,
maShadowOffset,
maReliefColor,
- maReliefOffset );
+ maReliefOffset,
+ maTextFillColor);
}
#if 0 // see #if'ed out use in OutlineAction::renderSubset below:
@@ -2048,6 +2133,7 @@ namespace cppcanvas
const ::Color& rReliefColor,
const ::Size& rShadowOffset,
const ::Color& rShadowColor,
+ const ::Color& rTextFillColor,
const OUString& rText,
sal_Int32 nStartPos,
sal_Int32 nLen,
@@ -2181,7 +2267,8 @@ namespace cppcanvas
!rState.textUnderlineStyle &&
!rState.textStrikeoutStyle &&
rReliefColor == aEmptyColor &&
- rShadowColor == aEmptyColor )
+ rShadowColor == aEmptyColor &&
+ rTextFillColor == aEmptyColor )
{
// nope
if( rParms.maTextTransformation.is_initialized() )
@@ -2214,6 +2301,7 @@ namespace cppcanvas
rReliefColor,
aShadowOffset,
rShadowColor,
+ rTextFillColor,
rText,
nStartPos,
nLen,
@@ -2229,6 +2317,7 @@ namespace cppcanvas
rReliefColor,
aShadowOffset,
rShadowColor,
+ rTextFillColor,
rText,
nStartPos,
nLen,
diff --git a/cppcanvas/source/mtfrenderer/textaction.hxx b/cppcanvas/source/mtfrenderer/textaction.hxx
index 2c0b240fc847..1770470f9fff 100644
--- a/cppcanvas/source/mtfrenderer/textaction.hxx
+++ b/cppcanvas/source/mtfrenderer/textaction.hxx
@@ -66,6 +66,7 @@ namespace cppcanvas
const ::Color& rReliefColor,
const ::Size& rShadowOffset,
const ::Color& rShadowColor,
+ const ::Color& rTextFillColor,
const OUString& rText,
sal_Int32 nStartPos,
sal_Int32 nLen,
--
2.17.0