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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 30 07:42:21 UTC 2020


 sw/qa/extras/tiledrendering/data/tdf114799.docx |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx  |   27 ++++++++++++++++++++++++
 sw/source/core/text/txtfld.cxx                  |   14 ++++++------
 3 files changed, 34 insertions(+), 7 deletions(-)

New commits:
commit 315d56582f8a56d8f2d3ea6cda63ea4832249608
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Tue Apr 28 16:48:09 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Thu Apr 30 09:41:45 2020 +0200

    tdf#114799 DOCX import: fix missing numbering highlight
    
    opening a DOCX with shadowing (w:shd) instead of highlight
    (w:highlight), for example, a DOCX saved in LibreOffice.
    
    This reverts also commit aa02ed306f7c633bbffede16e44e8e736977ace4
    (tdf#106991: Highlighting remains after select no fill).
    
    Change-Id: I0935694e3c309b5a450cd424fd398a88d13f8b22
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93082
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/tiledrendering/data/tdf114799.docx b/sw/qa/extras/tiledrendering/data/tdf114799.docx
new file mode 100644
index 000000000000..730ef91dcef9
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/tdf114799.docx differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 441c06271d52..355ae56cc29f 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 testHighlightNumbering();
     void testClipText();
     void testAnchorTypes();
     void testLanguageStatus();
@@ -186,6 +187,7 @@ public:
     CPPUNIT_TEST(testVisCursorInvalidation);
     CPPUNIT_TEST(testDeselectCustomShape);
     CPPUNIT_TEST(testSemiTransparent);
+    CPPUNIT_TEST(testHighlightNumbering);
     CPPUNIT_TEST(testClipText);
     CPPUNIT_TEST(testAnchorTypes);
     CPPUNIT_TEST(testLanguageStatus);
@@ -2386,6 +2388,31 @@ void SwTiledRenderingTest::testSemiTransparent()
     CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.B));
 }
 
+void SwTiledRenderingTest::testHighlightNumbering()
+{
+    // Load a document where the top left tile contains a semi-transparent rectangle shape.
+    SwXTextDocument* pXTextDocument = createDoc("tdf114799.docx");
+
+    // Render a larger area, and then get the color of the bottom right corner of our 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);
+
+    // Yellow highlighting over numbering
+    Color aColor(pAccess->GetPixel(103, 148));
+    CPPUNIT_ASSERT_EQUAL(COL_YELLOW, aColor);
+}
+
 void SwTiledRenderingTest::testClipText()
 {
     // Load a document where the top left tile contains table text with
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index a1c27cbb3597..5442f3f87922 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -466,17 +466,17 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
         const SfxPoolItem* pItem = aIter.GetCurItem();
         do
         {
-            if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which()))
-                pCleanedSet->ClearItem(pItem->Which());
-            else if (pFormat && pFormat->HasItem(pItem->Which()))
-                pCleanedSet->ClearItem(pItem->Which());
+            if (pItem->Which() != RES_CHRATR_BACKGROUND)
+            {
+                if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which()))
+                    pCleanedSet->ClearItem(pItem->Which());
+                else if (pFormat && pFormat->HasItem(pItem->Which()))
+                    pCleanedSet->ClearItem(pItem->Which());
+            }
 
             pItem = aIter.NextItem();
         } while (pItem);
-        // Highlightcolor also needed to be untouched, but we can't have that just by clearing the item
-        Color nSaveHighlight = pNumFnt->GetHighlightColor();
         pNumFnt->SetDiffFnt(pCleanedSet.get(), pIDSA);
-        pNumFnt->SetHighlightColor(nSaveHighlight);
     }
 }
 


More information about the Libreoffice-commits mailing list