summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-05-12 12:10:53 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-05-12 13:54:33 +0200
commitfe000080c514891f7cd65c3dd1c6f38732d78e7d (patch)
tree9601659509c8db20a272726e38b41b2e57680d10
parentSimplify ScTransferObj::SetDrawClipDoc a bit (diff)
downloadcore-fe000080c514891f7cd65c3dd1c6f38732d78e7d.tar.gz
core-fe000080c514891f7cd65c3dd1c6f38732d78e7d.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>
-rw-r--r--include/vcl/pdfwriter.hxx2
-rw-r--r--toolkit/source/helper/formpdfexport.cxx16
-rw-r--r--vcl/inc/pdf/pdfwriter_impl.hxx3
-rw-r--r--vcl/qa/cppunit/pdfexport/data/tdf148442.odtbin10573 -> 10558 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx6
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx41
6 files changed, 67 insertions, 1 deletions
diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx
index a894a6a64b6b..44b6ec449b0e 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 bd9bd536840f..80008f03ca3b 100644
--- a/toolkit/source/helper/formpdfexport.cxx
+++ b/toolkit/source/helper/formpdfexport.cxx
@@ -571,6 +571,14 @@ namespace toolkitform
catch(...)
{
}
+
+ try
+ {
+ xModelProps->getPropertyValue( "SecondaryRefValue" ) >>= pCheckBoxWidget->OffValue;
+ }
+ catch(...)
+ {
+ }
}
@@ -590,6 +598,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 6326f83755e0..4826b7903229 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
index 31fea48e62b2..819595df22a2 100644
--- a/vcl/qa/cppunit/pdfexport/data/tdf148442.odt
+++ b/vcl/qa/cppunit/pdfexport/data/tdf148442.odt
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 329e294a4640..7aaa6c19631b 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -860,6 +860,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)
{
@@ -869,6 +870,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
{
@@ -876,6 +878,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 f017a93c7a35..aabf9d5bdcb4 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -4188,6 +4188,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 );
@@ -10736,6 +10755,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" )
{
@@ -10853,6 +10892,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;
@@ -10875,6 +10915,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 );
}