summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-01 09:19:41 +0100
committerMichael Stahl <mstahl@redhat.com>2016-03-30 11:53:37 +0000
commit8de829c25511add434373e58e69df997d25e1e5c (patch)
tree2fa6b6edcb060e20ecc4ab35ddd0b672c946b717
parent490ce780fa876ec14055d95339933ea0081ce0e7 (diff)
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@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sw/qa/extras/rtfimport/data/tdf96326.rtf27
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx15
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx3
3 files changed, 44 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfimport/data/tdf96326.rtf b/sw/qa/extras/rtfimport/data/tdf96326.rtf
new file mode 100644
index 000000000000..a19303f4cf43
--- /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 1c4b45741b14..7c9c09872226 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 f9cf14618b63..db18c5b513e6 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);