diff options
-rw-r--r-- | include/vcl/pdfwriter.hxx | 2 | ||||
-rw-r--r-- | toolkit/source/helper/formpdfexport.cxx | 16 | ||||
-rw-r--r-- | vcl/inc/pdf/pdfwriter_impl.hxx | 3 | ||||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/data/tdf148442.odt | bin | 10573 -> 10558 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 41 |
6 files changed, 67 insertions, 1 deletions
diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx index 3dfcc31e0994..822b6870c89c 100644 --- a/include/vcl/pdfwriter.hxx +++ b/include/vcl/pdfwriter.hxx @@ -333,6 +333,7 @@ public: { bool Checked; OUString OnValue; // the value of the checkbox if it is selected + OUString OffValue; // the value of the checkbox if it is not selected CheckBoxWidget() : AnyWidget( vcl::PDFWriter::CheckBox ), @@ -350,6 +351,7 @@ public: bool Selected; sal_Int32 RadioGroup; OUString OnValue; // the value of the radio button if it is selected + OUString OffValue; // the value of the radio button if it is not selected RadioButtonWidget() : AnyWidget( vcl::PDFWriter::RadioButton ), diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx index 5f04f69f7721..aa5224e377f2 100644 --- a/toolkit/source/helper/formpdfexport.cxx +++ b/toolkit/source/helper/formpdfexport.cxx @@ -572,6 +572,14 @@ namespace toolkitform catch(...) { } + + try + { + xModelProps->getPropertyValue( "SecondaryRefValue" ) >>= pCheckBoxWidget->OffValue; + } + catch(...) + { + } } @@ -591,6 +599,14 @@ namespace toolkitform catch(...) { } + + try + { + xModelProps->getPropertyValue( "SecondaryRefValue" ) >>= pRadioWidget->OffValue; + } + catch(...) + { + } } diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index b8bdc3825eee..f6a9bba96f6a 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -463,7 +463,8 @@ struct PDFWidget : public PDFAnnotation sal_Int32 m_nParent; // if not 0, parent's object number std::vector<sal_Int32> m_aKids; // widget children, contains object numbers std::vector<sal_Int32> m_aKidsIndex; // widget children, contains index to m_aWidgets - OUString m_aOnValue; + OUString m_aOnValue; + OUString m_aOffValue; sal_Int32 m_nTabOrder; // lowest number gets first in tab order sal_Int32 m_nRadioGroup; sal_Int32 m_nMaxLen; diff --git a/vcl/qa/cppunit/pdfexport/data/tdf148442.odt b/vcl/qa/cppunit/pdfexport/data/tdf148442.odt Binary files differindex 31fea48e62b2..819595df22a2 100644 --- a/vcl/qa/cppunit/pdfexport/data/tdf148442.odt +++ b/vcl/qa/cppunit/pdfexport/data/tdf148442.odt diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 19c823b7f2bb..95c6325c5a26 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -858,6 +858,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148442) CPPUNIT_ASSERT_EQUAL(OString("Yes"), pAS->GetValue()); CPPUNIT_ASSERT(!pN->GetItems().count("ref")); CPPUNIT_ASSERT(pN->GetItems().count("Yes")); + CPPUNIT_ASSERT(pN->GetItems().count("Off")); } else if (nBtnCount == 2) { @@ -867,6 +868,7 @@ 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")); + CPPUNIT_ASSERT(pN->GetItems().count("Off")); } else { @@ -874,6 +876,10 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148442) CPPUNIT_ASSERT_EQUAL(OString("Off"), pAS->GetValue()); CPPUNIT_ASSERT(pN->GetItems().count("ref")); CPPUNIT_ASSERT(!pN->GetItems().count("Yes")); + + // tdf#143612: Without the fix in place, this test would have failed here + CPPUNIT_ASSERT(!pN->GetItems().count("Off")); + CPPUNIT_ASSERT(pN->GetItems().count("refOff")); } } } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 1dcadd84b349..06daee9efadc 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -4186,6 +4186,25 @@ bool PDFWriterImpl::emitWidgetAnnotations() SAL_INFO("vcl.pdfwriter", "error: CheckBox without \"Yes\" stream" ); } } + + if ( !rWidget.m_aOffValue.isEmpty() ) + { + auto app_it = rWidget.m_aAppearances.find( "N" ); + if( app_it != rWidget.m_aAppearances.end() ) + { + auto stream_it = app_it->second.find( "Off" ); + if( stream_it != app_it->second.end() ) + { + SvMemoryStream* pStream = stream_it->second; + app_it->second.erase( stream_it ); + OStringBuffer aBuf( rWidget.m_aOffValue.getLength()*2 ); + appendName( rWidget.m_aOffValue, aBuf ); + (app_it->second)[ aBuf.makeStringAndClear() ] = pStream; + } + else + SAL_INFO("vcl.pdfwriter", "error: CheckBox without \"Off\" stream" ); + } + } } OStringBuffer aLine( 1024 ); @@ -10743,6 +10762,26 @@ void PDFWriterImpl::ensureUniqueRadioOnValues() SAL_INFO("vcl.pdfwriter", "error: RadioButton without \"Yes\" stream" ); } } + + if ( !rKid.m_aOffValue.isEmpty() ) + { + auto app_it = rKid.m_aAppearances.find( "N" ); + if( app_it != rKid.m_aAppearances.end() ) + { + auto stream_it = app_it->second.find( "Off" ); + if( stream_it != app_it->second.end() ) + { + SvMemoryStream* pStream = stream_it->second; + app_it->second.erase( stream_it ); + OStringBuffer aBuf( rKid.m_aOffValue.getLength()*2 ); + appendName( rKid.m_aOffValue, aBuf ); + (app_it->second)[ aBuf.makeStringAndClear() ] = pStream; + } + else + SAL_INFO("vcl.pdfwriter", "error: RadioButton without \"Off\" stream" ); + } + } + // update selected radio button if( rKid.m_aValue != "Off" ) { @@ -10860,6 +10899,7 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa rNewWidget.m_aValue = "Off"; rNewWidget.m_aOnValue = rBtn.OnValue; + rNewWidget.m_aOffValue = rBtn.OffValue; if( rRadioButton.m_aValue.isEmpty() && rBtn.Selected ) { rNewWidget.m_aValue = rNewWidget.m_aOnValue; @@ -10882,6 +10922,7 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa rNewWidget.m_aValue = rBox.Checked ? std::u16string_view(u"Yes") : std::u16string_view(u"Off" ); rNewWidget.m_aOnValue = rBox.OnValue; + rNewWidget.m_aOffValue = rBox.OffValue; // create default appearance before m_aRect gets transformed createDefaultCheckBoxAppearance( rNewWidget, rBox ); } |