sw/qa/extras/ooxmlexport/ooxmlexport10.cxx |   27 +--------------------------
 sw/qa/extras/rtfexport/rtfexport2.cxx      |   14 ++++++++------
 sw/qa/extras/rtfexport/rtfexport5.cxx      |    2 +-
 sw/qa/extras/rtfexport/rtfexport6.cxx      |    4 ++--
 sw/qa/extras/rtfimport/rtfimport.cxx       |    8 ++++----
 sw/qa/inc/swmodeltestbase.hxx              |    2 +-
 sw/qa/unit/swmodeltestbase.cxx             |    6 +++---
 7 files changed, 20 insertions(+), 43 deletions(-)

New commits:
commit 34331280c89e51331303fd6f7d5b39aadf88b638
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Apr 11 12:48:46 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Apr 11 15:44:38 2023 +0200

    sw: remove duplicated code
    
    Change-Id: I200061d0624318abdc8f2850661a0b8c0005bfe3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150227
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index c4464f9d5cfb..3065083f9254 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -13,7 +13,6 @@
 #include <com/sun/star/awt/FontUnderline.hpp>
 #include <com/sun/star/awt/FontWeight.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
-#include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
 #include <com/sun/star/text/TableColumnSeparator.hpp>
 #include <com/sun/star/text/VertOrientation.hpp>
@@ -27,19 +26,13 @@
 #include <com/sun/star/text/SizeType.hpp>
 #include <com/sun/star/text/XDocumentIndex.hpp>
 #include <com/sun/star/style/CaseMap.hpp>
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
 
 #include <tools/UnitConversion.hxx>
 #include <unotools/fltrcfg.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 #include <oox/drawingml/drawingmltypes.hxx>
-#include <unotools/streamwrap.hxx>
-#include <comphelper/propertysequence.hxx>
 #include <svx/svdpage.hxx>
-#include <unotools/ucbstreamhelper.hxx>
-#include <o3tl/string_view.hxx>
 
 #include <drawdoc.hxx>
 #include <IDocumentDrawModelAccess.hxx>
@@ -71,24 +64,6 @@ public:
         }
         return nullptr;
     }
-
-protected:
-    /// Copy&paste helper.
-    bool paste(std::u16string_view rFilename, const 
uno::Reference<text::XTextRange>& xTextRange)
-    {
-        uno::Reference<document::XFilter> 
xFilter(m_xSFactory->createInstance("com.sun.star.comp.Writer.WriterFilter"), 
uno::UNO_QUERY_THROW);
-        uno::Reference<document::XImporter> xImporter(xFilter, 
uno::UNO_QUERY_THROW);
-        xImporter->setTargetDocument(mxComponent);
-        std::unique_ptr<SvStream> pStream = 
utl::UcbStreamHelper::CreateStream(m_directories.getURLFromSrc(u"/sw/qa/extras/ooxmlexport/data/")
 + rFilename, StreamMode::READ);
-        uno::Reference<io::XStream> xStream(new 
utl::OStreamWrapper(std::move(pStream)));
-        uno::Sequence<beans::PropertyValue> 
aDescriptor(comphelper::InitPropertySequence(
-        {
-            {"InputStream", uno::Any(xStream)},
-            {"InputMode", uno::Any(true)},
-            {"TextInsertModeRange", uno::Any(xTextRange)},
-        }));
-        return xFilter->filter(aDescriptor);
-    }
 };
 
 DECLARE_OOXMLEXPORT_TEST(testWPGtextboxes, "testWPGtextboxes.docx")
@@ -1160,7 +1135,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf94374)
     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
     // This failed: it wasn't possible to insert a DOCX document into an 
existing Writer one.
-    CPPUNIT_ASSERT(paste(u"tdf94374.docx", xEnd));
+    paste(u"ooxmlexport/data/tdf94374.docx", 
"com.sun.star.comp.Writer.WriterFilter", xEnd);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf83300, "tdf83300.docx")
diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx 
b/sw/qa/extras/rtfexport/rtfexport2.cxx
index 03d24c40be03..be7c31796612 100644
--- a/sw/qa/extras/rtfexport/rtfexport2.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport2.cxx
@@ -581,7 +581,8 @@ CPPUNIT_TEST_FIXTURE(Test, testCopyPastePageStyle)
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
-    paste(u"rtfexport/data/copypaste-pagestyle-paste.rtf", xEnd);
+    paste(u"rtfexport/data/copypaste-pagestyle-paste.rtf", 
"com.sun.star.comp.Writer.RtfFilter",
+          xEnd);
 
     uno::Reference<beans::XPropertySet> 
xPropertySet(getStyles("PageStyles")->getByName("Standard"),
                                                      uno::UNO_QUERY);
@@ -596,7 +597,8 @@ CPPUNIT_TEST_FIXTURE(Test, testCopyPasteFootnote)
     uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<container::XIndexAccess> xFootnotes = 
xFootnotesSupplier->getFootnotes();
     uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), 
uno::UNO_QUERY);
-    paste(u"rtfexport/data/copypaste-footnote-paste.rtf", xTextRange);
+    paste(u"rtfexport/data/copypaste-footnote-paste.rtf", 
"com.sun.star.comp.Writer.RtfFilter",
+          xTextRange);
 
     CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange->getString());
 }
