vcl: convert PCX to use ImportOutput
Change-Id: I979091f0d7d6c6c5bf31209d3dc64606e230ba19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185077 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
parent
1251d5314a
commit
f4ed5e6f62
@ -19,8 +19,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vcl/graph.hxx>
|
class SvStream;
|
||||||
|
class ImportOutput;
|
||||||
|
|
||||||
VCL_DLLPUBLIC bool ImportPcxGraphic(SvStream& rStream, Graphic& rGraphic);
|
VCL_DLLPUBLIC bool ImportPcxGraphic(SvStream& rStream, ImportOutput& rImportOutput);
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <test/bootstrapfixture.hxx>
|
#include <test/bootstrapfixture.hxx>
|
||||||
#include <vcl/FilterConfigItem.hxx>
|
#include <vcl/FilterConfigItem.hxx>
|
||||||
#include <tools/stream.hxx>
|
#include <tools/stream.hxx>
|
||||||
#include <vcl/graph.hxx>
|
#include <vcl/filter/ImportOutput.hxx>
|
||||||
#include <filter/PcxReader.hxx>
|
#include <filter/PcxReader.hxx>
|
||||||
|
|
||||||
using namespace css;
|
using namespace css;
|
||||||
@ -44,8 +44,8 @@ bool PcxFilterTest::load(const OUString &,
|
|||||||
SfxFilterFlags, SotClipboardFormatId, unsigned int)
|
SfxFilterFlags, SotClipboardFormatId, unsigned int)
|
||||||
{
|
{
|
||||||
SvFileStream aFileStream(rURL, StreamMode::READ);
|
SvFileStream aFileStream(rURL, StreamMode::READ);
|
||||||
Graphic aGraphic;
|
ImportOutput aImportOutput;
|
||||||
return ImportPcxGraphic(aFileStream, aGraphic);
|
return ImportPcxGraphic(aFileStream, aImportOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PcxFilterTest::testCVEs()
|
void PcxFilterTest::testCVEs()
|
||||||
|
@ -1234,8 +1234,12 @@ ErrCode GraphicFilter::readRAS(SvStream & rStream, Graphic & rGraphic)
|
|||||||
|
|
||||||
ErrCode GraphicFilter::readPCX(SvStream & rStream, Graphic & rGraphic)
|
ErrCode GraphicFilter::readPCX(SvStream & rStream, Graphic & rGraphic)
|
||||||
{
|
{
|
||||||
if (ImportPcxGraphic(rStream, rGraphic))
|
ImportOutput aImportOutput;
|
||||||
|
if (ImportPcxGraphic(rStream, aImportOutput))
|
||||||
|
{
|
||||||
|
rGraphic = Graphic(*aImportOutput.moBitmap);
|
||||||
return ERRCODE_NONE;
|
return ERRCODE_NONE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return ERRCODE_GRFILTER_FILTERERROR;
|
return ERRCODE_GRFILTER_FILTERERROR;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vcl/graph.hxx>
|
#include <vcl/filter/ImportOutput.hxx>
|
||||||
#include <vcl/BitmapTools.hxx>
|
#include <vcl/BitmapTools.hxx>
|
||||||
#include <tools/stream.hxx>
|
#include <tools/stream.hxx>
|
||||||
#include <filter/PcxReader.hxx>
|
#include <filter/PcxReader.hxx>
|
||||||
@ -58,7 +58,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PCXReader(SvStream &rStream);
|
explicit PCXReader(SvStream &rStream);
|
||||||
bool ReadPCX(Graphic & rGraphic );
|
bool ReadPCX(ImportOutput& rImportOutput);
|
||||||
// Reads a PCX file from the stream and fills the GDIMetaFile
|
// Reads a PCX file from the stream and fills the GDIMetaFile
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ PCXReader::PCXReader(SvStream &rStream)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PCXReader::ReadPCX(Graphic & rGraphic)
|
bool PCXReader::ReadPCX(ImportOutput& rImportOutput)
|
||||||
{
|
{
|
||||||
if ( m_rPCX.GetError() )
|
if ( m_rPCX.GetError() )
|
||||||
return false;
|
return false;
|
||||||
@ -143,7 +143,7 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
|
|||||||
|
|
||||||
if ( bStatus )
|
if ( bStatus )
|
||||||
{
|
{
|
||||||
rGraphic = vcl::bitmap::CreateFromData(std::move(*mpBitmap));
|
rImportOutput.moBitmap = vcl::bitmap::CreateFromData(std::move(*mpBitmap));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,10 +399,10 @@ void PCXReader::ImplReadPalette( unsigned int nCol )
|
|||||||
|
|
||||||
//================== GraphicImport - the exported function ================
|
//================== GraphicImport - the exported function ================
|
||||||
|
|
||||||
bool ImportPcxGraphic(SvStream & rStream, Graphic & rGraphic)
|
bool ImportPcxGraphic(SvStream& rStream, ImportOutput& rImportOutput)
|
||||||
{
|
{
|
||||||
PCXReader aPCXReader(rStream);
|
PCXReader aPCXReader(rStream);
|
||||||
bool bRetValue = aPCXReader.ReadPCX(rGraphic);
|
bool bRetValue = aPCXReader.ReadPCX(rImportOutput);
|
||||||
if ( !bRetValue )
|
if ( !bRetValue )
|
||||||
rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
|
rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
|
||||||
return bRetValue;
|
return bRetValue;
|
||||||
|
@ -226,9 +226,9 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
|
|||||||
}
|
}
|
||||||
else if (strcmp(argv[2], "pcx") == 0)
|
else if (strcmp(argv[2], "pcx") == 0)
|
||||||
{
|
{
|
||||||
Graphic aGraphic;
|
ImportOutput aImportOutput;
|
||||||
SvFileStream aFileStream(out, StreamMode::READ);
|
SvFileStream aFileStream(out, StreamMode::READ);
|
||||||
ret = static_cast<int>(ImportPcxGraphic(aFileStream, aGraphic));
|
ret = static_cast<int>(ImportPcxGraphic(aFileStream, aImportOutput));
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[2], "ras") == 0)
|
else if (strcmp(argv[2], "ras") == 0)
|
||||||
{
|
{
|
||||||
|
@ -49,8 +49,8 @@ extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
|
|||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
|
SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
|
||||||
Graphic aGraphic;
|
ImportOutput aImportOutput;
|
||||||
(void)ImportPcxGraphic(aStream, aGraphic);
|
(void)ImportPcxGraphic(aStream, aImportOutput);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user