ofz#29691 revert throw SvStreamEOFException

reasonably sane code like
s.ReadUInt32(a).ReadUInt32(b).ReadUInt32(c).ReadUInt32(d);
if (s.good())
    // use a, b, c d;
stopped working.

FWIW on a short read we retain whatever was in the variable before the
read, rather than overwrite it with new random data, so
sal_uInt32 a(0xdead); s.ReadUInt32(a); assert(s.good() || a == 0xdead);

the msoffice ppt/escher/xls/doc filters especially speculatively parse
and rely on a variables preinit value in the case of a short read.

commit b345a2bab0
    cid#1470786 Uncaught exception

commit 71aec4726a
    ofz#29528 uncaught exception

commit bed03603f6
    ofz#29414 uncaught exception

commit 684885a99a
    ofz#29443 uncaught exception

commit 93574ac776
    ofz#29251 Abrt

commit 413db68d95
    ofz#29152 short read

commit f400e88304
    ofz#29151 short read

commit 96ea80a725
    ofz#29129 Abrt on uncaught exception

commit 646a635efe
    ofz#28931 Indirect-leak

commit b0e573f186
    ofz#29030 Abrt in xlsfuzzer

commit 95407c3916
    ofz#28902 uncaught exception

commit 45175d655a
    oss-fuzz: tgafuzzer doesn't pass sanity check

commit b82fc702ba
    oss-fuzz: psdfuzzer doesn't pass sanity check

commit e7c76d604a
    oss-fuzz: epsfuzzer doesn't pass sanity check

commit 901e5e7c91
    oss-fuzz: xlsfuzzer doesn't pass sanity check

commit 127bfab61c
    oss-fuzz: pngfuzzer doesn't pass sanity check

commit 77387ae00a
    oss-fuzz: mtpfuzzer doesn't pass sanity check

commit 974ffa79b0
    oss-fuzz: xlsxfuzzer doesn't pass sanity check

commit 6d6d104cbb
    oss-fuzz: bmpfuzzer doesn't pass sanity check

commit a7d1d107ec
    oss-fuzz: qpwfuzzer doesn't pass sanity check

commit 898993aa62
    oss-fuzz: pcxfuzzer doesn't pass sanity check

throw/catch parts of
commit 8c9a4ff511
    throw exception in SvStream when reading past end of file

