23#include <com/sun/star/io/NotConnectedException.hpp>
24#include <com/sun/star/io/XSeekable.hpp>
25#include <com/sun/star/graphic/GraphicProvider.hpp>
26#include <com/sun/star/graphic/XGraphicProvider.hpp>
27#include <com/sun/star/io/XStream.hpp>
31#include <osl/diagnose.h>
56 StreamSupplier(uno::Reference<io::XInputStream> xInput, uno::Reference<io::XOutputStream> xOutput);
60 virtual uno::Reference<io::XInputStream> SAL_CALL getInputStream()
override;
61 virtual uno::Reference<io::XOutputStream> SAL_CALL
getOutputStream()
override;
64 virtual void SAL_CALL seek(sal_Int64 location)
override;
65 virtual sal_Int64 SAL_CALL getPosition()
override;
66 virtual sal_Int64 SAL_CALL
getLength()
override;
71StreamSupplier::StreamSupplier(uno::Reference<io::XInputStream> xInput, uno::Reference<io::XOutputStream> xOutput)
78 OSL_ENSURE(
m_xSeekable.is(),
"StreamSupplier::StreamSupplier: at least one of both must be seekable!");
81uno::Reference<io::XInputStream> SAL_CALL StreamSupplier::getInputStream()
86uno::Reference<io::XOutputStream> SAL_CALL StreamSupplier::getOutputStream()
91void SAL_CALL StreamSupplier::seek(sal_Int64 nLocation)
94 throw io::NotConnectedException();
98sal_Int64 SAL_CALL StreamSupplier::getPosition()
101 throw io::NotConnectedException();
105sal_Int64 SAL_CALL StreamSupplier::getLength()
108 throw io::NotConnectedException();
121std::unique_ptr<SvStream>
getImageStream(uno::Reference<uno::XComponentContext>
const & rxContext, OUString
const & rImageResourceURL)
123 std::unique_ptr<SvMemoryStream> pMemBuffer;
128 uno::Reference<graphic::XGraphicProvider> xProvider = css::graphic::GraphicProvider::create(rxContext);
132 "URL", rImageResourceURL) };
133 uno::Reference<graphic::XGraphic> xGraphic(xProvider->queryGraphic(aMediaProperties));
135 OSL_ENSURE(xGraphic.is(),
"GraphicAccess::getImageStream: the provider did not give us a graphic object!");
141 uno::Reference<io::XStream> xBufferAccess =
new StreamSupplier(
142 new OSeekableInputStreamWrapper(*pMemBuffer),
143 new OSeekableOutputStreamWrapper(*pMemBuffer));
147 xProvider->storeGraphic(xGraphic, aMediaProperties);
151 catch (
const uno::Exception&)
160uno::Reference<io::XInputStream>
getImageXStream(uno::Reference<uno::XComponentContext>
const & rxContext, OUString
const & rImageResourceURL)
162 return new OSeekableInputStreamWrapper(
getImageStream(rxContext, rImageResourceURL).release(),
true);
#define TOOLS_WARN_EXCEPTION(area, stream)
uno::Reference< io::XSeekable > m_xSeekable
uno::Reference< io::XOutputStream > m_xOutput
uno::Reference< io::XInputStream > m_xInput
double getLength(const B2DPolygon &rCandidate)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
bool getOutputStream(ProgramOptions const &options, OString const &extension, std::ostream **ppOutputStream, OString &targetSourceFileName, OString &tmpSourceFileName)
std::unique_ptr< SvStream > getImageStream(uno::Reference< uno::XComponentContext > const &rxContext, OUString const &rImageResourceURL)
bool isSupportedURL(std::u16string_view rURL)
::cppu::WeakImplHelper< io::XStream, io::XSeekable > StreamSupplier_Base
uno::Reference< io::XInputStream > getImageXStream(uno::Reference< uno::XComponentContext > const &rxContext, OUString const &rImageResourceURL)