sw/qa/extras/rtfimport/data/tdf96326.rtf | 27 +++++++++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 15 +++++++++++++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 3 +- 3 files changed, 44 insertions(+), 1 deletion(-)
New commits: commit 829596eb36de32bd87b426d9ad11901eabeae7be Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Mar 1 09:19:41 2016 +0100 tdf#96326 RTF import: handle checkbox form field undefined result The RTF spec is quite terse on how the form filed result should be interpreted, but the binary equivalent documents properly that checkboxes have 3 valid states: 0, 1 and 25, the later meaning undefined. Use the default value in that case. Change-Id: I672bf8d1f63d7880227b7fa7b5c81f91e1877b2a diff --git a/sw/qa/extras/rtfimport/data/tdf96326.rtf b/sw/qa/extras/rtfimport/data/tdf96326.rtf new file mode 100644 index 0000000..a19303f --- /dev/null +++ b/sw/qa/extras/rtfimport/data/tdf96326.rtf @@ -0,0 +1,27 @@ +{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033\themelang1035\themelangfe0\themelangcs0 +\pard\plain +This is not checked: +{\field\flddirty\fldpriv +{\*\fldinst + FORMCHECKBOX +{\*\formfield +{\fftype1\ffres25\fftypetxt0\ffhps20 +\ffdefres0} +} +} +{\fldrslt } +} +\par +This is checked: +{\field\fldpriv +{\*\fldinst + FORMCHECKBOX +{\*\formfield +{\fftype1\ffres25\fftypetxt0\ffhps20 +\ffdefres1} +} +} +{\fldrslt } +} +\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 699278a..3d1c77e 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -49,6 +49,7 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/text/XFormField.hpp> #include <rtl/ustring.hxx> #include <vcl/outdev.hxx> @@ -1283,6 +1284,20 @@ DECLARE_RTFIMPORT_TEST(testPoshPosv, "posh-posv.rtf") CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getShape(1), "FrameIsAutomaticHeight")); } +DECLARE_RTFIMPORT_TEST(testTdf96326, "tdf96326.rtf") +{ + // Make sure this is not checked. + auto xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(1), 2), "Bookmark"); + uno::Reference<container::XNameContainer> xParameters = xFormField->getParameters(); + // This was true, ffres=25 was interpreted as checked. + CPPUNIT_ASSERT_EQUAL(false, bool(xParameters->hasElements())); + + // And this is checked. + xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(2), 2), "Bookmark"); + xParameters = xFormField->getParameters(); + CPPUNIT_ASSERT_EQUAL(true, xParameters->getByName("Checkbox_Checked").get<bool>()); +} + DECLARE_RTFIMPORT_TEST(testN825305, "n825305.rtf") { // The problem was that the textbox wasn't transparent, due to unimplemented fFilled == 0. diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 32a10a2..59ad5ee 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -4462,7 +4462,8 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFDDList_default, pIntValue); break; case RTF_FFRES: - if (m_nFormFieldType == RTFFormFieldType::CHECKBOX) + // 25 means undefined, see [MS-DOC] 2.9.79, FFDataBits. + if (m_nFormFieldType == RTFFormFieldType::CHECKBOX && nParam != 25) m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFCheckBox_checked, pIntValue); else if (m_nFormFieldType == RTFFormFieldType::LIST) m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFDDList_result, pIntValue); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits