cppcanvas/source/mtfrenderer/textaction.cxx |   77 ++++++++++++++++++++++------
 1 file changed, 62 insertions(+), 15 deletions(-)

New commits:
commit 65c3c83e3add38046fca2e50a2947518679cdfa7
Author:     Thorsten Behrens <[email protected]>
AuthorDate: Sun Oct 13 16:00:45 2024 +0200
Commit:     Adolfo Jayme Barrientos <[email protected]>
CommitDate: Thu Oct 17 07:09:55 2024 +0200

    tdf#163410: fix missing text highlight color for outline text
    
    During slideshow, the combination outline text mode, and highlight
    background color never worked. Adding cppcanvas code to handle it.
    
    Change-Id: I9abb45fca4c89d206ebb431ff5675288e5deab43
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174872
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <[email protected]>
    (cherry picked from commit 0e70c14134e899d3abb443761fe9f6a7249f724a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174784
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>

diff --git a/cppcanvas/source/mtfrenderer/textaction.cxx 
b/cppcanvas/source/mtfrenderer/textaction.cxx
index 2f2148c44dbd..ac3348daf68d 100644
--- a/cppcanvas/source/mtfrenderer/textaction.cxx
+++ b/cppcanvas/source/mtfrenderer/textaction.cxx
@@ -1592,6 +1592,8 @@ namespace cppcanvas::internal
                                const ::Color&                                  
     rReliefColor,
                                const ::basegfx::B2DSize&                       
     rShadowOffset,
                                const ::Color&                                  
     rShadowColor,
+                               const ::Color&                                  
     rFillColor,
+                               uno::Reference< rendering::XPolyPolygon2D >     
     xFillPoly,
                                const ::basegfx::B2DRectangle&                  
     rOutlineBounds,
                                uno::Reference< rendering::XPolyPolygon2D >     
     xTextPoly,
                                const uno::Sequence< double >&                  
     rOffsets,
@@ -1603,6 +1605,8 @@ namespace cppcanvas::internal
                                const ::Color&                                  
     rReliefColor,
                                const ::basegfx::B2DSize&                       
     rShadowOffset,
                                const ::Color&                                  
     rShadowColor,
+                               const ::Color&                                  
     rFillColor,
+                               uno::Reference< rendering::XPolyPolygon2D >     
     xFillPoly,
                                const ::basegfx::B2DRectangle&                  
     rOutlineBounds,
                                uno::Reference< rendering::XPolyPolygon2D >     
     xTextPoly,
                                const uno::Sequence< double >&                  
     rOffsets,
@@ -1642,6 +1646,7 @@ namespace cppcanvas::internal
                 rendering::RenderState                              maState;
                 double                                              
mnOutlineWidth;
                 const uno::Sequence< double >                       
maFillColor;
+                uno::Reference< rendering::XPolyPolygon2D >         
mxBackgroundFillPoly;
                 const tools::TextLineInfo                           
maTextLineInfo;
                 ::basegfx::B2DSize                                  
maLinesOverallSize;
                 const ::basegfx::B2DRectangle                       
maOutlineBounds;
@@ -1651,6 +1656,7 @@ namespace cppcanvas::internal
                 const ::basegfx::B2DSize                            
maShadowOffset;
                 const ::Color                                       
maShadowColor;
                 const ::Color                                       
maTextFillColor;
+                const ::Color                                       
maBackgroundFillColor;
             };
 
             double calcOutlineWidth( const OutDevState& rState,
@@ -1670,6 +1676,8 @@ namespace cppcanvas::internal
                                           const ::Color&                       
                 rReliefColor,
                                           const ::basegfx::B2DSize&            
                 rShadowOffset,
                                           const ::Color&                       
                 rShadowColor,
+                                          const ::Color&                       
                 rFillColor,
+                                          uno::Reference< 
rendering::XPolyPolygon2D >           xFillPoly,
                                           const ::basegfx::B2DRectangle&       
                 rOutlineBounds,
                                           uno::Reference< 
rendering::XPolyPolygon2D >           xTextPoly,
                                           const uno::Sequence< double >&       
                 rOffsets,
@@ -1684,12 +1692,14 @@ namespace cppcanvas::internal
                     vcl::unotools::colorToDoubleSequence(
                         COL_WHITE,
                         
rCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() )),
+                mxBackgroundFillPoly(std::move( xFillPoly )),
                 maTextLineInfo( tools::createTextLineInfo( rVDev, rState ) ),
                 maOutlineBounds( rOutlineBounds ),
                 maReliefOffset( rReliefOffset ),
                 maReliefColor( rReliefColor ),
                 maShadowOffset( rShadowOffset ),
-                maShadowColor( rShadowColor )
+                maShadowColor( rShadowColor ),
+                maBackgroundFillColor( rFillColor )
             {
                 double nLayoutWidth = 0.0;
 
@@ -1712,6 +1722,8 @@ namespace cppcanvas::internal
                                           const ::Color&                       
                 rReliefColor,
                                           const ::basegfx::B2DSize&            
                 rShadowOffset,
                                           const ::Color&                       
                 rShadowColor,
+                                          const ::Color&                       
                 rFillColor,
+                                          uno::Reference< 
rendering::XPolyPolygon2D >           xFillPoly,
                                           const ::basegfx::B2DRectangle&       
                 rOutlineBounds,
                                           uno::Reference< 
rendering::XPolyPolygon2D >           xTextPoly,
                                           const uno::Sequence< double >&       
                 rOffsets,
@@ -1727,12 +1739,14 @@ namespace cppcanvas::internal
                     vcl::unotools::colorToDoubleSequence(
                         COL_WHITE,
                         
rCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() )),
+                mxBackgroundFillPoly(std::move( xFillPoly )),
                 maTextLineInfo( tools::createTextLineInfo( rVDev, rState ) ),
                 maOutlineBounds( rOutlineBounds ),
                 maReliefOffset( rReliefOffset ),
                 maReliefColor( rReliefColor ),
                 maShadowOffset( rShadowOffset ),
