sd/qa/unit/export-tests.cxx  |   10 ++++++++++
 svx/source/inc/svdpdf.hxx    |    3 ++-
 svx/source/svdraw/svdpdf.cxx |   11 +++++++++--
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit 35a1641154d20278beff4cc1e5a7aba052d70ed8
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Oct 1 14:56:19 2025 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Oct 3 09:42:04 2025 +0200

    hide text shapes whose content was rendered as Invisible
    
    Change-Id: I9d4c3418ba4e1960d33d443518d25ed6ff7ecebd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191748
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index cf6a2a27ab0b..d305d34bd8d5 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -1161,6 +1161,16 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, 
testExplodedPdfGrayscaleImageUnderInvisibleTe
     // - Expected: rgba[ffffffff]
     // - Actual  : rgba[000000ff]
     CPPUNIT_ASSERT_EQUAL(aExpectedColor, aBitmap.GetPixelColor(5, 5));
+
+    // All the other shape in the group are text in front of that picture
+    // but with their pdf text mode as Invisible so it is the picture that
+    // is seen and the text is hidden. Test a sample text shape here. Without
+    // the fix this test would fail as these shapes were visible.
+    uno::Reference<beans::XPropertySet> 
xTextShape(xGroupShape->getByIndex(10), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xTextShape.is());
+    bool bVisible(true);
+    xTextShape->getPropertyValue(u"Visible"_ustr) >>= bVisible;
+    CPPUNIT_ASSERT_MESSAGE("Shape should be Invisible", !bVisible);
 }
 
 CPPUNIT_TEST_FIXTURE(SdExportTest, testEmbeddedText)
diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx
index c19d3da94611..2e7e7cce0a03 100644
--- a/svx/source/inc/svdpdf.hxx
+++ b/svx/source/inc/svdpdf.hxx
@@ -161,7 +161,8 @@ class ImpSdrPdfImport final
     void ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& 
pPageObject,
                     std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
                     int nPageObjectIndex);
-    void InsertTextObject(const Point& rPos, const Size& rSize, const 
OUString& rStr);
+    void InsertTextObject(const Point& rPos, const Size& rSize, const 
OUString& rStr,
+                          bool bInvisible);
 
     void SetupPageScale(const double dPageWidth, const double dPageHeight);
     void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 1ce55a13969f..c4e4e839552c 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1721,6 +1721,7 @@ void 
ImpSdrPdfImport::ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> con
     Color aTextColor(COL_TRANSPARENT);
     bool bFill = false;
     bool bUse = true;
+    bool bInvisible = false;
     switch (pPageObject->getTextRenderMode())
     {
         case vcl::pdf::PDFTextRenderMode::Fill:
@@ -1734,6 +1735,9 @@ void 
ImpSdrPdfImport::ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> con
         case vcl::pdf::PDFTextRenderMode::Unknown:
             break;
         case vcl::pdf::PDFTextRenderMode::Invisible:
+            bInvisible = true;
+            bUse = false;
+            break;
         case vcl::pdf::PDFTextRenderMode::Clip:
             bUse = false;
             break;
@@ -1751,11 +1755,11 @@ void 
ImpSdrPdfImport::ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> con
         mbFntDirty = true;
     }
 
-    InsertTextObject(aRect.TopLeft(), aRect.GetSize(), sText);
+    InsertTextObject(aRect.TopLeft(), aRect.GetSize(), sText, bInvisible);
 }
 
 void ImpSdrPdfImport::InsertTextObject(const Point& rPos, const Size& 
/*rSize*/,
-                                       const OUString& rStr)
+                                       const OUString& rStr, bool bInvisible)
 {
     FontMetric aFontMetric(mpVD->GetFontMetric());
     vcl::Font aFont(mpVD->GetFont());
@@ -1796,6 +1800,9 @@ void ImpSdrPdfImport::InsertTextObject(const Point& rPos, 
const Size& /*rSize*/,
 
     pText->SetMergedItem(makeSdrTextAutoGrowHeightItem(false));
 
+    if (bInvisible)
+        pText->SetVisible(false);
+
     pText->SetLayer(mnLayer);
     pText->NbcSetText(rStr);
     SetAttributes(pText.get(), true);

Reply via email to