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>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
dd3ab0fd73
commit
e7b6205bcf
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
@@ -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() );
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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, "");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ) );
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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* )
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user