summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpanoskorovesis <panoskorovesis@outlook.com>2021-08-05 17:37:13 +0300
committerTomaž Vajngerl <quikee@gmail.com>2021-08-17 04:40:46 +0200
commite7b6205bcf127d8afab8dfd015fef7573b296a22 (patch)
treec73551370ada11d7e208afe550bd4a922377d889
parentFix typos (diff)
downloadcore-e7b6205bcf127d8afab8dfd015fef7573b296a22.tar.gz
core-e7b6205bcf127d8afab8dfd015fef7573b296a22.zip
Replace GDIMetaFile::Write and WriteGDIMetaFile with SvmWriter::Write
Use the new write functionality. This change also sets SvmWriter::Write second argument as const, as it's value does not change Change-Id: I1620756542a0bc54b5f8fc7ce3f57d0243a2ee55 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120408 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--include/vcl/filter/SvmWriter.hxx2
-rw-r--r--sd/source/ui/unoidl/unopage.cxx6
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx7
-rw-r--r--svtools/source/misc/embedtransfer.cxx4
-rw-r--r--svx/source/gallery2/gallerybinaryengine.cxx4
-rw-r--r--svx/source/gallery2/galobj.cxx9
-rw-r--r--svx/source/xml/xmlgrhlp.cxx7
-rw-r--r--vcl/qa/cppunit/svm/svmtest.cxx3
-rw-r--r--vcl/source/filter/graphicfilter.cxx7
-rw-r--r--vcl/source/filter/svm/SvmWriter.cxx6
-rw-r--r--vcl/source/gdi/TypeSerializer.cxx9
-rw-r--r--vcl/source/gdi/impgraph.cxx7
-rw-r--r--vcl/source/gdi/metaact.cxx7
-rw-r--r--vcl/source/treelist/transfer.cxx4
-rw-r--r--writerperfect/source/writer/EPUBExportFilter.cxx4
15 files changed, 65 insertions, 21 deletions
diff --git a/include/vcl/filter/SvmWriter.hxx b/include/vcl/filter/SvmWriter.hxx
index 8d2a195695b5..9bd3989a1b9a 100644
--- a/include/vcl/filter/SvmWriter.hxx
+++ b/include/vcl/filter/SvmWriter.hxx
@@ -36,7 +36,7 @@ protected:
public:
SvmWriter(SvStream& rIStm);
- SvStream& Write(GDIMetaFile& rMetaFile);
+ SvStream& Write(const GDIMetaFile& rMetaFile);
void MetaActionHandler(MetaAction* pAction, ImplMetaWriteData* pData);
void ActionHandler(MetaAction* pAction);
void PixelHandler(MetaPixelAction* pAction);
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index f774fad439ef..e80bf3f20591 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -35,6 +35,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <rtl/ustrbuf.hxx>
#include <vcl/bitmapex.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <vcl/metaact.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/diagnose_ex.h>
@@ -1105,8 +1106,11 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
// Preview: WMF format.
ConvertGDIMetaFileToWMF(*xMetaFile, aDestStrm, nullptr, false);
else
+ {
// PreviewMetafile: SVM format.
- xMetaFile->Write(aDestStrm);
+ SvmWriter aWriter(aDestStrm);
+ aWriter.Write(*xMetaFile);
+ }
Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aDestStrm.GetData()), aDestStrm.Tell() );
aAny <<= aSeq;
}
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 50835238c40b..6d501fb4107b 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -76,6 +76,7 @@
#include <unotools/tempfile.hxx>
#include <osl/mutex.hxx>
#include <vcl/errcode.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <vcl/salctype.hxx>
#include <vcl/gdimtf.hxx>
#include <comphelper/fileformat.h>
@@ -2058,7 +2059,8 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla
SvMemoryStream aMemStm( 65535, 65535 );
aMemStm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
- xMetaFile->Write( aMemStm );
+ SvmWriter aWriter( aMemStm );
+ aWriter.Write( *xMetaFile );
aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ),
aMemStm.TellEnd() );
}
@@ -2076,7 +2078,8 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla
SvMemoryStream aMemStm( 65535, 65535 );
aMemStm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
- xMetaFile->Write( aMemStm );
+ SvmWriter aWriter( aMemStm );
+ aWriter.Write( *xMetaFile );
aAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ),
aMemStm.TellEnd() );
}
diff --git a/svtools/source/misc/embedtransfer.cxx b/svtools/source/misc/embedtransfer.cxx
index ac18b8cdead9..388a9f0f87a9 100644
--- a/svtools/source/misc/embedtransfer.cxx
+++ b/svtools/source/misc/embedtransfer.cxx
@@ -27,6 +27,7 @@
#include <svtools/embedtransfer.hxx>
#include <tools/mapunit.hxx>
#include <vcl/outdev.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <vcl/gdimtf.hxx>
#include <comphelper/fileformat.h>
#include <comphelper/propertysequence.hxx>
@@ -156,7 +157,8 @@ bool SvEmbedTransferHelper::GetData( const css::datatransfer::DataFlavor& rFlavo
aMemStm.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
const GDIMetaFile& aMetaFile = m_pGraphic->GetGDIMetaFile();
- const_cast<GDIMetaFile*>(&aMetaFile)->Write( aMemStm );
+ SvmWriter aWriter( aMemStm );
+ aWriter.Write( aMetaFile );
uno::Any aAny;
aAny <<= uno::Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ),
aMemStm.TellEnd() );
diff --git a/svx/source/gallery2/gallerybinaryengine.cxx b/svx/source/gallery2/gallerybinaryengine.cxx
index 661b3dd03bed..c2216b2766f5 100644
--- a/svx/source/gallery2/gallerybinaryengine.cxx
+++ b/svx/source/gallery2/gallerybinaryengine.cxx
@@ -28,6 +28,7 @@
#include "codec.hxx"
#include "gallerydrawmodel.hxx"
#include <vcl/cvtgrf.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <sal/log.hxx>
@@ -504,7 +505,8 @@ SgaObjectBmp GalleryBinaryEngine::insertGraphic(const Graphic& rGraphic, const G
{
GDIMetaFile aMtf(rGraphic.GetGDIMetaFile());
- aMtf.Write(*pOStm);
+ SvmWriter aWriter(*pOStm);
+ aWriter.Write(aMtf);
bRet = (pOStm->GetError() == ERRCODE_NONE);
}
else
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
index 80c81063d951..5044d0ff7934 100644
--- a/svx/source/gallery2/galobj.cxx
+++ b/svx/source/gallery2/galobj.cxx
@@ -33,6 +33,7 @@
#include <galobj.hxx>
#include <vcl/dibtools.hxx>
#include <vcl/filter/SvmReader.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include "gallerydrawmodel.hxx"
#include <bitmaps.hlst>
@@ -193,7 +194,13 @@ void SgaObject::WriteData( SvStream& rOut, const OUString& rDestDir ) const
rOut.SetCompressMode( nOldCompressMode );
}
else
- WriteGDIMetaFile( rOut, aThumbMtf );
+ {
+ if(!rOut.GetError())
+ {
+ SvmWriter aWriter(rOut);
+ aWriter.Write(aThumbMtf);
+ }
+ }
OUString aURLWithoutDestDir = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
aURLWithoutDestDir = aURLWithoutDestDir.replaceFirst(rDestDir, "");
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 27db089871a2..f6731422f0da 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -39,6 +39,7 @@
#include <unotools/streamwrap.hxx>
#include <unotools/tempfile.hxx>
#include <unotools/saveopt.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <vcl/gfxlink.hxx>
#include <vcl/metaact.hxx>
#include <tools/zcodec.hxx>
@@ -152,7 +153,8 @@ GraphicInputStream::GraphicInputStream(GraphicObject const & aGraphicObject, con
{
pStream->SetVersion(SOFFICE_FILEFORMAT_8);
pStream->SetCompressMode(SvStreamCompressFlags::ZBITMAP);
- const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()).Write(*pStream);
+ SvmWriter aWriter(*pStream);
+ aWriter.Write(aGraphic.GetGDIMetaFile());
bRet = (pStream->GetError() == ERRCODE_NONE);
}
else if (!rMimeType.isEmpty())
@@ -808,7 +810,8 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
}
else
{
- rMtf.Write(*pStream);
+ SvmWriter aWriter(*pStream);
+ aWriter.Write(rMtf);
}
bSuccess = (pStream->GetError() == ERRCODE_NONE);
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index 2ffb8ff14c9b..05a3a8ce78a3 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -309,7 +309,8 @@ static void writeMetaFile(GDIMetaFile& rInputMetafile, const OUString& rUrl)
{
SvFileStream aFileStream(rUrl, StreamMode::WRITE);
aFileStream.Seek(STREAM_SEEK_TO_BEGIN);
- rInputMetafile.Write(aFileStream);
+ SvmWriter aWriter(aFileStream);
+ aWriter.Write(rInputMetafile);
aFileStream.Close();
}
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index b0ee96a0e54c..d7848b83a8bb 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -31,6 +31,7 @@
#include <fltcall.hxx>
#include <vcl/salctype.hxx>
#include <vcl/filter/PngImageReader.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <vcl/pngwrite.hxx>
#include <vcl/vectorgraphicdata.hxx>
#include <vcl/virdev.hxx>
@@ -1623,7 +1624,8 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
// #i119735# just use GetGDIMetaFile, it will create a buffered version of contained bitmap now automatically
GDIMetaFile aMTF(aGraphic.GetGDIMetaFile());
- aMTF.Write( rOStm );
+ SvmWriter aWriter( rOStm );
+ aWriter.Write( aMTF );
if( rOStm.GetError() )
nStatus = ERRCODE_GRFILTER_IOERROR;
@@ -1821,7 +1823,8 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r
SvMemoryStream aMemStm( 65535, 65535 );
// #i119735# just use GetGDIMetaFile, it will create a buffered version of contained bitmap now automatically
- const_cast<GDIMetaFile&>( aGraphic.GetGDIMetaFile() ).Write( aMemStm );
+ SvmWriter aWriter( aMemStm );
+ aWriter.Write( aGraphic.GetGDIMetaFile() );
xActiveDataSource->setOutputStream( css::uno::Reference< css::io::XOutputStream >(
xStmIf, css::uno::UNO_QUERY ) );
diff --git a/vcl/source/filter/svm/SvmWriter.cxx b/vcl/source/filter/svm/SvmWriter.cxx
index bb1901f19dc2..189f6a8e69ac 100644
--- a/vcl/source/filter/svm/SvmWriter.cxx
+++ b/vcl/source/filter/svm/SvmWriter.cxx
@@ -35,7 +35,7 @@ void SvmWriter::WriteColor(::Color aColor)
mrStream.WriteUInt32(static_cast<sal_uInt32>(aColor));
}
-SvStream& SvmWriter::Write(GDIMetaFile& rMetaFile)
+SvStream& SvmWriter::Write(const GDIMetaFile& rMetaFile)
{
const SvStreamCompressFlags nStmCompressMode = mrStream.GetCompressMode();
SvStreamEndian nOldFormat = mrStream.GetEndian();
@@ -57,11 +57,11 @@ SvStream& SvmWriter::Write(GDIMetaFile& rMetaFile)
aWriteData.meActualCharSet = mrStream.GetStreamCharSet();
- MetaAction* pAct = rMetaFile.FirstAction();
+ MetaAction* pAct = const_cast<GDIMetaFile&>(rMetaFile).FirstAction();
while (pAct)
{
MetaActionHandler(pAct, &aWriteData);
- pAct = rMetaFile.NextAction();
+ pAct = const_cast<GDIMetaFile&>(rMetaFile).NextAction();
}
mrStream.SetEndian(nOldFormat);
diff --git a/vcl/source/gdi/TypeSerializer.cxx b/vcl/source/gdi/TypeSerializer.cxx
index 6f88b1954e25..403ec5e56428 100644
--- a/vcl/source/gdi/TypeSerializer.cxx
+++ b/vcl/source/gdi/TypeSerializer.cxx
@@ -23,6 +23,7 @@
#include <sal/log.hxx>
#include <comphelper/fileformat.h>
#include <vcl/filter/SvmReader.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/dibtools.hxx>
@@ -410,7 +411,13 @@ void TypeSerializer::writeGraphic(const Graphic& rGraphic)
default:
{
if (aGraphic.IsSupportedGraphic())
- WriteGDIMetaFile(mrStream, rGraphic.GetGDIMetaFile());
+ {
+ if (!mrStream.GetError())
+ {
+ SvmWriter aWriter(mrStream);
+ aWriter.Write(rGraphic.GetGDIMetaFile());
+ }
+ }
}
break;
}
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 242e1d22e49e..6e4416935100 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -32,6 +32,7 @@
#include <unotools/ucbstreamhelper.hxx>
#include <unotools/tempfile.hxx>
#include <vcl/filter/SvmReader.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <vcl/outdev.hxx>
#include <vcl/graphicfilter.hxx>
#include <vcl/virdev.hxx>
@@ -1188,7 +1189,11 @@ bool ImpGraphic::swapOutGraphic(SvStream& rStream)
{
case GraphicType::GdiMetafile:
{
- WriteGDIMetaFile(rStream, maMetaFile);
+ if(!rStream.GetError())
+ {
+ SvmWriter aWriter(rStream);
+ aWriter.Write(maMetaFile);
+ }
}
break;
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx
index 0685f939683f..5ec7e2055fa8 100644
--- a/vcl/source/gdi/metaact.cxx
+++ b/vcl/source/gdi/metaact.cxx
@@ -26,6 +26,7 @@
#include <tools/helpers.hxx>
#include <vcl/dibtools.hxx>
#include <vcl/filter/SvmReader.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <vcl/outdev.hxx>
#include <vcl/metaact.hxx>
#include <vcl/graphictools.hxx>
@@ -3023,7 +3024,8 @@ void MetaFloatTransparentAction::Write( SvStream& rOStm, ImplMetaWriteData* pDat
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
- maMtf.Write( rOStm );
+ SvmWriter aWriter( rOStm );
+ aWriter.Write( maMtf );
TypeSerializer aSerializer(rOStm);
aSerializer.writePoint(maPoint);
aSerializer.writeSize(maSize);
@@ -3089,7 +3091,8 @@ void MetaEPSAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
aSerializer.writeGfxLink(maGfxLink);
aSerializer.writePoint(maPoint);
aSerializer.writeSize(maSize);
- maSubst.Write( rOStm );
+ SvmWriter aWriter( rOStm );
+ aWriter.Write( maSubst );
}
void MetaEPSAction::Read( SvStream& rIStm, ImplMetaReadData* )
diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx
index 99f76a0ce78e..c8dfe375b6c9 100644
--- a/vcl/source/treelist/transfer.cxx
+++ b/vcl/source/treelist/transfer.cxx
@@ -32,6 +32,7 @@
#include <sot/storage.hxx>
#include <vcl/bitmap.hxx>
#include <vcl/filter/SvmReader.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/graph.hxx>
#include <vcl/cvtgrf.hxx>
@@ -723,7 +724,8 @@ bool TransferableHelper::SetGDIMetaFile( const GDIMetaFile& rMtf )
{
SvMemoryStream aMemStm( 65535, 65535 );
- const_cast<GDIMetaFile&>(rMtf).Write( aMemStm );
+ SvmWriter aWriter( aMemStm );
+ aWriter.Write( rMtf );
maAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.TellEnd() );
}
diff --git a/writerperfect/source/writer/EPUBExportFilter.cxx b/writerperfect/source/writer/EPUBExportFilter.cxx
index d944b080ddd3..129d2941c795 100644
--- a/writerperfect/source/writer/EPUBExportFilter.cxx
+++ b/writerperfect/source/writer/EPUBExportFilter.cxx
@@ -24,6 +24,7 @@
#include <comphelper/propertysetinfo.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <svtools/DocumentToGraphicRenderer.hxx>
+#include <vcl/filter/SvmWriter.hxx>
#include <vcl/gdimtf.hxx>
#include <tools/stream.hxx>
@@ -158,7 +159,8 @@ void EPUBExportFilter::CreateMetafiles(std::vector<exp::FixedLayoutPage>& rPageM
rGDIMetaFile.SetPrefSize(aLogic);
SvMemoryStream aMemoryStream;
- rGDIMetaFile.Write(aMemoryStream);
+ SvmWriter aWriter(aMemoryStream);
+ aWriter.Write(rGDIMetaFile);
uno::Sequence<sal_Int8> aSequence(static_cast<const sal_Int8*>(aMemoryStream.GetData()),
aMemoryStream.Tell());