@@ -608,7 +610,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo63428)
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
-    paste(u"rtfexport/data/fdo63428.rtf", xEnd);
+    paste(u"rtfexport/data/fdo63428.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
 
     // Additionally, commented range was imported as a normal comment.
     CPPUNIT_ASSERT_EQUAL(OUString("Annotation"),
@@ -633,7 +635,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo69384Inserted)
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
-    paste(u"rtfexport/data/fdo69384-paste.rtf", xEnd);
+    paste(u"rtfexport/data/fdo69384-paste.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
 
     // During insert of the RTF document we do not change pre-existing styles
     // vs testFdo69384 where it is
@@ -649,7 +651,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo61193)
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
-    paste(u"rtfexport/data/fdo61193.rtf", xEnd);
+    paste(u"rtfexport/data/fdo61193.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf108123)
@@ -660,7 +662,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf108123)
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
-    paste(u"rtfexport/data/tdf108123.rtf", xEnd);
+    paste(u"rtfexport/data/tdf108123.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
 }
 
 DECLARE_RTFEXPORT_TEST(testShptxtPard, "shptxt-pard.rtf")
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx 
b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 3e86a2f3c642..c8b9ac0dc206 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -156,7 +156,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo62044)
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
-    paste(u"rtfexport/data/fdo62044-paste.rtf", xEnd);
+    paste(u"rtfexport/data/fdo62044-paste.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
 
     uno::Reference<beans::XPropertySet> xPropertySet(
         getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
diff --git a/sw/qa/extras/rtfexport/rtfexport6.cxx 
b/sw/qa/extras/rtfexport/rtfexport6.cxx
index 4078030804e7..ffe786097541 100644
--- a/sw/qa/extras/rtfexport/rtfexport6.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport6.cxx
@@ -146,7 +146,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf90260Nopar)
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
-    paste(u"rtfexport/data/tdf90260-nopar.rtf", xEnd);
+    paste(u"rtfexport/data/tdf90260-nopar.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
     CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
 }
 
@@ -324,7 +324,7 @@ CPPUNIT_TEST_FIXTURE(Test, testClassificatonPasteLevels)
     // Classified source and classified destination, but internal only has a
     // higher level than confidential: nothing should happen.
     OUString aOld = xText->getString();
-    paste(u"rtfexport/data/classification-yes.rtf", xEnd);
+    paste(u"rtfexport/data/classification-yes.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
     CPPUNIT_ASSERT_EQUAL(aOld, xText->getString());
 }
 
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx 
b/sw/qa/extras/rtfimport/rtfimport.cxx
index 37acceaa7d6c..05bfaf66d6f7 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -835,7 +835,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo68291)
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
-    paste(u"rtfimport/data/fdo68291-paste.rtf", xEnd);
+    paste(u"rtfimport/data/fdo68291-paste.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
 
     // This was "Standard", causing an unwanted page break on next paste.
     CPPUNIT_ASSERT_EQUAL(uno::Any(),
@@ -1241,7 +1241,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf90260Par)
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xText = xTextDocument->getText();
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
-    paste(u"rtfimport/data/tdf90260-par.rtf", xEnd);
+    paste(u"rtfimport/data/tdf90260-par.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
     CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
 }
 
@@ -1352,12 +1352,12 @@ CPPUNIT_TEST_FIXTURE(Test, testClassificatonPaste)
     uno::Reference<text::XTextRange> xEnd = xText->getEnd();
 
     // Not classified source, not classified destination: OK.
-    paste(u"rtfimport/data/classification-no.rtf", xEnd);
+    paste(u"rtfimport/data/classification-no.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
     CPPUNIT_ASSERT_EQUAL(OUString("classification-no"), 
getParagraph(2)->getString());
 
     // Classified source, not classified destination: nothing should happen.
     OUString aOld = xText->getString();
-    paste(u"rtfimport/data/classification-yes.rtf", xEnd);
+    paste(u"rtfimport/data/classification-yes.rtf", 
"com.sun.star.comp.Writer.RtfFilter", xEnd);
     CPPUNIT_ASSERT_EQUAL(aOld, xText->getString());
 }
 
diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx
index 380b59040a16..4e62d3b07ff7 100644
--- a/sw/qa/inc/swmodeltestbase.hxx
+++ b/sw/qa/inc/swmodeltestbase.hxx
@@ -104,7 +104,7 @@ protected:
     virtual OUString getTestName() { return OUString(); }
 
     /// Copy&paste helper.
-    void paste(std::u16string_view aFilename, 
css::uno::Reference<css::text::XTextRange> const& xTextRange);
+    void paste(std::u16string_view aFilename, OUString aInstance, 
css::uno::Reference<css::text::XTextRange> const& xTextRange);
 
 public:
     /// Temporarily enables DOCX::ImportFloatingTableAsSplitFly.
diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx
index a5d32101068a..496f1ed713f0 100644
--- a/sw/qa/unit/swmodeltestbase.cxx
+++ b/sw/qa/unit/swmodeltestbase.cxx
@@ -54,11 +54,11 @@ SwModelTestBase::FlySplitGuard::~FlySplitGuard()
     pChanges->commit();
 }
 
-void SwModelTestBase::paste(std::u16string_view aFilename,
+void SwModelTestBase::paste(std::u16string_view aFilename, OUString aInstance,
                             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::XFilter> 
xFilter(m_xSFactory->createInstance(aInstance),
+                                              uno::UNO_QUERY_THROW);
     uno::Reference<document::XImporter> xImporter(xFilter, 
uno::UNO_QUERY_THROW);
     xImporter->setTargetDocument(mxComponent);
     std::unique_ptr<SvStream> pStream = utl::UcbStreamHelper::CreateStream(

Reply via email to