diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-05-12 12:10:53 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-05-16 10:52:44 +0200 |
commit | 50fd91de9babf7c043759f13d8064ce5c22f307d (patch) | |
tree | cc4b01b6e00a4eecd236f54fd63fd66048595dad | |
parent | related: tdf#148442: do not replace 'Yes' if onValue is empty (diff) | |
download | core-50fd91de9babf7c043759f13d8064ce5c22f307d.tar.gz core-50fd91de9babf7c043759f13d8064ce5c22f307d.zip |
tdf#143612: map SecondaryRefValue in form pdf export
Change-Id: I590784eb94fb6f4f3a20c4f6d8e3fb618f60d0fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134227
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/+/134242
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-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 1d9028726040..ca54551f0b09 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 2176ddd31003..18a106bb2f4f 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 ); @@ -10741,6 +10760,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" ) { @@ -10858,6 +10897,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; @@ -10880,6 +10920,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 ); } |