[Libreoffice-commits] core.git: sw/qa

Stephan Bergmann sbergman at redhat.com
Thu Mar 29 06:04:13 UTC 2018


 sw/qa/extras/rtfexport/rtfexport2.cxx |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

New commits:
commit ad284bde785fd1273565163e217be6bc8d4b7da9
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Mar 28 16:17:59 2018 +0200

    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 at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

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);


More information about the Libreoffice-commits mailing list