diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-05-23 15:26:14 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-05-23 16:36:38 +0200 |
commit | 6a91ea82502c0b9e6632d625962bf9da006c4a2f (patch) | |
tree | c3696fcd29d3583ef5d718664cb2b8d6f1a8b5e9 /svtools | |
parent | f11cbcb60d546ce9c7a840a67458c5c88f8a8531 (diff) |
vcl GraphicFilter: add ImportGraphics()
This is similar to ImportGraphic(), but can handle multiple streams with
one function call.
Change-Id: I8d5dc8de64321c3c1fb9e1037527b411fd68dca8
Reviewed-on: https://gerrit.libreoffice.org/37953
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/graphic/provider.cxx | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx index faec3fcd4d9b..fa34c5c712d6 100644 --- a/svtools/source/graphic/provider.cxx +++ b/svtools/source/graphic/provider.cxx @@ -438,11 +438,49 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co uno::Sequence< uno::Reference<graphic::XGraphic> > SAL_CALL GraphicProvider::queryGraphics(const uno::Sequence< uno::Sequence<beans::PropertyValue> >& rMediaPropertiesSeq) { - std::vector< uno::Reference<graphic::XGraphic> > aRet; + SolarMutexGuard aGuard; + // Turn properties into streams. + std::vector< std::shared_ptr<SvStream> > aStreams; for (const auto& rMediaProperties : rMediaPropertiesSeq) { - aRet.push_back(queryGraphic(rMediaProperties)); + SvStream* pStream = nullptr; + uno::Reference<io::XInputStream> xStream; + + for (sal_Int32 i = 0; rMediaProperties.getLength(); ++i) + { + if (rMediaProperties[i].Name == "InputStream") + { + rMediaProperties[i].Value >>= xStream; + if (xStream.is()) + pStream = utl::UcbStreamHelper::CreateStream(xStream); + break; + } + } + + aStreams.push_back(std::shared_ptr<SvStream>(pStream)); + + } + + // Import: streams to graphics. + std::vector< std::shared_ptr<Graphic> > aGraphics; + GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); + rFilter.ImportGraphics(aGraphics, aStreams); + + // Returning: graphics to UNO objects. + std::vector< uno::Reference<graphic::XGraphic> > aRet; + for (const auto& pGraphic : aGraphics) + { + uno::Reference<graphic::XGraphic> xGraphic; + + if (pGraphic) + { + auto pUnoGraphic = new unographic::Graphic(); + pUnoGraphic->init(*pGraphic); + xGraphic = pUnoGraphic; + } + + aRet.push_back(xGraphic); } return comphelper::containerToSequence(aRet); |