Change-Id: Ic49c249768b17b64d8e868655dbc05b31906c2e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109621
Tested-by: Jenkins
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2021-01-20 16:20:25 +01:00
parent ab85732e1c
commit 4e639c37b4
51 changed files with 2528 additions and 2849 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ namespace emfio::emfreader
pStream->SetEndian(SvStreamEndian::LITTLE);
sal_uInt32 nMetaType(0);
if (checkSeek(*pStream, 0x28) && pStream->remainingSize() >= 4)
if (checkSeek(*pStream, 0x28))
pStream->ReadUInt32(nMetaType);
pStream->Seek(nOrgPos);
+202 -210
View File
@@ -596,232 +596,224 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
auto nOrigPos = nPSStreamPos = rStream.Tell();
SvStreamEndian nOldFormat = rStream.GetEndian();
try
rStream.SetEndian( SvStreamEndian::LITTLE );
rStream.ReadUInt32( nSignature );
if ( nSignature == 0xc6d3d0c5 )
{
rStream.SetEndian( SvStreamEndian::LITTLE );
rStream.ReadUInt32( nSignature );
if ( nSignature == 0xc6d3d0c5 )
rStream.ReadUInt32( nPSStreamPos ).ReadUInt32( nPSSize ).ReadUInt32( nPosWMF ).ReadUInt32( nSizeWMF );
// first we try to get the metafile grafix
if ( nSizeWMF )
{
rStream.ReadUInt32( nPSStreamPos ).ReadUInt32( nPSSize ).ReadUInt32( nPosWMF ).ReadUInt32( nSizeWMF );
// first we try to get the metafile grafix
if ( nSizeWMF )
if (nPosWMF && checkSeek(rStream, nOrigPos + nPosWMF))
{
if (nPosWMF && checkSeek(rStream, nOrigPos + nPosWMF))
{
if (GraphicConverter::Import(rStream, aGraphic, ConvertDataFormat::WMF) == ERRCODE_NONE)
bHasPreview = bRetValue = true;
}
}
else
{
rStream.ReadUInt32( nPosTIFF ).ReadUInt32( nSizeTIFF );
// else we have to get the tiff grafix
if (nPosTIFF && nSizeTIFF && checkSeek(rStream, nOrigPos + nPosTIFF))
{
if ( GraphicConverter::Import( rStream, aGraphic, ConvertDataFormat::TIF ) == ERRCODE_NONE )
{
MakeAsMeta(aGraphic);
rStream.Seek( nOrigPos + nPosTIFF );
bHasPreview = bRetValue = true;
}
}
if (GraphicConverter::Import(rStream, aGraphic, ConvertDataFormat::WMF) == ERRCODE_NONE)
bHasPreview = bRetValue = true;
}
}
else
{
nPSStreamPos = nOrigPos; // no preview available _>so we must get the size manually
nPSSize = rStream.Seek( STREAM_SEEK_TO_END ) - nOrigPos;
}
rStream.ReadUInt32( nPosTIFF ).ReadUInt32( nSizeTIFF );
std::unique_ptr<sal_uInt8[]> pHeader( new sal_uInt8[ 22 ] );
rStream.Seek( nPSStreamPos );
rStream.ReadBytes(pHeader.get(), 22); // check PostScript header
bool bOk = ImplSearchEntry(pHeader.get(), reinterpret_cast<sal_uInt8 const *>("%!PS-Adobe"), 10, 10) &&
ImplSearchEntry(&pHeader[ 15 ], reinterpret_cast<sal_uInt8 const *>("EPS"), 3, 3);
if (bOk)
{
rStream.Seek(nPSStreamPos);
bOk = rStream.remainingSize() >= nPSSize;
SAL_WARN_IF(!bOk, "filter.eps", "eps claims to be: " << nPSSize << " in size, but only " << rStream.remainingSize() << " remains");
}
if (bOk)
{
std::unique_ptr<sal_uInt8[]> pBuf( new sal_uInt8[ nPSSize ] );
// else we have to get the tiff grafix
sal_uInt32 nBufStartPos = rStream.Tell();
sal_uInt32 nBytesRead = rStream.ReadBytes(pBuf.get(), nPSSize);
if ( nBytesRead == nPSSize )
if (nPosTIFF && nSizeTIFF && checkSeek(rStream, nOrigPos + nPosTIFF))
{
sal_uInt32 nSecurityCount = 32;
// if there is no tiff/wmf preview, we will parse for a preview in
// the eps prolog
if (!bHasPreview && nBytesRead >= nSecurityCount)
if ( GraphicConverter::Import( rStream, aGraphic, ConvertDataFormat::TIF ) == ERRCODE_NONE )
{
sal_uInt8* pDest = ImplSearchEntry( pBuf.get(), reinterpret_cast<sal_uInt8 const *>("%%BeginPreview:"), nBytesRead - nSecurityCount, 15 );
sal_uInt32 nRemainingBytes = pDest ? (nBytesRead - (pDest - pBuf.get())) : 0;
if (nRemainingBytes >= 15)
{
pDest += 15;
nSecurityCount = nRemainingBytes - 15;
tools::Long nWidth = ImplGetNumber(pDest, nSecurityCount);
tools::Long nHeight = ImplGetNumber(pDest, nSecurityCount);
tools::Long nBitDepth = ImplGetNumber(pDest, nSecurityCount);
tools::Long nScanLines = ImplGetNumber(pDest, nSecurityCount);
pDest = ImplSearchEntry(pDest, reinterpret_cast<sal_uInt8 const *>("%"), nSecurityCount, 1); // go to the first Scanline
bOk = pDest && nWidth > 0 && nHeight > 0 && ( ( nBitDepth == 1 ) || ( nBitDepth == 8 ) ) && nScanLines;
if (bOk)
{
tools::Long nResult;
bOk = !o3tl::checked_multiply(nWidth, nHeight, nResult) && nResult <= SAL_MAX_INT32/2/3;
}
if (bOk)
{
rStream.Seek( nBufStartPos + ( pDest - pBuf.get() ) );
vcl::bitmap::RawBitmap aBitmap( Size( nWidth, nHeight ), 24 );
{
bool bIsValid = true;
sal_uInt8 nDat = 0;
char nByte;
for (tools::Long y = 0; bIsValid && y < nHeight; ++y)
{
int nBitsLeft = 0;
for (tools::Long x = 0; x < nWidth; ++x)
{
if ( --nBitsLeft < 0 )
{
while ( bIsValid && ( nBitsLeft != 7 ) )
{
rStream.ReadChar(nByte);
bIsValid = rStream.good();
if (!bIsValid)
break;
switch (nByte)
{
case 0x0a :
if ( --nScanLines < 0 )
bIsValid = false;
break;
case 0x09 :
case 0x0d :
case 0x20 :
case 0x25 :
break;
default:
{
if ( nByte >= '0' )
{
if ( nByte > '9' )
{
nByte &=~0x20; // case none sensitive for hexadecimal values
nByte -= ( 'A' - 10 );
if ( nByte > 15 )
bIsValid = false;
}
else
nByte -= '0';
nBitsLeft += 4;
nDat <<= 4;
nDat |= ( nByte ^ 0xf ); // in epsi a zero bit represents white color
}
else
bIsValid = false;
}
break;
}
}
}
if (!bIsValid)
break;
if ( nBitDepth == 1 )
aBitmap.SetPixel( y, x, Color(ColorTransparency, static_cast<sal_uInt8>(nDat >> nBitsLeft) & 1) );
else
{
aBitmap.SetPixel( y, x, nDat ? COL_WHITE : COL_BLACK ); // nBitDepth == 8
nBitsLeft = 0;
}
}
}
if (bIsValid)
{
ScopedVclPtrInstance<VirtualDevice> pVDev;
GDIMetaFile aMtf;
Size aSize( nWidth, nHeight );
pVDev->EnableOutput( false );
aMtf.Record( pVDev );
aSize = OutputDevice::LogicToLogic(aSize, MapMode(), MapMode(MapUnit::Map100thMM));
pVDev->DrawBitmapEx( Point(), aSize, vcl::bitmap::CreateFromData(std::move(aBitmap)) );
aMtf.Stop();
aMtf.WindStart();
aMtf.SetPrefMapMode(MapMode(MapUnit::Map100thMM));
aMtf.SetPrefSize( aSize );
aGraphic = aMtf;
bHasPreview = bRetValue = true;
}
}
}
}
}
sal_uInt8* pDest = ImplSearchEntry( pBuf.get(), reinterpret_cast<sal_uInt8 const *>("%%BoundingBox:"), nBytesRead, 14 );
sal_uInt32 nRemainingBytes = pDest ? (nBytesRead - (pDest - pBuf.get())) : 0;
if (nRemainingBytes >= 14)
{
pDest += 14;
nSecurityCount = std::min<sal_uInt32>(nRemainingBytes - 14, 100);
tools::Long nNumb[4];
nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0;
for ( int i = 0; ( i < 4 ) && nSecurityCount; i++ )
{
nNumb[ i ] = ImplGetNumber(pDest, nSecurityCount);
}
bool bFail = nSecurityCount == 0;
tools::Long nWidth(0), nHeight(0);
if (!bFail)
bFail = o3tl::checked_sub(nNumb[2], nNumb[0], nWidth) || o3tl::checked_add(nWidth, tools::Long(1), nWidth);
if (!bFail)
bFail = o3tl::checked_sub(nNumb[3], nNumb[1], nHeight) || o3tl::checked_add(nHeight, tools::Long(1), nHeight);
if (!bFail && nWidth > 0 && nHeight > 0)
{
GDIMetaFile aMtf;
// if there is no preview -> try with gs to make one
if (!bHasPreview && !utl::ConfigManager::IsFuzzing())
{
bHasPreview = RenderAsEMF(pBuf.get(), nBytesRead, aGraphic);
if (!bHasPreview)
bHasPreview = RenderAsBMP(pBuf.get(), nBytesRead, aGraphic);
}
// if there is no preview -> make a red box
if( !bHasPreview )
{
MakePreview(pBuf.get(), nBytesRead, nWidth, nHeight,
aGraphic);
}
GfxLink aGfxLink( std::move(pBuf), nPSSize, GfxLinkType::EpsBuffer ) ;
aMtf.AddAction( static_cast<MetaAction*>( new MetaEPSAction( Point(), Size( nWidth, nHeight ),
aGfxLink, aGraphic.GetGDIMetaFile() ) ) );
CreateMtfReplacementAction( aMtf, rStream, nOrigPos, nPSSize, nPosWMF, nSizeWMF, nPosTIFF, nSizeTIFF );
aMtf.WindStart();
aMtf.SetPrefMapMode(MapMode(MapUnit::MapPoint));
aMtf.SetPrefSize( Size( nWidth, nHeight ) );
rGraphic = aMtf;
bRetValue = true;
}
MakeAsMeta(aGraphic);
rStream.Seek( nOrigPos + nPosTIFF );
bHasPreview = bRetValue = true;
}
}
}
}
catch (const SvStreamEOFException&)
else
{
SAL_WARN("filter.eps", "EOF");
bRetValue = false;
nPSStreamPos = nOrigPos; // no preview available _>so we must get the size manually
nPSSize = rStream.Seek( STREAM_SEEK_TO_END ) - nOrigPos;
}
std::unique_ptr<sal_uInt8[]> pHeader( new sal_uInt8[ 22 ] );
rStream.Seek( nPSStreamPos );
rStream.ReadBytes(pHeader.get(), 22); // check PostScript header
bool bOk = ImplSearchEntry(pHeader.get(), reinterpret_cast<sal_uInt8 const *>("%!PS-Adobe"), 10, 10) &&
ImplSearchEntry(&pHeader[ 15 ], reinterpret_cast<sal_uInt8 const *>("EPS"), 3, 3);
if (bOk)
{
rStream.Seek(nPSStreamPos);
bOk = rStream.remainingSize() >= nPSSize;
SAL_WARN_IF(!bOk, "filter.eps", "eps claims to be: " << nPSSize << " in size, but only " << rStream.remainingSize() << " remains");
}
if (bOk)
{
std::unique_ptr<sal_uInt8[]> pBuf( new sal_uInt8[ nPSSize ] );
sal_uInt32 nBufStartPos = rStream.Tell();
sal_uInt32 nBytesRead = rStream.ReadBytes(pBuf.get(), nPSSize);
if ( nBytesRead == nPSSize )
{
sal_uInt32 nSecurityCount = 32;
// if there is no tiff/wmf preview, we will parse for a preview in
// the eps prolog
if (!bHasPreview && nBytesRead >= nSecurityCount)
{
sal_uInt8* pDest = ImplSearchEntry( pBuf.get(), reinterpret_cast<sal_uInt8 const *>("%%BeginPreview:"), nBytesRead - nSecurityCount, 15 );
sal_uInt32 nRemainingBytes = pDest ? (nBytesRead - (pDest - pBuf.get())) : 0;
if (nRemainingBytes >= 15)
{
pDest += 15;
nSecurityCount = nRemainingBytes - 15;
tools::Long nWidth = ImplGetNumber(pDest, nSecurityCount);
tools::Long nHeight = ImplGetNumber(pDest, nSecurityCount);
tools::Long nBitDepth = ImplGetNumber(pDest, nSecurityCount);
tools::Long nScanLines = ImplGetNumber(pDest, nSecurityCount);
pDest = ImplSearchEntry(pDest, reinterpret_cast<sal_uInt8 const *>("%"), nSecurityCount, 1); // go to the first Scanline
bOk = pDest && nWidth > 0 && nHeight > 0 && ( ( nBitDepth == 1 ) || ( nBitDepth == 8 ) ) && nScanLines;
if (bOk)
{
tools::Long nResult;
bOk = !o3tl::checked_multiply(nWidth, nHeight, nResult) && nResult <= SAL_MAX_INT32/2/3;
}
if (bOk)
{
rStream.Seek( nBufStartPos + ( pDest - pBuf.get() ) );
vcl::bitmap::RawBitmap aBitmap( Size( nWidth, nHeight ), 24 );
{
bool bIsValid = true;
sal_uInt8 nDat = 0;
char nByte;
for (tools::Long y = 0; bIsValid && y < nHeight; ++y)
{
int nBitsLeft = 0;
for (tools::Long x = 0; x < nWidth; ++x)
{
if ( --nBitsLeft < 0 )
{
while ( bIsValid && ( nBitsLeft != 7 ) )
{
rStream.ReadChar(nByte);
bIsValid = rStream.good();
if (!bIsValid)
break;
switch (nByte)
{
case 0x0a :
if ( --nScanLines < 0 )
bIsValid = false;
break;
case 0x09 :
case 0x0d :
case 0x20 :
case 0x25 :
break;
default:
{
if ( nByte >= '0' )
{
if ( nByte > '9' )
{
nByte &=~0x20; // case none sensitive for hexadecimal values
nByte -= ( 'A' - 10 );
if ( nByte > 15 )
bIsValid = false;
}
else
nByte -= '0';
nBitsLeft += 4;
nDat <<= 4;
nDat |= ( nByte ^ 0xf ); // in epsi a zero bit represents white color
}
else
bIsValid = false;
}
break;
}
}
}
if (!bIsValid)
break;
if ( nBitDepth == 1 )
aBitmap.SetPixel( y, x, Color(ColorTransparency, static_cast<sal_uInt8>(nDat >> nBitsLeft) & 1) );
else
{
aBitmap.SetPixel( y, x, nDat ? COL_WHITE : COL_BLACK ); // nBitDepth == 8
nBitsLeft = 0;
}
}
}
if (bIsValid)
{
ScopedVclPtrInstance<VirtualDevice> pVDev;
GDIMetaFile aMtf;
Size aSize( nWidth, nHeight );
pVDev->EnableOutput( false );
aMtf.Record( pVDev );
aSize = OutputDevice::LogicToLogic(aSize, MapMode(), MapMode(MapUnit::Map100thMM));
pVDev->DrawBitmapEx( Point(), aSize, vcl::bitmap::CreateFromData(std::move(aBitmap)) );
aMtf.Stop();
aMtf.WindStart();
aMtf.SetPrefMapMode(MapMode(MapUnit::Map100thMM));
aMtf.SetPrefSize( aSize );
aGraphic = aMtf;
bHasPreview = bRetValue = true;
}
}
}
}
}
sal_uInt8* pDest = ImplSearchEntry( pBuf.get(), reinterpret_cast<sal_uInt8 const *>("%%BoundingBox:"), nBytesRead, 14 );
sal_uInt32 nRemainingBytes = pDest ? (nBytesRead - (pDest - pBuf.get())) : 0;
if (nRemainingBytes >= 14)
{
pDest += 14;
nSecurityCount = std::min<sal_uInt32>(nRemainingBytes - 14, 100);
tools::Long nNumb[4];
nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0;
for ( int i = 0; ( i < 4 ) && nSecurityCount; i++ )
{
nNumb[ i ] = ImplGetNumber(pDest, nSecurityCount);
}
bool bFail = nSecurityCount == 0;
tools::Long nWidth(0), nHeight(0);
if (!bFail)
bFail = o3tl::checked_sub(nNumb[2], nNumb[0], nWidth) || o3tl::checked_add(nWidth, tools::Long(1), nWidth);
if (!bFail)
bFail = o3tl::checked_sub(nNumb[3], nNumb[1], nHeight) || o3tl::checked_add(nHeight, tools::Long(1), nHeight);
if (!bFail && nWidth > 0 && nHeight > 0)
{
GDIMetaFile aMtf;
// if there is no preview -> try with gs to make one
if (!bHasPreview && !utl::ConfigManager::IsFuzzing())
{
bHasPreview = RenderAsEMF(pBuf.get(), nBytesRead, aGraphic);
if (!bHasPreview)
bHasPreview = RenderAsBMP(pBuf.get(), nBytesRead, aGraphic);
}
// if there is no preview -> make a red box
if( !bHasPreview )
{
MakePreview(pBuf.get(), nBytesRead, nWidth, nHeight,
aGraphic);
}
GfxLink aGfxLink( std::move(pBuf), nPSSize, GfxLinkType::EpsBuffer ) ;
aMtf.AddAction( static_cast<MetaAction*>( new MetaEPSAction( Point(), Size( nWidth, nHeight ),
aGfxLink, aGraphic.GetGDIMetaFile() ) ) );
CreateMtfReplacementAction( aMtf, rStream, nOrigPos, nPSSize, nPosWMF, nSizeWMF, nPosTIFF, nSizeTIFF );
aMtf.WindStart();
aMtf.SetPrefMapMode(MapMode(MapUnit::MapPoint));
aMtf.SetPrefSize( Size( nWidth, nHeight ) );
rGraphic = aMtf;
bRetValue = true;
}
}
}
}
rStream.SetEndian(nOldFormat);
@@ -2806,9 +2806,6 @@ imeGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
catch (const css::uno::Exception&)
{
}
catch(SvStreamEOFException&)
{
}
return bRet;
}
+1 -11
View File
@@ -19,7 +19,6 @@
#include <memory>
#include <sal/log.hxx>
#include <vcl/graph.hxx>
#include <vcl/BitmapTools.hxx>
#include <tools/stream.hxx>
@@ -403,16 +402,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool
ipxGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
{
PCXReader aPCXReader(rStream);
bool bRetValue;
try
{
bRetValue = aPCXReader.ReadPCX(rGraphic);
}
catch (const SvStreamEOFException&)
{
SAL_WARN("filter.pcx", "EOF");
bRetValue = false;
}
bool bRetValue = aPCXReader.ReadPCX(rGraphic);
if ( !bRetValue )
rStream.SetError( SVSTREAM_FILEFORMAT_ERROR );
return bRetValue;
+2 -11
View File
@@ -764,17 +764,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool
ipdGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
{
PSDReader aPSDReader(rStream);
bool bRet;
try
{
bRet = aPSDReader.ReadPSD(rGraphic);
}
catch (const SvStreamEOFException&)
{
SAL_WARN("filter.psd", "EOF");
bRet = false;
}
return bRet;
return aPSDReader.ReadPSD(rGraphic);
}
+2 -13
View File
@@ -18,10 +18,9 @@
*/
#include <sal/log.hxx>
#include <tools/stream.hxx>
#include <vcl/graph.hxx>
#include <vcl/BitmapTools.hxx>
#include <tools/stream.hxx>
#include <memory>
class FilterConfigItem;
@@ -786,17 +785,7 @@ itgGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* )
{
TGAReader aTGAReader(rStream);
bool bRet;
try
{
bRet = aTGAReader.ReadTGA(rGraphic);
}
catch (const SvStreamEOFException&)
{
SAL_WARN("filter.tga", "EOF");
bRet = false;
}
return bRet;
return aTGAReader.ReadTGA(rGraphic);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+5 -15
View File
@@ -29,7 +29,6 @@
#include <o3tl/safeint.hxx>
#include <osl/file.hxx>
#include <tools/solar.h>
#include <tools/diagnose_ex.h>
#include <sal/log.hxx>
#include <rtl/math.hxx>
@@ -4183,11 +4182,9 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
if( maShapeRecords.SeekToContent( rSt,
DFF_msofbtUDefProp ) )
{
sal_uInt32 nBytesLeft = maShapeRecords.Current()->nRecLen;
sal_uInt32 nBytesLeft = maShapeRecords.Current()->nRecLen;
while( 5 < nBytesLeft )
{
if (rSt.remainingSize() < 6)
break;
sal_uInt16 nPID(0);
rSt.ReadUInt16(nPID);
if (!rSt.good())
@@ -4201,11 +4198,11 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
mbRotateGranientFillWithAngle = nUDData & 0x20;
break;
}
nBytesLeft -= 6;
nBytesLeft -= 6;
}
}
aObjData.bShapeType = maShapeRecords.SeekToContent( rSt, DFF_msofbtSp );
if (aObjData.bShapeType && rSt.remainingSize() >= 8)
if ( aObjData.bShapeType )
{
sal_uInt32 temp;
rSt.ReadUInt32( aObjData.nShapeId )
@@ -4249,7 +4246,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
}
aObjData.bChildAnchor = maShapeRecords.SeekToContent( rSt, DFF_msofbtChildAnchor, SEEK_FROM_CURRENT_AND_RESTART );
if (aObjData.bChildAnchor && rSt.remainingSize() >= 16)
if ( aObjData.bChildAnchor )
{
sal_Int32 l(0), o(0), r(0), u(0);
rSt.ReadInt32( l ).ReadInt32( o ).ReadInt32( r ).ReadInt32( u );
@@ -5706,14 +5703,7 @@ SvxMSDffManager::SvxMSDffManager(SvStream& rStCtrl_,
SetDefaultPropSet( rStCtrl, nOffsDgg );
// read control stream, if successful set nBLIPCount
try
{
GetCtrlData( nOffsDgg );
}
catch(SvStreamEOFException&)
{
TOOLS_WARN_EXCEPTION("filter.ms", "");
}
GetCtrlData( nOffsDgg );
// check Text-Box-Story-Chain-Infos
CheckTxBxStoryChain();
+432 -447
View File
@@ -807,405 +807,398 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx
}
else
{
try
// try to load some ppt text
PPTTextObj aTextObj( rSt, static_cast<SdrPowerPointImport&>(*this), rPersistEntry, &rObjData );
if ( aTextObj.Count() || aTextObj.GetOEPlaceHolderAtom() )
{
// try to load some ppt text
PPTTextObj aTextObj( rSt, static_cast<SdrPowerPointImport&>(*this), rPersistEntry, &rObjData );
if ( aTextObj.Count() || aTextObj.GetOEPlaceHolderAtom() )
bool bVerticalText = false;
// and if the text object is not empty, it must be applied to pRet, the object we
// initially got from our escher import
Degree100 nTextRotationAngle(0);
if ( IsProperty( DFF_Prop_txflTextFlow ) )
{
bool bVerticalText = false;
// and if the text object is not empty, it must be applied to pRet, the object we
// initially got from our escher import
Degree100 nTextRotationAngle(0);
if ( IsProperty( DFF_Prop_txflTextFlow ) )
auto eTextFlow = GetPropertyValue(DFF_Prop_txflTextFlow, 0) & 0xFFFF;
switch( eTextFlow )
{
auto eTextFlow = GetPropertyValue(DFF_Prop_txflTextFlow, 0) & 0xFFFF;
switch( eTextFlow )
{
case mso_txflBtoT : // Bottom to Top non-@
nTextRotationAngle += 9000_deg100;
break;
case mso_txflTtoBA : /* #68110# */ // Top to Bottom @-font
case mso_txflTtoBN : // Top to Bottom non-@
case mso_txflVertN : // Vertical, non-@, top to bottom
bVerticalText = !bVerticalText; // nTextRotationAngle += 27000;
break;
// case mso_txflHorzN : // Horizontal non-@, normal
// case mso_txflHorzA : // Horizontal @-font, normal
default: break;
}
}
sal_Int32 nFontDirection = GetPropertyValue( DFF_Prop_cdirFont, mso_cdir0 );
if ( ( nFontDirection == 1 ) || ( nFontDirection == 3 ) )
{
bVerticalText = !bVerticalText;
}
const bool bFail = o3tl::checked_multiply<sal_Int32>(nFontDirection, 9000, nFontDirection);
if (!bFail)
nTextRotationAngle -= Degree100(nFontDirection);
else
SAL_WARN("filter.ms", "Parsing error: bad fontdirection: " << nFontDirection);
aTextObj.SetVertical( bVerticalText );
if ( pRet )
{
bool bDeleteSource = aTextObj.GetOEPlaceHolderAtom() != nullptr;
if ( bDeleteSource && dynamic_cast<const SdrGrafObj* >(pRet) == nullptr // we are not allowed to get
&& dynamic_cast<const SdrObjGroup* >(pRet) == nullptr // grouped placeholder objects
&& dynamic_cast<const SdrOle2Obj* >(pRet) == nullptr )
SdrObject::Free( pRet );
}
sal_uInt32 nTextFlags = aTextObj.GetTextFlags();
sal_Int32 nTextLeft = GetPropertyValue( DFF_Prop_dxTextLeft, 25 * 3600 ); // 0.25 cm (emu)
sal_Int32 nTextRight = GetPropertyValue( DFF_Prop_dxTextRight, 25 * 3600 ); // 0.25 cm (emu)
sal_Int32 nTextTop = GetPropertyValue( DFF_Prop_dyTextTop, 13 * 3600 ); // 0.13 cm (emu)
sal_Int32 nTextBottom = GetPropertyValue( DFF_Prop_dyTextBottom, 13 * 3600 );
ScaleEmu( nTextLeft );
ScaleEmu( nTextRight );
ScaleEmu( nTextTop );
ScaleEmu( nTextBottom );
sal_Int32 nMinFrameWidth = 0;
sal_Int32 nMinFrameHeight = 0;
bool bAutoGrowWidth, bAutoGrowHeight;
SdrTextVertAdjust eTVA;
SdrTextHorzAdjust eTHA;
nTextFlags &= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
| PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
if ( bVerticalText )
{
eTVA = SDRTEXTVERTADJUST_BLOCK;
eTHA = SDRTEXTHORZADJUST_CENTER;
// read text anchor
auto eTextAnchor = GetPropertyValue(DFF_Prop_anchorText, mso_anchorTop);
switch( eTextAnchor )
{
case mso_anchorTop:
case mso_anchorTopCentered:
case mso_anchorTopBaseline:
case mso_anchorTopCenteredBaseline:
eTHA = SDRTEXTHORZADJUST_RIGHT;
break;
case mso_anchorMiddle :
case mso_anchorMiddleCentered:
eTHA = SDRTEXTHORZADJUST_CENTER;
break;
case mso_anchorBottom:
case mso_anchorBottomCentered:
case mso_anchorBottomBaseline:
case mso_anchorBottomCenteredBaseline:
eTHA = SDRTEXTHORZADJUST_LEFT;
break;
}
switch ( eTextAnchor )
{
case mso_anchorTopCentered :
case mso_anchorMiddleCentered :
case mso_anchorBottomCentered :
case mso_anchorTopCenteredBaseline:
case mso_anchorBottomCenteredBaseline:
{
// check if it is sensible to use the centered alignment
const sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
switch (nTextFlags & nMask)
{
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK:
eTVA = SDRTEXTVERTADJUST_CENTER; // If the textobject has only one type of alignment, then the text has not to be displayed using the full width;
break;
}
break;
}
default:
break;
}
nMinFrameWidth = rTextRect.GetWidth() - ( nTextLeft + nTextRight );
}
else
{
eTVA = SDRTEXTVERTADJUST_CENTER;
eTHA = SDRTEXTHORZADJUST_BLOCK;
// read text anchor
auto eTextAnchor = GetPropertyValue(DFF_Prop_anchorText, mso_anchorTop);
switch( eTextAnchor )
{
case mso_anchorTop:
case mso_anchorTopCentered:
case mso_anchorTopBaseline:
case mso_anchorTopCenteredBaseline:
eTVA = SDRTEXTVERTADJUST_TOP;
break;
case mso_anchorMiddle :
case mso_anchorMiddleCentered:
eTVA = SDRTEXTVERTADJUST_CENTER;
break;
case mso_anchorBottom:
case mso_anchorBottomCentered:
case mso_anchorBottomBaseline:
case mso_anchorBottomCenteredBaseline:
eTVA = SDRTEXTVERTADJUST_BOTTOM;
break;
}
switch ( eTextAnchor )
{
case mso_anchorTopCentered :
case mso_anchorMiddleCentered :
case mso_anchorBottomCentered :
case mso_anchorTopCenteredBaseline:
case mso_anchorBottomCenteredBaseline:
{
// check if it is sensible to use the centered alignment
const sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
switch (nTextFlags & nMask)
{
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK:
eTHA = SDRTEXTHORZADJUST_CENTER; // If the textobject has only one type of alignment, then the text has not to be displayed using the full width;
break;
}
break;
}
default:
break;
}
nMinFrameHeight = rTextRect.GetHeight() - ( nTextTop + nTextBottom );
}
SdrObjKind eTextKind = OBJ_RECT;
if ( ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::NOTESSLIDEIMAGE )
|| ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::MASTERNOTESSLIDEIMAGE ) )
{
aTextObj.SetInstance( TSS_Type::Notes );
eTextKind = OBJ_TITLETEXT;
}
else if ( ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::MASTERNOTESBODYIMAGE )
|| ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::NOTESBODY ) )
{
aTextObj.SetInstance( TSS_Type::Notes );
eTextKind = OBJ_TEXT;
}
TSS_Type nDestinationInstance = aTextObj.GetInstance();
if ( rPersistEntry.ePageKind == PPT_MASTERPAGE )
{
if ( !rPersistEntry.pPresentationObjects )
{
rPersistEntry.pPresentationObjects.reset( new sal_uInt32[ PPT_STYLESHEETENTRIES ] );
memset( rPersistEntry.pPresentationObjects.get(), 0, PPT_STYLESHEETENTRIES * 4 );
}
if ( !rPersistEntry.pPresentationObjects[ static_cast<int>(nDestinationInstance) ] )
rPersistEntry.pPresentationObjects[ static_cast<int>(nDestinationInstance) ] = rObjData.rSpHd.GetRecBegFilePos();
}
switch ( nDestinationInstance )
{
case TSS_Type::PageTitle :
case TSS_Type::Title :
{
if ( GetSlideLayoutAtom()->eLayout == PptSlideLayout::TITLEMASTERSLIDE )
nDestinationInstance = TSS_Type::Title;
else
nDestinationInstance = TSS_Type::PageTitle;
}
case mso_txflBtoT : // Bottom to Top non-@
nTextRotationAngle += 9000_deg100;
break;
case TSS_Type::Body :
case TSS_Type::HalfBody :
case TSS_Type::QuarterBody :
nDestinationInstance = TSS_Type::Body;
case mso_txflTtoBA : /* #68110# */ // Top to Bottom @-font
case mso_txflTtoBN : // Top to Bottom non-@
case mso_txflVertN : // Vertical, non-@, top to bottom
bVerticalText = !bVerticalText; // nTextRotationAngle += 27000;
break;
// case mso_txflHorzN : // Horizontal non-@, normal
// case mso_txflHorzA : // Horizontal @-font, normal
default: break;
}
aTextObj.SetDestinationInstance( nDestinationInstance );
bool bAutoFit = false; // auto-scale text into shape box
switch ( aTextObj.GetInstance() )
{
case TSS_Type::PageTitle :
case TSS_Type::Title : eTextKind = OBJ_TITLETEXT; break;
case TSS_Type::Subtitle : eTextKind = OBJ_TEXT; break;
case TSS_Type::Body :
case TSS_Type::HalfBody :
case TSS_Type::QuarterBody : eTextKind = OBJ_OUTLINETEXT; bAutoFit = true; break;
default: break;
}
if ( aTextObj.GetDestinationInstance() != TSS_Type::TextInShape )
{
if ( !aTextObj.GetOEPlaceHolderAtom() || aTextObj.GetOEPlaceHolderAtom()->nPlaceholderId == PptPlaceholder::NONE )
{
aTextObj.SetDestinationInstance( TSS_Type::TextInShape );
eTextKind = OBJ_RECT;
}
}
SdrObject* pTObj = nullptr;
bool bWordWrap = GetPropertyValue(DFF_Prop_WrapText, mso_wrapSquare) != mso_wrapNone;
bool bFitShapeToText = ( GetPropertyValue( DFF_Prop_FitTextToShape, 0 ) & 2 ) != 0;
if ( dynamic_cast<const SdrObjCustomShape* >(pRet) != nullptr && ( eTextKind == OBJ_RECT ) )
{
bAutoGrowHeight = bFitShapeToText;
bAutoGrowWidth = !bWordWrap;
pTObj = pRet;
pRet = nullptr;
}
else
{
if ( dynamic_cast<const SdrObjCustomShape* >(pRet) != nullptr )
{
SdrObject::Free( pRet );
pRet = nullptr;
}
pTObj = new SdrRectObj(
*pSdrModel,
eTextKind != OBJ_RECT ? eTextKind : OBJ_TEXT);
SfxItemSet aSet( pSdrModel->GetItemPool() );
if ( !pRet )
ApplyAttributes( rSt, aSet, rObjData );
pTObj->SetMergedItemSet( aSet );
if ( pRet )
{
pTObj->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) );
pTObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) );
}
if ( bVerticalText )
{
bAutoGrowWidth = bFitShapeToText;
bAutoGrowHeight = false;
}
else
{
bAutoGrowWidth = false;
// #119885# re-activating bFitShapeToText here, could not find deeper explanations
// for it (it was from 2005). Keeping the old comment here for reference
// old comment: // bFitShapeToText; can't be used, because we cut the text if it is too height,
bAutoGrowHeight = bFitShapeToText;
}
}
pTObj->SetMergedItem( SvxFrameDirectionItem( bVerticalText ? SvxFrameDirection::Vertical_RL_TB : SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) );
//Autofit text only if there is no auto grow height and width
//See fdo#41245
if (bAutoFit && !bAutoGrowHeight && !bAutoGrowWidth)
{
pTObj->SetMergedItem( SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_AUTOFIT) );
}
if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
{
pTObj->SetMergedItem( makeSdrTextAutoGrowWidthItem( bAutoGrowWidth ) );
pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bAutoGrowHeight ) );
}
else
{
pTObj->SetMergedItem( makeSdrTextWordWrapItem( bWordWrap ) );
pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bFitShapeToText ) );
}
pTObj->SetMergedItem( SdrTextVertAdjustItem( eTVA ) );
pTObj->SetMergedItem( SdrTextHorzAdjustItem( eTHA ) );
if ( nMinFrameHeight < 0 )
nMinFrameHeight = 0;
if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
pTObj->SetMergedItem( makeSdrTextMinFrameHeightItem( nMinFrameHeight ) );
if ( nMinFrameWidth < 0 )
nMinFrameWidth = 0;
if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
pTObj->SetMergedItem( makeSdrTextMinFrameWidthItem( nMinFrameWidth ) );
// set margins at the borders of the textbox
pTObj->SetMergedItem( makeSdrTextLeftDistItem( nTextLeft ) );
pTObj->SetMergedItem( makeSdrTextRightDistItem( nTextRight ) );
pTObj->SetMergedItem( makeSdrTextUpperDistItem( nTextTop ) );
pTObj->SetMergedItem( makeSdrTextLowerDistItem( nTextBottom ) );
pTObj->SetMergedItem( SdrTextFixedCellHeightItem( true ) );
if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
pTObj->SetSnapRect( rTextRect );
pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage );
if ( pTObj )
{
/* check if our new snaprect makes trouble,
because we do not display the ADJUST_BLOCK
properly if the textsize is bigger than the
snaprect of the object. Then we will use
ADJUST_CENTER instead of ADJUST_BLOCK.
*/
if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr && !bFitShapeToText && !bWordWrap )
{
SdrTextObj* pText = dynamic_cast<SdrTextObj*>( pTObj );
if ( pText )
{
if ( bVerticalText )
{
if ( eTVA == SDRTEXTVERTADJUST_BLOCK )
{
Size aTextSize( pText->GetTextSize() );
aTextSize.AdjustWidth(nTextLeft + nTextRight );
aTextSize.AdjustHeight(nTextTop + nTextBottom );
if ( rTextRect.GetHeight() < aTextSize.Height() )
pTObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
}
}
else
{
if ( eTHA == SDRTEXTHORZADJUST_BLOCK )
{
Size aTextSize( pText->GetTextSize() );
aTextSize.AdjustWidth(nTextLeft + nTextRight );
aTextSize.AdjustHeight(nTextTop + nTextBottom );
if ( rTextRect.GetWidth() < aTextSize.Width() )
pTObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_CENTER ) );
}
}
}
}
// rotate text with shape?
Degree100 nAngle = ( rObjData.nSpFlags & ShapeFlag::FlipV ) ? -mnFix16Angle : mnFix16Angle; // #72116# vertical flip -> rotate by using the other way
nAngle += nTextRotationAngle;
if ( dynamic_cast< const SdrObjCustomShape* >(pTObj) == nullptr )
{
if ( rObjData.nSpFlags & ShapeFlag::FlipV )
{
double a = 18000 * F_PI18000;
pTObj->Rotate( rTextRect.Center(), 18000_deg100, sin( a ), cos( a ) );
}
if ( rObjData.nSpFlags & ShapeFlag::FlipH )
nAngle = 36000_deg100 - nAngle;
if ( nAngle )
pTObj->NbcRotate( rObjData.aBoundRect.Center(), nAngle );
}
if ( pRet )
{
SdrObject* pGroup = new SdrObjGroup(*pSdrModel);
pGroup->GetSubList()->NbcInsertObject( pRet );
pGroup->GetSubList()->NbcInsertObject( pTObj );
pRet = pGroup;
}
else
pRet = pTObj;
}
}
}
catch (const SvStreamEOFException&)
{
SAL_WARN("filter.ms", "EOF");
sal_Int32 nFontDirection = GetPropertyValue( DFF_Prop_cdirFont, mso_cdir0 );
if ( ( nFontDirection == 1 ) || ( nFontDirection == 3 ) )
{
bVerticalText = !bVerticalText;
}
const bool bFail = o3tl::checked_multiply<sal_Int32>(nFontDirection, 9000, nFontDirection);
if (!bFail)
nTextRotationAngle -= Degree100(nFontDirection);
else
SAL_WARN("filter.ms", "Parsing error: bad fontdirection: " << nFontDirection);
aTextObj.SetVertical( bVerticalText );
if ( pRet )
{
bool bDeleteSource = aTextObj.GetOEPlaceHolderAtom() != nullptr;
if ( bDeleteSource && dynamic_cast<const SdrGrafObj* >(pRet) == nullptr // we are not allowed to get
&& dynamic_cast<const SdrObjGroup* >(pRet) == nullptr // grouped placeholder objects
&& dynamic_cast<const SdrOle2Obj* >(pRet) == nullptr )
SdrObject::Free( pRet );
}
sal_uInt32 nTextFlags = aTextObj.GetTextFlags();
sal_Int32 nTextLeft = GetPropertyValue( DFF_Prop_dxTextLeft, 25 * 3600 ); // 0.25 cm (emu)
sal_Int32 nTextRight = GetPropertyValue( DFF_Prop_dxTextRight, 25 * 3600 ); // 0.25 cm (emu)
sal_Int32 nTextTop = GetPropertyValue( DFF_Prop_dyTextTop, 13 * 3600 ); // 0.13 cm (emu)
sal_Int32 nTextBottom = GetPropertyValue( DFF_Prop_dyTextBottom, 13 * 3600 );
ScaleEmu( nTextLeft );
ScaleEmu( nTextRight );
ScaleEmu( nTextTop );
ScaleEmu( nTextBottom );
sal_Int32 nMinFrameWidth = 0;
sal_Int32 nMinFrameHeight = 0;
bool bAutoGrowWidth, bAutoGrowHeight;
SdrTextVertAdjust eTVA;
SdrTextHorzAdjust eTHA;
nTextFlags &= PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT
| PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
if ( bVerticalText )
{
eTVA = SDRTEXTVERTADJUST_BLOCK;
eTHA = SDRTEXTHORZADJUST_CENTER;
// read text anchor
auto eTextAnchor = GetPropertyValue(DFF_Prop_anchorText, mso_anchorTop);
switch( eTextAnchor )
{
case mso_anchorTop:
case mso_anchorTopCentered:
case mso_anchorTopBaseline:
case mso_anchorTopCenteredBaseline:
eTHA = SDRTEXTHORZADJUST_RIGHT;
break;
case mso_anchorMiddle :
case mso_anchorMiddleCentered:
eTHA = SDRTEXTHORZADJUST_CENTER;
break;
case mso_anchorBottom:
case mso_anchorBottomCentered:
case mso_anchorBottomBaseline:
case mso_anchorBottomCenteredBaseline:
eTHA = SDRTEXTHORZADJUST_LEFT;
break;
}
switch ( eTextAnchor )
{
case mso_anchorTopCentered :
case mso_anchorMiddleCentered :
case mso_anchorBottomCentered :
case mso_anchorTopCenteredBaseline:
case mso_anchorBottomCenteredBaseline:
{
// check if it is sensible to use the centered alignment
const sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
switch (nTextFlags & nMask)
{
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK:
eTVA = SDRTEXTVERTADJUST_CENTER; // If the textobject has only one type of alignment, then the text has not to be displayed using the full width;
break;
}
break;
}
default:
break;
}
nMinFrameWidth = rTextRect.GetWidth() - ( nTextLeft + nTextRight );
}
else
{
eTVA = SDRTEXTVERTADJUST_CENTER;
eTHA = SDRTEXTHORZADJUST_BLOCK;
// read text anchor
auto eTextAnchor = GetPropertyValue(DFF_Prop_anchorText, mso_anchorTop);
switch( eTextAnchor )
{
case mso_anchorTop:
case mso_anchorTopCentered:
case mso_anchorTopBaseline:
case mso_anchorTopCenteredBaseline:
eTVA = SDRTEXTVERTADJUST_TOP;
break;
case mso_anchorMiddle :
case mso_anchorMiddleCentered:
eTVA = SDRTEXTVERTADJUST_CENTER;
break;
case mso_anchorBottom:
case mso_anchorBottomCentered:
case mso_anchorBottomBaseline:
case mso_anchorBottomCenteredBaseline:
eTVA = SDRTEXTVERTADJUST_BOTTOM;
break;
}
switch ( eTextAnchor )
{
case mso_anchorTopCentered :
case mso_anchorMiddleCentered :
case mso_anchorBottomCentered :
case mso_anchorTopCenteredBaseline:
case mso_anchorBottomCenteredBaseline:
{
// check if it is sensible to use the centered alignment
const sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK;
switch (nTextFlags & nMask)
{
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_CENTER:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT:
case PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_BLOCK:
eTHA = SDRTEXTHORZADJUST_CENTER; // If the textobject has only one type of alignment, then the text has not to be displayed using the full width;
break;
}
break;
}
default:
break;
}
nMinFrameHeight = rTextRect.GetHeight() - ( nTextTop + nTextBottom );
}
SdrObjKind eTextKind = OBJ_RECT;
if ( ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::NOTESSLIDEIMAGE )
|| ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::MASTERNOTESSLIDEIMAGE ) )
{
aTextObj.SetInstance( TSS_Type::Notes );
eTextKind = OBJ_TITLETEXT;
}
else if ( ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::MASTERNOTESBODYIMAGE )
|| ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::NOTESBODY ) )
{
aTextObj.SetInstance( TSS_Type::Notes );
eTextKind = OBJ_TEXT;
}
TSS_Type nDestinationInstance = aTextObj.GetInstance();
if ( rPersistEntry.ePageKind == PPT_MASTERPAGE )
{
if ( !rPersistEntry.pPresentationObjects )
{
rPersistEntry.pPresentationObjects.reset( new sal_uInt32[ PPT_STYLESHEETENTRIES ] );
memset( rPersistEntry.pPresentationObjects.get(), 0, PPT_STYLESHEETENTRIES * 4 );
}
if ( !rPersistEntry.pPresentationObjects[ static_cast<int>(nDestinationInstance) ] )
rPersistEntry.pPresentationObjects[ static_cast<int>(nDestinationInstance) ] = rObjData.rSpHd.GetRecBegFilePos();
}
switch ( nDestinationInstance )
{
case TSS_Type::PageTitle :
case TSS_Type::Title :
{
if ( GetSlideLayoutAtom()->eLayout == PptSlideLayout::TITLEMASTERSLIDE )
nDestinationInstance = TSS_Type::Title;
else
nDestinationInstance = TSS_Type::PageTitle;
}
break;
case TSS_Type::Body :
case TSS_Type::HalfBody :
case TSS_Type::QuarterBody :
nDestinationInstance = TSS_Type::Body;
break;
default: break;
}
aTextObj.SetDestinationInstance( nDestinationInstance );
bool bAutoFit = false; // auto-scale text into shape box
switch ( aTextObj.GetInstance() )
{
case TSS_Type::PageTitle :
case TSS_Type::Title : eTextKind = OBJ_TITLETEXT; break;
case TSS_Type::Subtitle : eTextKind = OBJ_TEXT; break;
case TSS_Type::Body :
case TSS_Type::HalfBody :
case TSS_Type::QuarterBody : eTextKind = OBJ_OUTLINETEXT; bAutoFit = true; break;
default: break;
}
if ( aTextObj.GetDestinationInstance() != TSS_Type::TextInShape )
{
if ( !aTextObj.GetOEPlaceHolderAtom() || aTextObj.GetOEPlaceHolderAtom()->nPlaceholderId == PptPlaceholder::NONE )
{
aTextObj.SetDestinationInstance( TSS_Type::TextInShape );
eTextKind = OBJ_RECT;
}
}
SdrObject* pTObj = nullptr;
bool bWordWrap = GetPropertyValue(DFF_Prop_WrapText, mso_wrapSquare) != mso_wrapNone;
bool bFitShapeToText = ( GetPropertyValue( DFF_Prop_FitTextToShape, 0 ) & 2 ) != 0;
if ( dynamic_cast<const SdrObjCustomShape* >(pRet) != nullptr && ( eTextKind == OBJ_RECT ) )
{
bAutoGrowHeight = bFitShapeToText;
bAutoGrowWidth = !bWordWrap;
pTObj = pRet;
pRet = nullptr;
}
else
{
if ( dynamic_cast<const SdrObjCustomShape* >(pRet) != nullptr )
{
SdrObject::Free( pRet );
pRet = nullptr;
}
pTObj = new SdrRectObj(
*pSdrModel,
eTextKind != OBJ_RECT ? eTextKind : OBJ_TEXT);
SfxItemSet aSet( pSdrModel->GetItemPool() );
if ( !pRet )
ApplyAttributes( rSt, aSet, rObjData );
pTObj->SetMergedItemSet( aSet );
if ( pRet )
{
pTObj->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) );
pTObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) );
}
if ( bVerticalText )
{
bAutoGrowWidth = bFitShapeToText;
bAutoGrowHeight = false;
}
else
{
bAutoGrowWidth = false;
// #119885# re-activating bFitShapeToText here, could not find deeper explanations
// for it (it was from 2005). Keeping the old comment here for reference
// old comment: // bFitShapeToText; can't be used, because we cut the text if it is too height,
bAutoGrowHeight = bFitShapeToText;
}
}
pTObj->SetMergedItem( SvxFrameDirectionItem( bVerticalText ? SvxFrameDirection::Vertical_RL_TB : SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) );
//Autofit text only if there is no auto grow height and width
//See fdo#41245
if (bAutoFit && !bAutoGrowHeight && !bAutoGrowWidth)
{
pTObj->SetMergedItem( SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_AUTOFIT) );
}
if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
{
pTObj->SetMergedItem( makeSdrTextAutoGrowWidthItem( bAutoGrowWidth ) );
pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bAutoGrowHeight ) );
}
else
{
pTObj->SetMergedItem( makeSdrTextWordWrapItem( bWordWrap ) );
pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bFitShapeToText ) );
}
pTObj->SetMergedItem( SdrTextVertAdjustItem( eTVA ) );
pTObj->SetMergedItem( SdrTextHorzAdjustItem( eTHA ) );
if ( nMinFrameHeight < 0 )
nMinFrameHeight = 0;
if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
pTObj->SetMergedItem( makeSdrTextMinFrameHeightItem( nMinFrameHeight ) );
if ( nMinFrameWidth < 0 )
nMinFrameWidth = 0;
if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
pTObj->SetMergedItem( makeSdrTextMinFrameWidthItem( nMinFrameWidth ) );
// set margins at the borders of the textbox
pTObj->SetMergedItem( makeSdrTextLeftDistItem( nTextLeft ) );
pTObj->SetMergedItem( makeSdrTextRightDistItem( nTextRight ) );
pTObj->SetMergedItem( makeSdrTextUpperDistItem( nTextTop ) );
pTObj->SetMergedItem( makeSdrTextLowerDistItem( nTextBottom ) );
pTObj->SetMergedItem( SdrTextFixedCellHeightItem( true ) );
if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
pTObj->SetSnapRect( rTextRect );
pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage );
if ( pTObj )
{
/* check if our new snaprect makes trouble,
because we do not display the ADJUST_BLOCK
properly if the textsize is bigger than the
snaprect of the object. Then we will use
ADJUST_CENTER instead of ADJUST_BLOCK.
*/
if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr && !bFitShapeToText && !bWordWrap )
{
SdrTextObj* pText = dynamic_cast<SdrTextObj*>( pTObj );
if ( pText )
{
if ( bVerticalText )
{
if ( eTVA == SDRTEXTVERTADJUST_BLOCK )
{
Size aTextSize( pText->GetTextSize() );
aTextSize.AdjustWidth(nTextLeft + nTextRight );
aTextSize.AdjustHeight(nTextTop + nTextBottom );
if ( rTextRect.GetHeight() < aTextSize.Height() )
pTObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
}
}
else
{
if ( eTHA == SDRTEXTHORZADJUST_BLOCK )
{
Size aTextSize( pText->GetTextSize() );
aTextSize.AdjustWidth(nTextLeft + nTextRight );
aTextSize.AdjustHeight(nTextTop + nTextBottom );
if ( rTextRect.GetWidth() < aTextSize.Width() )
pTObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_CENTER ) );
}
}
}
}
// rotate text with shape?
Degree100 nAngle = ( rObjData.nSpFlags & ShapeFlag::FlipV ) ? -mnFix16Angle : mnFix16Angle; // #72116# vertical flip -> rotate by using the other way
nAngle += nTextRotationAngle;
if ( dynamic_cast< const SdrObjCustomShape* >(pTObj) == nullptr )
{
if ( rObjData.nSpFlags & ShapeFlag::FlipV )
{
double a = 18000 * F_PI18000;
pTObj->Rotate( rTextRect.Center(), 18000_deg100, sin( a ), cos( a ) );
}
if ( rObjData.nSpFlags & ShapeFlag::FlipH )
nAngle = 36000_deg100 - nAngle;
if ( nAngle )
pTObj->NbcRotate( rObjData.aBoundRect.Center(), nAngle );
}
if ( pRet )
{
SdrObject* pGroup = new SdrObjGroup(*pSdrModel);
pGroup->GetSubList()->NbcInsertObject( pRet );
pGroup->GetSubList()->NbcInsertObject( pTObj );
pRet = pGroup;
}
else
pRet = pTObj;
}
}
}
}
@@ -4775,66 +4768,58 @@ bool PPTTextSpecInfoAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader&
rRecHd.SeekToContent( rIn );
auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, rRecHd.GetRecEndFilePos());
try
while (rIn.Tell() < nEndRecPos && rIn.good())
{
while (rIn.Tell() < nEndRecPos && rIn.good())
if ( nRecordType == PPT_PST_TextSpecInfoAtom )
{
if ( nRecordType == PPT_PST_TextSpecInfoAtom )
{
sal_uInt32 nCharCount(0);
rIn.ReadUInt32( nCharCount );
nCharIdx += nCharCount;
}
sal_uInt32 nFlags(0);
rIn.ReadUInt32(nFlags);
PPTTextSpecInfo aEntry( nCharIdx );
if ( pTextSpecDefault )
{
aEntry.nDontKnow = pTextSpecDefault->nDontKnow;
aEntry.nLanguage[ 0 ] = pTextSpecDefault->nLanguage[ 0 ];
aEntry.nLanguage[ 1 ] = pTextSpecDefault->nLanguage[ 1 ];
aEntry.nLanguage[ 2 ] = pTextSpecDefault->nLanguage[ 2 ];
}
for (sal_uInt32 i = 1; nFlags && i ; i <<= 1)
{
sal_uInt16 nLang = 0;
switch( nFlags & i )
{
case 0 : break;
case 1 : rIn.ReadUInt16( aEntry.nDontKnow ); break;
case 2 : rIn.ReadUInt16( nLang ); break;
case 4 : rIn.ReadUInt16( nLang ); break;
default :
{
rIn.SeekRel( 2 );
}
}
if ( nLang )
{
// #i119985#, we could probably handle this better if we have a
// place to override the final language for weak
// characters/fields to fallback to, rather than the current
// application locale. Assuming that we can determine what the
// default fallback language for a given .ppt, etc is during
// load time.
if (i == 2)
{
aEntry.nLanguage[ 0 ] = aEntry.nLanguage[ 1 ] = aEntry.nLanguage[ 2 ] = LanguageType(nLang);
}
}
nFlags &= ~i;
}
aList.push_back( aEntry );
sal_uInt32 nCharCount(0);
rIn.ReadUInt32( nCharCount );
nCharIdx += nCharCount;
}
bValid = rIn.Tell() == rRecHd.GetRecEndFilePos();
}
catch (const SvStreamEOFException&)
{
SAL_WARN("filter.ms", "EOF");
bValid = false;
sal_uInt32 nFlags(0);
rIn.ReadUInt32(nFlags);
PPTTextSpecInfo aEntry( nCharIdx );
if ( pTextSpecDefault )
{
aEntry.nDontKnow = pTextSpecDefault->nDontKnow;
aEntry.nLanguage[ 0 ] = pTextSpecDefault->nLanguage[ 0 ];
aEntry.nLanguage[ 1 ] = pTextSpecDefault->nLanguage[ 1 ];
aEntry.nLanguage[ 2 ] = pTextSpecDefault->nLanguage[ 2 ];
}
for (sal_uInt32 i = 1; nFlags && i ; i <<= 1)
{
sal_uInt16 nLang = 0;
switch( nFlags & i )
{
case 0 : break;
case 1 : rIn.ReadUInt16( aEntry.nDontKnow ); break;
case 2 : rIn.ReadUInt16( nLang ); break;
case 4 : rIn.ReadUInt16( nLang ); break;
default :
{
rIn.SeekRel( 2 );
}
}
if ( nLang )
{
// #i119985#, we could probably handle this better if we have a
// place to override the final language for weak
// characters/fields to fallback to, rather than the current
// application locale. Assuming that we can determine what the
// default fallback language for a given .ppt, etc is during
// load time.
if (i == 2)
{
aEntry.nLanguage[ 0 ] = aEntry.nLanguage[ 1 ] = aEntry.nLanguage[ 2 ] = LanguageType(nLang);
}
}
nFlags &= ~i;
}
aList.push_back( aEntry );
}
bValid = rIn.Tell() == rRecHd.GetRecEndFilePos();
return bValid;
}
-1
View File
@@ -228,7 +228,6 @@ certain functionality.
@li @c filter.ms - escher import/export
@li @c filter.odfflatxml
@li @c filter.os2met
@li @c filter.pcx
@li @c filter.pdf
@li @c filter.pict
@li @c filter.psd
-7
View File
@@ -672,11 +672,4 @@ public:
virtual sal_uInt64 TellEnd() override { FlushBuffer(); return nEndOfData; }
};
/** thrown when reading past the end of file */
class TOOLS_DLLPUBLIC SvStreamEOFException : public std::exception
{
public:
virtual const char * what() const throw() override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
File diff suppressed because it is too large Load Diff
+26 -34
View File
@@ -388,46 +388,38 @@ XclBiff XclImpStream::DetectBiffVersion( SvStream& rStrm )
XclBiff eBiff = EXC_BIFF_UNKNOWN;
rStrm.Seek( STREAM_SEEK_TO_BEGIN );
try
{
sal_uInt16 nBofId, nBofSize;
rStrm.ReadUInt16( nBofId ).ReadUInt16( nBofSize );
sal_uInt16 nBofId, nBofSize;
rStrm.ReadUInt16( nBofId ).ReadUInt16( nBofSize );
if( (4 <= nBofSize) && (nBofSize <= 16) ) switch( nBofId )
if( (4 <= nBofSize) && (nBofSize <= 16) ) switch( nBofId )
{
case EXC_ID2_BOF:
eBiff = EXC_BIFF2;
break;
case EXC_ID3_BOF:
eBiff = EXC_BIFF3;
break;
case EXC_ID4_BOF:
eBiff = EXC_BIFF4;
break;
case EXC_ID5_BOF:
{
case EXC_ID2_BOF:
eBiff = EXC_BIFF2;
break;
case EXC_ID3_BOF:
eBiff = EXC_BIFF3;
break;
case EXC_ID4_BOF:
eBiff = EXC_BIFF4;
break;
case EXC_ID5_BOF:
sal_uInt16 nVersion;
rStrm.ReadUInt16( nVersion );
// #i23425# #i44031# #i62752# there are some *really* broken documents out there...
switch( nVersion & 0xFF00 )
{
sal_uInt16 nVersion;
rStrm.ReadUInt16( nVersion );
// #i23425# #i44031# #i62752# there are some *really* broken documents out there...
switch( nVersion & 0xFF00 )
{
case 0: eBiff = EXC_BIFF5; break; // #i44031# #i62752#
case EXC_BOF_BIFF2: eBiff = EXC_BIFF2; break;
case EXC_BOF_BIFF3: eBiff = EXC_BIFF3; break;
case EXC_BOF_BIFF4: eBiff = EXC_BIFF4; break;
case EXC_BOF_BIFF5: eBiff = EXC_BIFF5; break;
case EXC_BOF_BIFF8: eBiff = EXC_BIFF8; break;
default: SAL_WARN("sc", "XclImpStream::DetectBiffVersion - unknown BIFF version: 0x" << std::hex << nVersion );
}
case 0: eBiff = EXC_BIFF5; break; // #i44031# #i62752#
case EXC_BOF_BIFF2: eBiff = EXC_BIFF2; break;
case EXC_BOF_BIFF3: eBiff = EXC_BIFF3; break;
case EXC_BOF_BIFF4: eBiff = EXC_BIFF4; break;
case EXC_BOF_BIFF5: eBiff = EXC_BIFF5; break;
case EXC_BOF_BIFF8: eBiff = EXC_BIFF8; break;
default: SAL_WARN("sc", "XclImpStream::DetectBiffVersion - unknown BIFF version: 0x" << std::hex << nVersion );
}
break;
}
break;
}
catch (const SvStreamEOFException&)
{
SAL_WARN("sc", "EOF");
}
return eBiff;
}
+1 -8
View File
@@ -341,15 +341,8 @@ ScCTBWrapper::Read( SvStream &rS)
{
SAL_INFO("sc.filter", "stream pos " << rS.Tell());
nOffSet = rS.Tell();
try
{
if (!ctbSet.Read(rS))
return false;
}
catch(SvStreamEOFException&)
{
if (!ctbSet.Read(rS))
return false;
}
//ScCTB is 1 TB which is min 15bytes, nViews TBVisualData which is min 20bytes
//and one 32bit number (4 bytes)
+5 -12
View File
@@ -323,21 +323,14 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportWKS(SvStream& rStream)
LotusContext aContext(aDocument, RTL_TEXTENCODING_ASCII_US);
ImportLotus aLotusImport(aContext, rStream, RTL_TEXTENCODING_ASCII_US);
try
ErrCode eRet = aLotusImport.parse();
if (eRet == ErrCode(0xFFFFFFFF))
{
ErrCode eRet = aLotusImport.parse();
if (eRet == ErrCode(0xFFFFFFFF))
{
rStream.Seek(0);
eRet = ScImportLotus123old(aContext, rStream, RTL_TEXTENCODING_ASCII_US);
}
return eRet == ERRCODE_NONE;
}
catch(SvStreamEOFException&)
{
return false;
rStream.Seek(0);
eRet = ScImportLotus123old(aContext, rStream, RTL_TEXTENCODING_ASCII_US);
}
return eRet == ERRCODE_NONE;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+2 -19
View File
@@ -227,15 +227,7 @@ ErrCode ScQProReader::parse(ScDocument& rDoc)
ErrCode ScQProReader::import( ScDocument& rDoc)
{
ErrCode eRet;
try
{
eRet = parse(rDoc);
}
catch (SvStreamEOFException&)
{
eRet = SCERR_IMPORT_OPEN;
}
ErrCode eRet = parse(rDoc);
rDoc.CalcAfterLoad();
return eRet;
}
@@ -254,16 +246,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportQPW(SvStream &rStream)
aDocument.SetHardRecalcState(ScDocument::HardRecalcState::ETERNAL);
ScQProReader aReader(&rStream);
ErrCode eRet;
try
{
eRet = aReader.parse(aDocument);
}
catch (SvStreamEOFException&)
{
eRet = SCERR_IMPORT_OPEN;
}
ErrCode eRet = aReader.parse(aDocument);
return eRet == ERRCODE_NONE;
}
+2 -9
View File
@@ -2773,15 +2773,8 @@ ImplSdPPTImport::ReadFormControl( tools::SvRef<SotStorage>& rSrc1, css::uno::Ref
extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool ImportPPT(
SdDrawDocument* pDocument, SvStream& rDocStream, SotStorage& rStorage, SfxMedium& rMedium )
{
try
{
std::unique_ptr<SdPPTImport> pImport( new SdPPTImport( pDocument, rDocStream, rStorage, rMedium ));
return pImport->Import();
}
catch(SvStreamEOFException&)
{
return false;
}
std::unique_ptr<SdPPTImport> pImport( new SdPPTImport( pDocument, rDocStream, rStorage, rMedium ));
return pImport->Import();
}
extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportPPT(SvStream &rStream)
+32 -40
View File
@@ -941,13 +941,12 @@ void SfxOleSection::ImplLoad( SvStream& rStrm )
mnStartPos = rStrm.Tell();
sal_uInt32 nSize(0);
sal_Int32 nPropCount(0);
if (rStrm.remainingSize() >= 8)
rStrm.ReadUInt32( nSize ).ReadInt32( nPropCount );
rStrm.ReadUInt32( nSize ).ReadInt32( nPropCount );
// read property ID/position pairs
typedef ::std::map< sal_Int32, sal_uInt32 > SfxOlePropPosMap;
SfxOlePropPosMap aPropPosMap;
for (sal_Int32 nPropIdx = 0; nPropIdx < nPropCount && rStrm.good() && rStrm.remainingSize() >= 8; ++nPropIdx)
for (sal_Int32 nPropIdx = 0; nPropIdx < nPropCount && rStrm.good(); ++nPropIdx)
{
sal_Int32 nPropId(0);
sal_uInt32 nPropPos(0);
@@ -957,7 +956,7 @@ void SfxOleSection::ImplLoad( SvStream& rStrm )
// read codepage property
SfxOlePropPosMap::iterator aCodePageIt = aPropPosMap.find( PROPID_CODEPAGE );
if( (aCodePageIt != aPropPosMap.end()) && SeekToPropertyPos(rStrm, aCodePageIt->second) && rStrm.remainingSize() >= 4)
if( (aCodePageIt != aPropPosMap.end()) && SeekToPropertyPos( rStrm, aCodePageIt->second ) )
{
// codepage property must be of type signed int-16
sal_Int32 nPropType(0);
@@ -973,7 +972,7 @@ void SfxOleSection::ImplLoad( SvStream& rStrm )
if( (aDictIt != aPropPosMap.end()) && SeekToPropertyPos( rStrm, aDictIt->second ) )
{
// #i66214# #i66428# applications may write broken dictionary properties in wrong sections
if (mbSupportsDict && rStrm.remainingSize() >= 4)
if( mbSupportsDict )
{
// dictionary property contains number of pairs in property type field
sal_Int32 nNameCount(0);
@@ -1155,43 +1154,36 @@ SfxOleSection& SfxOlePropertySet::AddSection( const SvGlobalName& rSectionGuid )
void SfxOlePropertySet::ImplLoad( SvStream& rStrm )
{
try
{
// read property set header
sal_uInt16 nByteOrder;
sal_uInt16 nVersion;
sal_uInt16 nOsMinor;
sal_uInt16 nOsType;
SvGlobalName aGuid;
sal_Int32 nSectCount(0);
rStrm.ReadUInt16( nByteOrder ).ReadUInt16( nVersion ).ReadUInt16( nOsMinor ).ReadUInt16( nOsType );
rStrm >> aGuid;
rStrm.ReadInt32( nSectCount );
// read property set header
sal_uInt16 nByteOrder;
sal_uInt16 nVersion;
sal_uInt16 nOsMinor;
sal_uInt16 nOsType;
SvGlobalName aGuid;
sal_Int32 nSectCount(0);
rStrm.ReadUInt16( nByteOrder ).ReadUInt16( nVersion ).ReadUInt16( nOsMinor ).ReadUInt16( nOsType );
rStrm >> aGuid;
rStrm.ReadInt32( nSectCount );
// read sections
sal_uInt64 nSectPosPos = rStrm.Tell();
for (sal_Int32 nSectIdx = 0; nSectIdx < nSectCount; ++nSectIdx)
{
// read section guid/position pair
rStrm.Seek(nSectPosPos);
SvGlobalName aSectGuid;
rStrm >> aSectGuid;
sal_uInt32 nSectPos(0);
rStrm.ReadUInt32(nSectPos);
if (!rStrm.good())
break;
nSectPosPos = rStrm.Tell();
// read section
if (!checkSeek(rStrm, nSectPos))
break;
LoadObject(rStrm, AddSection(aSectGuid));
if (!rStrm.good())
break;
}
}
catch (const SvStreamEOFException&)
// read sections
sal_uInt64 nSectPosPos = rStrm.Tell();
for (sal_Int32 nSectIdx = 0; nSectIdx < nSectCount; ++nSectIdx)
{
rStrm.SetError(SVSTREAM_READ_ERROR);
// read section guid/position pair
rStrm.Seek(nSectPosPos);
SvGlobalName aSectGuid;
rStrm >> aSectGuid;
sal_uInt32 nSectPos(0);
rStrm.ReadUInt32(nSectPos);
if (!rStrm.good())
break;
nSectPosPos = rStrm.Tell();
// read section
if (!checkSeek(rStrm, nSectPos))
break;
LoadObject(rStrm, AddSection(aSectGuid));
if (!rStrm.good())
break;
}
}
+2 -11
View File
@@ -315,17 +315,8 @@ bool Storage::IsStorageFile( SvStream* pStream )
{
StgHeader aHdr;
sal_uInt64 nPos = pStream->Tell();
try
{
bRet = ( aHdr.Load( *pStream ) && aHdr.Check() );
}
catch(SvStreamEOFException&)
{
// It's not a stream error if it is too small for an OLE storage header
pStream->ResetError();
pStream->Seek( nPos );
return false;
}
bRet = ( aHdr.Load( *pStream ) && aHdr.Check() );
// It's not a stream error if it is too small for an OLE storage header
if ( pStream->GetErrorCode() == ERRCODE_IO_CANTSEEK )
pStream->ResetError();
+2 -2
View File
@@ -126,9 +126,9 @@ bool StgHeader::Load( SvStream& r )
{
r.Seek( 0 );
r.ReadBytes( m_cSignature, 8 );
ReadClsId( r, m_aClsId ); // 08 Class ID
ReadClsId( r, m_aClsId ); // 08 Class ID
r.ReadInt32( m_nVersion ) // 1A version number
.ReadUInt16( m_nByteOrder ) // 1C Unicode byte order indicator
.ReadUInt16( m_nByteOrder ) // 1C Unicode byte order indicator
.ReadInt16( m_nPageSize ) // 1E 1 << nPageSize = block size
.ReadInt16( m_nDataPageSize ); // 20 1 << this size == data block size
if (!r.good())
+1 -11
View File
@@ -55,17 +55,7 @@ bool StgIo::Load()
{
if( GetStrm() )
{
bool bLoaded;
try
{
bLoaded = m_aHdr.Load(*this);
}
catch (const SvStreamEOFException&)
{
SAL_WARN("sot", "EOF");
bLoaded = false;
}
if (bLoaded)
if( m_aHdr.Load( *this ) )
{
if( m_aHdr.Check() )
SetupStreams();
+20 -28
View File
@@ -558,36 +558,28 @@ bool MathType::Parse(SvStream* pStream)
pS = pStream;
pS->SetEndian( SvStreamEndian::LITTLE );
bool bRet;
try
{
EQNOLEFILEHDR aHdr;
aHdr.Read(pS);
sal_uInt8 nProdVersion;
sal_uInt8 nProdSubVersion;
sal_uInt8 nPlatform;
sal_uInt8 nProduct;
pS->ReadUChar( nVersion );
pS->ReadUChar( nPlatform );
pS->ReadUChar( nProduct );
pS->ReadUChar( nProdVersion );
pS->ReadUChar( nProdSubVersion );
EQNOLEFILEHDR aHdr;
aHdr.Read(pS);
sal_uInt8 nProdVersion;
sal_uInt8 nProdSubVersion;
sal_uInt8 nPlatform;
sal_uInt8 nProduct;
pS->ReadUChar( nVersion );
pS->ReadUChar( nPlatform );
pS->ReadUChar( nProduct );
pS->ReadUChar( nProdVersion );
pS->ReadUChar( nProdSubVersion );
if (nVersion > 3) // allow only supported versions of MathType to be parsed
return false;
if (nVersion > 3) // allow only supported versions of MathType to be parsed
return false;
bool bRet = HandleRecords(0);
//little crude hack to close occasionally open expressions
//a sophisticated system to determine what expressions are
//opened is required, but this is as much work as rewriting
//starmaths internals.
rRet.append("{}");
bRet = HandleRecords(0);
//little crude hack to close occasionally open expressions
//a sophisticated system to determine what expressions are
//opened is required, but this is as much work as rewriting
//starmaths internals.
rRet.append("{}");
}
catch (const SvStreamEOFException&)
{
SAL_WARN("starmath", "EOF");
bRet = false;
}
return bRet;
}
+41 -48
View File
@@ -99,56 +99,49 @@ bool ParseOLE2Presentation(SvStream& rOle2, sal_uInt32& nWidth, sal_uInt32& nHei
{
// See [MS-OLEDS] 2.3.4, OLEPresentationStream
rOle2.Seek(0);
try
{
tools::SvRef<SotStorage> pStorage = new SotStorage(rOle2);
tools::SvRef<SotStorageStream> xOle2Presentation
= pStorage->OpenSotStream("\002OlePres000", StreamMode::STD_READ);
tools::SvRef<SotStorage> pStorage = new SotStorage(rOle2);
tools::SvRef<SotStorageStream> xOle2Presentation
= pStorage->OpenSotStream("\002OlePres000", StreamMode::STD_READ);
// Read AnsiClipboardFormat.
sal_uInt32 nMarkerOrLength = 0;
xOle2Presentation->ReadUInt32(nMarkerOrLength);
if (nMarkerOrLength != 0xffffffff)
// FormatOrAnsiString is not present
return false;
sal_uInt32 nFormatOrAnsiLength = 0;
xOle2Presentation->ReadUInt32(nFormatOrAnsiLength);
if (nFormatOrAnsiLength != 0x00000003) // CF_METAFILEPICT
return false;
// Read TargetDeviceSize.
sal_uInt32 nTargetDeviceSize = 0;
xOle2Presentation->ReadUInt32(nTargetDeviceSize);
if (nTargetDeviceSize != 0x00000004)
// TargetDevice is present
return false;
sal_uInt32 nAspect = 0;
xOle2Presentation->ReadUInt32(nAspect);
sal_uInt32 nLindex = 0;
xOle2Presentation->ReadUInt32(nLindex);
sal_uInt32 nAdvf = 0;
xOle2Presentation->ReadUInt32(nAdvf);
sal_uInt32 nReserved1 = 0;
xOle2Presentation->ReadUInt32(nReserved1);
xOle2Presentation->ReadUInt32(nWidth);
xOle2Presentation->ReadUInt32(nHeight);
sal_uInt32 nSize = 0;
xOle2Presentation->ReadUInt32(nSize);
// Read Data.
if (nSize > xOle2Presentation->remainingSize())
return false;
std::vector<char> aBuffer(nSize);
xOle2Presentation->ReadBytes(aBuffer.data(), aBuffer.size());
rPresentationData.WriteBytes(aBuffer.data(), aBuffer.size());
return true;
}
catch (SvStreamEOFException&)
{
// Read AnsiClipboardFormat.
sal_uInt32 nMarkerOrLength = 0;
xOle2Presentation->ReadUInt32(nMarkerOrLength);
if (nMarkerOrLength != 0xffffffff)
// FormatOrAnsiString is not present
return false;
}
sal_uInt32 nFormatOrAnsiLength = 0;
xOle2Presentation->ReadUInt32(nFormatOrAnsiLength);
if (nFormatOrAnsiLength != 0x00000003) // CF_METAFILEPICT
return false;
// Read TargetDeviceSize.
sal_uInt32 nTargetDeviceSize = 0;
xOle2Presentation->ReadUInt32(nTargetDeviceSize);
if (nTargetDeviceSize != 0x00000004)
// TargetDevice is present
return false;
sal_uInt32 nAspect = 0;
xOle2Presentation->ReadUInt32(nAspect);
sal_uInt32 nLindex = 0;
xOle2Presentation->ReadUInt32(nLindex);
sal_uInt32 nAdvf = 0;
xOle2Presentation->ReadUInt32(nAdvf);
sal_uInt32 nReserved1 = 0;
xOle2Presentation->ReadUInt32(nReserved1);
xOle2Presentation->ReadUInt32(nWidth);
xOle2Presentation->ReadUInt32(nHeight);
sal_uInt32 nSize = 0;
xOle2Presentation->ReadUInt32(nSize);
// Read Data.
if (nSize > xOle2Presentation->remainingSize())
return false;
std::vector<char> aBuffer(nSize);
xOle2Presentation->ReadBytes(aBuffer.data(), aBuffer.size());
rPresentationData.WriteBytes(aBuffer.data(), aBuffer.size());
return true;
}
/**
+12
View File
@@ -84,6 +84,18 @@ namespace
//yet, the read didn't succeed
CPPUNIT_ASSERT(!aMemStream.good());
//set things up so that there is only one byte available on an attempt
//to read a two-byte sal_uInt16. The byte should be consumed, but the
//operation should fail, and tools_b should remain unchanged,
sal_uInt16 tools_b = 0x1122;
aMemStream.SeekRel(-1);
CPPUNIT_ASSERT(!aMemStream.eof());
CPPUNIT_ASSERT(aMemStream.good());
aMemStream.ReadUInt16( tools_b );
CPPUNIT_ASSERT(!aMemStream.good());
CPPUNIT_ASSERT(aMemStream.eof());
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(0x1122), tools_b);
iss.clear();
iss.seekg(0);
CPPUNIT_ASSERT(iss.good());
+6 -28
View File
@@ -527,8 +527,6 @@ bool SvStream::ReadLine( OString& rStr, sal_Int32 nMaxBytesToRead )
bool SvStream::ReadUniStringLine( OUString& rStr, sal_Int32 nMaxCodepointsToRead )
{
if (!good())
throw SvStreamEOFException();
sal_Unicode buf[256+1];
bool bEnd = false;
sal_uInt64 nOldFilePos = Tell();
@@ -821,8 +819,6 @@ sal_uInt64 SvStream::SeekRel(sal_Int64 const nPos)
SvStream& SvStream::ReadUInt16(sal_uInt16& r)
{
if (remainingSize() < 2)
throw SvStreamEOFException();
sal_uInt16 n = 0;
readNumberWithoutSwap(n);
if (good())
@@ -836,8 +832,6 @@ SvStream& SvStream::ReadUInt16(sal_uInt16& r)
SvStream& SvStream::ReadUInt32(sal_uInt32& r)
{
if (remainingSize() < 4)
throw SvStreamEOFException();
sal_uInt32 n = 0;
readNumberWithoutSwap(n);
if (good())
@@ -851,8 +845,6 @@ SvStream& SvStream::ReadUInt32(sal_uInt32& r)
SvStream& SvStream::ReadUInt64(sal_uInt64& r)
{
if (remainingSize() < 8)
throw SvStreamEOFException();
sal_uInt64 n = 0;
readNumberWithoutSwap(n);
if (good())
@@ -866,8 +858,6 @@ SvStream& SvStream::ReadUInt64(sal_uInt64& r)
SvStream& SvStream::ReadInt16(sal_Int16& r)
{
if (remainingSize() < 2)
throw SvStreamEOFException();
sal_Int16 n = 0;
readNumberWithoutSwap(n);
if (good())
@@ -881,8 +871,6 @@ SvStream& SvStream::ReadInt16(sal_Int16& r)
SvStream& SvStream::ReadInt32(sal_Int32& r)
{
if (remainingSize() < 4)
throw SvStreamEOFException();
sal_Int32 n = 0;
readNumberWithoutSwap(n);
if (good())
@@ -896,13 +884,14 @@ SvStream& SvStream::ReadInt32(sal_Int32& r)
SvStream& SvStream::ReadInt64(sal_Int64& r)
{
if (remainingSize() < 8)
throw SvStreamEOFException();
sal_Int64 n = 0;
readNumberWithoutSwap(n);
if (m_isSwap)
SwapInt64(n);
r = n;
if (good())
{
if (m_isSwap)
SwapInt64(n);
r = n;
}
return *this;
}
@@ -952,8 +941,6 @@ SvStream& SvStream::ReadUChar( unsigned char& r )
SvStream& SvStream::ReadUtf16(sal_Unicode& r)
{
if (remainingSize() < 2)
throw SvStreamEOFException();
sal_uInt16 n = 0;
readNumberWithoutSwap(n);
if (good())
@@ -990,8 +977,6 @@ SvStream& SvStream::ReadCharAsBool( bool& r )
SvStream& SvStream::ReadFloat(float& r)
{
if (remainingSize() < 4)
throw SvStreamEOFException();
float n = 0;
readNumberWithoutSwap(n);
if (good())
@@ -1007,8 +992,6 @@ SvStream& SvStream::ReadFloat(float& r)
SvStream& SvStream::ReadDouble(double& r)
{
if (remainingSize() < 8)
throw SvStreamEOFException();
double n = 0;
readNumberWithoutSwap(n);
if (good())
@@ -2149,9 +2132,4 @@ std::size_t write_uInt16_lenPrefixed_uInt8s_FromOString(SvStream& rStrm,
return nWritten;
}
const char * SvStreamEOFException::what() const throw()
{
return "SvStreamEOFException";
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

+5 -12
View File
@@ -1654,23 +1654,16 @@ bool ImplReadDIB(
rIStm.SetEndian(SvStreamEndian::LITTLE);
try
if(bFileHeader)
{
if(bFileHeader)
if(ImplReadDIBFileHeader(rIStm, nOffset))
{
if(ImplReadDIBFileHeader(rIStm, nOffset))
{
bRet = ImplReadDIBBody(rIStm, rTarget, nOffset >= DIBV5HEADERSIZE ? pTargetAlpha : nullptr, nOffset, bIsMask, bMSOFormat);
}
}
else
{
bRet = ImplReadDIBBody(rIStm, rTarget, nullptr, nOffset, bIsMask, bMSOFormat);
bRet = ImplReadDIBBody(rIStm, rTarget, nOffset >= DIBV5HEADERSIZE ? pTargetAlpha : nullptr, nOffset, bIsMask, bMSOFormat);
}
}
catch (const SvStreamEOFException&)
else
{
SAL_WARN("vcl", "EOF");
bRet = ImplReadDIBBody(rIStm, rTarget, nullptr, nOffset, bIsMask, bMSOFormat);
}
if(!bRet)
+1 -8
View File
@@ -987,14 +987,7 @@ ErrCode GraphicFilter::ImportGraphic(
GraphicFilterImportFlags nImportFlags,
WmfExternal const *pExtHeader)
{
try
{
return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, nullptr, pExtHeader );
}
catch (SvStreamEOFException&)
{
return ERRCODE_GRFILTER_FORMATERROR;
}
return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, nullptr, pExtHeader );
}
namespace {
File diff suppressed because it is too large Load Diff
-4
View File
@@ -1719,10 +1719,6 @@ bool ImportTiffGraphicImport(SvStream & rStream, Graphic & rGraphic)
{
return aTIFFReader.ReadTIFF(rStream, rGraphic);
}
catch (const SvStreamEOFException &)
{
return false;
}
catch (const std::bad_alloc &)
{
return false;
+58 -72
View File
@@ -229,16 +229,11 @@ PNGReaderImpl::PNGReaderImpl( SvStream& rPNGStream )
mnStreamSize = mrPNGStream.TellEnd();
// check the PNG header magic
if (mnStreamSize < 8)
mbStatus = false;
else
{
sal_uInt32 nDummy = 0;
mrPNGStream.ReadUInt32( nDummy );
mbStatus = (nDummy == 0x89504e47);
mrPNGStream.ReadUInt32( nDummy );
mbStatus = (nDummy == 0x0d0a1a0a) && mbStatus;
}
sal_uInt32 nDummy = 0;
mrPNGStream.ReadUInt32( nDummy );
mbStatus = (nDummy == 0x89504e47);
mrPNGStream.ReadUInt32( nDummy );
mbStatus = (nDummy == 0x0d0a1a0a) && mbStatus;
mnPreviewShift = 0;
mnPreviewMask = (1 << mnPreviewShift) - 1;
@@ -257,77 +252,68 @@ PNGReaderImpl::~PNGReaderImpl()
bool PNGReaderImpl::ReadNextChunk()
{
try
if( maChunkIter == maChunkSeq.end() )
{
if( maChunkIter == maChunkSeq.end() )
// get the next chunk from the stream
// unless we are at the end of the PNG stream
if (!mrPNGStream.good() || mrPNGStream.remainingSize() < 8)
return false;
if( !maChunkSeq.empty() && (maChunkSeq.back().nType == PNGCHUNK_IEND) )
return false;
PNGReader::ChunkData aDummyChunk;
maChunkIter = maChunkSeq.insert( maChunkSeq.end(), aDummyChunk );
PNGReader::ChunkData& rChunkData = *maChunkIter;
// read the chunk header
mnChunkLen = 0;
mnChunkType = 0;
mrPNGStream.ReadInt32( mnChunkLen ).ReadUInt32( mnChunkType );
rChunkData.nType = mnChunkType;
// fdo#61847 truncate over-long, trailing chunks
const std::size_t nStreamPos = mrPNGStream.Tell();
if( mnChunkLen < 0 || nStreamPos + mnChunkLen >= mnStreamSize )
mnChunkLen = mnStreamSize - nStreamPos;
// calculate chunktype CRC (swap it back to original byte order)
sal_uInt32 nChunkType = mnChunkType;
#if defined(__LITTLEENDIAN) || defined(OSL_LITENDIAN)
nChunkType = OSL_SWAPDWORD( nChunkType );
#endif
sal_uInt32 nCRC32 = rtl_crc32( 0, &nChunkType, 4 );
// read the chunk data and check the CRC
if( mnChunkLen && !mrPNGStream.eof() )
{
// get the next chunk from the stream
rChunkData.aData.resize( mnChunkLen );
// unless we are at the end of the PNG stream
if (!mrPNGStream.good() || mrPNGStream.remainingSize() < 8)
return false;
if( !maChunkSeq.empty() && (maChunkSeq.back().nType == PNGCHUNK_IEND) )
return false;
PNGReader::ChunkData aDummyChunk;
maChunkIter = maChunkSeq.insert( maChunkSeq.end(), aDummyChunk );
PNGReader::ChunkData& rChunkData = *maChunkIter;
// read the chunk header
mnChunkLen = 0;
mnChunkType = 0;
mrPNGStream.ReadInt32( mnChunkLen ).ReadUInt32( mnChunkType );
rChunkData.nType = mnChunkType;
// fdo#61847 truncate over-long, trailing chunks
const std::size_t nStreamPos = mrPNGStream.Tell();
if( mnChunkLen < 0 || nStreamPos + mnChunkLen >= mnStreamSize )
mnChunkLen = mnStreamSize - nStreamPos;
// calculate chunktype CRC (swap it back to original byte order)
sal_uInt32 nChunkType = mnChunkType;
#if defined(__LITTLEENDIAN) || defined(OSL_LITENDIAN)
nChunkType = OSL_SWAPDWORD( nChunkType );
#endif
sal_uInt32 nCRC32 = rtl_crc32( 0, &nChunkType, 4 );
// read the chunk data and check the CRC
if( mnChunkLen && !mrPNGStream.eof() )
sal_Int32 nBytesRead = 0;
do
{
rChunkData.aData.resize( mnChunkLen );
sal_uInt8& rPtr = rChunkData.aData[nBytesRead];
nBytesRead += mrPNGStream.ReadBytes(&rPtr, mnChunkLen - nBytesRead);
} while (nBytesRead < mnChunkLen && mrPNGStream.good());
sal_Int32 nBytesRead = 0;
do
{
sal_uInt8& rPtr = rChunkData.aData[nBytesRead];
nBytesRead += mrPNGStream.ReadBytes(&rPtr, mnChunkLen - nBytesRead);
} while (nBytesRead < mnChunkLen && mrPNGStream.good());
nCRC32 = rtl_crc32( nCRC32, rChunkData.aData.data(), mnChunkLen );
maDataIter = rChunkData.aData.begin();
}
sal_uInt32 nCheck(0);
mrPNGStream.ReadUInt32( nCheck );
if (!mbIgnoreCRC && nCRC32 != nCheck)
return false;
nCRC32 = rtl_crc32( nCRC32, rChunkData.aData.data(), mnChunkLen );
maDataIter = rChunkData.aData.begin();
}
else
{
// the next chunk was already read
mnChunkType = (*maChunkIter).nType;
mnChunkLen = (*maChunkIter).aData.size();
maDataIter = (*maChunkIter).aData.begin();
}
++maChunkIter;
return mnChunkType != PNGCHUNK_IEND;
sal_uInt32 nCheck(0);
mrPNGStream.ReadUInt32( nCheck );
if (!mbIgnoreCRC && nCRC32 != nCheck)
return false;
}
catch (const SvStreamEOFException&)
else
{
mbStatus = false;
SAL_WARN("vcl", "EOF");
// the next chunk was already read
mnChunkType = (*maChunkIter).nType;
mnChunkLen = (*maChunkIter).aData.size();
maDataIter = (*maChunkIter).aData.begin();
}
return false;
++maChunkIter;
return mnChunkType != PNGCHUNK_IEND;
}
const std::vector< vcl::PNGReader::ChunkData >& PNGReaderImpl::GetAllChunks()
+18 -25
View File
@@ -1117,34 +1117,27 @@ bool ImpGraphic::swapInContent(SvStream& rStream)
sal_Int32 nType;
sal_Int32 nLength;
try
rStream.ReadUInt32(nId);
// check version
if (SWAP_FORMAT_ID != nId)
{
rStream.ReadUInt32(nId);
// check version
if (SWAP_FORMAT_ID != nId)
{
SAL_WARN("vcl", "Incompatible swap file!");
return false;
}
rStream.ReadInt32(nType);
rStream.ReadInt32(nLength);
meType = static_cast<GraphicType>(nType);
if (meType == GraphicType::NONE || meType == GraphicType::Default)
{
return true;
}
else
{
bRet = swapInGraphic(rStream);
}
SAL_WARN("vcl", "Incompatible swap file!");
return false;
}
catch (const SvStreamEOFException&)
rStream.ReadInt32(nType);
rStream.ReadInt32(nLength);
meType = static_cast<GraphicType>(nType);
if (meType == GraphicType::NONE || meType == GraphicType::Default)
{
SAL_WARN("vcl", "EOF");
return true;
}
else
{
bRet = swapInGraphic(rStream);
}
return bRet;