toolkit/source/helper/formpdfexport.cxx |    2 -
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |    3 +
 vcl/source/gdi/pdfwriter_impl.cxx       |   50 +++++++++++++++++---------------
 3 files changed, 31 insertions(+), 24 deletions(-)

New commits:
commit f6d2f218ad0dd1f3817411c4eb42dffc5bea9bf5
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu May 12 10:48:00 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu May 12 12:19:10 2022 +0200

    related: tdf#148442: do not replace 'Yes' if onValue is empty
    
    Change-Id: I748422dfbe7a385f4206c5d129eb3091289a180d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134220
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/toolkit/source/helper/formpdfexport.cxx 
b/toolkit/source/helper/formpdfexport.cxx
index 7a88bcbbe171..bd9bd536840f 100644
--- a/toolkit/source/helper/formpdfexport.cxx
+++ b/toolkit/source/helper/formpdfexport.cxx
@@ -570,7 +570,6 @@ namespace toolkitform
                 }
                 catch(...)
                 {
-                    pCheckBoxWidget->OnValue = "On";
                 }
             }
 
@@ -590,7 +589,6 @@ namespace toolkitform
                 }
                 catch(...)
                 {
-                    pRadioWidget->OnValue = "On";
                 }
             }
 
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index d2adddd39b31..329e294a4640 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -859,6 +859,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148442)
                 CPPUNIT_ASSERT_EQUAL(OString("Checkbox1"), pT->GetValue());
                 CPPUNIT_ASSERT_EQUAL(OString("Yes"), pAS->GetValue());
                 CPPUNIT_ASSERT(!pN->GetItems().count("ref"));
+                CPPUNIT_ASSERT(pN->GetItems().count("Yes"));
             }
             else if (nBtnCount == 2)
             {
@@ -867,12 +868,14 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148442)
 
                 // Without the fix in place, this test would have failed here
                 CPPUNIT_ASSERT(pN->GetItems().count("ref"));
+                CPPUNIT_ASSERT(!pN->GetItems().count("Yes"));
             }
             else
             {
                 CPPUNIT_ASSERT_EQUAL(OString("Checkbox3"), pT->GetValue());
                 CPPUNIT_ASSERT_EQUAL(OString("Off"), pAS->GetValue());
                 CPPUNIT_ASSERT(pN->GetItems().count("ref"));
+                CPPUNIT_ASSERT(!pN->GetItems().count("Yes"));
             }
         }
     }
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index b7a2f381bd08..f017a93c7a35 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -4170,20 +4170,23 @@ bool PDFWriterImpl::emitWidgetAnnotations()
 
         if( rWidget.m_eType == PDFWriter::CheckBox )
         {
-            auto app_it = rWidget.m_aAppearances.find( "N" );
-            if( app_it != rWidget.m_aAppearances.end() )
+            if ( !rWidget.m_aOnValue.isEmpty() )
             {
-                auto stream_it = app_it->second.find( "Yes" );
-                if( stream_it != app_it->second.end() )
+                auto app_it = rWidget.m_aAppearances.find( "N" );
+                if( app_it != rWidget.m_aAppearances.end() )
                 {
-                    SvMemoryStream* pStream = stream_it->second;
-                    app_it->second.erase( stream_it );
-                    OStringBuffer aBuf( rWidget.m_aOnValue.getLength()*2 );
-                    appendName( rWidget.m_aOnValue, aBuf );
-                    (app_it->second)[ aBuf.makeStringAndClear() ] = pStream;
+                    auto stream_it = app_it->second.find( "Yes" );
+                    if( stream_it != app_it->second.end() )
+                    {
+                        SvMemoryStream* pStream = stream_it->second;
+                        app_it->second.erase( stream_it );
+                        OStringBuffer aBuf( rWidget.m_aOnValue.getLength()*2 );
+                        appendName( rWidget.m_aOnValue, aBuf );
+                        (app_it->second)[ aBuf.makeStringAndClear() ] = 
pStream;
+                    }
+                    else
+                        SAL_INFO("vcl.pdfwriter", "error: CheckBox without 
\"Yes\" stream" );
                 }
-                else
-                    SAL_INFO("vcl.pdfwriter", "error: CheckBox without \"Yes\" 
stream" );
             }
         }
 
@@ -10715,20 +10718,23 @@ void PDFWriterImpl::ensureUniqueRadioOnValues()
         for (auto const& nKidIndex : rGroupWidget.m_aKidsIndex)
         {
             PDFWidget& rKid = m_aWidgets[nKidIndex];
-            auto app_it = rKid.m_aAppearances.find( "N" );
-            if( app_it != rKid.m_aAppearances.end() )
+            if ( !rKid.m_aOnValue.isEmpty() )
             {
-                auto stream_it = app_it->second.find( "Yes" );
-                if( stream_it != app_it->second.end() )
+                auto app_it = rKid.m_aAppearances.find( "N" );
+                if( app_it != rKid.m_aAppearances.end() )
                 {
-                    SvMemoryStream* pStream = stream_it->second;
-                    app_it->second.erase( stream_it );
-                    OStringBuffer aBuf( rKid.m_aOnValue.getLength()*2 );
-                    appendName( rKid.m_aOnValue, aBuf );
-                    (app_it->second)[ aBuf.makeStringAndClear() ] = pStream;
+                    auto stream_it = app_it->second.find( "Yes" );
+                    if( stream_it != app_it->second.end() )
+                    {
+                        SvMemoryStream* pStream = stream_it->second;
+                        app_it->second.erase( stream_it );
+                        OStringBuffer aBuf( rKid.m_aOnValue.getLength()*2 );
+                        appendName( rKid.m_aOnValue, aBuf );
+                        (app_it->second)[ aBuf.makeStringAndClear() ] = 
pStream;
+                    }
+                    else
+                        SAL_INFO("vcl.pdfwriter", "error: RadioButton without 
\"Yes\" stream" );
                 }
-                else
-                    SAL_INFO("vcl.pdfwriter", "error: RadioButton without 
\"Yes\" stream" );
             }
             // update selected radio button
             if( rKid.m_aValue != "Off" )

Reply via email to