-                maShadowColor( rShadowColor )
+                maShadowColor( rShadowColor ),
+                maBackgroundFillColor( rFillColor )
             {
                 double nLayoutWidth = 0.0;
                 initLayoutWidth(nLayoutWidth, rOffsets);
@@ -1755,6 +1769,14 @@ namespace cppcanvas::internal
                 const rendering::ViewState&                 rViewState( 
mpCanvas->getViewState() );
                 const uno::Reference< rendering::XCanvas >& rCanvas( 
mpCanvas->getUNOCanvas() );
 
+                if (mxBackgroundFillPoly.is())
+                {
+                    rendering::RenderState aLocalState( rRenderState );
+                    aLocalState.DeviceColor = 
vcl::unotools::colorToDoubleSequence(
+                        maBackgroundFillColor, 
rCanvas->getDevice()->getDeviceColorSpace());
+                    rCanvas->fillPolyPolygon(mxBackgroundFillPoly, rViewState, 
aLocalState);
+                }
+
                 rendering::StrokeAttributes aStrokeAttributes;
 
                 aStrokeAttributes.StrokeWidth  = mnOutlineWidth;
@@ -1977,19 +1999,20 @@ namespace cppcanvas::internal
                 it.
              */
             std::shared_ptr<Action> createOutline( const ::basegfx::B2DPoint&  
     rStartPoint,
-                                           const ::basegfx::B2DSize&        
rReliefOffset,
-                                           const ::Color&                   
rReliefColor,
-                                           const ::basegfx::B2DSize&        
rShadowOffset,
-                                           const ::Color&                   
rShadowColor,
-                                           const OUString&                  
rText,
-                                           sal_Int32                        
nStartPos,
-                                           sal_Int32                        
nLen,
-                                           KernArraySpan                    
pDXArray,
-                                           std::span<const sal_Bool>       
pKashidaArray,
-                                           VirtualDevice&                   
rVDev,
-                                           const CanvasSharedPtr&           
rCanvas,
-                                           const OutDevState&               
rState,
-                                           const Renderer::Parameters&      
rParms  )
+                                                   const ::basegfx::B2DSize&   
     rReliefOffset,
+                                                   const ::Color&              
     rReliefColor,
+                                                   const ::basegfx::B2DSize&   
     rShadowOffset,
+                                                   const ::Color&              
     rShadowColor,
+                                                   const ::Color&              
     rTextFillColor,
+                                                   const OUString&             
     rText,
+                                                   sal_Int32                   
     nStartPos,
+                                                   sal_Int32                   
     nLen,
+                                                   KernArraySpan               
     pDXArray,
+                                                   std::span<const sal_Bool>   
     pKashidaArray,
+                                                   VirtualDevice&              
     rVDev,
+                                                   const CanvasSharedPtr&      
     rCanvas,
+                                                   const OutDevState&          
     rState,
+                                                   const Renderer::Parameters& 
     rParms  )
             {
                 // operate on raw DX array here (in logical coordinate
                 // system), to have a higher resolution
@@ -2070,6 +2093,25 @@ namespace cppcanvas::internal
                         rCanvas->getUNOCanvas()->getDevice(),
                         aResultingPolyPolygon ) );
 
+                // create background color fill polygon?
+                css::uno::Reference<css::rendering::XPolyPolygon2D> 
xTextBoundsPoly;
+                if (rTextFillColor != COL_AUTO)
+                {
+                    rendering::StringContext aStringContext( rText, nStartPos, 
nLen );
+                    uno::Reference< rendering::XTextLayout > xTextLayout(
+                        rState.xFont->createTextLayout(
+                            aStringContext,
+                            rState.textDirection,
+                            0 ) );
+
+                    auto aTextBounds = xTextLayout->queryTextBounds();
+                    auto aB2DBounds = 
::basegfx::unotools::b2DRectangleFromRealRectangle2D(aTextBounds);
+                    auto aTextBoundsPoly = 
::basegfx::utils::createPolygonFromRect(aB2DBounds);
+                    xTextBoundsPoly = 
::basegfx::unotools::xPolyPolygonFromB2DPolygon(
+                        rCanvas->getUNOCanvas()->getDevice(),
+                        aTextBoundsPoly);
+                }
+
                 if( rParms.maTextTransformation )
                 {
                     return std::make_shared<OutlineAction>(
@@ -2078,6 +2120,8 @@ namespace cppcanvas::internal
                             rReliefColor,
                             rShadowOffset,
                             rShadowColor,
+                            rTextFillColor,
+                            xTextBoundsPoly,
                             ::basegfx::utils::getRange(aResultingPolyPolygon),
                             xTextPoly,
                             aCharWidthSeq,
@@ -2094,6 +2138,8 @@ namespace cppcanvas::internal
                             rReliefColor,
                             rShadowOffset,
                             rShadowColor,
+                            rTextFillColor,
+                            xTextBoundsPoly,
                             ::basegfx::utils::getRange(aResultingPolyPolygon),
                             xTextPoly,
                             aCharWidthSeq,
@@ -2145,6 +2191,7 @@ namespace cppcanvas::internal
                             rReliefColor,
                             aShadowOffset,
                             rShadowColor,
+                            rTextFillColor,
                             rText,
                             nStartPos,
                             nLen,

Reply via email to