diff --git a/qadevOOo/runner/util/DesktopTools.java b/qadevOOo/runner/util/DesktopTools.java index c78e450ae721..997ee34e1ef2 100644 --- a/qadevOOo/runner/util/DesktopTools.java +++ b/qadevOOo/runner/util/DesktopTools.java @@ -258,51 +258,6 @@ public class DesktopTools return oDoc; } - /** - * loads a document of from a given path using an input stream - * - * @param xMSF the MultiServiceFactory - * @param filePath the path of the document to load. - * @return the XComponent Interface of the document - */ - public static XComponent loadDocUsingStream(XMultiServiceFactory xMSF, String filePath) - { - XInputStream inputStream = null; - try { - final InputStream inputFile = new BufferedInputStream( - new FileInputStream(filePath)); - try { - final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - final byte[] byteBuffer = new byte[4096]; - int byteBufferLength = 0; - while ((byteBufferLength = inputFile.read(byteBuffer)) > 0) - bytes.write(byteBuffer, 0, byteBufferLength); - inputStream = new ByteArrayToXInputStreamAdapter( - bytes.toByteArray()); - } finally { - inputFile.close(); - } - } catch (java.io.IOException e) { - e.printStackTrace(); - } - - PropertyValue[] loadProps = new PropertyValue[1]; - loadProps[0] = new PropertyValue(); - loadProps[0].Name = "InputStream"; - loadProps[0].Value = inputStream; - - XComponent oDoc = null; - try - { - oDoc = getCLoader(xMSF).loadComponentFromURL("private:stream", "_blank", 0, loadProps); - } - catch (com.sun.star.uno.Exception e) - { - throw new IllegalArgumentException("Document could not be loaded", e); - } - return oDoc; - } - /** * closes a given document * @param DocumentToClose the document to close diff --git a/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java b/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java index b49122e7f947..8e5754a0b981 100644 --- a/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java +++ b/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java @@ -578,21 +578,6 @@ public class DocumentMetadataAccess } } - @Test - public void checkTdf123293() throws Exception - { - XComponent xComp = null; - try { - xComp = util.DesktopTools.loadDocUsingStream(xMSF, TestDocument.getPath("TESTRDFA.odt")); - - // Metadata was discarded when loading from stream, make sure it's there now - XRepositorySupplier xRepoSupplier = UnoRuntime.queryInterface(XRepositorySupplier.class, xComp); - assertNotNull("No metadata loaded", xRepoSupplier); - } finally { - close(xComp); - } - } - // utilities ------------------------------------------------------------- static void close(XComponent i_comp) diff --git a/sfx2/qa/complex/sfx2/testdocuments/TESTRDFA.odt b/sfx2/qa/complex/sfx2/testdocuments/TESTRDFA.odt deleted file mode 100644 index d59739142df6..000000000000 Binary files a/sfx2/qa/complex/sfx2/testdocuments/TESTRDFA.odt and /dev/null differ diff --git a/sfx2/qa/cppunit/test_misc.cxx b/sfx2/qa/cppunit/test_misc.cxx index 094c4b8964ef..28067357b3b5 100644 --- a/sfx2/qa/cppunit/test_misc.cxx +++ b/sfx2/qa/cppunit/test_misc.cxx @@ -15,10 +15,6 @@ #endif #include -#include -#include -#include - #include #include #include @@ -31,20 +27,20 @@ #include #include #include -#include +#include #include #include +#include #include +#include #include #include #include - using namespace ::com::sun::star; - namespace { class MiscTest @@ -56,7 +52,6 @@ public: { } - virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override { // ODF @@ -451,6 +446,26 @@ CPPUNIT_TEST_FIXTURE(MiscTest, testRDFa) saveAndReload(u"writer8"_ustr); verify(/*bIsExport*/ true); } + +CPPUNIT_TEST_FIXTURE(MiscTest, testTdf123293) +{ + const uno::Reference xContext(comphelper::getProcessComponentContext(), + css::uno::UNO_SET_THROW); + const uno::Reference xFileAccess( + xContext->getServiceManager()->createInstanceWithContext( + u"com.sun.star.ucb.SimpleFileAccess"_ustr, xContext), + uno::UNO_QUERY_THROW); + const uno::Reference xInputStream(xFileAccess->openFileRead(createFileURL(u"TESTRDFA.odt") ), + uno::UNO_SET_THROW); + uno::Sequence aLoadArgs{ comphelper::makePropertyValue( + "InputStream", xInputStream) }; + mxComponent = mxDesktop->loadComponentFromURL(u"private:stream"_ustr, u"_blank"_ustr, 0, aLoadArgs); + CPPUNIT_ASSERT(mxComponent.is()); + uno::Reference xDocumentMetadataAccess(mxComponent, uno::UNO_QUERY); + uno::Reference xRepo = xDocumentMetadataAccess->getRDFRepository(); + uno::Reference xDocRepo(xRepo, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDocRepo); +} } CPPUNIT_PLUGIN_IMPLEMENT();