diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-06-11 09:00:46 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-06-11 17:35:44 +0200 |
commit | a3c95ec45397b146c86a3fa44445c763de99d3a3 (patch) | |
tree | 4c32e0d1ab85f034cd202a3f370e7a253f95859b /cppcanvas | |
parent | ef73142148c92319c1e96f2fe87a061fb6384937 (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/55629
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cppcanvas')
-rw-r--r-- | cppcanvas/source/mtfrenderer/emfplus.cxx | 2 | ||||
-rw-r--r-- | cppcanvas/source/mtfrenderer/implrenderer.cxx | 6 | ||||
-rw-r--r-- | cppcanvas/source/mtfrenderer/textaction.cxx | 131 | ||||
-rw-r--r-- | 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 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 f0b867272651..d6918db4a3fe 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -864,6 +864,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; @@ -929,6 +930,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( @@ -937,6 +941,7 @@ namespace cppcanvas aReliefColor, aShadowOffset, aShadowColor, + aTextFillColor, rString, nIndex, nLength, @@ -1001,6 +1006,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 8292935e976f..41c2f4ac3557 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), @@ -820,6 +824,7 @@ namespace cppcanvas const ::Color maReliefColor; const ::basegfx::B2DSize maShadowOffset; const ::Color maShadowColor; + const ::Color maTextFillColor; const sal_Int8 maTextDirection; }; @@ -902,7 +907,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() ); @@ -911,6 +916,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, @@ -933,7 +950,8 @@ namespace cppcanvas maShadowColor, maShadowOffset, maReliefColor, - maReliefOffset ); + maReliefOffset, + maTextFillColor); } bool EffectTextAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation, @@ -948,7 +966,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 @@ -958,11 +976,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() ), @@ -1183,6 +1214,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, @@ -1195,6 +1227,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, @@ -1219,7 +1252,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), @@ -1238,6 +1273,7 @@ namespace cppcanvas const ::Color maReliefColor; const ::basegfx::B2DSize maShadowOffset; const ::Color maShadowColor; + const ::Color maTextFillColor; }; EffectTextArrayAction::EffectTextArrayAction( const ::basegfx::B2DPoint& rStartPoint, @@ -1245,6 +1281,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, @@ -1261,7 +1298,8 @@ namespace cppcanvas maReliefOffset( rReliefOffset ), maReliefColor( rReliefColor ), maShadowOffset( rShadowOffset ), - maShadowColor( rShadowColor ) + maShadowColor( rShadowColor ), + maTextFillColor( rTextFillColor ) { initEffectLinePolyPolygon( maLinesOverallSize, mxTextLines, @@ -1285,6 +1323,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, @@ -1302,7 +1341,8 @@ namespace cppcanvas maReliefOffset( rReliefOffset ), maReliefColor( rReliefColor ), maShadowOffset( rShadowOffset ), - maShadowColor( rShadowColor ) + maShadowColor( rShadowColor ), + maTextFillColor( rTextFillColor ) { initEffectLinePolyPolygon( maLinesOverallSize, mxTextLines, @@ -1322,7 +1362,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() ); @@ -1331,6 +1379,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 ); @@ -1352,7 +1412,8 @@ namespace cppcanvas maShadowColor, maShadowOffset, maReliefColor, - maReliefOffset ); + maReliefOffset, + maTextFillColor); } class EffectTextArrayRenderHelper : public TextRenderer @@ -1370,12 +1431,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 ); @@ -1384,6 +1457,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; @@ -1441,7 +1523,8 @@ namespace cppcanvas maShadowColor, maShadowOffset, maReliefColor, - maReliefOffset ); + maReliefOffset, + maTextFillColor); } ::basegfx::B2DRange EffectTextArrayAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const @@ -1553,7 +1636,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), @@ -1577,6 +1660,7 @@ namespace cppcanvas const ::Color maReliefColor; const ::basegfx::B2DSize maShadowOffset; const ::Color maShadowColor; + const ::Color maTextFillColor; }; double calcOutlineWidth( const OutDevState& rState, @@ -1675,7 +1759,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() ); @@ -1731,7 +1815,8 @@ namespace cppcanvas maShadowColor, maShadowOffset, maReliefColor, - maReliefOffset ); + maReliefOffset, + maTextFillColor); } #if 0 // see #if'ed out use in OutlineAction::renderSubset below: @@ -2040,6 +2125,7 @@ namespace cppcanvas const ::Color& rReliefColor, const ::Size& rShadowOffset, const ::Color& rShadowColor, + const ::Color& rTextFillColor, const OUString& rText, sal_Int32 nStartPos, sal_Int32 nLen, @@ -2173,7 +2259,8 @@ namespace cppcanvas !rState.textUnderlineStyle && !rState.textStrikeoutStyle && rReliefColor == aEmptyColor && - rShadowColor == aEmptyColor ) + rShadowColor == aEmptyColor && + rTextFillColor == aEmptyColor ) { // nope if( rParms.maTextTransformation.is_initialized() ) @@ -2206,6 +2293,7 @@ namespace cppcanvas rReliefColor, aShadowOffset, rShadowColor, + rTextFillColor, rText, nStartPos, nLen, @@ -2221,6 +2309,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, |