Kaydet (Commit) 829596eb authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 5420ef46
{\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
}
......@@ -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.
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment