[Libreoffice-commits] core.git: sw/qa
Stephan Bergmann
sbergman at redhat.com
Thu Mar 29 18:09:06 UTC 2018
sw/qa/extras/inc/swmodeltestbase.hxx | 26 +++++++++++++++++++++
sw/qa/extras/rtfexport/rtfexport2.cxx | 42 +++++++---------------------------
sw/qa/extras/rtfimport/rtfimport.cxx | 37 +++--------------------------
3 files changed, 39 insertions(+), 66 deletions(-)
New commits:
commit f04f48e1517509930ba34bf7bd5b412508b7b7a2
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Mar 29 18:33:30 2018 +0200
Clean up copy/paste (of a function called "paste")
Change-Id: Iea48bb3304e2688b440c5c396ed340ffffa11568
Reviewed-on: https://gerrit.libreoffice.org/52121
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index de9db84162f5..5a11a088b9ba 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -13,6 +13,8 @@
#include <memory>
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
@@ -35,6 +37,7 @@
#include <test/xmltesttools.hxx>
#include <test/testinteractionhandler.hxx>
#include <unotest/macros_test.hxx>
+#include <unotools/streamwrap.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
@@ -180,6 +183,29 @@ protected:
virtual OUString getTestName() { return OUString(); }
+ /// Copy&paste helper.
+ 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(3);
+ aDescriptor[0].Name = "InputStream";
+ SvStream* pStream = utl::UcbStreamHelper::CreateStream(
+ m_directories.getURLFromSrc("/sw/qa/extras/") + aFilename,
+ StreamMode::STD_READ);
+ CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, pStream->GetError());
+ uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+ aDescriptor[0].Value <<= xStream;
+ aDescriptor[1].Name = "InsertMode";
+ aDescriptor[1].Value <<= true;
+ aDescriptor[2].Name = "TextInsertModeRange";
+ aDescriptor[2].Value <<= xTextRange;
+ CPPUNIT_ASSERT(xFilter->filter(aDescriptor));
+ }
+
public:
void setFilterOptions(const OUString &rFilterOptions)
{
diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx
index b04f99a08e68..571c96e5d6a2 100644
--- a/sw/qa/extras/rtfexport/rtfexport2.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport2.cxx
@@ -11,8 +11,6 @@
#include <swmodeltestbase.hxx>
#include <com/sun/star/awt/FontWeight.hpp>
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/graphic/GraphicType.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -46,7 +44,6 @@
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <unotools/ucbstreamhelper.hxx>
-#include <unotools/streamwrap.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/configuration.hxx>
@@ -85,27 +82,6 @@ public:
}
protected:
- /// Copy&paste helper.
- 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(3);
- aDescriptor[0].Name = "InputStream";
- SvStream* pStream = utl::UcbStreamHelper::CreateStream(
- m_directories.getURLFromSrc("/sw/qa/extras/rtfexport/data/") + aFilename,
- StreamMode::WRITE);
- uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
- aDescriptor[0].Value <<= xStream;
- aDescriptor[1].Name = "InsertMode";
- aDescriptor[1].Value <<= true;
- aDescriptor[2].Name = "TextInsertModeRange";
- aDescriptor[2].Value <<= xTextRange;
- xFilter->filter(aDescriptor);
- }
AllSettings m_aSavedSettings;
};
@@ -639,7 +615,7 @@ DECLARE_RTFEXPORT_TEST(testCopyPastePageStyle, "copypaste-pagestyle.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);
+ paste("rtfexport/data/copypaste-pagestyle-paste.rtf", xEnd);
uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Standard"),
uno::UNO_QUERY);
@@ -656,7 +632,7 @@ DECLARE_RTFEXPORT_TEST(testCopyPasteFootnote, "copypaste-footnote.rtf")
uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(),
uno::UNO_QUERY);
uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
- paste("copypaste-footnote-paste.rtf", xTextRange);
+ paste("rtfexport/data/copypaste-footnote-paste.rtf", xTextRange);
CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange->getString());
}
@@ -667,7 +643,7 @@ DECLARE_RTFEXPORT_TEST(testFdo63428, "hello.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("fdo63428.rtf", xEnd);
+ paste("rtfexport/data/fdo63428.rtf", xEnd);
// Additionally, commented range was imported as a normal comment.
CPPUNIT_ASSERT_EQUAL(OUString("Annotation"),
@@ -689,7 +665,7 @@ DECLARE_RTFEXPORT_TEST(testFdo69384Inserted, "hello.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("fdo69384-paste.rtf", xEnd);
+ paste("rtfexport/data/fdo69384-paste.rtf", xEnd);
// During insert of the RTF document we do not insert new styles
CPPUNIT_ASSERT(!getStyles("ParagraphStyles")->hasByName("Text body justified"));
@@ -701,7 +677,7 @@ DECLARE_RTFEXPORT_TEST(testFdo61193, "hello.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("fdo61193.rtf", xEnd);
+ paste("rtfexport/data/fdo61193.rtf", xEnd);
}
DECLARE_RTFEXPORT_TEST(testTdf108123, "hello.rtf")
@@ -711,7 +687,7 @@ DECLARE_RTFEXPORT_TEST(testTdf108123, "hello.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("tdf108123.rtf", xEnd);
+ paste("rtfexport/data/tdf108123.rtf", xEnd);
}
DECLARE_RTFEXPORT_TEST(testShptxtPard, "shptxt-pard.rtf")
@@ -1060,7 +1036,7 @@ DECLARE_RTFEXPORT_TEST(testFdo62044, "fdo62044.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("fdo62044-paste.rtf", xEnd);
+ paste("rtfexport/data/fdo62044-paste.rtf", xEnd);
uno::Reference<beans::XPropertySet> xPropertySet(
getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
@@ -1724,7 +1700,7 @@ DECLARE_RTFEXPORT_TEST(testTdf90260Nopar, "hello.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("tdf90260-nopar.rtf", xEnd);
+ paste("rtfexport/data/tdf90260-nopar.rtf", xEnd);
CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
}
@@ -1869,7 +1845,7 @@ DECLARE_RTFEXPORT_TEST(testClassificatonPasteLevels, "classification-confidentia
// Classified source and classified destination, but internal only has a
// higher level than confidential: nothing should happen.
OUString aOld = xText->getString();
- paste("classification-yes.rtf", xEnd);
+ paste("rtfexport/data/classification-yes.rtf", xEnd);
CPPUNIT_ASSERT_EQUAL(aOld, xText->getString());
}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index a99ba78d5aa9..ee9b1711f165 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -12,8 +12,6 @@
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/awt/FontUnderline.hpp>
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
@@ -44,7 +42,6 @@
#include <rtl/ustring.hxx>
#include <vcl/settings.hxx>
#include <unotools/ucbstreamhelper.hxx>
-#include <unotools/streamwrap.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/configuration.hxx>
@@ -57,32 +54,6 @@ public:
}
protected:
- /// Copy&paste helper.
- void paste(const OUString& aFilename, uno::Reference<text::XTextRange> const& 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(
- m_directories.getURLFromSrc("/sw/qa/extras/rtfimport/data/") + aFilename,
- StreamMode::STD_READ);
- CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, pStream->GetError());
- uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
- aDescriptor[0].Value <<= xStream;
- aDescriptor[1].Name = "InsertMode";
- aDescriptor[1].Value <<= true;
- if (xTextRange.is())
- {
- aDescriptor[2].Name = "TextInsertModeRange";
- aDescriptor[2].Value <<= xTextRange;
- }
- CPPUNIT_ASSERT(xFilter->filter(aDescriptor));
- }
AllSettings m_aSavedSettings;
};
@@ -744,7 +715,7 @@ DECLARE_RTFIMPORT_TEST(testFdo68291, "fdo68291.odt")
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("fdo68291-paste.rtf", xEnd);
+ paste("rtfimport/data/fdo68291-paste.rtf", xEnd);
// This was "Standard", causing an unwanted page break on next paste.
CPPUNIT_ASSERT_EQUAL(uno::Any(),
@@ -1133,7 +1104,7 @@ DECLARE_RTFIMPORT_TEST(testTdf90260Par, "hello.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("tdf90260-par.rtf", xEnd);
+ paste("rtfimport/data/tdf90260-par.rtf", xEnd);
CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
}
@@ -1229,12 +1200,12 @@ DECLARE_RTFIMPORT_TEST(testClassificatonPaste, "hello.rtf")
uno::Reference<text::XTextRange> xEnd = xText->getEnd();
// Not classified source, not classified destination: OK.
- paste("classification-no.rtf", xEnd);
+ paste("rtfimport/data/classification-no.rtf", xEnd);
CPPUNIT_ASSERT_EQUAL(OUString("classification-no"), getParagraph(2)->getString());
// Classified source, not classified destination: nothing should happen.
OUString aOld = xText->getString();
- paste("classification-yes.rtf", xEnd);
+ paste("rtfimport/data/classification-yes.rtf", xEnd);
CPPUNIT_ASSERT_EQUAL(aOld, xText->getString());
}
More information about the Libreoffice-commits
mailing list