[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Mar 30 11:53:58 UTC 2016
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 8de829c25511add434373e58e69df997d25e1e5c
Author: Miklos Vajna <vmiklos at 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.
(cherry picked from commit 829596eb36de32bd87b426d9ad11901eabeae7be)
Change-Id: I672bf8d1f63d7880227b7fa7b5c81f91e1877b2a
Reviewed-on: https://gerrit.libreoffice.org/23511
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
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 1c4b457..7c9c098 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>
@@ -1278,6 +1279,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 f9cf146..db18c5b 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -4438,7 +4438,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);
More information about the Libreoffice-commits
mailing list