comphelper/source/streaming/memorystream.cxx | 59 ------ dbaccess/source/ui/app/AppDetailPageHelper.cxx | 4 forms/source/component/ImageControl.cxx | 6 framework/source/uielement/langselectionstatusbarcontroller.cxx | 6 include/comphelper/memorystream.hxx | 87 ++++++++++ include/oox/export/shapes.hxx | 1 oox/source/core/filterdetect.cxx | 8 oox/source/core/xmlfilterbase.cxx | 6 oox/source/export/shapes.cxx | 12 - package/Library_xstor.mk | 4 package/source/xstor/owriteablestream.cxx | 24 -- sfx2/source/doc/docfile.cxx | 10 - sfx2/source/doc/objstor.cxx | 10 - sw/source/filter/ww8/docxexport.cxx | 15 - sw/source/uibase/uiview/viewling.cxx | 5 xmloff/source/draw/shapeexport.cxx | 3 16 files changed, 133 insertions(+), 127 deletions(-)
New commits: commit 7b9bce25a671a22c4c28c568e715502881c1a8ef Author: Noel Grandin <[email protected]> AuthorDate: Sat Jun 14 12:22:20 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sat Jun 14 14:45:18 2025 +0200 use more concrete UNO Change-Id: Ib3cded8314cecf837579af234d47e8377cb942a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186492 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx index 291786e4fa64..8e6165b53989 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx @@ -21,7 +21,6 @@ #include <comphelper/diagnose_ex.hxx> #include <tabletree.hxx> #include <dbtreelistbox.hxx> -#include <com/sun/star/awt/PopupMenu.hpp> #include <com/sun/star/awt/XTabController.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/container/XContainer.hpp> @@ -53,6 +52,7 @@ #include <vcl/commandinfoprovider.hxx> #include <vcl/cvtgrf.hxx> #include <tools/stream.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include "AppController.hxx" #include <com/sun/star/document/XDocumentProperties.hpp> @@ -1110,7 +1110,7 @@ IMPL_LINK_NOARG(OAppDetailPageHelper, OnDropdownClickHdl, weld::Toggleable&, voi if (!xPopupController.is()) return; - css::uno::Reference<css::awt::XPopupMenu> xPopupMenu(css::awt::PopupMenu::create(xContext)); + rtl::Reference<VCLXPopupMenu> xPopupMenu(new VCLXPopupMenu()); xPopupController->setPopupMenu(xPopupMenu); css::util::URL aTargetURL; diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index d06cd0e82214..289b39c70424 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -27,8 +27,6 @@ #include <svtools/imageresourceaccess.hxx> #include <sfx2/filedlghelper.hxx> -#include <com/sun/star/awt/PopupMenu.hpp> -#include <com/sun/star/awt/XPopupMenu.hpp> #include <com/sun/star/awt/PopupMenuDirection.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> @@ -55,6 +53,7 @@ #include <unotools/streamwrap.hxx> #include <unotools/ucbstreamhelper.hxx> #include <svl/urihelper.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <memory> @@ -867,8 +866,7 @@ void OImageControlControl::mousePressed(const css::awt::MouseEvent& e) // is this a request for a context menu? if ( e.PopupTrigger ) { - Reference< XPopupMenu > xMenu( awt::PopupMenu::create( m_xContext ) ); - DBG_ASSERT( xMenu.is(), "OImageControlControl::mousePressed: could not create a popup menu!" ); + rtl::Reference< VCLXPopupMenu > xMenu( new VCLXPopupMenu() ); Reference< XWindowPeer > xWindowPeer = getPeer(); DBG_ASSERT( xWindowPeer.is(), "OImageControlControl::mousePressed: no window!" ); diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index 03ceaa3d47d8..6f303e5bc296 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -23,7 +23,6 @@ #include <vcl/svapp.hxx> #include <cppuhelper/supportsservice.hxx> -#include <com/sun/star/awt/PopupMenu.hpp> #include <com/sun/star/awt/PopupMenuDirection.hpp> #include <svtools/langtab.hxx> #include <svtools/statusbarcontroller.hxx> @@ -42,6 +41,7 @@ #include <helper/mischelper.hxx> #include <rtl/ustrbuf.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <map> #include <set> @@ -121,9 +121,9 @@ void LangSelectionStatusbarController::LangMenu( bool bCalc = xService.is() && xService->supportsService(u"com.sun.star.sheet.SpreadsheetDocument"_ustr); bool bWriter = xService.is() && xService->supportsService(u"com.sun.star.text.GenericTextDocument"_ustr); //add context menu - Reference< awt::XPopupMenu > xPopupMenu( awt::PopupMenu::create( m_xContext ) ); + rtl::Reference< VCLXPopupMenu > xPopupMenu( new VCLXPopupMenu() ); //sub menu that contains all items except the last two items: Separator + Set Language for Paragraph - Reference< awt::XPopupMenu > subPopupMenu( awt::PopupMenu::create( m_xContext ) ); + rtl::Reference< VCLXPopupMenu > subPopupMenu( new VCLXPopupMenu() ); // get languages to be displayed in the menu std::set< OUString > aLangItems; diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx index 0c7bb1c09c9a..bf32181ce7ab 100644 --- a/sw/source/uibase/uiview/viewling.cxx +++ b/sw/source/uibase/uiview/viewling.cxx @@ -826,10 +826,9 @@ void SwView::ExecSmartTagPopup( const Point& rPt ) xContext->getServiceManager()->createInstanceWithArgumentsAndContext( u"com.sun.star.comp.svx.SmartTagMenuController"_ustr, aArgs, xContext ), css::uno::UNO_QUERY ); - css::uno::Reference< css::awt::XPopupMenu > xPopupMenu( xContext->getServiceManager()->createInstanceWithContext( - u"com.sun.star.awt.PopupMenu"_ustr, xContext ), css::uno::UNO_QUERY ); + rtl::Reference< VCLXPopupMenu > xPopupMenu( new VCLXPopupMenu() ); - if ( xPopupController.is() && xPopupMenu.is() ) + if ( xPopupController.is() ) { xPopupController->setPopupMenu( xPopupMenu ); commit c8d2e22e545406d590fa3b9e52839211b3ccb3cf Author: Noel Grandin <[email protected]> AuthorDate: Sat Jun 14 09:31:58 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sat Jun 14 14:45:07 2025 +0200 construct UNOMemoryStream directly no need to go via UNO context manager Change-Id: I4e6695cb361d3420224dda6df21af557da92d222 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186490 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/comphelper/source/streaming/memorystream.cxx b/comphelper/source/streaming/memorystream.cxx index 39ae66b51d07..7031f814d287 100644 --- a/comphelper/source/streaming/memorystream.cxx +++ b/comphelper/source/streaming/memorystream.cxx @@ -21,24 +21,17 @@ #include <cassert> #include <memory> -#include <boost/core/noinit_adaptor.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/io/IOException.hpp> -#include <com/sun/star/io/XStream.hpp> -#include <com/sun/star/io/XSeekableInputStream.hpp> -#include <com/sun/star/io/XTruncate.hpp> //#include <com/sun/star/uno/XComponentContext.hpp> -#include <comphelper/bytereader.hxx> -#include <cppuhelper/implbase.hxx> +#include <comphelper/memorystream.hxx> #include <cppuhelper/supportsservice.hxx> #include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <string.h> -#include <vector> namespace com::sun::star::uno { class XComponentContext; } @@ -51,56 +44,6 @@ using namespace ::com::sun::star::lang; namespace comphelper { -namespace { - -class UNOMemoryStream : - public WeakImplHelper<XServiceInfo, XStream, XSeekableInputStream, XOutputStream, XTruncate>, - public comphelper::ByteWriter, public comphelper::ByteReader -{ -public: - UNOMemoryStream(); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; - virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; - - // XStream - virtual Reference< XInputStream > SAL_CALL getInputStream( ) override; - virtual Reference< XOutputStream > SAL_CALL getOutputStream( ) override; - - // XInputStream - virtual sal_Int32 SAL_CALL readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) override; - virtual sal_Int32 SAL_CALL readSomeBytes( Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) override; - virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) override; - virtual sal_Int32 SAL_CALL available() override; - virtual void SAL_CALL closeInput() override; - - // XSeekable - virtual void SAL_CALL seek( sal_Int64 location ) override; - virtual sal_Int64 SAL_CALL getPosition() override; - virtual sal_Int64 SAL_CALL getLength() override; - - // XOutputStream - virtual void SAL_CALL writeBytes( const Sequence< sal_Int8 >& aData ) override; - virtual void SAL_CALL flush() override; - virtual void SAL_CALL closeOutput() override; - - // XTruncate - virtual void SAL_CALL truncate() override; - - // comphelper::ByteWriter - virtual void writeBytes(const sal_Int8* aData, sal_Int32 nBytesToWrite) override; - - // comphelper::ByteReader - virtual sal_Int32 readSomeBytes(sal_Int8* aData, sal_Int32 nBytesToRead) override; - -private: - std::vector< sal_Int8, boost::noinit_adaptor<std::allocator<sal_Int8>> > maData; - sal_Int32 mnCursor; -}; - -} UNOMemoryStream::UNOMemoryStream() : mnCursor(0) diff --git a/include/comphelper/memorystream.hxx b/include/comphelper/memorystream.hxx new file mode 100644 index 000000000000..21aad1bcc63c --- /dev/null +++ b/include/comphelper/memorystream.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <comphelper/comphelperdllapi.h> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/io/XStream.hpp> +#include <com/sun/star/io/XSeekableInputStream.hpp> +#include <com/sun/star/io/XTruncate.hpp> +#include <cppuhelper/implbase.hxx> +#include <comphelper/bytereader.hxx> +#include <boost/core/noinit_adaptor.hpp> +#include <vector> + +namespace comphelper +{ +class COMPHELPER_DLLPUBLIC UNOMemoryStream + : public cppu::WeakImplHelper<css::lang::XServiceInfo, css::io::XStream, + css::io::XSeekableInputStream, css::io::XOutputStream, + css::io::XTruncate>, + public comphelper::ByteWriter, + public comphelper::ByteReader +{ +public: + UNOMemoryStream(); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + // XStream + virtual css::uno::Reference<XInputStream> SAL_CALL getInputStream() override; + virtual css::uno::Reference<XOutputStream> SAL_CALL getOutputStream() override; + + // XInputStream + virtual sal_Int32 SAL_CALL readBytes(css::uno::Sequence<sal_Int8>& aData, + sal_Int32 nBytesToRead) override; + virtual sal_Int32 SAL_CALL readSomeBytes(css::uno::Sequence<sal_Int8>& aData, + sal_Int32 nMaxBytesToRead) override; + virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) override; + virtual sal_Int32 SAL_CALL available() override; + virtual void SAL_CALL closeInput() override; + + // XSeekable + virtual void SAL_CALL seek(sal_Int64 location) override; + virtual sal_Int64 SAL_CALL getPosition() override; + virtual sal_Int64 SAL_CALL getLength() override; + + // XOutputStream + virtual void SAL_CALL writeBytes(const css::uno::Sequence<sal_Int8>& aData) override; + virtual void SAL_CALL flush() override; + virtual void SAL_CALL closeOutput() override; + + // XTruncate + virtual void SAL_CALL truncate() override; + + // comphelper::ByteWriter + virtual void writeBytes(const sal_Int8* aData, sal_Int32 nBytesToWrite) override; + + // comphelper::ByteReader + virtual sal_Int32 readSomeBytes(sal_Int8* aData, sal_Int32 nBytesToRead) override; + +private: + std::vector<sal_Int8, boost::noinit_adaptor<std::allocator<sal_Int8>>> maData; + sal_Int32 mnCursor; +}; + +} // namespace comphelper + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx index bf37a0f8f857..c8f2bf6e73d1 100644 --- a/include/oox/export/shapes.hxx +++ b/include/oox/export/shapes.hxx @@ -66,7 +66,6 @@ class Graphic; namespace oox { OOX_DLLPUBLIC css::uno::Reference<css::io::XInputStream> GetOLEObjectStream( - css::uno::Reference<css::uno::XComponentContext> const& xContext, css::uno::Reference<css::embed::XEmbeddedObject> const& xObj, std::u16string_view i_rProgID, OUString & o_rMediaType, diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index ccd879f4494b..3088170c241a 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/io/XStream.hpp> #include <comphelper/docpasswordhelper.hxx> +#include <comphelper/memorystream.hxx> #include <unotools/mediadescriptor.hxx> #include <cppuhelper/supportsservice.hxx> @@ -386,10 +387,7 @@ Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescript else { // create MemoryStream for unencrypted package - rather not put this in a tempfile - Reference<XStream> const xTempStream( - mxContext->getServiceManager()->createInstanceWithContext( - u"com.sun.star.comp.MemoryStream"_ustr, mxContext), - UNO_QUERY_THROW); + rtl::Reference< comphelper::UNOMemoryStream > xTempStream = new comphelper::UNOMemoryStream(); // if decryption was unsuccessful (corrupted file or any other reason) if (!aDecryptor.decrypt(xTempStream)) @@ -399,7 +397,7 @@ Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescript else { // store temp file in media descriptor to keep it alive - rMediaDescriptor.setComponentDataEntry( u"DecryptedPackage"_ustr, Any( xTempStream ) ); + rMediaDescriptor.setComponentDataEntry( u"DecryptedPackage"_ustr, Any( Reference<XStream>(xTempStream) ) ); Reference<XInputStream> xDecryptedInputStream = xTempStream->getInputStream(); if (lclIsZipPackage(mxContext, xDecryptedInputStream, bRepairPackage)) diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index f2d51de6c0e4..4bd29f8efc1b 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -57,6 +57,7 @@ #include <com/sun/star/xml/dom/DocumentBuilder.hpp> #include <comphelper/diagnose_ex.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/memorystream.hxx> #include <oox/core/filterdetect.hxx> #include <comphelper/stl_types.hxx> #include <comphelper/storagehelper.hxx> @@ -1016,10 +1017,7 @@ Reference<XStream> XmlFilterBase::implGetOutputStream( MediaDescriptor& rMediaDe } else // We need to encrypt the stream so create a memory stream { - Reference< XComponentContext > xContext = getComponentContext(); - return Reference< XStream > ( - xContext->getServiceManager()->createInstanceWithContext(u"com.sun.star.comp.MemoryStream"_ustr, xContext), - uno::UNO_QUERY_THROW ); + return new comphelper::UNOMemoryStream(); } } diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index d8c396382217..7ba84690285d 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -72,6 +72,7 @@ #include <comphelper/classids.hxx> #include <comphelper/propertysequence.hxx> #include <comphelper/storagehelper.hxx> +#include <comphelper/memorystream.hxx> #include <sot/exchange.hxx> #include <utility> #include <vcl/graph.hxx> @@ -208,7 +209,6 @@ static void lcl_ConvertProgID(std::u16string_view rProgID, } static uno::Reference<io::XInputStream> lcl_StoreOwnAsOOXML( - uno::Reference<uno::XComponentContext> const& xContext, uno::Reference<embed::XEmbeddedObject> const& xObj, char const*& o_rpProgID, OUString & o_rMediaType, OUString & o_rRelationType, OUString & o_rSuffix) @@ -264,10 +264,7 @@ static uno::Reference<io::XInputStream> lcl_StoreOwnAsOOXML( } // use a temp stream - while it would work to store directly to a // fragment stream, an error during export means we'd have to delete it - uno::Reference<io::XStream> const xTempStream( - xContext->getServiceManager()->createInstanceWithContext( - u"com.sun.star.comp.MemoryStream"_ustr, xContext), - uno::UNO_QUERY_THROW); + rtl::Reference< comphelper::UNOMemoryStream > xTempStream = new comphelper::UNOMemoryStream(); uno::Sequence<beans::PropertyValue> args( comphelper::InitPropertySequence({ { "OutputStream", Any(xTempStream->getOutputStream()) }, { "FilterName", Any(OUString::createFromAscii(pFilterName)) } @@ -287,7 +284,6 @@ static uno::Reference<io::XInputStream> lcl_StoreOwnAsOOXML( } uno::Reference<io::XInputStream> GetOLEObjectStream( - uno::Reference<uno::XComponentContext> const& xContext, uno::Reference<embed::XEmbeddedObject> const& xObj, std::u16string_view i_rProgID, OUString & o_rMediaType, @@ -313,7 +309,7 @@ uno::Reference<io::XInputStream> GetOLEObjectStream( } else // the object is ODF - either the whole document is { // ODF, or the OLE was edited so it was converted to ODF - xInStream = lcl_StoreOwnAsOOXML(xContext, xObj, + xInStream = lcl_StoreOwnAsOOXML(xObj, o_rpProgID, o_rMediaType, o_rRelationType, o_rSuffix); } } @@ -2882,7 +2878,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape ) uno::Reference<io::XInputStream> const xInStream = oox::GetOLEObjectStream( - mpFB->getComponentContext(), xObj, progID, + xObj, progID, sMediaType, sRelationType, sSuffix, pProgID); OUString sURL; diff --git a/package/Library_xstor.mk b/package/Library_xstor.mk index ea6b503e1380..4c929a4e8fd9 100644 --- a/package/Library_xstor.mk +++ b/package/Library_xstor.mk @@ -30,6 +30,10 @@ $(eval $(call gb_Library_use_libraries,xstor,\ utl \ )) +$(eval $(call gb_Library_use_externals,xstor,\ + boost_headers \ +)) + $(eval $(call gb_Library_add_exception_objects,xstor,\ package/source/xstor/disposelistener \ package/source/xstor/ocompinstream \ diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index e3a12ee8db55..b8013e96f745 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -42,6 +42,7 @@ #include <cppuhelper/exc_hlp.hxx> #include <osl/diagnose.h> +#include <comphelper/memorystream.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/servicehelper.hxx> #include <comphelper/storagehelper.hxx> @@ -212,14 +213,6 @@ bool SequencesEqual( const uno::Sequence< beans::NamedValue >& aSequence1, const return true; } -uno::Reference< io::XStream > CreateMemoryStream( const uno::Reference< uno::XComponentContext >& rContext ) -{ - static constexpr OUStringLiteral sName(u"com.sun.star.comp.MemoryStream"); - return uno::Reference< io::XStream >( - rContext->getServiceManager()->createInstanceWithContext(sName, rContext), - uno::UNO_QUERY_THROW); -} - const beans::StringPair* lcl_findPairByName(const uno::Sequence<beans::StringPair>& rSeq, const OUString& rName) { return std::find_if(rSeq.begin(), rSeq.end(), @@ -497,9 +490,8 @@ void OWriteStream_Impl::FillTempGetFileName() if ( !xOrigStream.is() ) { // in case of new inserted package stream it is possible that input stream still was not set - uno::Reference< io::XStream > xCacheStream = CreateMemoryStream( m_xContext ); - SAL_WARN_IF( !xCacheStream.is(), "package.xstor", "If the stream can not be created an exception must be thrown!" ); - m_xCacheSeek.set( xCacheStream, uno::UNO_QUERY_THROW ); + rtl::Reference< comphelper::UNOMemoryStream > xCacheStream = new comphelper::UNOMemoryStream(); + m_xCacheSeek = xCacheStream; m_xCacheStream = std::move(xCacheStream); } else @@ -512,15 +504,14 @@ void OWriteStream_Impl::FillTempGetFileName() if ( nRead <= MAX_STORCACHE_SIZE ) { - uno::Reference< io::XStream > xCacheStream = CreateMemoryStream( m_xContext ); - SAL_WARN_IF( !xCacheStream.is(), "package.xstor", "If the stream can not be created an exception must be thrown!" ); + rtl::Reference< comphelper::UNOMemoryStream > xCacheStream = new comphelper::UNOMemoryStream(); if ( nRead ) { uno::Reference< io::XOutputStream > xOutStream( xCacheStream->getOutputStream(), uno::UNO_SET_THROW ); xOutStream->writeBytes( aData ); } - m_xCacheSeek.set( xCacheStream, uno::UNO_QUERY_THROW ); + m_xCacheSeek = xCacheStream; m_xCacheStream = std::move(xCacheStream); m_xCacheSeek->seek( 0 ); } @@ -1215,8 +1206,9 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream_Impl( sal_Int32 nStre if ( m_pParent ) m_pParent->m_bIsModified = true; - xStream = CreateMemoryStream( m_xContext ); - m_xCacheSeek.set( xStream, uno::UNO_QUERY_THROW ); + rtl::Reference<comphelper::UNOMemoryStream> xMemStream = new comphelper::UNOMemoryStream(); + xStream = xMemStream; + m_xCacheSeek = xMemStream; m_xCacheStream = xStream; } else if ( !m_bHasInsertedStreamOptimization ) diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 760d21bf48da..a0ef7b2bc210 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -78,6 +78,7 @@ #include <unotools/tempfile.hxx> #include <comphelper/lok.hxx> #include <comphelper/fileurl.hxx> +#include <comphelper/memorystream.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/interaction.hxx> @@ -447,7 +448,7 @@ public: uno::Reference<io::XStream> xStream; uno::Reference<io::XStream> m_xLockingStream; uno::Reference<task::XInteractionHandler> xInteraction; - uno::Reference<io::XStream> m_xODFDecryptedInnerPackageStream; + rtl::Reference< comphelper::UNOMemoryStream > m_xODFDecryptedInnerPackageStream; uno::Reference<embed::XStorage> m_xODFEncryptedOuterStorage; uno::Reference<embed::XStorage> m_xODFDecryptedInnerZipStorage; @@ -1758,10 +1759,7 @@ SfxMedium::TryEncryptedInnerPackage(uno::Reference<embed::XStorage> const & xSto assert(xDecryptedInnerPackage.is()); // need a seekable stream => copy Reference<uno::XComponentContext> const& xContext(::comphelper::getProcessComponentContext()); - uno::Reference<io::XStream> const xDecryptedInnerPackageStream( - xContext->getServiceManager()->createInstanceWithContext( - u"com.sun.star.comp.MemoryStream"_ustr, xContext), - UNO_QUERY_THROW); + rtl::Reference< comphelper::UNOMemoryStream > xDecryptedInnerPackageStream = new comphelper::UNOMemoryStream(); comphelper::OStorageHelper::CopyInputToOutput(xDecryptedInnerPackage->getInputStream(), xDecryptedInnerPackageStream->getOutputStream()); xDecryptedInnerPackageStream->getOutputStream()->closeOutput(); #if 0 @@ -4429,7 +4427,7 @@ void SfxMedium::SignContents_Impl(weld::Window* pDialogParent, if (pImpl->m_bODFWholesomeEncryption) { // manually copy the inner package to the outer one - uno::Reference<io::XSeekable>(pImpl->m_xODFDecryptedInnerPackageStream, uno::UNO_QUERY_THROW)->seek(0); + pImpl->m_xODFDecryptedInnerPackageStream->seek(0); uno::Reference<io::XStream> const xEncryptedPackage = pImpl->m_xODFEncryptedOuterStorage->openStreamElement( u"encrypted-package"_ustr, diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index bde35636ad63..078291d93e03 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -74,6 +74,7 @@ #include <unotools/securityoptions.hxx> #include <tools/urlobj.hxx> #include <comphelper/diagnose_ex.hxx> +#include <comphelper/memorystream.hxx> #include <unotools/ucbhelper.hxx> #include <unotools/tempfile.hxx> #include <unotools/docinfohelper.hxx> @@ -1548,7 +1549,7 @@ bool SfxObjectShell::SaveTo_Impl } } - uno::Reference<io::XStream> xODFDecryptedInnerPackageStream; + rtl::Reference< comphelper::UNOMemoryStream > xODFDecryptedInnerPackageStream; uno::Reference<embed::XStorage> xODFDecryptedInnerPackage; uno::Sequence<beans::NamedValue> aEncryptionData; if (GetEncryptionData_Impl(&rMedium.GetItemSet(), aEncryptionData)) @@ -1562,10 +1563,7 @@ bool SfxObjectShell::SaveTo_Impl // clear now to store inner package (+ embedded objects) unencrypted rMedium.GetItemSet().ClearItem(SID_ENCRYPTIONDATA); rMedium.GetItemSet().ClearItem(SID_PASSWORD); - xODFDecryptedInnerPackageStream.set( - xContext->getServiceManager()->createInstanceWithContext( - u"com.sun.star.comp.MemoryStream"_ustr, xContext), - UNO_QUERY_THROW); + xODFDecryptedInnerPackageStream = new comphelper::UNOMemoryStream(); xODFDecryptedInnerPackage = ::comphelper::OStorageHelper::GetStorageOfFormatFromStream( PACKAGE_STORAGE_FORMAT_STRING, xODFDecryptedInnerPackageStream, css::embed::ElementModes::WRITE, xContext, false); @@ -2089,7 +2087,7 @@ bool SfxObjectShell::SaveTo_Impl xEncryptedPackageProps->setPropertyValue(u"MediaType"_ustr, mediaType); // encryption: just copy into package stream - uno::Reference<io::XSeekable>(xODFDecryptedInnerPackageStream, uno::UNO_QUERY_THROW)->seek(0); + xODFDecryptedInnerPackageStream->seek(0); comphelper::OStorageHelper::CopyInputToOutput( xODFDecryptedInnerPackageStream->getInputStream(), xEncryptedInnerPackage->getOutputStream()); diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index daf484eed592..ebd8cb1efbde 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -93,6 +93,7 @@ #include "ww8scan.hxx" #include <oox/token/properties.hxx> +#include <comphelper/memorystream.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> #include <comphelper/storagehelper.hxx> @@ -425,7 +426,7 @@ OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID) const char * pProgID(nullptr); uno::Reference<io::XInputStream> const xInStream = - oox::GetOLEObjectStream(xContext, xObj, io_rProgID, + oox::GetOLEObjectStream(xObj, io_rProgID, sMediaType, sRelationType, sSuffix, pProgID); if (!xInStream.is()) @@ -1711,17 +1712,14 @@ void DocxExport::WriteCustomXml() if (m_SdtData.size()) { // There are some SDT blocks data with data bindings which can update some custom xml values - uno::Reference< io::XStream > xMemStream( - comphelper::getProcessComponentContext()->getServiceManager()->createInstanceWithContext(u"com.sun.star.comp.MemoryStream"_ustr, - comphelper::getProcessComponentContext()), - uno::UNO_QUERY_THROW); + rtl::Reference< comphelper::UNOMemoryStream > xMemStream = new comphelper::UNOMemoryStream(); writer->setOutputStream(xMemStream->getOutputStream()); serializer->serialize(writer, uno::Sequence< beans::StringPair >()); uno::Reference< io::XStream > xXSLTInStream = xMemStream; - uno::Reference< io::XStream > xXSLTOutStream; + rtl::Reference< comphelper::UNOMemoryStream > xXSLTOutStream; // Apply XSLT transformations for each SDT data binding // Seems it is not possible to do this as one transformation: each data binding // can have different namespaces, but with conflicting names (ns0, ns1, etc..) @@ -1734,10 +1732,7 @@ void DocxExport::WriteCustomXml() } else { - xXSLTOutStream.set( - comphelper::getProcessComponentContext()->getServiceManager()->createInstanceWithContext(u"com.sun.star.comp.MemoryStream"_ustr, - comphelper::getProcessComponentContext()), - uno::UNO_QUERY_THROW); + xXSLTOutStream = new comphelper::UNOMemoryStream(); lcl_UpdateXmlValues(m_SdtData[i], xXSLTInStream->getInputStream(), xXSLTOutStream->getOutputStream()); // Use previous output as an input for next run xXSLTInStream.set( xXSLTOutStream ); diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 5eb127ac8a89..d488832f9db8 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -83,6 +83,7 @@ #include <com/sun/star/text/XText.hpp> #include <comphelper/classids.hxx> +#include <comphelper/memorystream.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> @@ -3435,7 +3436,7 @@ void ExportGraphicPreview(const uno::Reference<graphic::XGraphic>& xGraphic, SvX OUString sPictureName; if( bExportEmbedded ) { - xPictureStream.set( xContext->getServiceManager()->createInstanceWithContext( u"com.sun.star.comp.MemoryStream"_ustr, xContext), uno::UNO_QUERY_THROW ); + xPictureStream = new comphelper::UNOMemoryStream(); } else {
