summaryrefslogtreecommitdiffstats
path: root/embeddedobj/qa
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /embeddedobj/qa
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--embeddedobj/qa/cppunit/data/insert-file-config.docbin0 -> 22016 bytes
-rw-r--r--embeddedobj/qa/cppunit/data/insert-file-config.pdfbin0 -> 11157 bytes
-rw-r--r--embeddedobj/qa/cppunit/data/insert-file-config.vsdxbin0 -> 12483 bytes
-rw-r--r--embeddedobj/qa/cppunit/data/ole2.ole19
-rw-r--r--embeddedobj/qa/cppunit/data/ole2.pngbin0 -> 766 bytes
-rw-r--r--embeddedobj/qa/cppunit/data/reqif-ole2.xhtml5
-rw-r--r--embeddedobj/qa/cppunit/general.cxx156
-rw-r--r--embeddedobj/qa/cppunit/msole.cxx145
-rw-r--r--embeddedobj/qa/embedding/EmbeddingTest.java25
-rw-r--r--embeddedobj/qa/embedding/EmbeddingUnitTest.java82
-rw-r--r--embeddedobj/qa/embedding/Test01.java153
-rw-r--r--embeddedobj/qa/embedding/TestHelper.java54
-rw-r--r--embeddedobj/qa/embedding/makefile.mk75
13 files changed, 714 insertions, 0 deletions
diff --git a/embeddedobj/qa/cppunit/data/insert-file-config.doc b/embeddedobj/qa/cppunit/data/insert-file-config.doc
new file mode 100644
index 000000000..182a70c34
--- /dev/null
+++ b/embeddedobj/qa/cppunit/data/insert-file-config.doc
Binary files differ
diff --git a/embeddedobj/qa/cppunit/data/insert-file-config.pdf b/embeddedobj/qa/cppunit/data/insert-file-config.pdf
new file mode 100644
index 000000000..630245740
--- /dev/null
+++ b/embeddedobj/qa/cppunit/data/insert-file-config.pdf
Binary files differ
diff --git a/embeddedobj/qa/cppunit/data/insert-file-config.vsdx b/embeddedobj/qa/cppunit/data/insert-file-config.vsdx
new file mode 100644
index 000000000..bb3a129cf
--- /dev/null
+++ b/embeddedobj/qa/cppunit/data/insert-file-config.vsdx
Binary files differ
diff --git a/embeddedobj/qa/cppunit/data/ole2.ole b/embeddedobj/qa/cppunit/data/ole2.ole
new file mode 100644
index 000000000..c0013db40
--- /dev/null
+++ b/embeddedobj/qa/cppunit/data/ole2.ole
@@ -0,0 +1,19 @@
+{\object\objemb\objw240\objh240{\*\objclass PBrush}{\*\objdata 01050000020000000700000050427275736800000000000000000040030000
+424d36030000000000003600000028000000100000001000000001001800000000000003000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000001050000050000000d0000004d45544146494c455049435400a701000059feffffe40000000800a701a7010000
+0100090000036e00000000004500000000000400000003010800050000000b0200000000050000000c0211001100030000001e000400000007010400040000000701040045000000410b2000cc00100010000000000010001000000000002800000010000000100000000100010000000000000000000000000000000000
+000000000000000000000000ffffff00ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101040000002701ffff030000000000}{\result {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid793696
+{\*\shppict{\pict{\*\picprop\shplid1027{\sp{\sn shapeType}{\sv 75}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}{\sp{\sn fLockAspectRatio}{\sv 1}}{\sp{\sn pictureGray}{\sv 0}}
+{\sp{\sn pictureBiLevel}{\sv 0}}{\sp{\sn pictureActive}{\sv 0}}{\sp{\sn fRecolorFillAsPicture}{\sv 0}}{\sp{\sn fUseShapeAnchor}{\sv 0}}{\sp{\sn fFilled}{\sv 0}}{\sp{\sn fHitTestFill}{\sv 1}}
+{\sp{\sn fillShape}{\sv 1}}{\sp{\sn fillUseRect}{\sv 0}}{\sp{\sn fNoFillHitTest}{\sv 0}}{\sp{\sn fLine}{\sv 0}}{\sp{\sn fPreferRelativeResize}{\sv 1}}{\sp{\sn fReallyHidden}{\sv 0}}
+{\sp{\sn fScriptAnchor}{\sv 0}}{\sp{\sn fFakeMaster}{\sv 0}}{\sp{\sn fCameFromImgDummy}{\sv 0}}{\sp{\sn fLayoutInCell}{\sv 1}}}\picscalex100\picscaley100\piccropl0\piccropr0\piccropt0\piccropb0
+\picw423\pich423\picwgoal240\pichgoal240\pngblip\bliptag602933164{\*\blipuid 23f007ac3ac2aed53753eaea27c13e03}89504e470d0a1a0a0000000d494844520000001000000010080200000090916836000000017352474200aece1ce9000000097048597300000ec700000ec70138
+922f760000001f49444154384f63fcffff3f0329808914c520b5a31a8809b1d1501a1ca10400556d031d6ec895ac0000000049454e44ae426082}}{\nonshppict{\pict\picscalex100\picscaley100\piccropl0\piccropr0\piccropt0\piccropb0
+\picw423\pich423\picwgoal240\pichgoal240\wmetafile8\bliptag602933164\blipupi96{\*\blipuid 23f007ac3ac2aed53753eaea27c13e03}0100090000036e00000000004500000000000400000003010800050000000b0200000000050000000c0211001100030000001e00040000000701040004000000
+0701040045000000410b2000cc001000100000000000100010000000000028000000100000001000000001000100000000000000000000000000000000000000
+00000000000000000000ffffff00ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101ffff0101040000002701ffff030000000000}}}}}
diff --git a/embeddedobj/qa/cppunit/data/ole2.png b/embeddedobj/qa/cppunit/data/ole2.png
new file mode 100644
index 000000000..fdad35484
--- /dev/null
+++ b/embeddedobj/qa/cppunit/data/ole2.png
Binary files differ
diff --git a/embeddedobj/qa/cppunit/data/reqif-ole2.xhtml b/embeddedobj/qa/cppunit/data/reqif-ole2.xhtml
new file mode 100644
index 000000000..716ecd1bd
--- /dev/null
+++ b/embeddedobj/qa/cppunit/data/reqif-ole2.xhtml
@@ -0,0 +1,5 @@
+<reqif-xhtml:div>
+ <reqif-xhtml:object data="ole2.ole" type="text/rtf">
+ <reqif-xhtml:object data="ole2.png" type="image/png">OLE Object</reqif-xhtml:object>
+ </reqif-xhtml:object>
+</reqif-xhtml:div>
diff --git a/embeddedobj/qa/cppunit/general.cxx b/embeddedobj/qa/cppunit/general.cxx
new file mode 100644
index 000000000..c7824fe87
--- /dev/null
+++ b/embeddedobj/qa/cppunit/general.cxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+
+#include <comphelper/embeddedobjectcontainer.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <comphelper/scopeguard.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <officecfg/Office/Common.hxx>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+/// Covers embeddedobj/source/general/ fixes.
+class Test : public test::BootstrapFixture, public unotest::MacrosTest
+{
+private:
+ uno::Reference<lang::XComponent> mxComponent;
+
+public:
+ void setUp() override;
+ void tearDown() override;
+ uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+};
+
+void Test::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void Test::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertFileConfig)
+{
+ // Explicitly disable Word->Writer mapping for this test.
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::set(false, pBatch);
+ pBatch->commit();
+ comphelper::ScopeGuard g([]() {
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatchReset(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::set(true,
+ pBatchReset);
+ pBatchReset->commit();
+ });
+ getComponent().set(
+ loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"));
+
+ // Insert a file as an embedded object.
+ uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
+ comphelper::EmbeddedObjectContainer aContainer(xStorage);
+ OUString aFileName
+ = m_directories.getURLFromSrc(u"embeddedobj/qa/cppunit/data/insert-file-config.doc");
+ uno::Sequence<beans::PropertyValue> aMedium{ comphelper::makePropertyValue("URL", aFileName) };
+ OUString aName("Object 1");
+ uno::Reference<embed::XEmbeddedObject> xObject
+ = aContainer.InsertEmbeddedObject(aMedium, aName);
+
+ // Make sure that the insertion fails:
+ // 1) the user explicitly requested that the data is not loaded into Writer
+ // 2) this is non-Windows, so OLE embedding is not an option
+ // so silently still loading the data into Writer would be bad.
+ CPPUNIT_ASSERT(!xObject.is());
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertFileConfigVsdx)
+{
+ // Explicitly disable Word->Writer mapping for this test.
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::set(false, pBatch);
+ pBatch->commit();
+ comphelper::ScopeGuard g([]() {
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatchReset(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Microsoft::Import::VisioToDraw::set(true, pBatchReset);
+ pBatchReset->commit();
+ });
+ getComponent().set(
+ loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"));
+
+ // Insert a file as an embedded object.
+ uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
+ comphelper::EmbeddedObjectContainer aContainer(xStorage);
+ OUString aFileName
+ = m_directories.getURLFromSrc(u"embeddedobj/qa/cppunit/data/insert-file-config.vsdx");
+ uno::Sequence<beans::PropertyValue> aMedium{ comphelper::makePropertyValue("URL", aFileName) };
+ OUString aName("Object 1");
+ uno::Reference<embed::XEmbeddedObject> xObject
+ = aContainer.InsertEmbeddedObject(aMedium, aName);
+
+ // Make sure that the insertion fails:
+ // 1) the user explicitly requested that the data is not loaded into Writer
+ // 2) this is non-Windows, so OLE embedding is not an option
+ // so silently still loading the data into Writer would be bad.
+ CPPUNIT_ASSERT(!xObject.is());
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testInsertFileConfigPdf)
+{
+ // Explicitly disable Word->Writer mapping for this test.
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::set(false, pBatch);
+ pBatch->commit();
+ comphelper::ScopeGuard g([]() {
+ std::shared_ptr<comphelper::ConfigurationChanges> pBatchReset(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Filter::Adobe::Import::PDFToDraw::set(true, pBatchReset);
+ pBatchReset->commit();
+ });
+ getComponent().set(
+ loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"));
+
+ // Insert a PDF file as an embedded object.
+ uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
+ comphelper::EmbeddedObjectContainer aContainer(xStorage);
+ OUString aFileName
+ = m_directories.getURLFromSrc(u"embeddedobj/qa/cppunit/data/insert-file-config.pdf");
+ uno::Sequence<beans::PropertyValue> aMedium{ comphelper::makePropertyValue("URL", aFileName) };
+ OUString aName("Object 1");
+ uno::Reference<embed::XEmbeddedObject> xObject
+ = aContainer.InsertEmbeddedObject(aMedium, aName);
+
+ // Make sure that the insertion fails:
+ // 1) the user explicitly requested that the data is not loaded into Writer
+ // 2) this is non-Windows, so OLE embedding is not an option
+ // so silently still loading the data into Writer would be bad.
+ CPPUNIT_ASSERT(!xObject.is());
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embeddedobj/qa/cppunit/msole.cxx b/embeddedobj/qa/cppunit/msole.cxx
new file mode 100644
index 000000000..85be38938
--- /dev/null
+++ b/embeddedobj/qa/cppunit/msole.cxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <test/xmltesttools.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
+
+#include <comphelper/embeddedobjectcontainer.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <comphelper/scopeguard.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <officecfg/Office/Common.hxx>
+#include <unotools/tempfile.hxx>
+#include <osl/thread.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/debug.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <vcl/outdev.hxx>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+/// Covers embeddedobj/source/msole/ fixes.
+class Test : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
+{
+private:
+ uno::Reference<lang::XComponent> mxComponent;
+
+public:
+ void setUp() override;
+ void tearDown() override;
+ uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+ void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override;
+};
+}
+
+void Test::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void Test::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+
+void Test::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx)
+{
+ XmlTestTools::registerODFNamespaces(pXmlXpathCtx);
+}
+
+namespace
+{
+class OdtExportThread : public osl::Thread
+{
+ uno::Reference<lang::XComponent> mxComponent;
+ OUString maURL;
+
+public:
+ OdtExportThread(const uno::Reference<lang::XComponent>& xComponent, const OUString& rURL);
+ virtual void SAL_CALL run() override;
+};
+
+OdtExportThread::OdtExportThread(const uno::Reference<lang::XComponent>& xComponent,
+ const OUString& rURL)
+ : mxComponent(xComponent)
+ , maURL(rURL)
+{
+}
+
+void OdtExportThread::run()
+{
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aStoreProperties = {
+ comphelper::makePropertyValue("FilterName", OUString("writer8")),
+ };
+ xStorable->storeToURL(maURL, aStoreProperties);
+}
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testSaveOnThread)
+{
+ // Given an embedded object which hosts mspaint data:
+ if (Application::GetDefaultDevice()->GetDPIX() != 96)
+ {
+ return;
+ }
+
+ DBG_TESTSOLARMUTEX();
+ OUString aURL = m_directories.getURLFromSrc(u"embeddedobj/qa/cppunit/data/reqif-ole2.xhtml");
+ uno::Sequence<beans::PropertyValue> aLoadProperties = {
+ comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")),
+ comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")),
+ };
+ getComponent().set(loadFromDesktop(aURL, "com.sun.star.text.TextDocument", aLoadProperties));
+
+ // When saving that document on a thread:
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ OdtExportThread aThread(getComponent(), aTempFile.GetURL());
+ aThread.create();
+ {
+ SolarMutexReleaser r;
+ while (aThread.isRunning())
+ {
+ SolarMutexGuard g;
+ Application::Reschedule(/*bHandleAllCurrentEvents=*/true);
+ }
+ }
+
+ // Then make sure its visible area's width is correct.
+ uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
+ = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL());
+ uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName("content.xml"),
+ uno::UNO_QUERY);
+ std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
+ xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get());
+ // 16 pixels, assuming 96 DPI.
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 0.1665in
+ // - Actual : 1.9685in
+ // i.e. we wrote a hardcoded 5cm width, not the real one.
+ assertXPath(pXmlDoc, "//style:graphic-properties", "visible-area-width", "0.1665in");
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/embeddedobj/qa/embedding/EmbeddingTest.java b/embeddedobj/qa/embedding/EmbeddingTest.java
new file mode 100644
index 000000000..c2ab6faf0
--- /dev/null
+++ b/embeddedobj/qa/embedding/EmbeddingTest.java
@@ -0,0 +1,25 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package complex.embedding;
+
+public interface EmbeddingTest
+{
+ boolean test();
+}
+
diff --git a/embeddedobj/qa/embedding/EmbeddingUnitTest.java b/embeddedobj/qa/embedding/EmbeddingUnitTest.java
new file mode 100644
index 000000000..245dd1225
--- /dev/null
+++ b/embeddedobj/qa/embedding/EmbeddingUnitTest.java
@@ -0,0 +1,82 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package complex.embedding;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.XNamingService;
+import com.sun.star.uno.XComponentContext;
+
+import com.sun.star.container.*;
+import com.sun.star.beans.*;
+import com.sun.star.lang.*;
+
+import complexlib.ComplexTestCase;
+
+import complex.embedding.*;
+
+import util.utils;
+import java.util.*;
+import java.io.*;
+
+/* This unit test for storage objects is designed to
+ * test most important statements from storage service
+ * specification.
+ *
+ * Regression tests are added to extend the tested
+ * functionalities.
+ */
+public class EmbeddingUnitTest extends ComplexTestCase
+{
+ private XMultiServiceFactory m_xMSF = null;
+
+ public String[] getTestMethodNames()
+ {
+ return new String[] {
+ "ExecuteTest01" };
+ }
+
+ public String getTestObjectName()
+ {
+ return "EmbeddingUnitTest";
+ }
+
+ public void before()
+ {
+ m_xMSF = (XMultiServiceFactory)param.getMSF();
+ if ( m_xMSF == null )
+ {
+ failed( "Can't create service factory!" );
+ return;
+ }
+ }
+
+ public void ExecuteTest01()
+ {
+ EmbeddingTest aTest = new Test01( m_xMSF, log );
+ assure( "Test01 failed!", aTest.test() );
+ }
+
+}
+
diff --git a/embeddedobj/qa/embedding/Test01.java b/embeddedobj/qa/embedding/Test01.java
new file mode 100644
index 000000000..3a8b425bb
--- /dev/null
+++ b/embeddedobj/qa/embedding/Test01.java
@@ -0,0 +1,153 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package complex.embedding;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.frame.XLoadable;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XShape;
+import com.sun.star.graphic.XGraphic;
+
+import com.sun.star.embed.*;
+
+import share.LogWriter;
+import complex.embedding.TestHelper;
+import complex.embedding.EmbeddingTest;
+
+public class Test01 implements EmbeddingTest {
+
+ XMultiServiceFactory m_xMSF;
+ TestHelper m_aTestHelper;
+
+ public Test01( XMultiServiceFactory xMSF, LogWriter aLogWriter )
+ {
+ m_xMSF = xMSF;
+ m_aTestHelper = new TestHelper( aLogWriter, "Test01: " );
+ }
+
+ public boolean test()
+ {
+ try
+ {
+ Object oDoc = m_xMSF.createInstance( "com.sun.star.comp.Draw.DrawingDocument" );
+ XLoadable xLoad = (XLoadable) UnoRuntime.queryInterface( XLoadable.class, oDoc );
+ if ( xLoad == null )
+ {
+ m_aTestHelper.Error( "Can not get XLoadable!" );
+ return false;
+ }
+
+ xLoad.initNew();
+
+ XDrawPagesSupplier xDPSupply = (XDrawPagesSupplier) UnoRuntime.queryInterface( XDrawPagesSupplier.class, oDoc );
+ if ( xDPSupply == null )
+ {
+ m_aTestHelper.Error( "Can not get XDrawPagesSupplier!" );
+ return false;
+ }
+
+ XDrawPages xDrawPages = xDPSupply.getDrawPages();
+ if ( xDrawPages == null )
+ {
+ m_aTestHelper.Error( "Can not get XDrawPages object!" );
+ return false;
+ }
+
+ if ( xDrawPages.getCount() == 0 )
+ {
+ m_aTestHelper.Error( "There must be at least one page in the document!" );
+ return false;
+ }
+
+ Object oPage = xDrawPages.getByIndex( 0 );
+ XDrawPage xPage = (XDrawPage) UnoRuntime.queryInterface( XDrawPage.class, oPage );
+ if ( xPage == null )
+ {
+ m_aTestHelper.Error( "Can not get access to drawing page!" );
+ return false;
+ }
+
+ XMultiServiceFactory xDrFactory = ( XMultiServiceFactory ) UnoRuntime.queryInterface( XMultiServiceFactory.class,
+ oDoc );
+ if ( xDrFactory == null )
+ {
+ m_aTestHelper.Error( "Can not get drawing factory!" );
+ return false;
+ }
+
+ Object oShape = xDrFactory.createInstance( "com.sun.star.drawing.OLE2Shape" );
+ XShape xShape = ( XShape ) UnoRuntime.queryInterface( XShape.class, oShape );
+ if ( xShape == null )
+ {
+ m_aTestHelper.Error( "Can not create new shape!" );
+ return false;
+ }
+
+ XPropertySet xShapeProps = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, oShape );
+ if ( xShapeProps == null )
+ {
+ m_aTestHelper.Error( "Can not get access to shapes properties!" );
+ return false;
+ }
+
+ xPage.add( xShape );
+ xShapeProps.setPropertyValue( "CLSID", "078B7ABA-54FC-457F-8551-6147e776a997" );
+
+ Object oEmbObj = xShapeProps.getPropertyValue( "EmbeddedObject" );
+ XEmbeddedObject xEmbObj = ( XEmbeddedObject ) UnoRuntime.queryInterface( XEmbeddedObject.class, oEmbObj );
+ if ( xEmbObj == null )
+ {
+ m_aTestHelper.Error( "Embedded object can not be accessed!" );
+ return false;
+ }
+
+ XEmbeddedClient xClient = xEmbObj.getClientSite();
+ if ( xClient == null )
+ {
+ m_aTestHelper.Error( "The client for the object must be set!" );
+ return false;
+ }
+
+ Object oReplacement = xShapeProps.getPropertyValue( "Graphic" );
+ XGraphic xReplGraph = ( XGraphic ) UnoRuntime.queryInterface( XGraphic.class, oReplacement );
+ if ( xReplGraph == null )
+ {
+ m_aTestHelper.Error( "The replacement graphic should be available!" );
+ return false;
+ }
+
+ return true;
+ }
+ catch( Exception e )
+ {
+ m_aTestHelper.Error( "Exception: " + e );
+ return false;
+ }
+ }
+}
+
diff --git a/embeddedobj/qa/embedding/TestHelper.java b/embeddedobj/qa/embedding/TestHelper.java
new file mode 100644
index 000000000..299311171
--- /dev/null
+++ b/embeddedobj/qa/embedding/TestHelper.java
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+package complex.embedding;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.AnyConverter;
+
+import com.sun.star.lang.*;
+import com.sun.star.embed.*;
+import com.sun.star.packages.*;
+import com.sun.star.io.*;
+import com.sun.star.beans.*;
+
+import share.LogWriter;
+
+public class TestHelper {
+
+ LogWriter m_aLogWriter;
+ String m_sTestPrefix;
+
+ public TestHelper( LogWriter aLogWriter, String sTestPrefix )
+ {
+ m_aLogWriter = aLogWriter;
+ m_sTestPrefix = sTestPrefix;
+ }
+
+ public void Error( String sError )
+ {
+ m_aLogWriter.println( m_sTestPrefix + "Error: " + sError );
+ }
+
+ public void Message( String sMessage )
+ {
+ m_aLogWriter.println( m_sTestPrefix + sMessage );
+ }
+}
+
diff --git a/embeddedobj/qa/embedding/makefile.mk b/embeddedobj/qa/embedding/makefile.mk
new file mode 100644
index 000000000..483440c22
--- /dev/null
+++ b/embeddedobj/qa/embedding/makefile.mk
@@ -0,0 +1,75 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+PRJ = ..$/..
+TARGET = EmbeddingUnitTest
+PRJNAME = embeddedobj
+PACKAGE = complex$/embedding
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+
+JAVAFILES =\
+ EmbeddingUnitTest.java\
+ EmbeddingTest.java\
+ TestHelper.java\
+ Test01.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice --accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE: target.mk
+
+RUN: run
+
+run:
+ java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST)
+
+