diff options
author | Justin Luth <justin.luth@collabora.com> | 2022-12-24 15:39:06 -0500 |
---|---|---|
committer | Justin Luth <jluth@mail.com> | 2022-12-26 13:47:14 +0000 |
commit | 6a46845839f0d7e6ca2b1586e3ab268dcdbb2dea (patch) | |
tree | 3a623ad5f831c194bb7d582e148dcc6fc6426245 | |
parent | 68c4dbcebed057084083b968f244b8c430a4dc60 (diff) |
tdf#151548 ww8export: export formfield names
This should have been looking for ODF_FORMCHECKBOX_NAME
for checkboxes instead of a never-created grabbag "name".
In any case, since LO 7.5 all the three true formfields
preserve their name in the name property, so no grabbags
are necessary any more.
Unforunately the unit test is not very good.
I copied it from the DOCX case, but I just can't
get it to fail - even without any patching.
Yet I know it is broken b/c it is broken in MS Word 2010,
but now it isn't broken after the patch round-trips it.
Change-Id: I88e92d4c6d0b0e26ba80c428e06e63859941a3ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144815
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf151548_formFieldMacros.doc | bin | 0 -> 43520 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export4.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 16 |
3 files changed, 19 insertions, 10 deletions
diff --git a/sw/qa/extras/ww8export/data/tdf151548_formFieldMacros.doc b/sw/qa/extras/ww8export/data/tdf151548_formFieldMacros.doc Binary files differnew file mode 100644 index 000000000000..4ea915f0afe4 --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf151548_formFieldMacros.doc diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index f409c8e8dfa8..1910178d0ac8 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -20,6 +20,7 @@ #include <o3tl/string_view.hxx> #include <docsh.hxx> +#include <IDocumentMarkAccess.hxx> #include <IDocumentSettingAccess.hxx> #include <unotxdoc.hxx> @@ -65,6 +66,18 @@ DECLARE_WW8EXPORT_TEST(testTdf117994_CRnumformatting, "tdf117994_CRnumformatting CPPUNIT_ASSERT_EQUAL(OUString("160"), parseDump("//body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", "font-height")); } +DECLARE_WW8EXPORT_TEST(testTdf151548_formFieldMacros, "tdf151548_formFieldMacros.doc") +{ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess(); + for(auto aIter = pMarkAccess->getFieldmarksBegin(); aIter != pMarkAccess->getFieldmarksEnd(); ++aIter) + { + const OUString sName = (*aIter)->GetName(); + CPPUNIT_ASSERT(sName == "Check1" || sName == "Check2" || sName == "Text1" || sName == "Dropdown1"); + } +} + 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 0e3765d39210..625583ee179f 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -4094,15 +4094,9 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) if ( rFieldmark.GetFieldname() == ODF_FORMDROPDOWN ) type=2; - ::sw::mark::IFieldmark::parameter_map_t::const_iterator pParameter = rFieldmark.GetParameters()->find("name"); - OUString ffname; - if ( pParameter != rFieldmark.GetParameters()->end() ) - { - OUString aName; - pParameter->second >>= aName; - const sal_Int32 nLen = std::min( sal_Int32(20), aName.getLength() ); - ffname = aName.copy(0, nLen); - } + OUString ffname = rFieldmark.GetName(); + if (ffname.getLength() > 20) + ffname = ffname.copy(0, 20); sal_uInt64 nDataStt = m_pDataStrm->Tell(); m_pChpPlc->AppendFkpEntry(Strm().Tell()); @@ -4154,10 +4148,12 @@ void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) OUString ffstattext; OUString ffentrymcr; OUString ffexitmcr; + + ::sw::mark::IFieldmark::parameter_map_t::const_iterator pParameter + = rFieldmark.GetParameters()->find("Type"); if (type == 0) // iTypeText { sal_uInt16 nType = 0; - pParameter = rFieldmark.GetParameters()->find("Type"); if ( pParameter != rFieldmark.GetParameters()->end() ) { OUString aType; |