summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-11-04 12:37:45 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-11-06 09:49:18 +0000
commit82c01116a7df315b78bfd3af6ccd936572b45d78 (patch)
tree50bd5c507d5198444a198e478aaaee03fb604f97
parentfae7fed54206b98cc3aac24abcdac384d3bd9437 (diff)
bnc#636128 DOC filter: fix handling of FFData.cch
(cherry picked from commit dfa26e6d489a2c5bd79652450a9f27343008d37f) (cherry picked from commit 2ad1f195b875f2c1052c8ffab79602b9f6871ccb) Change-Id: Ia1a3a4ef5e61d8ed2a3bde689f3d2101525efc46 Reviewed-on: https://gerrit.libreoffice.org/12257 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/qa/extras/ww8export/data/bnc636128.docbin0 -> 26112 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export.cxx10
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx10
-rw-r--r--sw/source/filter/ww8/ww8par.hxx4
-rw-r--r--sw/source/filter/ww8/ww8par3.cxx5
5 files changed, 26 insertions, 3 deletions
diff --git a/sw/qa/extras/ww8export/data/bnc636128.doc b/sw/qa/extras/ww8export/data/bnc636128.doc
new file mode 100644
index 000000000000..5f92c3e2ecd1
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/bnc636128.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 585755969bf4..3a9cf7cac62f 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -18,6 +18,7 @@
#include <com/sun/star/table/ShadowFormat.hpp>
#include <com/sun/star/table/TableBorder2.hpp>
#include <com/sun/star/text/GraphicCrop.hpp>
+#include <com/sun/star/text/XFormField.hpp>
class Test : public SwModelTestBase
{
@@ -347,6 +348,15 @@ DECLARE_WW8EXPORT_TEST(testBorderColoursExport, "bordercolours.odt")
}
#endif
+DECLARE_WW8EXPORT_TEST(testBnc636128, "bnc636128.doc")
+{
+ // Import / export of FFData.cch was missing.
+ uno::Reference<text::XFormField> xFormField = getProperty< uno::Reference<text::XFormField> >(getRun(getParagraph(1), 2), "Bookmark");
+ uno::Reference<container::XNameContainer> xParameters = xFormField->getParameters();
+ // This resulted in a container.NoSuchElementException.
+ CPPUNIT_ASSERT_EQUAL(OUString("5"), xParameters->getByName("MaxLength").get<OUString>());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index f52a273aacb3..5917aa601a1d 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3782,6 +3782,16 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
ffres = 0;
}
aFldHeader.bits |= ( (ffres<<2) & 0x7C );
+ if (type == 0) // iTypeText
+ {
+ sw::mark::IFieldmark::parameter_map_t::const_iterator pParameter = rFieldmark.GetParameters()->find("MaxLength");
+ if (pParameter != rFieldmark.GetParameters()->end())
+ {
+ OUString aLength;
+ pParameter->second >>= aLength;
+ aFldHeader.cch = aLength.toUInt32();
+ }
+ }
std::vector< OUString > aListItems;
if (type==2)
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index cbacc1f0d02a..a50724d084e9 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -617,7 +617,7 @@ public:
WW8FormulaControl(const OUString& rN, SwWW8ImplReader &rR)
: rRdr(rR), fUnknown(0), fDropdownIndex(0),
fToolTip(0), fNoMark(0), fUseSize(0), fNumbersOnly(0), fDateOnly(0),
- fUnused(0), nSize(0), hpsCheckBox(20), nChecked(0), sName( rN )
+ fUnused(0), nSize(0), hpsCheckBox(20), nChecked(0), mnMaxLen(0), sName( rN )
{
}
sal_uInt8 fUnknown:2;
@@ -633,6 +633,8 @@ public:
sal_uInt16 hpsCheckBox;
sal_uInt16 nChecked;
+ /// FFData.cch in the spec: maximum length, in characters, of the value of the textbox.
+ sal_uInt16 mnMaxLen;
OUString sTitle;
OUString sDefault;
OUString sFormatting;
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index b547cd080366..5e10c8d029b6 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -164,6 +164,8 @@ eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, OUString& rStr )
maFieldStack.back().SetBookmarkType(ODF_FORMTEXT);
maFieldStack.back().getParameters()["Description"] = uno::makeAny(OUString(aFormula.sToolTip));
maFieldStack.back().getParameters()["Name"] = uno::makeAny(OUString(aFormula.sTitle));
+ if (aFormula.mnMaxLen)
+ maFieldStack.back().getParameters()["MaxLength"] = uno::makeAny(OUString::number(aFormula.mnMaxLen));
}
return FLD_TEXT;
}
@@ -2173,8 +2175,7 @@ void WW8FormulaControl::FormulaRead(SwWw8ControlType nWhich,
sal_uInt8 iRes = (bits1 & 0x7C) >> 2;
- sal_uInt16 cch = 0;
- pDataStream->ReadUInt16( cch );
+ pDataStream->ReadUInt16( mnMaxLen );
sal_uInt16 hps = 0;
pDataStream->ReadUInt16( hps );