Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/3404
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/04/3404/1
fdo#61193 fix crash on RTF paste of footnote
Regression from 232ad2f2588beff50cb5c1f3b689c581ba317583.
(cherry picked from commit e7664052d6693598e773f4c9dd6b819213d80d60)
Change-Id: Ia0873851979df5bba0a4693f044aab2aeff2b8e4
---
A sw/qa/extras/rtfimport/data/fdo61193.rtf
A sw/qa/extras/rtfimport/data/hello.rtf
M sw/qa/extras/rtfimport/rtfimport.cxx
M writerfilter/source/dmapper/DomainMapper_Impl.cxx
4 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/sw/qa/extras/rtfimport/data/fdo61193.rtf b/sw/qa/extras/rtfimport/data/fdo61193.rtf
new file mode 100644
index 0000000..6618bda
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo61193.rtf
@@ -0,0 +1 @@
+{\rtf1\ansi text.{\footnote footnote}}
diff --git a/sw/qa/extras/rtfimport/data/hello.rtf b/sw/qa/extras/rtfimport/data/hello.rtf
new file mode 100644
index 0000000..472817d
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/hello.rtf
@@ -0,0 +1 @@
+{\rtf1 Hello world!\par}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 6a70ad7..246358e 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -145,6 +145,7 @@
void testFdo62288();
void testFdo37716();
void testFdo51916();
+ void testFdo61193();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -156,6 +157,26 @@
void run();
/// Get page count.
int getPages();
+ /// Copy&paste helper.
+ void paste(OUString aFilename, uno::Reference<text::XTextRange> xTextRange =
uno::Reference<text::XTextRange>())
+ {
+ uno::Reference<document::XFilter>
xFilter(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
+ xImporter->setTargetDocument(mxComponent);
+ uno::Sequence<beans::PropertyValue> aDescriptor(xTextRange.is() ? 3 : 2);
+ aDescriptor[0].Name = "InputStream";
+ SvStream* pStream =
utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + aFilename,
STREAM_WRITE);
+ uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+ aDescriptor[0].Value <<= xStream;
+ aDescriptor[1].Name = "IsNewDoc";
+ aDescriptor[1].Value <<= sal_False;
+ if (xTextRange.is())
+ {
+ aDescriptor[2].Name = "TextInsertModeRange";
+ aDescriptor[2].Value <<= xTextRange;
+ }
+ xFilter->filter(aDescriptor);
+ }
};
void Test::run()
@@ -240,6 +261,7 @@
{"fdo62288.rtf", &Test::testFdo62288},
{"fdo37716.rtf", &Test::testFdo37716},
{"fdo51916.rtf", &Test::testFdo51916},
+ {"hello.rtf", &Test::testFdo61193},
};
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{
@@ -906,6 +928,15 @@
CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange->getString());
}
+void Test::testFdo61193()
+{
+ // Pasting content that contained a footnote caused a crash.
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xEnd = xText->getEnd();
+ paste("fdo61193.rtf", xEnd);
+}
+
void Test::testShptxtPard()
{
// The problem was that \pard inside \shptxt caused loss of shape text
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 6074add..deda4f1 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -726,6 +726,8 @@
void DomainMapper_Impl::CheckUnregisteredFrameConversion( )
{
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
+ if (m_aTextAppendStack.empty())
+ return;
TextAppendContext& rAppendContext = m_aTextAppendStack.top();
// n#779642: ignore fly frame inside table as it could lead to messy situations
if( rAppendContext.pLastParagraphProperties.get() &&
rAppendContext.pLastParagraphProperties->IsFrameMode()
@@ -969,6 +971,8 @@
#endif
ParagraphPropertyMap* pParaContext = dynamic_cast< ParagraphPropertyMap* >( pPropertyMap.get()
);
+ if (!m_aTextAppendStack.size())
+ return;
TextAppendContext& rAppendContext = m_aTextAppendStack.top();
uno::Reference< text::XTextAppend > xTextAppend;
if (!m_aTextAppendStack.empty())
@@ -1453,14 +1457,14 @@
}
appendTextContent( uno::Reference< text::XTextContent >( xFootnoteText,
uno::UNO_QUERY_THROW ), aFontProperties );
m_aTextAppendStack.push(TextAppendContext(uno::Reference< text::XTextAppend >(
xFootnoteText, uno::UNO_QUERY_THROW ),
- m_bIsNewDoc ? uno::Reference<text::XTextCursor>() :
m_xBodyText->createTextCursorByRange(xFootnoteText->getStart())));
+ m_bIsNewDoc ? uno::Reference<text::XTextCursor>() :
xFootnoteText->createTextCursorByRange(xFootnoteText->getStart())));
// Redlines for the footnote anchor
CheckRedline( xFootnote->getAnchor( ) );
}
- catch( const uno::Exception& )
+ catch( const uno::Exception& e )
{
- OSL_FAIL( "exception in PushFootOrEndnote" );
+ SAL_WARN("writerfilter", "exception in PushFootOrEndnote: " << e.Message);
}
}
--
To view, visit https://gerrit.libreoffice.org/3404
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia0873851979df5bba0a4693f044aab2aeff2b8e4
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Miklos Vajna <vmiklos@suse.cz>
Context
- [PATCH libreoffice-4-0] fdo#61193 fix crash on RTF paste of footnote · Miklos Vajna (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.