summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-05-12 10:48:00 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-05-16 10:52:07 +0200
commit9ff32ff939cd88bd5a609ef76fa145671dba44fb (patch)
tree005892f589223f7b1387ddfc3dc932ede6ab8a5b
parent2f1e299983379c89e17bd32dbd49a49b3709e606 (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.cxx2
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx3
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx50
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 1dc8f40c3b3d..1d9028726040 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 6a450314a6a0..2176ddd31003 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" );
}
}
@@ -10720,20 +10723,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" )