diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-03-28 16:17:59 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-03-29 08:03:46 +0200 |
commit | ad284bde785fd1273565163e217be6bc8d4b7da9 (patch) | |
tree | 246d3be9e0e4f21bfd48ac6c740d513cd847f55e /sw | |
parent | dcb9bd40810b773359464979eb7dbfddc03bc2d4 (diff) |
Always pass in a TextInsertModeRange
...otherwise testCopyPastePageStyle would have caused the call to
xFilter->filter in paste() to fail, throwing an "End of content node doesn't
have the proper start node" RuntimeException in
SwXBodyText::createTextCursorByRange (sw/source/core/unocore/unotext.cxx) called
from the writerfilter::dmapper::DomainMapper_Impl ctor
(writerfilter/source/dmapper/DomainMapper_Impl.cxx) (and which would be caught
and swallowed in RtfFilter::filter (writerfilter/source/filter/RtfFilter.cxx),
causing it to return false).
Change-Id: I83b720a365e06edc41c3d9c82614df488ee33d35
Reviewed-on: https://gerrit.libreoffice.org/52013
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport2.cxx | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx index 891dbd7606c2..b04f99a08e68 100644 --- a/sw/qa/extras/rtfexport/rtfexport2.cxx +++ b/sw/qa/extras/rtfexport/rtfexport2.cxx @@ -86,15 +86,14 @@ public: protected: /// Copy&paste helper. - void paste(const OUString& aFilename, uno::Reference<text::XTextRange> const& xTextRange - = uno::Reference<text::XTextRange>()) + void paste(const OUString& aFilename, uno::Reference<text::XTextRange> const& 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); + uno::Sequence<beans::PropertyValue> aDescriptor(3); aDescriptor[0].Name = "InputStream"; SvStream* pStream = utl::UcbStreamHelper::CreateStream( m_directories.getURLFromSrc("/sw/qa/extras/rtfexport/data/") + aFilename, @@ -103,11 +102,8 @@ protected: aDescriptor[0].Value <<= xStream; aDescriptor[1].Name = "InsertMode"; aDescriptor[1].Value <<= true; - if (xTextRange.is()) - { - aDescriptor[2].Name = "TextInsertModeRange"; - aDescriptor[2].Value <<= xTextRange; - } + aDescriptor[2].Name = "TextInsertModeRange"; + aDescriptor[2].Value <<= xTextRange; xFilter->filter(aDescriptor); } AllSettings m_aSavedSettings; @@ -640,7 +636,10 @@ DECLARE_RTFEXPORT_TEST(testCopyPastePageStyle, "copypaste-pagestyle.rtf") { // The problem was that RTF import during copy&paste did not ignore page styles. // Once we have more copy&paste tests, makes sense to refactor this to some helper method. - paste("copypaste-pagestyle-paste.rtf"); + 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("copypaste-pagestyle-paste.rtf", xEnd); uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); |