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 /sc | |
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 'sc')
-rw-r--r-- | sc/inc/tablink.hxx | 9 | ||||
-rw-r--r-- | sc/qa/extras/scstylefamiliesobj.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/docshell/tablink.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/unoobj/styleuno.cxx | 22 |
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(); |