summaryrefslogtreecommitdiff
path: root/cppcanvas/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-06-11 09:00:46 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-06-12 10:10:27 +0200
commitb00ebb587812927a1a8f91b876d00a861cc059e6 (patch)
tree7470193708d5c22514e55fbaba734365e403e386 /cppcanvas/source
parentc1d89a237ed678c6749213c8d517729e8a7f46a1 (diff)
rhbz#1589029 tdf#93789 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 Reviewed-on: https://gerrit.libreoffice.org/55634 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cppcanvas/source')
-rw-r--r--cppcanvas/source/mtfrenderer/emfplus.cxx2
-rw-r--r--cppcanvas/source/mtfrenderer/implrenderer.cxx6
-rw-r--r--cppcanvas/source/mtfrenderer/textaction.cxx131
-rw-r--r--cppcanvas/source/mtfrenderer/textaction.hxx1
4 files changed, 119 insertions, 21 deletions
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 369ac9ccb3b9..f2dcb9906bf3 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -1298,6 +1298,7 @@ namespace cppcanvas
::Color(),
::Size(),
::Color(),
+ ::Color(),
text,
0,
stringLength,
@@ -1612,6 +1613,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 25e9b1b3f1a3..b8387ddaa508 100644
--- a/cppcanvas/source/mtfrenderer/implrenderer.cxx
+++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx
@@ -865,6 +865,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;
@@ -930,6 +931,9 @@ namespace cppcanvas
aReliefColor.SetTransparency( aTextColor.GetTransparency() );
}
+ if (rState.isTextFillColorSet)
+ aTextFillColor = vcl::unotools::doubleSequenceToColor(rState.textFillColor, xColorSpace);
+
// create the actual text action
std::shared_ptr<Action> pTextAction(
TextActionFactory::createTextAction(
@@ -938,6 +942,7 @@ namespace cppcanvas
aReliefColor,
aShadowOffset,
aShadowColor,
+ aTextFillColor,
rString,
nIndex,
nLength,
@@ -1002,6 +1007,7 @@ namespace cppcanvas
aReliefColor,
aShadowOffset,
aShadowColor,
+ aTextFillColor,
aStrikeoutText,
0/*nStartPos*/,
aStrikeoutText.getLength(),
diff --git a/cppcanvas/source/mtfrenderer/textaction.cxx b/cppcanvas/source/mtfrenderer/textaction.cxx
index 7444c06c0012..19d6041ab79e 100644
--- a/cppcanvas/source/mtfrenderer/textaction.cxx
+++ b/cppcanvas/source/mtfrenderer/textaction.cxx
@@ -470,7 +470,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.
@@ -486,7 +486,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(
@@ -507,7 +508,7 @@ namespace cppcanvas
vcl::unotools::colorToDoubleSequence( rShadowColor,
xColorSpace );
- rRenderer( aShadowState );
+ rRenderer( aShadowState, rTextFillColor );
}
// draw relief text, if enabled
@@ -525,11 +526,11 @@ namespace cppcanvas
vcl::unotools::colorToDoubleSequence( rReliefColor,
xColorSpace );
- rRenderer( aReliefState );
+ rRenderer( aReliefState, rTextFillColor );
}
// draw normal text
- rRenderer( rRenderState );
+ rRenderer( rRenderState, rTextFillColor );
return true;
}
@@ -800,7 +801,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),
@@ -821,6 +825,7 @@ namespace cppcanvas
const ::Color maReliefColor;
const ::basegfx::B2DSize maShadowOffset;
const ::Color maShadowColor;
+ const ::Color maTextFillColor;
const sal_Int8 maTextDirection;
};
@@ -903,7 +908,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() );
@@ -912,6 +917,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,
@@ -934,7 +951,8 @@ namespace cppcanvas
maShadowColor,
maShadowOffset,
maReliefColor,
- maReliefOffset );
+ maReliefOffset,
+ maTextFillColor);
}
bool EffectTextAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
@@ -949,7 +967,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
@@ -959,11 +977,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::utils::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() ),
@@ -1184,6 +1215,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,
@@ -1196,6 +1228,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,
@@ -1220,7 +1253,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),
@@ -1239,6 +1274,7 @@ namespace cppcanvas
const ::Color maReliefColor;
const ::basegfx::B2DSize maShadowOffset;
const ::Color maShadowColor;
+ const ::Color maTextFillColor;
};
EffectTextArrayAction::EffectTextArrayAction( const ::basegfx::B2DPoint& rStartPoint,
@@ -1246,6 +1282,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,
@@ -1262,7 +1299,8 @@ namespace cppcanvas
maReliefOffset( rReliefOffset ),
maReliefColor( rReliefColor ),
maShadowOffset( rShadowOffset ),
- maShadowColor( rShadowColor )
+ maShadowColor( rShadowColor ),
+ maTextFillColor( rTextFillColor )
{
initEffectLinePolyPolygon( maLinesOverallSize,
mxTextLines,
@@ -1286,6 +1324,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,
@@ -1303,7 +1342,8 @@ namespace cppcanvas
maReliefOffset( rReliefOffset ),
maReliefColor( rReliefColor ),
maShadowOffset( rShadowOffset ),
- maShadowColor( rShadowColor )
+ maShadowColor( rShadowColor ),
+ maTextFillColor( rTextFillColor )
{
initEffectLinePolyPolygon( maLinesOverallSize,
mxTextLines,
@@ -1323,7 +1363,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::utils::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() );
@@ -1332,6 +1380,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 );
@@ -1353,7 +1413,8 @@ namespace cppcanvas
maShadowColor,
maShadowOffset,
maReliefColor,
- maReliefOffset );
+ maReliefOffset,
+ maTextFillColor);
}
class EffectTextArrayRenderHelper : public TextRenderer
@@ -1371,12 +1432,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 );
@@ -1385,6 +1458,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::utils::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;
@@ -1442,7 +1524,8 @@ namespace cppcanvas
maShadowColor,
maShadowOffset,
maReliefColor,
- maReliefOffset );
+ maReliefOffset,
+ maTextFillColor);
}
::basegfx::B2DRange EffectTextArrayAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
@@ -1554,7 +1637,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),
@@ -1578,6 +1661,7 @@ namespace cppcanvas
const ::Color maReliefColor;
const ::basegfx::B2DSize maShadowOffset;
const ::Color maShadowColor;
+ const ::Color maTextFillColor;
};
double calcOutlineWidth( const OutDevState& rState,
@@ -1676,7 +1760,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() );
@@ -1732,7 +1816,8 @@ namespace cppcanvas
maShadowColor,
maShadowOffset,
maReliefColor,
- maReliefOffset );
+ maReliefOffset,
+ maTextFillColor);
}
#if 0 // see #if'ed out use in OutlineAction::renderSubset below:
@@ -2041,6 +2126,7 @@ namespace cppcanvas
const ::Color& rReliefColor,
const ::Size& rShadowOffset,
const ::Color& rShadowColor,
+ const ::Color& rTextFillColor,
const OUString& rText,
sal_Int32 nStartPos,
sal_Int32 nLen,
@@ -2174,7 +2260,8 @@ namespace cppcanvas
!rState.textUnderlineStyle &&
!rState.textStrikeoutStyle &&
rReliefColor == aEmptyColor &&
- rShadowColor == aEmptyColor )
+ rShadowColor == aEmptyColor &&
+ rTextFillColor == aEmptyColor )
{
// nope
if( rParms.maTextTransformation.is_initialized() )
@@ -2207,6 +2294,7 @@ namespace cppcanvas
rReliefColor,
aShadowOffset,
rShadowColor,
+ rTextFillColor,
rText,
nStartPos,
nLen,
@@ -2222,6 +2310,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 1760477bf79a..e31cab63e78b 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,