summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-01 09:19:41 +0100
committerAndras Timar <andras.timar@collabora.com>2016-04-04 23:56:26 +0200
commitf2fda745d6f11ea599bcb36eb33fef305e07110e (patch)
tree89046a6d537120d9f6f779827bea469c7ee87834 /sw
parent6fdbedf117ed1929adb52e566174cdeaf44616db (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> (cherry picked from commit 8de829c25511add434373e58e69df997d25e1e5c)
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfimport/data/tdf96326.rtf27
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx15
2 files changed, 42 insertions, 0 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.