diff options
author | Justin Luth <jluth@mail.com> | 2022-08-11 09:29:58 -0400 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-01-03 12:40:14 +0000 |
commit | e85070c43018fe64f3bcf48ff854e7a5560b15c4 (patch) | |
tree | 78da0befe43f527d6a0ed39997562d6c85e9e69f | |
parent | 21c8dc9a87a811fef0bc11da3f3448397a396d79 (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>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144822
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | solenv/clang-format/excludelist | 1 | ||||
-rw-r--r-- | sw/CppunitTest_sw_ww8export4.mk | 14 | ||||
-rw-r--r-- | sw/Module_sw.mk | 1 | ||||
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf151548_formFieldMacros.doc | bin | 0 -> 43520 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export4.cxx | 57 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 16 |
6 files changed, 79 insertions, 10 deletions
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index d3b97ee92735..e32a452a98d0 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -12327,6 +12327,7 @@ sw/qa/extras/uiwriter/uiwriter.cxx sw/qa/extras/ww8export/ww8export.cxx sw/qa/extras/ww8export/ww8export2.cxx sw/qa/extras/ww8export/ww8export3.cxx +sw/qa/extras/ww8export/ww8export4.cxx sw/qa/extras/ww8import/ww8import.cxx sw/qa/inc/bordertest.hxx sw/qa/inc/swmodeltestbase.hxx diff --git a/sw/CppunitTest_sw_ww8export4.mk b/sw/CppunitTest_sw_ww8export4.mk new file mode 100644 index 000000000000..47ac483ba688 --- /dev/null +++ b/sw/CppunitTest_sw_ww8export4.mk @@ -0,0 +1,14 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call sw_ww8export_test,4)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index a9583fca3bb4..8ad8313c28ae 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -100,6 +100,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_ww8export \ CppunitTest_sw_ww8export2 \ CppunitTest_sw_ww8export3 \ + CppunitTest_sw_ww8export4 \ CppunitTest_sw_ww8import \ CppunitTest_sw_rtfimport \ CppunitTest_sw_odfexport \ 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 new file mode 100644 index 000000000000..f686cd99d021 --- /dev/null +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/text/XTextDocument.hpp> + +#include <comphelper/sequenceashashmap.hxx> +#include <o3tl/string_view.hxx> + +#include <docsh.hxx> +#include <IDocumentMarkAccess.hxx> +#include <IDocumentSettingAccess.hxx> +#include <unotxdoc.hxx> + +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/extras/ww8export/data/", "MS Word 97") + { + } + + bool mustTestImportOf(const char* filename) const override + { + // If the testcase is stored in some other format, it's pointless to test. + return o3tl::ends_with(filename, ".doc"); + } +}; + + +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 d179858fd3f3..1eba84327404 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -4095,15 +4095,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 = pDataStrm->Tell(); m_pChpPlc->AppendFkpEntry(Strm().Tell()); @@ -4155,10 +4149,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; |