diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-12-18 15:01:38 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-12-23 08:21:14 +0100 |
commit | 0322a41224a7264bbe03a068647ab093bcc88f90 (patch) | |
tree | f3727c86193227546c9e5e5a393395f3da769522 /test | |
parent | f3e0595fcba689b07f6419c2fb540731a3aadecf (diff) |
XStyleLoader::loadStylesFromURL Allow loading from stream
Change-Id: Iab0c301096118203466dd91c724c25f1283a0488
Reviewed-on: https://gerrit.libreoffice.org/85392
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/source/style/xstyleloader.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/source/style/xstyleloader.cxx b/test/source/style/xstyleloader.cxx index 573bc1e16152..fd3f8eec5303 100644 --- a/test/source/style/xstyleloader.cxx +++ b/test/source/style/xstyleloader.cxx @@ -11,16 +11,21 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/style/XStyle.hpp> #include <com/sun/star/style/XStyleLoader2.hpp> +#include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <rtl/ustring.hxx> #include <cppunit/TestAssert.h> +#include <comphelper/processfactory.hxx> +#include <comphelper/storagehelper.hxx> +using namespace comphelper; using namespace css; using namespace css::uno; @@ -54,6 +59,31 @@ void XStyleLoader::testLoadStylesFromDocument() checkStyleProperties(xFamilySupplier); } +void XStyleLoader::testLoadStylesFromStream() +{ + uno::Reference<style::XStyleLoader2> xStyleLoader(init(), uno::UNO_QUERY_THROW); + + uno::Reference<sheet::XSpreadsheetDocument> xDoc(getTargetDoc(), uno::UNO_SET_THROW); + const OUString aFileURL = getTestURL(); + const uno::Reference<io::XInputStream> xInputStream + = OStorageHelper::GetInputStreamFromURL(aFileURL, getProcessComponentContext()); + + uno::Sequence<beans::PropertyValue> aOptions = xStyleLoader->getStyleLoaderOptions(); + auto nLength = aOptions.getLength(); + aOptions.realloc(nLength + 1); + beans::PropertyValue aInputStream; + aInputStream.Name = "InputStream"; + uno::Any aTmp; + aTmp <<= xInputStream; + aInputStream.Value = aTmp; + aOptions[nLength] = aInputStream; + + xStyleLoader->loadStylesFromURL("private:stream", aOptions); + + uno::Reference<style::XStyleFamiliesSupplier> xFamilySupplier(xDoc, UNO_QUERY_THROW); + checkStyleProperties(xFamilySupplier); +} + void XStyleLoader::checkStyleProperties( uno::Reference<style::XStyleFamiliesSupplier> const& xFamilySupplier) { |