Kaydet (Commit) ccf9b735 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Andras Timar

tdf#115861 DOCX import: avoid last-paragraph removal when discarding footer

Discarding header/footer is necessary when the document or section
settings request to ignore first or even headers/footers. In the bugdoc
case settings.xml didn't opt-in for different even/odd footers, but
there was an even footer to be ignored.

Handle this state at two more places, so we don't end up in a situation
where we ignore the footer but not its "remove last (empty) paragraph at
the end of the footer" action.

Also make the debug dumper for text ranges more robust to have a working
token dump when we try to get the string for a table.

(cherry picked from commit 49cf733e)

Change-Id: I6395f37aa40c42304e2c918d87dadecb21e9d378
Reviewed-on: https://gerrit.libreoffice.org/50884Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
(cherry picked from commit 0edb7585)
üst f67e3d18
...@@ -81,6 +81,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112694, "tdf112694.docx") ...@@ -81,6 +81,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112694, "tdf112694.docx")
CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn")); CPPUNIT_ASSERT(!getProperty<bool>(aPageStyle, "HeaderIsOn"));
} }
DECLARE_OOXMLEXPORT_TEST(testTdf115861, "tdf115861.docx")
{
// Second item in the paragraph enumeration was a table, 2nd paragraph was
// lost.
CPPUNIT_ASSERT_EQUAL(OUString("(k)"), getParagraph(2)->getString());
}
DECLARE_OOXMLEXPORT_TEST(testTdf67207_MERGEFIELD, "mailmerge.docx") DECLARE_OOXMLEXPORT_TEST(testTdf67207_MERGEFIELD, "mailmerge.docx")
{ {
uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField"); uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField");
......
...@@ -388,6 +388,9 @@ void DomainMapper_Impl::AddDummyParaForTableInSection() ...@@ -388,6 +388,9 @@ void DomainMapper_Impl::AddDummyParaForTableInSection()
void DomainMapper_Impl::RemoveLastParagraph( ) void DomainMapper_Impl::RemoveLastParagraph( )
{ {
if (m_bDiscardHeaderFooter)
return;
if (m_aTextAppendStack.empty()) if (m_aTextAppendStack.empty())
return; return;
uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend; uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
...@@ -1061,6 +1064,9 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( ) ...@@ -1061,6 +1064,9 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( )
void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap ) void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap )
{ {
if (m_bDiscardHeaderFooter)
return;
#ifdef DEBUG_WRITERFILTER #ifdef DEBUG_WRITERFILTER
TagLogger::getInstance().startElement("finishParagraph"); TagLogger::getInstance().startElement("finishParagraph");
#endif #endif
......
...@@ -34,7 +34,19 @@ std::string XTextRangeToString(uno::Reference< text::XTextRange > const & textRa ...@@ -34,7 +34,19 @@ std::string XTextRangeToString(uno::Reference< text::XTextRange > const & textRa
#ifdef DEBUG_WRITERFILTER #ifdef DEBUG_WRITERFILTER
if (textRange.get()) if (textRange.get())
{ {
OUString aOUStr = textRange->getString(); OUString aOUStr;
try
{
aOUStr = textRange->getString();
}
catch (const uno::Exception& rException)
{
result += "(exception: ";
result += rException.Message.toUtf8().getStr();
result += ")";
}
OString aOStr(aOUStr.getStr(), aOUStr.getLength(), RTL_TEXTENCODING_ASCII_US ); OString aOStr(aOUStr.getStr(), aOUStr.getLength(), RTL_TEXTENCODING_ASCII_US );
result = aOStr.getStr(); result = aOStr.getStr();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment