[Libreoffice-commits] core.git: sw/qa sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 1 15:23:09 UTC 2020


 sw/qa/extras/tiledrendering/data/tdf117448.fodt |   29 +++++++++++++++++++++
 sw/qa/extras/tiledrendering/tiledrendering.cxx  |   32 ++++++++++++++++++++++++
 sw/source/core/text/itrpaint.cxx                |    8 +++++-
 sw/source/core/text/txtpaint.cxx                |   11 +++++++-
 sw/source/core/text/txtpaint.hxx                |   11 ++++++--
 5 files changed, 86 insertions(+), 5 deletions(-)

New commits:
commit b6ef43f678c55330d7d8174201fadc55d5381f42
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Fri Mar 20 15:12:06 2020 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Apr 1 17:22:30 2020 +0200

    tdf#117448 Writer table: don't clip text on margins
    
    Use area of paragraph margins to show top and bottom
    of the clipped text at small fixed line height, like
    MSO does. This results noticeable difference in tables,
    where small fixed line height is a method to set narrow
    table rows, but LibreOffice hid top and bottom of the
    characters according to the line height which is smaller,
    than the character height.
    
    Note: PDF export has already showed top and bottom of the
    characters in this case, and not in tables. But according
    to the editing glitches (missing update of the clipped
    area during typing), we don't want to extend this behaviour
    for not table content, yet.
    
    Change-Id: I7aff5405314948f301bfb71bf35cc1911e194f8b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90798
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/tiledrendering/data/tdf117448.fodt b/sw/qa/extras/tiledrendering/data/tdf117448.fodt
new file mode 100644
index 000000000000..eccadee25974
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/tdf117448.fodt
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+  <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+  <style:style style:name="Text_20_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" loext:contextual-spacing="false" fo:line-height="115%"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
+   <style:paragraph-properties fo:margin-top="6.01pt" fo:margin-bottom="6.01pt" loext:contextual-spacing="false" fo:line-height="6.01pt"/>
+  </style:style>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text>
+   <table:table table:name="Táblázat1" table:style-name="Táblázat1">
+    <table:table-column table:style-name="Táblázat1.A"/>
+    <table:table-row>
+     <table:table-cell table:style-name="Táblázat1.A1" office:value-type="string">
+      <text:p text:style-name="P1">Text without clipping.</text:p>
+     </table:table-cell>
+    </table:table-row>
+   </table:table>
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 1e8baea4312f..e6272136f4ab 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -121,6 +121,7 @@ public:
     void testVisCursorInvalidation();
     void testDeselectCustomShape();
     void testSemiTransparent();
+    void testClipText();
     void testAnchorTypes();
     void testLanguageStatus();
     void testRedlineNotificationDuringSave();
@@ -184,6 +185,7 @@ public:
     CPPUNIT_TEST(testVisCursorInvalidation);
     CPPUNIT_TEST(testDeselectCustomShape);
     CPPUNIT_TEST(testSemiTransparent);
+    CPPUNIT_TEST(testClipText);
     CPPUNIT_TEST(testAnchorTypes);
     CPPUNIT_TEST(testLanguageStatus);
     CPPUNIT_TEST(testRedlineNotificationDuringSave);
@@ -2382,6 +2384,36 @@ void SwTiledRenderingTest::testSemiTransparent()
     CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.B));
 }
 
+void SwTiledRenderingTest::testClipText()
+{
+    // Load a document where the top left tile contains table text with
+    // too small line height, but with top and bottom paragraph margins,
+    // avoiding of clipping top and bottom parts of the characters.
+    SwXTextDocument* pXTextDocument = createDoc("tdf117448.fodt");
+
+    // Render a larger area, and then get the top and bottom of the text in that tile
+    size_t nCanvasWidth = 1024;
+    size_t nCanvasHeight = 512;
+    size_t nTileSize = 256;
+    std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
+    ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
+    pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
+    pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight),
+                                                    Fraction(1.0), Point(), aPixmap.data());
+    pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0,
+                              /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680);
+    pDevice->EnableMapMode(false);
+    Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize));
+    Bitmap::ScopedReadAccess pAccess(aBitmap);
+
+    // check top of the letter "T", it's not a white pixel
+    Color aTopTextColor(pAccess->GetPixel(98, 100));
+    CPPUNIT_ASSERT_LESS(255, static_cast<int>(aTopTextColor.R));
+    // check bottom of the letter "g", it's not a white pixel
+    Color aBottomTextColor(pAccess->GetPixel(112, 228));
+    CPPUNIT_ASSERT_LESS(255, static_cast<int>(aBottomTextColor.R));
+}
+
 void SwTiledRenderingTest::testAnchorTypes()
 {
     SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 30889d15f2d4..28eb142d63af 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -224,7 +224,13 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, SwSaveClip &rClip,
 
     if( m_pCurr->IsClipping() )
     {
-        rClip.ChgClip( aLineRect, m_pFrame );
+        const SwTextFrame& rFrame = *GetInfo().GetTextFrame();
+        // tdf#117448 at small fixed line height, enlarge clipping area in table cells
+        // to show previously clipped text content on the area of paragraph margins
+        if ( rFrame.IsInTab() )
+            rClip.ChgClip( aLineRect, m_pFrame, false, rFrame.GetTopMargin(), rFrame.GetBottomMargin() );
+        else
+            rClip.ChgClip( aLineRect, m_pFrame );
         bClip = false;
     }
 
diff --git a/sw/source/core/text/txtpaint.cxx b/sw/source/core/text/txtpaint.cxx
index 0518d3330b70..e2292d70beef 100644
--- a/sw/source/core/text/txtpaint.cxx
+++ b/sw/source/core/text/txtpaint.cxx
@@ -41,7 +41,9 @@ SwSaveClip::~SwSaveClip()
 }
 
 void SwSaveClip::ChgClip_( const SwRect &rRect, const SwTextFrame* pFrame,
-                           bool bEnlargeRect )
+                           bool bEnlargeRect,
+                           sal_Int32 nEnlargeTop,
+                           sal_Int32 nEnlargeBottom )
 {
     SwRect aOldRect( rRect );
     const bool bVertical = pFrame && pFrame->IsVertical();
@@ -78,6 +80,13 @@ void SwSaveClip::ChgClip_( const SwRect &rRect, const SwTextFrame* pFrame,
         if ( bEnlargeRect && ! bVertical )
             aRect.AdjustBottom(40 );
 
+        // enlarge clip for paragraph margins at small fixed line height
+        if ( nEnlargeTop > 0 )
+            aRect.AdjustTop( -nEnlargeTop );
+
+        if ( nEnlargeBottom > 0 )
+            aRect.AdjustBottom( nEnlargeBottom );
+
         // If the ClipRect is identical, nothing will happen
         if( pOut->IsClipRegion() ) // no && because of Mac
         {
diff --git a/sw/source/core/text/txtpaint.hxx b/sw/source/core/text/txtpaint.hxx
index 68149c9bc5a8..0c8e0466b906 100644
--- a/sw/source/core/text/txtpaint.hxx
+++ b/sw/source/core/text/txtpaint.hxx
@@ -31,7 +31,9 @@ class SwSaveClip final
 
     VclPtr<OutputDevice> pOut;
     void ChgClip_( const SwRect &rRect, const SwTextFrame* pFrame,
-                   bool bEnlargeRect );
+                   bool bEnlargeRect,
+                   sal_Int32 nEnlargeTop,
+                   sal_Int32 nEnlargeBottom );
 public:
     explicit SwSaveClip(OutputDevice* pOutDev)
         : bOn(pOutDev && pOutDev->IsClipRegion())
@@ -42,8 +44,11 @@ public:
 
     ~SwSaveClip();
     void ChgClip( const SwRect &rRect, const SwTextFrame* pFrame = nullptr,
-                         bool bEnlargeRect = false)
-             { if( pOut ) ChgClip_( rRect, pFrame, bEnlargeRect ); }
+                         bool bEnlargeRect = false,
+                         sal_Int32 nEnlargeTop = 0,
+                         sal_Int32 nEnlargeBottom = 0)
+             { if( pOut ) ChgClip_( rRect, pFrame,
+                         bEnlargeRect, nEnlargeTop, nEnlargeBottom ); }
     bool IsOn()  const { return bOn; }
     bool IsChg() const { return bChg; }
 };


More information about the Libreoffice-commits mailing list