summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-12-18 15:01:38 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-12-23 08:21:14 +0100
commit0322a41224a7264bbe03a068647ab093bcc88f90 (patch)
treef3727c86193227546c9e5e5a393395f3da769522 /sc
parentf3e0595fcba689b07f6419c2fb540731a3aadecf (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 'sc')
-rw-r--r--sc/inc/tablink.hxx9
-rw-r--r--sc/qa/extras/scstylefamiliesobj.cxx1
-rw-r--r--sc/source/ui/docshell/tablink.cxx5
-rw-r--r--sc/source/ui/unoobj/styleuno.cxx22
4 files changed, 31 insertions, 6 deletions
diff --git a/sc/inc/tablink.hxx b/sc/inc/tablink.hxx
index 7038bd345fae..eb5e2f665696 100644
--- a/sc/inc/tablink.hxx
+++ b/sc/inc/tablink.hxx
@@ -82,10 +82,11 @@ private:
SfxMedium* pMedium;
public:
- ScDocumentLoader( const OUString& rFileName,
- OUString& rFilterName, OUString& rOptions,
- sal_uInt32 nRekCnt = 0, weld::Window* pInteractionParent = nullptr );
- ~ScDocumentLoader();
+ ScDocumentLoader(const OUString& rFileName, OUString& rFilterName, OUString& rOptions,
+ sal_uInt32 nRekCnt = 0, weld::Window* pInteractionParent = nullptr,
+ css::uno::Reference<css::io::XInputStream> xInputStream
+ = css::uno::Reference<css::io::XInputStream>());
+ ~ScDocumentLoader();
ScDocument* GetDocument();
ScDocShell* GetDocShell() { return pDocShell; }
bool IsError() const;
diff --git a/sc/qa/extras/scstylefamiliesobj.cxx b/sc/qa/extras/scstylefamiliesobj.cxx
index 26cbce051de5..991334d192b7 100644
--- a/sc/qa/extras/scstylefamiliesobj.cxx
+++ b/sc/qa/extras/scstylefamiliesobj.cxx
@@ -70,6 +70,7 @@ public:
// XStyleLoader
CPPUNIT_TEST(testLoadStylesFromDocument);
+ CPPUNIT_TEST(testLoadStylesFromStream);
CPPUNIT_TEST(testLoadStylesFromURL);
CPPUNIT_TEST_SUITE_END();
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
index 6d43206f4c0a..9ef612caa161 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -514,7 +514,8 @@ SfxMedium* ScDocumentLoader::CreateMedium( const OUString& rFileName, std::share
ScDocumentLoader::ScDocumentLoader(const OUString& rFileName,
OUString& rFilterName, OUString& rOptions,
- sal_uInt32 nRekCnt, weld::Window* pInteractionParent)
+ sal_uInt32 nRekCnt, weld::Window* pInteractionParent,
+ css::uno::Reference<css::io::XInputStream> xInputStream)
: pDocShell(nullptr)
, pMedium(nullptr)
{
@@ -524,6 +525,8 @@ ScDocumentLoader::ScDocumentLoader(const OUString& rFileName,
std::shared_ptr<const SfxFilter> pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( rFilterName );
pMedium = CreateMedium(rFileName, pFilter, rOptions, pInteractionParent);
+ if (xInputStream.is())
+ pMedium->setStreamToLoadFrom(xInputStream, true);
if ( pMedium->GetError() != ERRCODE_NONE )
return ;
diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx
index aed15b31427e..452c5dc3d345 100644
--- a/sc/source/ui/unoobj/styleuno.cxx
+++ b/sc/source/ui/unoobj/styleuno.cxx
@@ -529,7 +529,27 @@ void SAL_CALL ScStyleFamiliesObj::loadStylesFromURL( const OUString& aURL,
OUString aFilter; // empty - detect
OUString aFiltOpt;
- ScDocumentLoader aLoader( aURL, aFilter, aFiltOpt );
+ uno::Reference<io::XInputStream> xInputStream;
+ if (aURL == "private:stream")
+ {
+ for (const auto& rProp : aOptions)
+ {
+ if (rProp.Name == "InputStream")
+ {
+ rProp.Value >>= xInputStream;
+ if (!xInputStream.is())
+ {
+ throw lang::IllegalArgumentException(
+ "Parameter 'InputStream' could not be converted "
+ "to type 'com::sun::star::io::XInputStream'",
+ nullptr, 0);
+ }
+ break;
+ }
+ }
+ }
+
+ ScDocumentLoader aLoader( aURL, aFilter, aFiltOpt, 0, nullptr, xInputStream );
ScDocShell* pSource = aLoader.GetDocShell();