diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-12-18 15:01:38 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-01-08 12:12:44 +0100 |
commit | 3871b7247f760cae30b3fb49c9efe0c9aaa95d06 (patch) | |
tree | 48e99fd604e039713a5222b320224d7eb2bf3db7 /test | |
parent | 8c1dc30cc9fc96ef3d3ab0c4445959473248ae4d (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>
(cherry picked from commit 0322a41224a7264bbe03a068647ab093bcc88f90)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85728
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@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 725351b2bbe5..afb3559da7b3 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/extensions/HelperMacros.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) { |