sw/qa/extras/ww8export/data/tdf151548_formFieldMacros.doc |binary sw/qa/extras/ww8export/ww8export4.cxx | 13 +++++++++++ sw/source/filter/ww8/wrtww8.cxx | 16 +++++--------- 3 files changed, 19 insertions(+), 10 deletions(-)
New commits: commit 6a46845839f0d7e6ca2b1586e3ab268dcdbb2dea Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Sat Dec 24 15:39:06 2022 -0500 Commit: Justin Luth <jl...@mail.com> CommitDate: Mon Dec 26 13:47:14 2022 +0000 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 <jl...@mail.com> diff --git a/sw/qa/extras/ww8export/data/tdf151548_formFieldMacros.doc b/sw/qa/extras/ww8export/data/tdf151548_formFieldMacros.doc new file mode 100644 index 000000000000..4ea915f0afe4 Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf151548_formFieldMacros.doc differ 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;