sw/qa/extras/rtfimport/data/tdf54584.rtf | 4 ++++ sw/qa/extras/rtfimport/rtfimport.cxx | 10 ++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 7 +++++++ 3 files changed, 21 insertions(+)
New commits: commit a800cc780b60d61fd871ec5598c80a431e13903f Author: Mike Kaganski <mike.kagan...@collabora.com> Date: Sun Dec 6 21:39:11 2015 +1000 tdf#54584: allow backslash before field type in RTF and DOCX In some RTF and DOCX files, field type may be prepended with backslash. It seems not strictly standard-conformant (at least not to [MS-RTF]). Still, MS Word reads these fields OK. This patch allows LO to read them, too. Change-Id: I1f6bbdd9d57adbea8882d078761dd97298ca03b3 Reviewed-on: https://gerrit.libreoffice.org/20420 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/rtfimport/data/tdf54584.rtf b/sw/qa/extras/rtfimport/data/tdf54584.rtf new file mode 100644 index 0000000..2a497de --- /dev/null +++ b/sw/qa/extras/rtfimport/data/tdf54584.rtf @@ -0,0 +1,4 @@ +{\rtf1 +{\footer +Page {\field{\*\fldinst \\PAGE}}} +text} \ No newline at end of file diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 36eaf03..17cae46 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2373,6 +2373,16 @@ DECLARE_RTFIMPORT_TEST(testTdf59454, "tdf59454.rtf") CPPUNIT_ASSERT_EQUAL(2, getPages()); } +DECLARE_RTFIMPORT_TEST(testTdf54584, "tdf54584.rtf") +{ + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + // \PAGE was ignored, so no fields were in document -> exception was thrown + CPPUNIT_ASSERT_NO_THROW_MESSAGE("No fields in document found: field \"\\PAGE\" was not properly read", + xFields->nextElement()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 2d858d4..8e079ea 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2292,6 +2292,13 @@ lcl_SplitFieldCommand(const OUString& rCommand) std::vector<OUString> arguments; std::vector<OUString> switches; sal_Int32 nStartIndex(0); + // tdf#54584: Field may be prepended by a backslash - skip it + if ((rCommand.getLength() >= nStartIndex + 2) && + (rCommand[nStartIndex] == '\\') && + (rCommand[nStartIndex + 1] != '\\')) + { + ++nStartIndex; + } do { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits