From 4e639c37b4dcdc27d46111d0d0cbca966544c2cb Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 18 Jan 2021 16:19:10 +0000 Subject: ofz#29691 revert throw SvStreamEOFException MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 b345a2bab0d6f981049951a86b172ce49ce7d4c2 cid#1470786 Uncaught exception commit 71aec4726a94dcde1169fd293dbecfeb0e840e6d ofz#29528 uncaught exception commit bed03603f6cae264abb9e5b58aa2ab00448d92ff ofz#29414 uncaught exception commit 684885a99a1eb7ad943e9736166d4bb1468663be ofz#29443 uncaught exception commit 93574ac7768d247ed754ecda322e54e4bd447e43 ofz#29251 Abrt commit 413db68d95bd39d34e6a6b81a7c5c9478ced0514 ofz#29152 short read commit f400e883044143f999c460375a293647b4a57244 ofz#29151 short read commit 96ea80a725dfe4ef38993f78917c243f13e3beb5 ofz#29129 Abrt on uncaught exception commit 646a635efe6eecbc3d1dd3a7cbb02a278c6f3be5 ofz#28931 Indirect-leak commit b0e573f18629d28fe3179c12d0d434653f92fc93 ofz#29030 Abrt in xlsfuzzer commit 95407c39168d186ee44e67b1a6a4bcf592c58b84 ofz#28902 uncaught exception commit 45175d655ad3773df1c006182108cf25e87b1091 oss-fuzz: tgafuzzer doesn't pass sanity check commit b82fc702bae9d6190bda1b4818a47cfa197df6d8 oss-fuzz: psdfuzzer doesn't pass sanity check commit e7c76d604a4694e6568bf10c2a06a786f1096319 oss-fuzz: epsfuzzer doesn't pass sanity check commit 901e5e7c9170184e286ea3e46fce406136aa9572 oss-fuzz: xlsfuzzer doesn't pass sanity check commit 127bfab61c297df06fd8e71e709bc4362cb89d21 oss-fuzz: pngfuzzer doesn't pass sanity check commit 77387ae00ae27e3f8bcdf7bccf97fb2db8f196b7 oss-fuzz: mtpfuzzer doesn't pass sanity check commit 974ffa79b0fef4ca76558bb8b16bce84af3aaf6c oss-fuzz: xlsxfuzzer doesn't pass sanity check commit 6d6d104cbb382d0045e1f04b12d268992fa5c624 oss-fuzz: bmpfuzzer doesn't pass sanity check commit a7d1d107ec58d3b00b4019c89edddcff71ca6ff3 oss-fuzz: qpwfuzzer doesn't pass sanity check commit 898993aa62276f59480df8af1da4bad530829b56 oss-fuzz: pcxfuzzer doesn't pass sanity check throw/catch parts of commit 8c9a4ff511a3b1d84a7a6d08a1b153c07f164abb 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 Reviewed-by: Noel Grandin Reviewed-by: Caolán McNamara --- filter/qa/cppunit/data/met/fail/hang-3.met | Bin 608 -> 0 bytes filter/qa/cppunit/data/met/pass/hang-3.met | Bin 0 -> 608 bytes filter/source/graphicfilter/ieps/ieps.cxx | 350 ++++++----- filter/source/graphicfilter/ios2met/ios2met.cxx | 3 - filter/source/graphicfilter/ipcx/ipcx.cxx | 12 +- filter/source/graphicfilter/ipsd/ipsd.cxx | 13 +- filter/source/graphicfilter/itga/itga.cxx | 15 +- filter/source/msfilter/msdffimp.cxx | 20 +- filter/source/msfilter/svdfppt.cxx | 751 ++++++++++++------------ 9 files changed, 549 insertions(+), 615 deletions(-) delete mode 100644 filter/qa/cppunit/data/met/fail/hang-3.met create mode 100644 filter/qa/cppunit/data/met/pass/hang-3.met (limited to 'filter') diff --git a/filter/qa/cppunit/data/met/fail/hang-3.met b/filter/qa/cppunit/data/met/fail/hang-3.met deleted file mode 100644 index 84b432e63f69..000000000000 Binary files a/filter/qa/cppunit/data/met/fail/hang-3.met and /dev/null differ diff --git a/filter/qa/cppunit/data/met/pass/hang-3.met b/filter/qa/cppunit/data/met/pass/hang-3.met new file mode 100644 index 000000000000..84b432e63f69 Binary files /dev/null and b/filter/qa/cppunit/data/met/pass/hang-3.met differ diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index b70407027b7d..ed294f9ec1fb 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -596,233 +596,225 @@ 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 ); + rStream.ReadUInt32( nPSStreamPos ).ReadUInt32( nPSSize ).ReadUInt32( nPosWMF ).ReadUInt32( nSizeWMF ); - // first we try to get the metafile grafix + // first we try to get the metafile grafix - if ( nSizeWMF ) + 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; - } + if (GraphicConverter::Import(rStream, aGraphic, ConvertDataFormat::WMF) == ERRCODE_NONE) + bHasPreview = bRetValue = true; } - else - { - rStream.ReadUInt32( nPosTIFF ).ReadUInt32( nSizeTIFF ); + } + else + { + rStream.ReadUInt32( nPosTIFF ).ReadUInt32( nSizeTIFF ); - // else we have to get the tiff grafix + // else we have to get the tiff grafix - if (nPosTIFF && nSizeTIFF && checkSeek(rStream, nOrigPos + nPosTIFF)) + if (nPosTIFF && nSizeTIFF && checkSeek(rStream, nOrigPos + nPosTIFF)) + { + if ( GraphicConverter::Import( rStream, aGraphic, ConvertDataFormat::TIF ) == ERRCODE_NONE ) { - if ( GraphicConverter::Import( rStream, aGraphic, ConvertDataFormat::TIF ) == ERRCODE_NONE ) - { - MakeAsMeta(aGraphic); - rStream.Seek( nOrigPos + nPosTIFF ); - bHasPreview = bRetValue = true; - } + MakeAsMeta(aGraphic); + rStream.Seek( nOrigPos + nPosTIFF ); + bHasPreview = bRetValue = true; } } } - else - { - nPSStreamPos = nOrigPos; // no preview available _>so we must get the size manually - nPSSize = rStream.Seek( STREAM_SEEK_TO_END ) - nOrigPos; - } + } + else + { + nPSStreamPos = nOrigPos; // no preview available _>so we must get the size manually + nPSSize = rStream.Seek( STREAM_SEEK_TO_END ) - nOrigPos; + } - std::unique_ptr pHeader( new sal_uInt8[ 22 ] ); - rStream.Seek( nPSStreamPos ); - rStream.ReadBytes(pHeader.get(), 22); // check PostScript header - bool bOk = ImplSearchEntry(pHeader.get(), reinterpret_cast("%!PS-Adobe"), 10, 10) && - ImplSearchEntry(&pHeader[ 15 ], reinterpret_cast("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 pBuf( new sal_uInt8[ nPSSize ] ); + std::unique_ptr pHeader( new sal_uInt8[ 22 ] ); + rStream.Seek( nPSStreamPos ); + rStream.ReadBytes(pHeader.get(), 22); // check PostScript header + bool bOk = ImplSearchEntry(pHeader.get(), reinterpret_cast("%!PS-Adobe"), 10, 10) && + ImplSearchEntry(&pHeader[ 15 ], reinterpret_cast("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 pBuf( new sal_uInt8[ nPSSize ] ); - sal_uInt32 nBufStartPos = rStream.Tell(); - sal_uInt32 nBytesRead = rStream.ReadBytes(pBuf.get(), nPSSize); - if ( nBytesRead == 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_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("%%BeginPreview:"), nBytesRead - nSecurityCount, 15 ); + sal_uInt32 nRemainingBytes = pDest ? (nBytesRead - (pDest - pBuf.get())) : 0; + if (nRemainingBytes >= 15) { - sal_uInt8* pDest = ImplSearchEntry( pBuf.get(), reinterpret_cast("%%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("%"), nSecurityCount, 1); // go to the first Scanline + bOk = pDest && nWidth > 0 && nHeight > 0 && ( ( nBitDepth == 1 ) || ( nBitDepth == 8 ) ) && nScanLines; + if (bOk) { - 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("%"), 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() ) ); + 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 ); + 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) { - 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) { - int nBitsLeft = 0; - for (tools::Long x = 0; x < nWidth; ++x) + if ( --nBitsLeft < 0 ) { - if ( --nBitsLeft < 0 ) + while ( bIsValid && ( nBitsLeft != 7 ) ) { - while ( bIsValid && ( nBitsLeft != 7 ) ) + rStream.ReadChar(nByte); + bIsValid = rStream.good(); + if (!bIsValid) + break; + switch (nByte) { - rStream.ReadChar(nByte); - bIsValid = rStream.good(); - if (!bIsValid) + case 0x0a : + if ( --nScanLines < 0 ) + bIsValid = false; break; - switch (nByte) + case 0x09 : + case 0x0d : + case 0x20 : + case 0x25 : + break; + default: { - case 0x0a : - if ( --nScanLines < 0 ) - bIsValid = false; - break; - case 0x09 : - case 0x0d : - case 0x20 : - case 0x25 : - break; - default: + if ( nByte >= '0' ) { - if ( nByte >= '0' ) + if ( nByte > '9' ) { - 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 + nByte &=~0x20; // case none sensitive for hexadecimal values + nByte -= ( 'A' - 10 ); + if ( nByte > 15 ) + bIsValid = false; } else - bIsValid = false; + nByte -= '0'; + nBitsLeft += 4; + nDat <<= 4; + nDat |= ( nByte ^ 0xf ); // in epsi a zero bit represents white color } - break; + else + bIsValid = false; } + break; } } - if (!bIsValid) - break; - if ( nBitDepth == 1 ) - aBitmap.SetPixel( y, x, Color(ColorTransparency, static_cast(nDat >> nBitsLeft) & 1) ); - else - { - aBitmap.SetPixel( y, x, nDat ? COL_WHITE : COL_BLACK ); // nBitDepth == 8 - nBitsLeft = 0; - } + } + if (!bIsValid) + break; + if ( nBitDepth == 1 ) + aBitmap.SetPixel( y, x, Color(ColorTransparency, static_cast(nDat >> nBitsLeft) & 1) ); + else + { + aBitmap.SetPixel( y, x, nDat ? COL_WHITE : COL_BLACK ); // nBitDepth == 8 + nBitsLeft = 0; } } - if (bIsValid) - { - ScopedVclPtrInstance 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; - } + } + if (bIsValid) + { + ScopedVclPtrInstance 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("%%BoundingBox:"), nBytesRead, 14 ); - sal_uInt32 nRemainingBytes = pDest ? (nBytesRead - (pDest - pBuf.get())) : 0; - if (nRemainingBytes >= 14) + sal_uInt8* pDest = ImplSearchEntry( pBuf.get(), reinterpret_cast("%%BoundingBox:"), nBytesRead, 14 ); + sal_uInt32 nRemainingBytes = pDest ? (nBytesRead - (pDest - pBuf.get())) : 0; + if (nRemainingBytes >= 14) + { + pDest += 14; + nSecurityCount = std::min(nRemainingBytes - 14, 100); + tools::Long nNumb[4]; + nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0; + for ( int i = 0; ( i < 4 ) && nSecurityCount; i++ ) { - pDest += 14; - nSecurityCount = std::min(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()) { - nNumb[ i ] = ImplGetNumber(pDest, nSecurityCount); + bHasPreview = RenderAsEMF(pBuf.get(), nBytesRead, aGraphic); + if (!bHasPreview) + bHasPreview = RenderAsBMP(pBuf.get(), nBytesRead, aGraphic); } - 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( 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; + // 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( 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; } } } } - catch (const SvStreamEOFException&) - { - SAL_WARN("filter.eps", "EOF"); - bRetValue = false; - } rStream.SetEndian(nOldFormat); rStream.Seek( nOrigPos ); diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx index e82c6a21eb99..f17565ebd715 100644 --- a/filter/source/graphicfilter/ios2met/ios2met.cxx +++ b/filter/source/graphicfilter/ios2met/ios2met.cxx @@ -2806,9 +2806,6 @@ imeGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* ) catch (const css::uno::Exception&) { } - catch(SvStreamEOFException&) - { - } return bRet; } diff --git a/filter/source/graphicfilter/ipcx/ipcx.cxx b/filter/source/graphicfilter/ipcx/ipcx.cxx index 1c012a8f78b9..67cbc947fefc 100644 --- a/filter/source/graphicfilter/ipcx/ipcx.cxx +++ b/filter/source/graphicfilter/ipcx/ipcx.cxx @@ -19,7 +19,6 @@ #include -#include #include #include #include @@ -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; diff --git a/filter/source/graphicfilter/ipsd/ipsd.cxx b/filter/source/graphicfilter/ipsd/ipsd.cxx index 528914a5cba1..91599bf3352b 100644 --- a/filter/source/graphicfilter/ipsd/ipsd.cxx +++ b/filter/source/graphicfilter/ipsd/ipsd.cxx @@ -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); } diff --git a/filter/source/graphicfilter/itga/itga.cxx b/filter/source/graphicfilter/itga/itga.cxx index 023351c33b4e..8c8af9d52cd8 100644 --- a/filter/source/graphicfilter/itga/itga.cxx +++ b/filter/source/graphicfilter/itga/itga.cxx @@ -18,10 +18,9 @@ */ -#include -#include #include #include +#include #include 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: */ diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 404dd3aff6bc..91b36b230129 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -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(); diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 77fe87758e8a..1d7a36032d4c 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -807,406 +807,399 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, Svx } else { - try - { - // try to load some ppt text - PPTTextObj aTextObj( rSt, static_cast(*this), rPersistEntry, &rObjData ); - if ( aTextObj.Count() || aTextObj.GetOEPlaceHolderAtom() ) + // try to load some ppt text + PPTTextObj aTextObj( rSt, static_cast(*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 ) - { - 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(nFontDirection, 9000, nFontDirection); - if (!bFail) - nTextRotationAngle -= Degree100(nFontDirection); - else - SAL_WARN("filter.ms", "Parsing error: bad fontdirection: " << nFontDirection); - aTextObj.SetVertical( bVerticalText ); - if ( pRet ) + auto eTextFlow = GetPropertyValue(DFF_Prop_txflTextFlow, 0) & 0xFFFF; + switch( eTextFlow ) { - bool bDeleteSource = aTextObj.GetOEPlaceHolderAtom() != nullptr; - if ( bDeleteSource && dynamic_cast(pRet) == nullptr // we are not allowed to get - && dynamic_cast(pRet) == nullptr // grouped placeholder objects - && dynamic_cast(pRet) == nullptr ) - SdrObject::Free( pRet ); + 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_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; + } + sal_Int32 nFontDirection = GetPropertyValue( DFF_Prop_cdirFont, mso_cdir0 ); + if ( ( nFontDirection == 1 ) || ( nFontDirection == 3 ) ) + { + bVerticalText = !bVerticalText; + } + const bool bFail = o3tl::checked_multiply(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(pRet) == nullptr // we are not allowed to get + && dynamic_cast(pRet) == nullptr // grouped placeholder objects + && dynamic_cast(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); + // 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; + 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_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_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: { - 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) { - // 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; - } + 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; } - default: - break; + break; } - nMinFrameWidth = rTextRect.GetWidth() - ( nTextLeft + nTextRight ); + default: + break; } - else - { - eTVA = SDRTEXTVERTADJUST_CENTER; - eTHA = SDRTEXTHORZADJUST_BLOCK; + nMinFrameWidth = rTextRect.GetWidth() - ( nTextLeft + nTextRight ); + } + else + { + eTVA = SDRTEXTVERTADJUST_CENTER; + eTHA = SDRTEXTHORZADJUST_BLOCK; - // read text anchor - auto eTextAnchor = GetPropertyValue(DFF_Prop_anchorText, mso_anchorTop); + // 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; + 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_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_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: { - 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) { - // 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; - } + 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; } - default: - break; + break; } - nMinFrameHeight = rTextRect.GetHeight() - ( nTextTop + nTextBottom ); + default: + break; } + nMinFrameHeight = rTextRect.GetHeight() - ( nTextTop + nTextBottom ); + } - SdrObjKind eTextKind = OBJ_RECT; - if ( ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::NOTESSLIDEIMAGE ) - || ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::MASTERNOTESSLIDEIMAGE ) ) + 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 ) { - aTextObj.SetInstance( TSS_Type::Notes ); - eTextKind = OBJ_TITLETEXT; + rPersistEntry.pPresentationObjects.reset( new sal_uInt32[ PPT_STYLESHEETENTRIES ] ); + memset( rPersistEntry.pPresentationObjects.get(), 0, PPT_STYLESHEETENTRIES * 4 ); } - else if ( ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::MASTERNOTESBODYIMAGE ) - || ( aPlaceholderAtom.nPlaceholderId == PptPlaceholder::NOTESBODY ) ) + if ( !rPersistEntry.pPresentationObjects[ static_cast(nDestinationInstance) ] ) + rPersistEntry.pPresentationObjects[ static_cast(nDestinationInstance) ] = rObjData.rSpHd.GetRecBegFilePos(); + } + switch ( nDestinationInstance ) + { + case TSS_Type::PageTitle : + case TSS_Type::Title : { - aTextObj.SetInstance( TSS_Type::Notes ); - eTextKind = OBJ_TEXT; + 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 ); - 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(nDestinationInstance) ] ) - rPersistEntry.pPresentationObjects[ static_cast(nDestinationInstance) ] = rObjData.rSpHd.GetRecBegFilePos(); - } - switch ( 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 ) { - 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( TSS_Type::TextInShape ); + eTextKind = OBJ_RECT; } - aTextObj.SetDestinationInstance( nDestinationInstance ); + } + SdrObject* pTObj = nullptr; + bool bWordWrap = GetPropertyValue(DFF_Prop_WrapText, mso_wrapSquare) != mso_wrapNone; + bool bFitShapeToText = ( GetPropertyValue( DFF_Prop_FitTextToShape, 0 ) & 2 ) != 0; - bool bAutoFit = false; // auto-scale text into shape box - switch ( aTextObj.GetInstance() ) + if ( dynamic_cast(pRet) != nullptr && ( eTextKind == OBJ_RECT ) ) + { + bAutoGrowHeight = bFitShapeToText; + bAutoGrowWidth = !bWordWrap; + pTObj = pRet; + pRet = nullptr; + } + else + { + if ( dynamic_cast(pRet) != nullptr ) { - 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; + SdrObject::Free( pRet ); + pRet = nullptr; } - if ( aTextObj.GetDestinationInstance() != TSS_Type::TextInShape ) + 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 ) { - if ( !aTextObj.GetOEPlaceHolderAtom() || aTextObj.GetOEPlaceHolderAtom()->nPlaceholderId == PptPlaceholder::NONE ) - { - aTextObj.SetDestinationInstance( TSS_Type::TextInShape ); - eTextKind = OBJ_RECT; - } + pTObj->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) ); + pTObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) ); } - 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(pRet) != nullptr && ( eTextKind == OBJ_RECT ) ) + if ( bVerticalText ) { - bAutoGrowHeight = bFitShapeToText; - bAutoGrowWidth = !bWordWrap; - pTObj = pRet; - pRet = nullptr; + bAutoGrowWidth = bFitShapeToText; + bAutoGrowHeight = false; } else { - if ( dynamic_cast(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; + 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; - } + // #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 ) ); + } + 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) ); - } + //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(pTObj) == nullptr ) - { - pTObj->SetMergedItem( makeSdrTextAutoGrowWidthItem( bAutoGrowWidth ) ); - pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bAutoGrowHeight ) ); - } - else - { - pTObj->SetMergedItem( makeSdrTextWordWrapItem( bWordWrap ) ); - pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bFitShapeToText ) ); - } + if ( dynamic_cast(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 ) ); + pTObj->SetMergedItem( SdrTextVertAdjustItem( eTVA ) ); + pTObj->SetMergedItem( SdrTextHorzAdjustItem( eTHA ) ); - if ( nMinFrameHeight < 0 ) - nMinFrameHeight = 0; - if ( dynamic_cast(pTObj) == nullptr ) - pTObj->SetMergedItem( makeSdrTextMinFrameHeightItem( nMinFrameHeight ) ); + if ( nMinFrameHeight < 0 ) + nMinFrameHeight = 0; + if ( dynamic_cast(pTObj) == nullptr ) + pTObj->SetMergedItem( makeSdrTextMinFrameHeightItem( nMinFrameHeight ) ); - if ( nMinFrameWidth < 0 ) - nMinFrameWidth = 0; - if ( dynamic_cast(pTObj) == nullptr ) - pTObj->SetMergedItem( makeSdrTextMinFrameWidthItem( nMinFrameWidth ) ); + if ( nMinFrameWidth < 0 ) + nMinFrameWidth = 0; + if ( dynamic_cast(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 ) ); + // 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(pTObj) == nullptr ) - pTObj->SetSnapRect( rTextRect ); - pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage ); + if ( dynamic_cast(pTObj) == nullptr ) + pTObj->SetSnapRect( rTextRect ); + pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage ); - if ( pTObj ) + 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(pTObj) == nullptr && !bFitShapeToText && !bWordWrap ) { - /* 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(pTObj) == nullptr && !bFitShapeToText && !bWordWrap ) + SdrTextObj* pText = dynamic_cast( pTObj ); + if ( pText ) { - SdrTextObj* pText = dynamic_cast( pTObj ); - if ( pText ) + if ( bVerticalText ) { - if ( bVerticalText ) + if ( eTVA == SDRTEXTVERTADJUST_BLOCK ) { - 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 ) ); - } + Size aTextSize( pText->GetTextSize() ); + aTextSize.AdjustWidth(nTextLeft + nTextRight ); + aTextSize.AdjustHeight(nTextTop + nTextBottom ); + if ( rTextRect.GetHeight() < aTextSize.Height() ) + pTObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) ); } - else + } + else + { + if ( eTHA == SDRTEXTHORZADJUST_BLOCK ) { - 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 ) ); - } + 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; + } + // 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 ) + if ( dynamic_cast< const SdrObjCustomShape* >(pTObj) == nullptr ) + { + if ( rObjData.nSpFlags & ShapeFlag::FlipV ) { - SdrObject* pGroup = new SdrObjGroup(*pSdrModel); - pGroup->GetSubList()->NbcInsertObject( pRet ); - pGroup->GetSubList()->NbcInsertObject( pTObj ); - pRet = pGroup; + double a = 18000 * F_PI18000; + pTObj->Rotate( rTextRect.Center(), 18000_deg100, sin( a ), cos( a ) ); } - else - pRet = pTObj; + 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"); - } } } else @@ -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 nCharCount(0); + rIn.ReadUInt32( nCharCount ); + nCharIdx += nCharCount; + } - sal_uInt32 nFlags(0); - rIn.ReadUInt32(nFlags); + 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) + 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 ) { - 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 : { - 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 ); - } + rIn.SeekRel( 2 ); } - if ( nLang ) + } + 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) { - // #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); - } + aEntry.nLanguage[ 0 ] = aEntry.nLanguage[ 1 ] = aEntry.nLanguage[ 2 ] = LanguageType(nLang); } - nFlags &= ~i; } - aList.push_back( aEntry ); + nFlags &= ~i; } - bValid = rIn.Tell() == rRecHd.GetRecEndFilePos(); - } - catch (const SvStreamEOFException&) - { - SAL_WARN("filter.ms", "EOF"); - bValid = false; + aList.push_back( aEntry ); } + bValid = rIn.Tell() == rRecHd.GetRecEndFilePos(); return bValid; } -- cgit