summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2024-04-01 20:52:59 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-04-02 07:53:43 +0200
commit25b642fdd87da4d5ed556600d0eb69d72865f666 (patch)
treedbf08943be588a9e9e09f7aaa2f03d057649c14c /svx
parent2ad14abcf790002ac6fe09afbc5a2cae46f62085 (diff)
simplify SotTempStream and lifetime
It is really just an SvStream instance, and the lifetime does not need reference counting Change-Id: Idb5ffd96f852aae0dc1a94cddc0a83fbcdf974ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165655 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/inc/galleryfilestorage.hxx6
-rw-r--r--svx/source/gallery2/galleryfilestorage.cxx14
-rw-r--r--svx/source/gallery2/galmisc.cxx18
-rw-r--r--svx/source/gallery2/galtheme.cxx12
4 files changed, 23 insertions, 27 deletions
diff --git a/svx/inc/galleryfilestorage.hxx b/svx/inc/galleryfilestorage.hxx
index f913b0574fc1..42c40beef667 100644
--- a/svx/inc/galleryfilestorage.hxx
+++ b/svx/inc/galleryfilestorage.hxx
@@ -81,10 +81,8 @@ public:
bool readModel(const GalleryObject* pObject, SdrModel& rModel);
SgaObjectSvDraw insertModel(const FmFormModel& rModel, const INetURLObject& rUserURL);
- bool readModelStream(const GalleryObject* pObject,
- tools::SvRef<SotTempStream> const& rxModelStream);
- SgaObjectSvDraw insertModelStream(const tools::SvRef<SotTempStream>& rxModelStream,
- const INetURLObject& rUserURL);
+ bool readModelStream(const GalleryObject* pObject, SvStream& rModelStream);
+ SgaObjectSvDraw insertModelStream(SvStream& rModelStream, const INetURLObject& rUserURL);
INetURLObject implCreateUniqueURL(SgaObjKind eObjKind, const INetURLObject& rUserURL,
ConvertDataFormat nFormat = ConvertDataFormat::Unknown);
diff --git a/svx/source/gallery2/galleryfilestorage.cxx b/svx/source/gallery2/galleryfilestorage.cxx
index bef365a0060c..73f6492c1268 100644
--- a/svx/source/gallery2/galleryfilestorage.cxx
+++ b/svx/source/gallery2/galleryfilestorage.cxx
@@ -332,8 +332,7 @@ SgaObjectSvDraw GalleryFileStorage::insertModel(const FmFormModel& rModel,
return SgaObjectSvDraw();
}
-bool GalleryFileStorage::readModelStream(const GalleryObject* pObject,
- tools::SvRef<SotTempStream> const& rxModelStream)
+bool GalleryFileStorage::readModelStream(const GalleryObject* pObject, SvStream& rxModelStream)
{
const INetURLObject aURL(ImplGetURL(pObject));
rtl::Reference<SotStorage> xSotStorage(GetSvDrawStorage());
@@ -363,13 +362,13 @@ bool GalleryFileStorage::readModelStream(const GalleryObject* pObject,
{
uno::Reference<io::XOutputStream> xDocOut(
- new utl::OOutputStreamWrapper(*rxModelStream));
+ new utl::OOutputStreamWrapper(rxModelStream));
SvxDrawingLayerExport(aModel.GetModel(), xDocOut);
}
}
- bRet = (rxModelStream->GetError() == ERRCODE_NONE);
+ bRet = (rxModelStream.GetError() == ERRCODE_NONE);
}
}
@@ -379,9 +378,8 @@ bool GalleryFileStorage::readModelStream(const GalleryObject* pObject,
return bRet;
}
-SgaObjectSvDraw
-GalleryFileStorage::insertModelStream(const tools::SvRef<SotTempStream>& rxModelStream,
- const INetURLObject& rUserURL)
+SgaObjectSvDraw GalleryFileStorage::insertModelStream(SvStream& rModelStream,
+ const INetURLObject& rUserURL)
{
INetURLObject aURL(implCreateUniqueURL(SgaObjKind::SvDraw, rUserURL));
rtl::Reference<SotStorage> xSotStorage(GetSvDrawStorage());
@@ -397,7 +395,7 @@ GalleryFileStorage::insertModelStream(const tools::SvRef<SotTempStream>& rxModel
GalleryCodec aCodec(*xOutputStream);
xOutputStream->SetBufferSize(16348);
- aCodec.Write(*rxModelStream);
+ aCodec.Write(rModelStream);
if (!xOutputStream->GetError())
{
diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx
index ab5713f7a4df..3eacf5691819 100644
--- a/svx/source/gallery2/galmisc.cxx
+++ b/svx/source/gallery2/galmisc.cxx
@@ -394,13 +394,13 @@ void GalleryTransferable::InitData( bool bLazy )
mpGraphicObject.reset(new GraphicObject( std::move(aGraphic) ));
}
- if( !mxModelStream.is() )
+ if( !mxModelStream )
{
- mxModelStream = new SotTempStream( "" );
+ mxModelStream = SotTempStream::Create( "" );
mxModelStream->SetBufferSize( 16348 );
- if (!mpTheme || !mpTheme->GetModelStream(mnObjectPos, mxModelStream))
- mxModelStream.clear();
+ if (!mpTheme || !mpTheme->GetModelStream(mnObjectPos, *mxModelStream))
+ mxModelStream.reset();
else
mxModelStream->Seek( 0 );
}
@@ -480,7 +480,7 @@ bool GalleryTransferable::GetData( const datatransfer::DataFlavor& rFlavor, cons
if( ( SotClipboardFormatId::DRAWING == nFormat ) && ( SgaObjKind::SvDraw == meObjectKind ) )
{
- bRet = ( mxModelStream.is() && SetObject( mxModelStream.get(), 0, rFlavor ) );
+ bRet = ( mxModelStream && SetObject( mxModelStream.get(), 0, rFlavor ) );
}
else if( ( SotClipboardFormatId::SIMPLE_FILE == nFormat ) && mpURL )
{
@@ -502,15 +502,15 @@ bool GalleryTransferable::GetData( const datatransfer::DataFlavor& rFlavor, cons
return bRet;
}
-bool GalleryTransferable::WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* pUserObject,
+bool GalleryTransferable::WriteObject( SvStream& rOStm, void* pUserObject,
sal_uInt32, const datatransfer::DataFlavor& )
{
bool bRet = false;
if( pUserObject )
{
- rxOStm->WriteStream( *static_cast< SotStorageStream* >( pUserObject ) );
- bRet = ( rxOStm->GetError() == ERRCODE_NONE );
+ rOStm.WriteStream( *static_cast< SotStorageStream* >( pUserObject ) );
+ bRet = ( rOStm.GetError() == ERRCODE_NONE );
}
return bRet;
@@ -533,7 +533,7 @@ void GalleryTransferable::DragFinished( sal_Int8 nDropAction )
void GalleryTransferable::ObjectReleased()
{
- mxModelStream.clear();
+ mxModelStream.reset();
mpGraphicObject.reset();
mpURL.reset();
}
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 4b6d0c86200a..857de6ecd413 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -456,24 +456,24 @@ bool GalleryTheme::InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos)
return bRet;
}
-bool GalleryTheme::GetModelStream(sal_uInt32 nPos, tools::SvRef<SotTempStream> const & rxModelStream)
+bool GalleryTheme::GetModelStream(sal_uInt32 nPos, SvStream& rModelStream)
{
const GalleryObject* pObject = maGalleryObjectCollection.getForPosition( nPos );
bool bRet = false;
if( pObject && ( SgaObjKind::SvDraw == pObject->eObjKind ) )
{
- bRet = mpGalleryStorageEngine->readModelStream(pObject, rxModelStream);
+ bRet = mpGalleryStorageEngine->readModelStream(pObject, rModelStream);
}
return bRet;
}
-bool GalleryTheme::InsertModelStream(const tools::SvRef<SotTempStream>& rxModelStream, sal_uInt32 nInsertPos)
+bool GalleryTheme::InsertModelStream(SvStream& rModelStream, sal_uInt32 nInsertPos)
{
bool bRet = false;
- const SgaObjectSvDraw aObjSvDraw = mpGalleryStorageEngine->insertModelStream(rxModelStream, GetParent()->GetUserURL());
+ const SgaObjectSvDraw aObjSvDraw = mpGalleryStorageEngine->insertModelStream(rModelStream, GetParent()->GetUserURL());
if(aObjSvDraw.IsValid())
bRet = InsertObject( aObjSvDraw, nInsertPos );
@@ -542,10 +542,10 @@ bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTrans
if( aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) )
{
- tools::SvRef<SotTempStream> xModelStm;
+ std::unique_ptr<SvStream> xModelStm;
if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING, xModelStm ) )
- bRet = InsertModelStream( xModelStm, nInsertPos );
+ bRet = InsertModelStream( *xModelStm, nInsertPos );
}
else if( aDataHelper.HasFormat( SotClipboardFormatId::FILE_LIST ) ||
aDataHelper.HasFormat( SotClipboardFormatId::SIMPLE_FILE ) )