include/vcl/BinaryDataContainer.hxx | 4 ++-- vcl/inc/pdf/ExternalPDFStreams.hxx | 2 +- vcl/source/filter/graphicfilter.cxx | 4 ++-- vcl/source/graphic/BinaryDataContainer.cxx | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-)
New commits: commit 98177a6b056fd688f18d6e5c62c3e704c2d0eddb Author: Mike Kaganski <[email protected]> AuthorDate: Wed Oct 1 13:57:28 2025 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Wed Oct 1 16:08:28 2025 +0200 Let BinaryDataContainer::getAsStream return unique_ptr It isn't shared in any way; the object is created anew each time. ReferencedMemoryStream itself uses a shared_prt internally, for referencing the data. Change-Id: I78bf63af2e4476c55680bf33843e9ccd47b1080d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191725 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/include/vcl/BinaryDataContainer.hxx b/include/vcl/BinaryDataContainer.hxx index 6e6cb4c91ac1..71a6b278e3e6 100644 --- a/include/vcl/BinaryDataContainer.hxx +++ b/include/vcl/BinaryDataContainer.hxx @@ -48,7 +48,7 @@ public: SAL_DLLPRIVATE css::uno::Sequence<sal_Int8> getCopyAsByteSequence() const; // Returns the data as a readonly stream open for reading - SAL_DLLPRIVATE std::shared_ptr<SvStream> getAsStream() const; + SAL_DLLPRIVATE std::unique_ptr<SvStream> getAsStream() const; // Returns the data as a readonly stream open for reading SAL_DLLPRIVATE css::uno::Reference<css::io::XInputStream> getAsXInputStream() const; diff --git a/vcl/inc/pdf/ExternalPDFStreams.hxx b/vcl/inc/pdf/ExternalPDFStreams.hxx index 67d12b556a5d..689af33ce9a2 100644 --- a/vcl/inc/pdf/ExternalPDFStreams.hxx +++ b/vcl/inc/pdf/ExternalPDFStreams.hxx @@ -38,7 +38,7 @@ struct VCL_DLLPUBLIC ExternalPDFStream { if (!mpPDFDocument) { - std::shared_ptr<SvStream> aPDFStream = maDataContainer.getAsStream(); + std::unique_ptr<SvStream> aPDFStream = maDataContainer.getAsStream(); auto pPDFDocument = std::make_shared<filter::PDFDocument>(); if (!pPDFDocument->ReadWithPossibleFixup(*aPDFStream)) { diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index de177cb56854..cedb91503a57 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -860,7 +860,7 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 size if (eLinkType == GfxLinkType::NativeGif && !aBinaryDataContainer.isEmpty()) { - std::shared_ptr<SvStream> pMemoryStream = aBinaryDataContainer.getAsStream(); + std::unique_ptr<SvStream> pMemoryStream = aBinaryDataContainer.getAsStream(); bAnimated = IsGIFAnimated(*pMemoryStream, aLogicSize); if (!pSizeHint && aLogicSize.getWidth() && aLogicSize.getHeight()) { @@ -910,7 +910,7 @@ ErrCode GraphicFilter::readPNG(SvStream & rStream, Graphic& rGraphic, GfxLinkTyp if (auto aMSGifChunk = vcl::PngImageReader::getMicrosoftGifChunk(rStream); !aMSGifChunk.isEmpty()) { - std::shared_ptr<SvStream> pIStrm(aMSGifChunk.getAsStream()); + std::unique_ptr<SvStream> pIStrm(aMSGifChunk.getAsStream()); if (ImportGIF(*pIStrm, aImportOutput)) { diff --git a/vcl/source/graphic/BinaryDataContainer.cxx b/vcl/source/graphic/BinaryDataContainer.cxx index 523290a1be69..8cd66d1c480b 100644 --- a/vcl/source/graphic/BinaryDataContainer.cxx +++ b/vcl/source/graphic/BinaryDataContainer.cxx @@ -140,10 +140,10 @@ public: }; } -std::shared_ptr<SvStream> BinaryDataContainer::getAsStream() const +std::unique_ptr<SvStream> BinaryDataContainer::getAsStream() const { ensureSwappedIn(); // TODO: transfer in streamed chunks - return std::make_shared<ReferencedMemoryStream>(mpImpl->mpData); + return std::make_unique<ReferencedMemoryStream>(mpImpl->mpData); } css::uno::Reference<css::io::XInputStream> BinaryDataContainer::getAsXInputStream() const commit 6a2ce3ab6aed04f5c1804d9f42d1133d841c00ed Author: Mike Kaganski <[email protected]> AuthorDate: Wed Oct 1 13:55:54 2025 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Wed Oct 1 16:08:19 2025 +0200 Let BinaryDataContainer::getAs*Stream be const They return "a readonly stream open for reading". Change-Id: Id06f95e6e84264ecedf56c2eb21041c45cfb3b1c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191724 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/include/vcl/BinaryDataContainer.hxx b/include/vcl/BinaryDataContainer.hxx index 131d41f747c7..6e6cb4c91ac1 100644 --- a/include/vcl/BinaryDataContainer.hxx +++ b/include/vcl/BinaryDataContainer.hxx @@ -48,10 +48,10 @@ public: SAL_DLLPRIVATE css::uno::Sequence<sal_Int8> getCopyAsByteSequence() const; // Returns the data as a readonly stream open for reading - SAL_DLLPRIVATE std::shared_ptr<SvStream> getAsStream(); + SAL_DLLPRIVATE std::shared_ptr<SvStream> getAsStream() const; // Returns the data as a readonly stream open for reading - SAL_DLLPRIVATE css::uno::Reference<css::io::XInputStream> getAsXInputStream(); + SAL_DLLPRIVATE css::uno::Reference<css::io::XInputStream> getAsXInputStream() const; /// writes the contents to the given stream std::size_t writeToStream(SvStream& rStream) const; diff --git a/vcl/source/graphic/BinaryDataContainer.cxx b/vcl/source/graphic/BinaryDataContainer.cxx index 3ed9d4020beb..523290a1be69 100644 --- a/vcl/source/graphic/BinaryDataContainer.cxx +++ b/vcl/source/graphic/BinaryDataContainer.cxx @@ -140,13 +140,13 @@ public: }; } -std::shared_ptr<SvStream> BinaryDataContainer::getAsStream() +std::shared_ptr<SvStream> BinaryDataContainer::getAsStream() const { ensureSwappedIn(); // TODO: transfer in streamed chunks return std::make_shared<ReferencedMemoryStream>(mpImpl->mpData); } -css::uno::Reference<css::io::XInputStream> BinaryDataContainer::getAsXInputStream() +css::uno::Reference<css::io::XInputStream> BinaryDataContainer::getAsXInputStream() const { ensureSwappedIn(); // TODO: transfer in streamed chunks return new ReferencedXInputStream(mpImpl->mpData);
