diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-05-12 10:48:00 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-05-25 09:27:14 +0200 |
commit | 6ed4f5eeff60b72db8a49c9f76a64db4eb044b60 (patch) | |
tree | 46d1d360e1ec3d08585469fa04810657505ebba7 | |
parent | 1de5627ecea8d9331de1977bf521de713b8b1b5f (diff) |
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 <xiscofauli@libreoffice.org>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134241
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | toolkit/source/helper/formpdfexport.cxx | 2 | ||||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 3 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 50 |
3 files changed, 31 insertions, 24 deletions
diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx index 8011ebf9e616..5f04f69f7721 100644 --- a/toolkit/source/helper/formpdfexport.cxx +++ b/toolkit/source/helper/formpdfexport.cxx @@ -571,7 +571,6 @@ namespace toolkitform } catch(...) { - pCheckBoxWidget->OnValue = "On"; } } @@ -591,7 +590,6 @@ namespace toolkitform } catch(...) { - pRadioWidget->OnValue = "On"; } } diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 32de9047ce00..19c823b7f2bb 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -857,6 +857,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) { @@ -865,12 +866,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 2915220cf2ec..1dcadd84b349 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -4168,20 +4168,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" ); } } @@ -10722,20 +10725,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" ) |