From be6261d522d24bd574602fee43715d46ea2710b2 Mon Sep 17 00:00:00 2001 From: Vasily Melenchuk Date: Mon, 25 Feb 2019 08:35:54 +0300 Subject: tdf#121440 writerfilter: do not use imported style for foot/endnotes Extra style is causing editing problem near footnote/endnote references. This behavior is a side effect of eaa9cf6a3069fba3d82c046f0041bfb537d9e648, allowing emission of these "technical" styles. Change-Id: I1885b92814746e7b5cd19f3ddd7bc22eb691615e Reviewed-on: https://gerrit.libreoffice.org/68304 Tested-by: Jenkins Reviewed-by: Thorsten Behrens (cherry picked from commit 691ca4e1a3e510d54894a1e7df7fa4ad9f9cba11) Reviewed-on: https://gerrit.libreoffice.org/68583 --- sw/CppunitTest_sw_ooxmlimport2.mk | 1 + sw/qa/extras/ooxmlimport/data/tdf121440.docx | Bin 0 -> 23209 bytes sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 17 +++++++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 ++++++ 4 files changed, 24 insertions(+) create mode 100644 sw/qa/extras/ooxmlimport/data/tdf121440.docx diff --git a/sw/CppunitTest_sw_ooxmlimport2.mk b/sw/CppunitTest_sw_ooxmlimport2.mk index d170cb822b2e..0b53d30b2999 100644 --- a/sw/CppunitTest_sw_ooxmlimport2.mk +++ b/sw/CppunitTest_sw_ooxmlimport2.mk @@ -39,6 +39,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_ooxmlimport2,\ $(eval $(call gb_CppunitTest_set_include,sw_ooxmlimport2,\ -I$(SRCDIR)/sw/inc \ -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/source/uibase/inc \ -I$(SRCDIR)/sw/qa/extras/inc \ $$(INCLUDE) \ )) diff --git a/sw/qa/extras/ooxmlimport/data/tdf121440.docx b/sw/qa/extras/ooxmlimport/data/tdf121440.docx new file mode 100644 index 000000000000..023599aec3ff Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf121440.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 45480023495f..a5271cd6332e 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -18,6 +18,7 @@ #endif #include +#include #include #include #include @@ -251,6 +252,22 @@ DECLARE_OOXMLIMPORT_TEST(testTdf122224, "tdf122224.docx") CPPUNIT_ASSERT_EQUAL(OUString("2000"), xCell->getString()); } +DECLARE_OOXMLIMPORT_TEST(testTdf121440, "tdf121440.docx") +{ + // Insert some text in front of footnote + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + SwRootFrame* pLayout(pWrtShell->GetLayout()); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); + pWrtShell->Insert("test"); + + // Ensure that inserted text is not superscripted + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Inserted text should be not a superscript!", static_cast(0), + getProperty(getRun(getParagraph(1), 1), "CharEscapement")); +} + // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 82db1031bc88..1ee7cc8600de 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1839,6 +1839,12 @@ void DomainMapper_Impl::PushFootOrEndnote( bool bIsFootnote ) m_aRedlines.push(std::vector< RedlineParamsPtr >()); PropertyMapPtr pTopContext = GetTopContext(); + + // Remove style reference, if any. This reference did appear here as a side effect of tdf#43017 + // Seems it is not required by LO, but causes side effects during editing. So remove it + // for footnotes/endnotes to restore original LO behavior here. + pTopContext->Erase(PROP_CHAR_STYLE_NAME); + uno::Reference< text::XText > xFootnoteText; if (GetTextFactory().is()) xFootnoteText.set( GetTextFactory()->createInstance( -- cgit v1.2.3