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 --- emfio/source/emfuno/xemfparser.cxx | 2 +- 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 ++++---- include/sal/log-areas.dox | 1 - include/tools/stream.hxx | 7 - sc/qa/unit/data/qpro/fail/CVE-2007-5745-1.wb2 | Bin 45006 -> 0 bytes sc/qa/unit/data/qpro/fail/CVE-2007-5745-2.wb2 | Bin 45006 -> 0 bytes sc/qa/unit/data/qpro/fail/ofz14090-1.wb2 | Bin 44 -> 0 bytes sc/qa/unit/data/qpro/pass/CVE-2007-5745-1.wb2 | Bin 0 -> 45006 bytes sc/qa/unit/data/qpro/pass/CVE-2007-5745-2.wb2 | Bin 0 -> 45006 bytes sc/qa/unit/data/qpro/pass/ofz14090-1.wb2 | Bin 0 -> 44 bytes sc/source/filter/excel/read.cxx | 1985 ++++++++++---------- sc/source/filter/excel/xistream.cxx | 60 +- sc/source/filter/excel/xltoolbar.cxx | 9 +- sc/source/filter/lotus/lotread.cxx | 17 +- sc/source/filter/qpro/qpro.cxx | 21 +- sd/qa/unit/data/ppt/fail/hang-14.ppt | Bin 7680 -> 0 bytes sd/qa/unit/data/ppt/fail/hang-21.ppt | Bin 7659 -> 0 bytes sd/qa/unit/data/ppt/fail/ofz14989-1.ppt | Bin 60108 -> 0 bytes sd/qa/unit/data/ppt/pass/hang-14.ppt | Bin 0 -> 7680 bytes sd/qa/unit/data/ppt/pass/hang-21.ppt | Bin 0 -> 7659 bytes sd/qa/unit/data/ppt/pass/ofz14989-1.ppt | Bin 0 -> 60108 bytes sd/source/filter/ppt/pptin.cxx | 11 +- sfx2/source/doc/oleprops.cxx | 74 +- sot/source/sdstor/stg.cxx | 13 +- sot/source/sdstor/stgelem.cxx | 4 +- sot/source/sdstor/stgio.cxx | 12 +- starmath/source/mathtype.cxx | 50 +- sw/qa/core/data/ww5/fail/crash-1.doc | Bin 3714 -> 0 bytes sw/qa/core/data/ww5/fail/hang-1.doc | Bin 4290 -> 0 bytes sw/qa/core/data/ww5/fail/hang-3.doc | Bin 35938 -> 0 bytes sw/qa/core/data/ww5/pass/crash-1.doc | Bin 0 -> 3714 bytes sw/qa/core/data/ww5/pass/hang-1.doc | Bin 0 -> 4290 bytes sw/qa/core/data/ww5/pass/hang-3.doc | Bin 0 -> 35938 bytes sw/qa/core/data/ww6/fail/crash-3.doc | Bin 6633 -> 0 bytes sw/qa/core/data/ww6/pass/crash-3.doc | Bin 0 -> 6633 bytes sw/qa/core/data/ww8/fail/CVE-2008-4841-1.doc | Bin 101888 -> 0 bytes sw/qa/core/data/ww8/fail/CVE-2009-0259-1.doc | Bin 101888 -> 0 bytes sw/qa/core/data/ww8/fail/CVE-2010-3454-1.doc | Bin 126464 -> 0 bytes sw/qa/core/data/ww8/fail/CVE-2014-6356-1.doc | Bin 39424 -> 0 bytes sw/qa/core/data/ww8/fail/CVE-2015-0064-1.doc | Bin 58880 -> 0 bytes sw/qa/core/data/ww8/fail/EDB-14092-1.doc | Bin 101888 -> 0 bytes sw/qa/core/data/ww8/fail/ofz18534-1.doc | Bin 49380 -> 0 bytes sw/qa/core/data/ww8/fail/ofz7322-1.doc | Bin 49544 -> 0 bytes sw/qa/core/data/ww8/pass/CVE-2008-4841-1.doc | Bin 0 -> 101888 bytes sw/qa/core/data/ww8/pass/CVE-2009-0259-1.doc | Bin 0 -> 101888 bytes sw/qa/core/data/ww8/pass/CVE-2010-3454-1.doc | Bin 0 -> 126464 bytes sw/qa/core/data/ww8/pass/CVE-2014-6356-1.doc | Bin 0 -> 39424 bytes sw/qa/core/data/ww8/pass/CVE-2015-0064-1.doc | Bin 0 -> 58880 bytes sw/qa/core/data/ww8/pass/EDB-14092-1.doc | Bin 0 -> 101888 bytes sw/qa/core/data/ww8/pass/ofz18534-1.doc | Bin 0 -> 49380 bytes sw/qa/core/data/ww8/pass/ofz7322-1.doc | Bin 0 -> 49544 bytes sw/source/filter/html/htmlreqifreader.cxx | 89 +- tools/qa/cppunit/test_stream.cxx | 12 + tools/source/stream/stream.cxx | 34 +- .../graphicfilter/data/png/fail/invalid-chunk.png | Bin 5312 -> 0 bytes .../graphicfilter/data/png/pass/invalid-chunk.png | Bin 0 -> 5312 bytes .../cppunit/graphicfilter/data/svm/fail/leak-1.svm | Bin 856 -> 0 bytes .../cppunit/graphicfilter/data/svm/pass/leak-1.svm | Bin 0 -> 856 bytes vcl/source/bitmap/dibtools.cxx | 17 +- vcl/source/filter/graphicfilter.cxx | 9 +- vcl/source/filter/graphicfilter2.cxx | 1229 ++++++------ vcl/source/filter/itiff/itiff.cxx | 4 - vcl/source/filter/png/pngread.cxx | 132 +- vcl/source/gdi/impgraph.cxx | 37 +- 72 files changed, 2336 insertions(+), 2657 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 delete mode 100644 sc/qa/unit/data/qpro/fail/CVE-2007-5745-1.wb2 delete mode 100644 sc/qa/unit/data/qpro/fail/CVE-2007-5745-2.wb2 delete mode 100644 sc/qa/unit/data/qpro/fail/ofz14090-1.wb2 create mode 100644 sc/qa/unit/data/qpro/pass/CVE-2007-5745-1.wb2 create mode 100644 sc/qa/unit/data/qpro/pass/CVE-2007-5745-2.wb2 create mode 100644 sc/qa/unit/data/qpro/pass/ofz14090-1.wb2 delete mode 100644 sd/qa/unit/data/ppt/fail/hang-14.ppt delete mode 100644 sd/qa/unit/data/ppt/fail/hang-21.ppt delete mode 100644 sd/qa/unit/data/ppt/fail/ofz14989-1.ppt create mode 100644 sd/qa/unit/data/ppt/pass/hang-14.ppt create mode 100644 sd/qa/unit/data/ppt/pass/hang-21.ppt create mode 100644 sd/qa/unit/data/ppt/pass/ofz14989-1.ppt delete mode 100644 sw/qa/core/data/ww5/fail/crash-1.doc delete mode 100644 sw/qa/core/data/ww5/fail/hang-1.doc delete mode 100644 sw/qa/core/data/ww5/fail/hang-3.doc create mode 100644 sw/qa/core/data/ww5/pass/crash-1.doc create mode 100644 sw/qa/core/data/ww5/pass/hang-1.doc create mode 100644 sw/qa/core/data/ww5/pass/hang-3.doc delete mode 100644 sw/qa/core/data/ww6/fail/crash-3.doc create mode 100644 sw/qa/core/data/ww6/pass/crash-3.doc delete mode 100644 sw/qa/core/data/ww8/fail/CVE-2008-4841-1.doc delete mode 100644 sw/qa/core/data/ww8/fail/CVE-2009-0259-1.doc delete mode 100644 sw/qa/core/data/ww8/fail/CVE-2010-3454-1.doc delete mode 100644 sw/qa/core/data/ww8/fail/CVE-2014-6356-1.doc delete mode 100644 sw/qa/core/data/ww8/fail/CVE-2015-0064-1.doc delete mode 100644 sw/qa/core/data/ww8/fail/EDB-14092-1.doc delete mode 100644 sw/qa/core/data/ww8/fail/ofz18534-1.doc delete mode 100644 sw/qa/core/data/ww8/fail/ofz7322-1.doc create mode 100644 sw/qa/core/data/ww8/pass/CVE-2008-4841-1.doc create mode 100644 sw/qa/core/data/ww8/pass/CVE-2009-0259-1.doc create mode 100644 sw/qa/core/data/ww8/pass/CVE-2010-3454-1.doc create mode 100644 sw/qa/core/data/ww8/pass/CVE-2014-6356-1.doc create mode 100644 sw/qa/core/data/ww8/pass/CVE-2015-0064-1.doc create mode 100644 sw/qa/core/data/ww8/pass/EDB-14092-1.doc create mode 100644 sw/qa/core/data/ww8/pass/ofz18534-1.doc create mode 100644 sw/qa/core/data/ww8/pass/ofz7322-1.doc delete mode 100644 vcl/qa/cppunit/graphicfilter/data/png/fail/invalid-chunk.png create mode 100644 vcl/qa/cppunit/graphicfilter/data/png/pass/invalid-chunk.png delete mode 100644 vcl/qa/cppunit/graphicfilter/data/svm/fail/leak-1.svm create mode 100644 vcl/qa/cppunit/graphicfilter/data/svm/pass/leak-1.svm diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx index 472f7ec9d358..7788802c4e1c 100644 --- a/emfio/source/emfuno/xemfparser.cxx +++ b/emfio/source/emfuno/xemfparser.cxx @@ -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); 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; } diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox index 4bdd3fb19a23..0d286366d598 100644 --- a/include/sal/log-areas.dox +++ b/include/sal/log-areas.dox @@ -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 diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx index 2032b30f1d74..fab4b005b40b 100644 --- a/include/tools/stream.hxx +++ b/include/tools/stream.hxx @@ -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: */ diff --git a/sc/qa/unit/data/qpro/fail/CVE-2007-5745-1.wb2 b/sc/qa/unit/data/qpro/fail/CVE-2007-5745-1.wb2 deleted file mode 100644 index 6e525c39f422..000000000000 Binary files a/sc/qa/unit/data/qpro/fail/CVE-2007-5745-1.wb2 and /dev/null differ diff --git a/sc/qa/unit/data/qpro/fail/CVE-2007-5745-2.wb2 b/sc/qa/unit/data/qpro/fail/CVE-2007-5745-2.wb2 deleted file mode 100644 index b034a8c15976..000000000000 Binary files a/sc/qa/unit/data/qpro/fail/CVE-2007-5745-2.wb2 and /dev/null differ diff --git a/sc/qa/unit/data/qpro/fail/ofz14090-1.wb2 b/sc/qa/unit/data/qpro/fail/ofz14090-1.wb2 deleted file mode 100644 index 57fa24d40855..000000000000 Binary files a/sc/qa/unit/data/qpro/fail/ofz14090-1.wb2 and /dev/null differ diff --git a/sc/qa/unit/data/qpro/pass/CVE-2007-5745-1.wb2 b/sc/qa/unit/data/qpro/pass/CVE-2007-5745-1.wb2 new file mode 100644 index 000000000000..6e525c39f422 Binary files /dev/null and b/sc/qa/unit/data/qpro/pass/CVE-2007-5745-1.wb2 differ diff --git a/sc/qa/unit/data/qpro/pass/CVE-2007-5745-2.wb2 b/sc/qa/unit/data/qpro/pass/CVE-2007-5745-2.wb2 new file mode 100644 index 000000000000..b034a8c15976 Binary files /dev/null and b/sc/qa/unit/data/qpro/pass/CVE-2007-5745-2.wb2 differ diff --git a/sc/qa/unit/data/qpro/pass/ofz14090-1.wb2 b/sc/qa/unit/data/qpro/pass/ofz14090-1.wb2 new file mode 100644 index 000000000000..57fa24d40855 Binary files /dev/null and b/sc/qa/unit/data/qpro/pass/ofz14090-1.wb2 differ diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx index 7b1dd32503fa..cf9465a37c95 100644 --- a/sc/source/filter/excel/read.cxx +++ b/sc/source/filter/excel/read.cxx @@ -69,734 +69,727 @@ namespace ErrCode ImportExcel::Read() { - ErrCode eLastErr = ERRCODE_NONE; - try + XclImpPageSettings& rPageSett = GetPageSettings(); + XclImpTabViewSettings& rTabViewSett = GetTabViewSettings(); + XclImpPalette& rPal = GetPalette(); + XclImpFontBuffer& rFontBfr = GetFontBuffer(); + XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer(); + XclImpXFBuffer& rXFBfr = GetXFBuffer(); + XclImpNameManager& rNameMgr = GetNameManager(); + // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets) + + enum STATE { + Z_BiffNull, // not a valid Biff-Format + Z_Biff2, // Biff2: only one table + + Z_Biff3, // Biff3: only one table + + Z_Biff4, // Biff4: only one table + Z_Biff4W, // Biff4 Workbook: Globals + Z_Biff4T, // Biff4 Workbook: a table itself + Z_Biff4E, // Biff4 Workbook: between tables + + Z_Biff5WPre,// Biff5: Prefetch Workbook + Z_Biff5W, // Biff5: Globals + Z_Biff5TPre,// Biff5: Prefetch for Shrfmla/Array Formula + Z_Biff5T, // Biff5: a table itself + Z_Biff5E, // Biff5: between tables + Z_Biffn0, // all Biffs: skip table till next EOF + Z_End }; + + STATE eCurrent = Z_BiffNull, ePrev = Z_BiffNull; + + ErrCode eLastErr = ERRCODE_NONE; + sal_uInt16 nOpcode; + sal_uInt16 nBofLevel = 0; + + std::unique_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar( + aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) ); + + /* #i104057# Need to track a base position for progress bar calculation, + because sheet substreams may not be in order of sheets. */ + std::size_t nProgressBasePos = 0; + std::size_t nProgressBaseSize = 0; + + for (; eCurrent != Z_End; mnLastRecId = nOpcode) { - XclImpPageSettings& rPageSett = GetPageSettings(); - XclImpTabViewSettings& rTabViewSett = GetTabViewSettings(); - XclImpPalette& rPal = GetPalette(); - XclImpFontBuffer& rFontBfr = GetFontBuffer(); - XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer(); - XclImpXFBuffer& rXFBfr = GetXFBuffer(); - XclImpNameManager& rNameMgr = GetNameManager(); - // call to GetCurrSheetDrawing() cannot be cached (changes in new sheets) - - enum STATE { - Z_BiffNull, // not a valid Biff-Format - Z_Biff2, // Biff2: only one table - - Z_Biff3, // Biff3: only one table - - Z_Biff4, // Biff4: only one table - Z_Biff4W, // Biff4 Workbook: Globals - Z_Biff4T, // Biff4 Workbook: a table itself - Z_Biff4E, // Biff4 Workbook: between tables - - Z_Biff5WPre,// Biff5: Prefetch Workbook - Z_Biff5W, // Biff5: Globals - Z_Biff5TPre,// Biff5: Prefetch for Shrfmla/Array Formula - Z_Biff5T, // Biff5: a table itself - Z_Biff5E, // Biff5: between tables - Z_Biffn0, // all Biffs: skip table till next EOF - Z_End }; - - STATE eCurrent = Z_BiffNull, ePrev = Z_BiffNull; - - sal_uInt16 nOpcode; - sal_uInt16 nBofLevel = 0; - - std::unique_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar( - aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) ); - - /* #i104057# Need to track a base position for progress bar calculation, - because sheet substreams may not be in order of sheets. */ - std::size_t nProgressBasePos = 0; - std::size_t nProgressBaseSize = 0; - - for (; eCurrent != Z_End; mnLastRecId = nOpcode) + if( eCurrent == Z_Biff5E ) { - if( eCurrent == Z_Biff5E ) + sal_uInt16 nScTab = GetCurrScTab(); + if( nScTab < maSheetOffsets.size() ) { - sal_uInt16 nScTab = GetCurrScTab(); - if( nScTab < maSheetOffsets.size() ) - { - nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos); - nProgressBasePos = maSheetOffsets[ nScTab ]; + nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos); + nProgressBasePos = maSheetOffsets[ nScTab ]; - bool bValid = TryStartNextRecord(aIn, nProgressBasePos); - if (!bValid) - { - // Safeguard ourselves from potential infinite loop. - eCurrent = Z_End; - } - } - else + bool bValid = TryStartNextRecord(aIn, nProgressBasePos); + if (!bValid) + { + // Safeguard ourselves from potential infinite loop. eCurrent = Z_End; + } } else - aIn.StartNextRecord(); + eCurrent = Z_End; + } + else + aIn.StartNextRecord(); - nOpcode = aIn.GetRecId(); + nOpcode = aIn.GetRecId(); - if( !aIn.IsValid() ) + if( !aIn.IsValid() ) + { + // finalize table if EOF is missing + switch( eCurrent ) { - // finalize table if EOF is missing - switch( eCurrent ) - { - case Z_Biff2: - case Z_Biff3: - case Z_Biff4: - case Z_Biff4T: - case Z_Biff5TPre: - case Z_Biff5T: - rNumFmtBfr.CreateScFormats(); - Eof(); - break; - default:; - } + case Z_Biff2: + case Z_Biff3: + case Z_Biff4: + case Z_Biff4T: + case Z_Biff5TPre: + case Z_Biff5T: + rNumFmtBfr.CreateScFormats(); + Eof(); break; + default:; } + break; + } - if( eCurrent == Z_End ) - break; + if( eCurrent == Z_End ) + break; - if( eCurrent != Z_Biff5TPre && eCurrent != Z_Biff5WPre ) - pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos ); + if( eCurrent != Z_Biff5TPre && eCurrent != Z_Biff5WPre ) + pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos ); - switch( eCurrent ) - { + switch( eCurrent ) + { - case Z_BiffNull: // ------------------------------- Z_BiffNull - + case Z_BiffNull: // ------------------------------- Z_BiffNull - + { + switch( nOpcode ) { - switch( nOpcode ) + case EXC_ID2_BOF: + case EXC_ID3_BOF: + case EXC_ID4_BOF: + case EXC_ID5_BOF: { - case EXC_ID2_BOF: - case EXC_ID3_BOF: - case EXC_ID4_BOF: - case EXC_ID5_BOF: + // #i23425# don't rely on the record ID, but on the detected BIFF version + switch( GetBiff() ) { - // #i23425# don't rely on the record ID, but on the detected BIFF version - switch( GetBiff() ) - { - case EXC_BIFF2: - Bof2(); - if( pExcRoot->eDateiTyp == Biff2 ) - { - eCurrent = Z_Biff2; - NewTable(); - } - break; - case EXC_BIFF3: - Bof3(); - if( pExcRoot->eDateiTyp == Biff3 ) - { - eCurrent = Z_Biff3; - NewTable(); - } - break; - case EXC_BIFF4: - Bof4(); - if( pExcRoot->eDateiTyp == Biff4 ) - { - eCurrent = Z_Biff4; - NewTable(); - } - else if( pExcRoot->eDateiTyp == Biff4W ) - eCurrent = Z_Biff4W; - break; - case EXC_BIFF5: - Bof5(); - if( pExcRoot->eDateiTyp == Biff5W ) - { - eCurrent = Z_Biff5WPre; - - nBdshtTab = 0; - - aIn.StoreGlobalPosition(); // store position - } - else if( pExcRoot->eDateiTyp == Biff5 ) - { - // #i62752# possible to have BIFF5 sheet without globals - NewTable(); - eCurrent = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch - nBofLevel = 0; - aIn.StoreGlobalPosition(); // store position - } - break; - default: - DBG_ERROR_BIFF(); - } + case EXC_BIFF2: + Bof2(); + if( pExcRoot->eDateiTyp == Biff2 ) + { + eCurrent = Z_Biff2; + NewTable(); + } + break; + case EXC_BIFF3: + Bof3(); + if( pExcRoot->eDateiTyp == Biff3 ) + { + eCurrent = Z_Biff3; + NewTable(); + } + break; + case EXC_BIFF4: + Bof4(); + if( pExcRoot->eDateiTyp == Biff4 ) + { + eCurrent = Z_Biff4; + NewTable(); + } + else if( pExcRoot->eDateiTyp == Biff4W ) + eCurrent = Z_Biff4W; + break; + case EXC_BIFF5: + Bof5(); + if( pExcRoot->eDateiTyp == Biff5W ) + { + eCurrent = Z_Biff5WPre; + + nBdshtTab = 0; + + aIn.StoreGlobalPosition(); // store position + } + else if( pExcRoot->eDateiTyp == Biff5 ) + { + // #i62752# possible to have BIFF5 sheet without globals + NewTable(); + eCurrent = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch + nBofLevel = 0; + aIn.StoreGlobalPosition(); // store position + } + break; + default: + DBG_ERROR_BIFF(); } - break; } - } break; + } + } + break; - case Z_Biff2: // ---------------------------------- Z_Biff2 - + case Z_Biff2: // ---------------------------------- Z_Biff2 - + { + switch( nOpcode ) { - switch( nOpcode ) - { - case EXC_ID2_DIMENSIONS: - case EXC_ID3_DIMENSIONS: ReadDimensions(); break; - case EXC_ID2_BLANK: - case EXC_ID3_BLANK: ReadBlank(); break; - case EXC_ID2_INTEGER: ReadInteger(); break; - case EXC_ID2_NUMBER: - case EXC_ID3_NUMBER: ReadNumber(); break; - case EXC_ID2_LABEL: - case EXC_ID3_LABEL: ReadLabel(); break; - case EXC_ID2_BOOLERR: - case EXC_ID3_BOOLERR: ReadBoolErr(); break; - case EXC_ID_RK: ReadRk(); break; - - case 0x06: Formula25(); break; // FORMULA [ 2 5] - case 0x08: Row25(); break; // ROW [ 2 5] - case 0x0A: // EOF [ 2345] - rNumFmtBfr.CreateScFormats(); - rNameMgr.ConvertAllTokens(); - Eof(); + case EXC_ID2_DIMENSIONS: + case EXC_ID3_DIMENSIONS: ReadDimensions(); break; + case EXC_ID2_BLANK: + case EXC_ID3_BLANK: ReadBlank(); break; + case EXC_ID2_INTEGER: ReadInteger(); break; + case EXC_ID2_NUMBER: + case EXC_ID3_NUMBER: ReadNumber(); break; + case EXC_ID2_LABEL: + case EXC_ID3_LABEL: ReadLabel(); break; + case EXC_ID2_BOOLERR: + case EXC_ID3_BOOLERR: ReadBoolErr(); break; + case EXC_ID_RK: ReadRk(); break; + + case 0x06: Formula25(); break; // FORMULA [ 2 5] + case 0x08: Row25(); break; // ROW [ 2 5] + case 0x0A: // EOF [ 2345] + rNumFmtBfr.CreateScFormats(); + rNameMgr.ConvertAllTokens(); + Eof(); + eCurrent = Z_End; + break; + case 0x14: + case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break; + case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] + case 0x18: rNameMgr.ReadName( maStrm ); break; + case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break; + case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; + case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break; + case 0x20: Columndefault(); break; // COLUMNDEFAULT[ 2 ] + case 0x21: Array25(); break; // ARRAY [ 2 5] + case 0x23: Externname25(); break; // EXTERNNAME [ 2 5] + case 0x24: Colwidth(); break; // COLWIDTH [ 2 ] + case 0x25: Defrowheight2(); break; // DEFAULTROWHEI[ 2 ] + case 0x26: + case 0x27: + case 0x28: + case 0x29: rPageSett.ReadMargin( maStrm ); break; + case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break; + case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break; + case 0x2F: // FILEPASS [ 2345] + eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); + if( eLastErr != ERRCODE_NONE ) eCurrent = Z_End; - break; - case 0x14: - case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break; - case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] - case 0x18: rNameMgr.ReadName( maStrm ); break; - case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break; - case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; - case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break; - case 0x20: Columndefault(); break; // COLUMNDEFAULT[ 2 ] - case 0x21: Array25(); break; // ARRAY [ 2 5] - case 0x23: Externname25(); break; // EXTERNNAME [ 2 5] - case 0x24: Colwidth(); break; // COLWIDTH [ 2 ] - case 0x25: Defrowheight2(); break; // DEFAULTROWHEI[ 2 ] - case 0x26: - case 0x27: - case 0x28: - case 0x29: rPageSett.ReadMargin( maStrm ); break; - case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break; - case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break; - case 0x2F: // FILEPASS [ 2345] - eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); - if( eLastErr != ERRCODE_NONE ) - eCurrent = Z_End; - break; - case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break; - case EXC_ID_EFONT: rFontBfr.ReadEfont( maStrm ); break; - case 0x3E: rTabViewSett.ReadWindow2( maStrm, false );break; - case 0x41: rTabViewSett.ReadPane( maStrm ); break; - case 0x42: Codepage(); break; // CODEPAGE [ 2345] - case 0x43: rXFBfr.ReadXF( maStrm ); break; - case 0x44: Ixfe(); break; // IXFE [ 2 ] - } + break; + case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break; + case EXC_ID_EFONT: rFontBfr.ReadEfont( maStrm ); break; + case 0x3E: rTabViewSett.ReadWindow2( maStrm, false );break; + case 0x41: rTabViewSett.ReadPane( maStrm ); break; + case 0x42: Codepage(); break; // CODEPAGE [ 2345] + case 0x43: rXFBfr.ReadXF( maStrm ); break; + case 0x44: Ixfe(); break; // IXFE [ 2 ] } - break; + } + break; - case Z_Biff3: // ---------------------------------- Z_Biff3 - + case Z_Biff3: // ---------------------------------- Z_Biff3 - + { + switch( nOpcode ) { - switch( nOpcode ) - { - // skip chart substream - case EXC_ID2_BOF: - case EXC_ID3_BOF: - case EXC_ID4_BOF: - case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break; - - case EXC_ID2_DIMENSIONS: - case EXC_ID3_DIMENSIONS: ReadDimensions(); break; - case EXC_ID2_BLANK: - case EXC_ID3_BLANK: ReadBlank(); break; - case EXC_ID2_INTEGER: ReadInteger(); break; - case EXC_ID2_NUMBER: - case EXC_ID3_NUMBER: ReadNumber(); break; - case EXC_ID2_LABEL: - case EXC_ID3_LABEL: ReadLabel(); break; - case EXC_ID2_BOOLERR: - case EXC_ID3_BOOLERR: ReadBoolErr(); break; - case EXC_ID_RK: ReadRk(); break; + // skip chart substream + case EXC_ID2_BOF: + case EXC_ID3_BOF: + case EXC_ID4_BOF: + case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break; + + case EXC_ID2_DIMENSIONS: + case EXC_ID3_DIMENSIONS: ReadDimensions(); break; + case EXC_ID2_BLANK: + case EXC_ID3_BLANK: ReadBlank(); break; + case EXC_ID2_INTEGER: ReadInteger(); break; + case EXC_ID2_NUMBER: + case EXC_ID3_NUMBER: ReadNumber(); break; + case EXC_ID2_LABEL: + case EXC_ID3_LABEL: ReadLabel(); break; + case EXC_ID2_BOOLERR: + case EXC_ID3_BOOLERR: ReadBoolErr(); break; + case EXC_ID_RK: ReadRk(); break; + + case 0x0A: // EOF [ 2345] + rNumFmtBfr.CreateScFormats(); + rNameMgr.ConvertAllTokens(); + Eof(); + eCurrent = Z_End; + break; + case 0x14: + case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break; + case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] + case 0x1A: + case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break; + case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break; + case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; + case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break; + case 0x22: Rec1904(); break; // 1904 [ 2345] + case 0x26: + case 0x27: + case 0x28: + case 0x29: rPageSett.ReadMargin( maStrm ); break; + case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break; + case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break; + case 0x2F: // FILEPASS [ 2345] + eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); + if( eLastErr != ERRCODE_NONE ) + eCurrent = Z_End; + break; + case EXC_ID_FILESHARING: ReadFileSharing(); break; + case 0x41: rTabViewSett.ReadPane( maStrm ); break; + case 0x42: Codepage(); break; // CODEPAGE [ 2345] + case 0x56: break; // BUILTINFMTCNT[ 34 ] + case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break; + case 0x7D: Colinfo(); break; // COLINFO [ 345] + case 0x8C: Country(); break; // COUNTRY [ 345] + case 0x92: rPal.ReadPalette( maStrm ); break; + case 0x0206: Formula3(); break; // FORMULA [ 3 ] + case 0x0208: Row34(); break; // ROW [ 34 ] + case 0x0218: rNameMgr.ReadName( maStrm ); break; + case 0x0221: Array34(); break; // ARRAY [ 34 ] + case 0x0223: break; // EXTERNNAME [ 34 ] + case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345] + case 0x0231: rFontBfr.ReadFont( maStrm ); break; + case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break; + case 0x0243: rXFBfr.ReadXF( maStrm ); break; + case 0x0293: rXFBfr.ReadStyle( maStrm ); break; + } + } + break; - case 0x0A: // EOF [ 2345] - rNumFmtBfr.CreateScFormats(); - rNameMgr.ConvertAllTokens(); - Eof(); + case Z_Biff4: // ---------------------------------- Z_Biff4 - + { + switch( nOpcode ) + { + // skip chart substream + case EXC_ID2_BOF: + case EXC_ID3_BOF: + case EXC_ID4_BOF: + case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break; + + case EXC_ID2_DIMENSIONS: + case EXC_ID3_DIMENSIONS: ReadDimensions(); break; + case EXC_ID2_BLANK: + case EXC_ID3_BLANK: ReadBlank(); break; + case EXC_ID2_INTEGER: ReadInteger(); break; + case EXC_ID2_NUMBER: + case EXC_ID3_NUMBER: ReadNumber(); break; + case EXC_ID2_LABEL: + case EXC_ID3_LABEL: ReadLabel(); break; + case EXC_ID2_BOOLERR: + case EXC_ID3_BOOLERR: ReadBoolErr(); break; + case EXC_ID_RK: ReadRk(); break; + + case 0x0A: // EOF [ 2345] + rNumFmtBfr.CreateScFormats(); + rNameMgr.ConvertAllTokens(); + Eof(); + eCurrent = Z_End; + break; + case 0x12: SheetProtect(); break; // SHEET PROTECTION + case 0x14: + case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break; + case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] + case 0x1A: + case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break; + case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break; + case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; + case 0x22: Rec1904(); break; // 1904 [ 2345] + case 0x26: + case 0x27: + case 0x28: + case 0x29: rPageSett.ReadMargin( maStrm ); break; + case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break; + case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break; + case 0x2F: // FILEPASS [ 2345] + eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); + if( eLastErr != ERRCODE_NONE ) eCurrent = Z_End; - break; - case 0x14: - case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break; - case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] - case 0x1A: - case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break; - case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break; - case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; - case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break; - case 0x22: Rec1904(); break; // 1904 [ 2345] - case 0x26: - case 0x27: - case 0x28: - case 0x29: rPageSett.ReadMargin( maStrm ); break; - case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break; - case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break; - case 0x2F: // FILEPASS [ 2345] - eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); - if( eLastErr != ERRCODE_NONE ) - eCurrent = Z_End; - break; - case EXC_ID_FILESHARING: ReadFileSharing(); break; - case 0x41: rTabViewSett.ReadPane( maStrm ); break; - case 0x42: Codepage(); break; // CODEPAGE [ 2345] - case 0x56: break; // BUILTINFMTCNT[ 34 ] - case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break; - case 0x7D: Colinfo(); break; // COLINFO [ 345] - case 0x8C: Country(); break; // COUNTRY [ 345] - case 0x92: rPal.ReadPalette( maStrm ); break; - case 0x0206: Formula3(); break; // FORMULA [ 3 ] - case 0x0208: Row34(); break; // ROW [ 34 ] - case 0x0218: rNameMgr.ReadName( maStrm ); break; - case 0x0221: Array34(); break; // ARRAY [ 34 ] - case 0x0223: break; // EXTERNNAME [ 34 ] - case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345] - case 0x0231: rFontBfr.ReadFont( maStrm ); break; - case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break; - case 0x0243: rXFBfr.ReadXF( maStrm ); break; - case 0x0293: rXFBfr.ReadStyle( maStrm ); break; - } + break; + case EXC_ID_FILESHARING: ReadFileSharing(); break; + case 0x41: rTabViewSett.ReadPane( maStrm ); break; + case 0x42: Codepage(); break; // CODEPAGE [ 2345] + case 0x55: DefColWidth(); break; + case 0x56: break; // BUILTINFMTCNT[ 34 ] + case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break; + case 0x7D: Colinfo(); break; // COLINFO [ 345] + case 0x8C: Country(); break; // COUNTRY [ 345] + case 0x92: rPal.ReadPalette( maStrm ); break; + case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45] + case 0xA1: rPageSett.ReadSetup( maStrm ); break; + case 0x0208: Row34(); break; // ROW [ 34 ] + case 0x0218: rNameMgr.ReadName( maStrm ); break; + case 0x0221: Array34(); break; // ARRAY [ 34 ] + case 0x0223: break; // EXTERNNAME [ 34 ] + case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345] + case 0x0231: rFontBfr.ReadFont( maStrm ); break; + case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break; + case 0x0406: Formula4(); break; // FORMULA [ 4 ] + case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break; + case 0x0443: rXFBfr.ReadXF( maStrm ); break; + case 0x0293: rXFBfr.ReadStyle( maStrm ); break; } - break; + } + break; - case Z_Biff4: // ---------------------------------- Z_Biff4 - + case Z_Biff4W: // --------------------------------- Z_Biff4W - + { + switch( nOpcode ) { - switch( nOpcode ) - { - // skip chart substream - case EXC_ID2_BOF: - case EXC_ID3_BOF: - case EXC_ID4_BOF: - case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break; + case 0x0A: // EOF [ 2345] + rNameMgr.ConvertAllTokens(); + eCurrent = Z_End; + break; + case 0x12: DocProtect(); break; // PROTECT [ 5] + case 0x2F: // FILEPASS [ 2345] + eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); + if( eLastErr != ERRCODE_NONE ) + eCurrent = Z_End; + break; + case EXC_ID_FILESHARING: ReadFileSharing(); break; + case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] + case 0x42: Codepage(); break; // CODEPAGE [ 2345] + case 0x55: DefColWidth(); break; + case 0x56: break; // BUILTINFMTCNT[ 34 ] + case 0x8C: Country(); break; // COUNTRY [ 345] + case 0x8F: break; // BUNDLEHEADER [ 4 ] + case 0x92: rPal.ReadPalette( maStrm ); break; + case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45] + case 0x0218: rNameMgr.ReadName( maStrm ); break; + case 0x0223: break; // EXTERNNAME [ 34 ] + case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345] + case 0x0231: rFontBfr.ReadFont( maStrm ); break; + case EXC_ID4_BOF: // BOF [ 4 ] + Bof4(); + if( pExcRoot->eDateiTyp == Biff4 ) + { + eCurrent = Z_Biff4T; + NewTable(); + } + else + eCurrent = Z_End; + break; + case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break; + case 0x0443: rXFBfr.ReadXF( maStrm ); break; + case 0x0293: rXFBfr.ReadStyle( maStrm ); break; + } - case EXC_ID2_DIMENSIONS: - case EXC_ID3_DIMENSIONS: ReadDimensions(); break; - case EXC_ID2_BLANK: - case EXC_ID3_BLANK: ReadBlank(); break; - case EXC_ID2_INTEGER: ReadInteger(); break; - case EXC_ID2_NUMBER: - case EXC_ID3_NUMBER: ReadNumber(); break; - case EXC_ID2_LABEL: - case EXC_ID3_LABEL: ReadLabel(); break; - case EXC_ID2_BOOLERR: - case EXC_ID3_BOOLERR: ReadBoolErr(); break; - case EXC_ID_RK: ReadRk(); break; + } + break; - case 0x0A: // EOF [ 2345] - rNumFmtBfr.CreateScFormats(); - rNameMgr.ConvertAllTokens(); - Eof(); + case Z_Biff4T: // --------------------------------- Z_Biff4T - + { + switch( nOpcode ) + { + // skip chart substream + case EXC_ID2_BOF: + case EXC_ID3_BOF: + case EXC_ID4_BOF: + case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break; + + case EXC_ID2_DIMENSIONS: + case EXC_ID3_DIMENSIONS: ReadDimensions(); break; + case EXC_ID2_BLANK: + case EXC_ID3_BLANK: ReadBlank(); break; + case EXC_ID2_INTEGER: ReadInteger(); break; + case EXC_ID2_NUMBER: + case EXC_ID3_NUMBER: ReadNumber(); break; + case EXC_ID2_LABEL: + case EXC_ID3_LABEL: ReadLabel(); break; + case EXC_ID2_BOOLERR: + case EXC_ID3_BOOLERR: ReadBoolErr(); break; + case EXC_ID_RK: ReadRk(); break; + + case 0x0A: // EOF [ 2345] + rNameMgr.ConvertAllTokens(); + Eof(); + eCurrent = Z_Biff4E; + break; + case 0x12: SheetProtect(); break; // SHEET PROTECTION + case 0x14: + case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break; + case 0x1A: + case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break; + case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break; + case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; + case 0x2F: // FILEPASS [ 2345] + eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); + if( eLastErr != ERRCODE_NONE ) eCurrent = Z_End; - break; - case 0x12: SheetProtect(); break; // SHEET PROTECTION - case 0x14: - case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break; - case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] - case 0x1A: - case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break; - case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break; - case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; - case 0x22: Rec1904(); break; // 1904 [ 2345] - case 0x26: - case 0x27: - case 0x28: - case 0x29: rPageSett.ReadMargin( maStrm ); break; - case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break; - case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break; - case 0x2F: // FILEPASS [ 2345] - eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); - if( eLastErr != ERRCODE_NONE ) - eCurrent = Z_End; - break; - case EXC_ID_FILESHARING: ReadFileSharing(); break; - case 0x41: rTabViewSett.ReadPane( maStrm ); break; - case 0x42: Codepage(); break; // CODEPAGE [ 2345] - case 0x55: DefColWidth(); break; - case 0x56: break; // BUILTINFMTCNT[ 34 ] - case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break; - case 0x7D: Colinfo(); break; // COLINFO [ 345] - case 0x8C: Country(); break; // COUNTRY [ 345] - case 0x92: rPal.ReadPalette( maStrm ); break; - case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45] - case 0xA1: rPageSett.ReadSetup( maStrm ); break; - case 0x0208: Row34(); break; // ROW [ 34 ] - case 0x0218: rNameMgr.ReadName( maStrm ); break; - case 0x0221: Array34(); break; // ARRAY [ 34 ] - case 0x0223: break; // EXTERNNAME [ 34 ] - case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345] - case 0x0231: rFontBfr.ReadFont( maStrm ); break; - case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break; - case 0x0406: Formula4(); break; // FORMULA [ 4 ] - case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break; - case 0x0443: rXFBfr.ReadXF( maStrm ); break; - case 0x0293: rXFBfr.ReadStyle( maStrm ); break; - } + break; + case 0x41: rTabViewSett.ReadPane( maStrm ); break; + case 0x42: Codepage(); break; // CODEPAGE [ 2345] + case 0x55: DefColWidth(); break; + case 0x56: break; // BUILTINFMTCNT[ 34 ] + case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break; + case 0x7D: Colinfo(); break; // COLINFO [ 345] + case 0x8C: Country(); break; // COUNTRY [ 345] + case 0x8F: break; // BUNDLEHEADER [ 4 ] + case 0x92: rPal.ReadPalette( maStrm ); break; + case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45] + case 0xA1: rPageSett.ReadSetup( maStrm ); break; + case 0x0208: Row34(); break; // ROW [ 34 ] + case 0x0218: rNameMgr.ReadName( maStrm ); break; + case 0x0221: Array34(); break; + case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345] + case 0x0231: rFontBfr.ReadFont( maStrm ); break; + case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break; + case 0x0406: Formula4(); break; + case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break; + case 0x0443: rXFBfr.ReadXF( maStrm ); break; + case 0x0293: rXFBfr.ReadStyle( maStrm ); break; } - break; - case Z_Biff4W: // --------------------------------- Z_Biff4W - + } + break; + + case Z_Biff4E: // --------------------------------- Z_Biff4E - + { + switch( nOpcode ) { - switch( nOpcode ) - { - case 0x0A: // EOF [ 2345] - rNameMgr.ConvertAllTokens(); - eCurrent = Z_End; - break; - case 0x12: DocProtect(); break; // PROTECT [ 5] - case 0x2F: // FILEPASS [ 2345] - eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); - if( eLastErr != ERRCODE_NONE ) - eCurrent = Z_End; - break; - case EXC_ID_FILESHARING: ReadFileSharing(); break; - case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] - case 0x42: Codepage(); break; // CODEPAGE [ 2345] - case 0x55: DefColWidth(); break; - case 0x56: break; // BUILTINFMTCNT[ 34 ] - case 0x8C: Country(); break; // COUNTRY [ 345] - case 0x8F: break; // BUNDLEHEADER [ 4 ] - case 0x92: rPal.ReadPalette( maStrm ); break; - case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45] - case 0x0218: rNameMgr.ReadName( maStrm ); break; - case 0x0223: break; // EXTERNNAME [ 34 ] - case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345] - case 0x0231: rFontBfr.ReadFont( maStrm ); break; - case EXC_ID4_BOF: // BOF [ 4 ] - Bof4(); - if( pExcRoot->eDateiTyp == Biff4 ) - { - eCurrent = Z_Biff4T; - NewTable(); - } - else - eCurrent = Z_End; - break; - case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break; - case 0x0443: rXFBfr.ReadXF( maStrm ); break; - case 0x0293: rXFBfr.ReadStyle( maStrm ); break; - } + case 0x0A: // EOF [ 2345] + eCurrent = Z_End; + break; + case 0x8F: break; // BUNDLEHEADER [ 4 ] + case EXC_ID4_BOF: // BOF [ 4 ] + Bof4(); + NewTable(); + if( pExcRoot->eDateiTyp == Biff4 ) + { + eCurrent = Z_Biff4T; + } + else + { + ePrev = eCurrent; + eCurrent = Z_Biffn0; + } + break; + } + } + break; + case Z_Biff5WPre: // ------------------------------ Z_Biff5WPre - + { + switch( nOpcode ) + { + case 0x0A: // EOF [ 2345] + eCurrent = Z_Biff5W; + aIn.SeekGlobalPosition(); // and back to old position + break; + case 0x12: DocProtect(); break; // PROTECT [ 5] + case 0x2F: // FILEPASS [ 2345] + eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); + if( eLastErr != ERRCODE_NONE ) + eCurrent = Z_End; + break; + case EXC_ID_FILESHARING: ReadFileSharing(); break; + case 0x3D: Window1(); break; + case 0x42: Codepage(); break; // CODEPAGE [ 2345] + case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5] + case 0x8C: Country(); break; // COUNTRY [ 345] + // PALETTE follows XFs, but already needed while reading the XFs + case 0x92: rPal.ReadPalette( maStrm ); break; } - break; + } + break; + case Z_Biff5W: // --------------------------------- Z_Biff5W - + { + switch( nOpcode ) + { + case 0x0A: // EOF [ 2345] + rNumFmtBfr.CreateScFormats(); + rXFBfr.CreateUserStyles(); + rNameMgr.ConvertAllTokens(); + eCurrent = Z_Biff5E; + break; + case 0x18: rNameMgr.ReadName( maStrm ); break; + case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break; + case 0x22: Rec1904(); break; // 1904 [ 2345] + case 0x31: rFontBfr.ReadFont( maStrm ); break; + case 0x56: break; // BUILTINFMTCNT[ 34 ] + case 0x8D: Hideobj(); break; // HIDEOBJ [ 345] + case 0xDE: Olesize(); break; + case 0xE0: rXFBfr.ReadXF( maStrm ); break; + case 0x0293: rXFBfr.ReadStyle( maStrm ); break; + case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break; + } + + } + break; - case Z_Biff4T: // --------------------------------- Z_Biff4T - + case Z_Biff5TPre: // ------------------------------- Z_Biff5Pre - + { + if (nOpcode == EXC_ID5_BOF) + nBofLevel++; + else if( (nOpcode == 0x000A) && nBofLevel ) + nBofLevel--; + else if( !nBofLevel ) // don't read chart records { switch( nOpcode ) { - // skip chart substream - case EXC_ID2_BOF: - case EXC_ID3_BOF: - case EXC_ID4_BOF: - case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break; - case EXC_ID2_DIMENSIONS: case EXC_ID3_DIMENSIONS: ReadDimensions(); break; - case EXC_ID2_BLANK: - case EXC_ID3_BLANK: ReadBlank(); break; - case EXC_ID2_INTEGER: ReadInteger(); break; - case EXC_ID2_NUMBER: - case EXC_ID3_NUMBER: ReadNumber(); break; - case EXC_ID2_LABEL: - case EXC_ID3_LABEL: ReadLabel(); break; - case EXC_ID2_BOOLERR: - case EXC_ID3_BOOLERR: ReadBoolErr(); break; - case EXC_ID_RK: ReadRk(); break; - + case 0x08: Row25(); break; // ROW [ 2 5] case 0x0A: // EOF [ 2345] - rNameMgr.ConvertAllTokens(); - Eof(); - eCurrent = Z_Biff4E; - break; + eCurrent = Z_Biff5T; + aIn.SeekGlobalPosition(); // and back to old position + break; case 0x12: SheetProtect(); break; // SHEET PROTECTION - case 0x14: - case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break; case 0x1A: case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break; - case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break; case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; - case 0x2F: // FILEPASS [ 2345] - eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); - if( eLastErr != ERRCODE_NONE ) - eCurrent = Z_End; - break; + case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] + case 0x21: Array25(); break; // ARRAY [ 2 5] + case 0x23: Externname25(); break; // EXTERNNAME [ 2 5] case 0x41: rTabViewSett.ReadPane( maStrm ); break; case 0x42: Codepage(); break; // CODEPAGE [ 2345] case 0x55: DefColWidth(); break; - case 0x56: break; // BUILTINFMTCNT[ 34 ] - case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break; case 0x7D: Colinfo(); break; // COLINFO [ 345] + case 0x81: Wsbool(); break; // WSBOOL [ 2345] case 0x8C: Country(); break; // COUNTRY [ 345] - case 0x8F: break; // BUNDLEHEADER [ 4 ] - case 0x92: rPal.ReadPalette( maStrm ); break; case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45] - case 0xA1: rPageSett.ReadSetup( maStrm ); break; case 0x0208: Row34(); break; // ROW [ 34 ] - case 0x0218: rNameMgr.ReadName( maStrm ); break; - case 0x0221: Array34(); break; + case 0x0221: Array34(); break; // ARRAY [ 34 ] + case 0x0223: break; // EXTERNNAME [ 34 ] case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345] - case 0x0231: rFontBfr.ReadFont( maStrm ); break; case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break; - case 0x0406: Formula4(); break; - case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break; - case 0x0443: rXFBfr.ReadXF( maStrm ); break; - case 0x0293: rXFBfr.ReadStyle( maStrm ); break; } - } - break; + } + break; - case Z_Biff4E: // --------------------------------- Z_Biff4E - + case Z_Biff5T: // --------------------------------- Z_Biff5T - + { + switch( nOpcode ) { - switch( nOpcode ) - { - case 0x0A: // EOF [ 2345] + case EXC_ID2_BLANK: + case EXC_ID3_BLANK: ReadBlank(); break; + case EXC_ID2_INTEGER: ReadInteger(); break; + case EXC_ID2_NUMBER: + case EXC_ID3_NUMBER: ReadNumber(); break; + case EXC_ID2_LABEL: + case EXC_ID3_LABEL: ReadLabel(); break; + case EXC_ID2_BOOLERR: + case EXC_ID3_BOOLERR: ReadBoolErr(); break; + case EXC_ID_RK: ReadRk(); break; + + case EXC_ID2_FORMULA: + case EXC_ID3_FORMULA: + case EXC_ID4_FORMULA: Formula25(); break; + case EXC_ID_SHRFMLA: Shrfmla(); break; + case 0x0A: Eof(); eCurrent = Z_Biff5E; break; + case 0x14: + case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break; + case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] + case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break; + case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; + case 0x23: Externname25(); break; // EXTERNNAME [ 2 5] + case 0x26: + case 0x27: + case 0x28: + case 0x29: rPageSett.ReadMargin( maStrm ); break; + case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break; + case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break; + case 0x2F: // FILEPASS [ 2345] + eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); + if( eLastErr != ERRCODE_NONE ) eCurrent = Z_End; - break; - case 0x8F: break; // BUNDLEHEADER [ 4 ] - case EXC_ID4_BOF: // BOF [ 4 ] - Bof4(); - NewTable(); - if( pExcRoot->eDateiTyp == Biff4 ) - { - eCurrent = Z_Biff4T; - } - else - { - ePrev = eCurrent; - eCurrent = Z_Biffn0; - } - break; - } - - } - break; - case Z_Biff5WPre: // ------------------------------ Z_Biff5WPre - - { - switch( nOpcode ) - { - case 0x0A: // EOF [ 2345] - eCurrent = Z_Biff5W; - aIn.SeekGlobalPosition(); // and back to old position - break; - case 0x12: DocProtect(); break; // PROTECT [ 5] - case 0x2F: // FILEPASS [ 2345] - eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); - if( eLastErr != ERRCODE_NONE ) - eCurrent = Z_End; - break; - case EXC_ID_FILESHARING: ReadFileSharing(); break; - case 0x3D: Window1(); break; - case 0x42: Codepage(); break; // CODEPAGE [ 2345] - case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5] - case 0x8C: Country(); break; // COUNTRY [ 345] - // PALETTE follows XFs, but already needed while reading the XFs - case 0x92: rPal.ReadPalette( maStrm ); break; - } + break; + case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break; + case 0x83: + case 0x84: rPageSett.ReadCenter( maStrm ); break; + case 0xA0: rTabViewSett.ReadScl( maStrm ); break; + case 0xA1: rPageSett.ReadSetup( maStrm ); break; + case 0xBD: Mulrk(); break; // MULRK [ 5] + case 0xBE: Mulblank(); break; // MULBLANK [ 5] + case 0xD6: Rstring(); break; // RSTRING [ 5] + case 0x00E5: Cellmerging(); break; // #i62300# + case 0x0236: TableOp(); break; // TABLE [ 5] + case EXC_ID5_BOF: // BOF [ 5] + XclTools::SkipSubStream( maStrm ); + break; } - break; - case Z_Biff5W: // --------------------------------- Z_Biff5W - - { - switch( nOpcode ) - { - case 0x0A: // EOF [ 2345] - rNumFmtBfr.CreateScFormats(); - rXFBfr.CreateUserStyles(); - rNameMgr.ConvertAllTokens(); - eCurrent = Z_Biff5E; - break; - case 0x18: rNameMgr.ReadName( maStrm ); break; - case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break; - case 0x22: Rec1904(); break; // 1904 [ 2345] - case 0x31: rFontBfr.ReadFont( maStrm ); break; - case 0x56: break; // BUILTINFMTCNT[ 34 ] - case 0x8D: Hideobj(); break; // HIDEOBJ [ 345] - case 0xDE: Olesize(); break; - case 0xE0: rXFBfr.ReadXF( maStrm ); break; - case 0x0293: rXFBfr.ReadStyle( maStrm ); break; - case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break; - } - } - break; + } + break; - case Z_Biff5TPre: // ------------------------------- Z_Biff5Pre - + case Z_Biff5E: // --------------------------------- Z_Biff5E - + { + switch( nOpcode ) { - if (nOpcode == EXC_ID5_BOF) - nBofLevel++; - else if( (nOpcode == 0x000A) && nBofLevel ) - nBofLevel--; - else if( !nBofLevel ) // don't read chart records - { - switch( nOpcode ) + case EXC_ID5_BOF: // BOF [ 5] + Bof5(); + NewTable(); + switch( pExcRoot->eDateiTyp ) { - case EXC_ID2_DIMENSIONS: - case EXC_ID3_DIMENSIONS: ReadDimensions(); break; - case 0x08: Row25(); break; // ROW [ 2 5] - case 0x0A: // EOF [ 2345] - eCurrent = Z_Biff5T; - aIn.SeekGlobalPosition(); // and back to old position - break; - case 0x12: SheetProtect(); break; // SHEET PROTECTION - case 0x1A: - case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break; - case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; - case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] - case 0x21: Array25(); break; // ARRAY [ 2 5] - case 0x23: Externname25(); break; // EXTERNNAME [ 2 5] - case 0x41: rTabViewSett.ReadPane( maStrm ); break; - case 0x42: Codepage(); break; // CODEPAGE [ 2345] - case 0x55: DefColWidth(); break; - case 0x7D: Colinfo(); break; // COLINFO [ 345] - case 0x81: Wsbool(); break; // WSBOOL [ 2345] - case 0x8C: Country(); break; // COUNTRY [ 345] - case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45] - case 0x0208: Row34(); break; // ROW [ 34 ] - case 0x0221: Array34(); break; // ARRAY [ 34 ] - case 0x0223: break; // EXTERNNAME [ 34 ] - case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345] - case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break; - } - } - } - break; - - case Z_Biff5T: // --------------------------------- Z_Biff5T - - { - switch( nOpcode ) - { - case EXC_ID2_BLANK: - case EXC_ID3_BLANK: ReadBlank(); break; - case EXC_ID2_INTEGER: ReadInteger(); break; - case EXC_ID2_NUMBER: - case EXC_ID3_NUMBER: ReadNumber(); break; - case EXC_ID2_LABEL: - case EXC_ID3_LABEL: ReadLabel(); break; - case EXC_ID2_BOOLERR: - case EXC_ID3_BOOLERR: ReadBoolErr(); break; - case EXC_ID_RK: ReadRk(); break; - - case EXC_ID2_FORMULA: - case EXC_ID3_FORMULA: - case EXC_ID4_FORMULA: Formula25(); break; - case EXC_ID_SHRFMLA: Shrfmla(); break; - case 0x0A: Eof(); eCurrent = Z_Biff5E; break; - case 0x14: - case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break; - case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345] - case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break; - case 0x1D: rTabViewSett.ReadSelection( maStrm ); break; - case 0x23: Externname25(); break; // EXTERNNAME [ 2 5] - case 0x26: - case 0x27: - case 0x28: - case 0x29: rPageSett.ReadMargin( maStrm ); break; - case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break; - case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break; - case 0x2F: // FILEPASS [ 2345] - eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); - if( eLastErr != ERRCODE_NONE ) - eCurrent = Z_End; + case Biff5: + case Biff5M4: + eCurrent = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch + nBofLevel = 0; + aIn.StoreGlobalPosition(); // store position break; - case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break; - case 0x83: - case 0x84: rPageSett.ReadCenter( maStrm ); break; - case 0xA0: rTabViewSett.ReadScl( maStrm ); break; - case 0xA1: rPageSett.ReadSetup( maStrm ); break; - case 0xBD: Mulrk(); break; // MULRK [ 5] - case 0xBE: Mulblank(); break; // MULBLANK [ 5] - case 0xD6: Rstring(); break; // RSTRING [ 5] - case 0x00E5: Cellmerging(); break; // #i62300# - case 0x0236: TableOp(); break; // TABLE [ 5] - case EXC_ID5_BOF: // BOF [ 5] - XclTools::SkipSubStream( maStrm ); + case Biff5C: // chart sheet + GetCurrSheetDrawing().ReadTabChart( maStrm ); + Eof(); + GetTracer().TraceChartOnlySheet(); break; - } + case Biff5V: + default: + rD.SetVisible( GetCurrScTab(), false ); + ePrev = eCurrent; + eCurrent = Z_Biffn0; + } + OSL_ENSURE( pExcRoot->eDateiTyp != Biff5W, + "+ImportExcel::Read(): Doppel-Whopper-Workbook!" ); + break; } - break; - case Z_Biff5E: // --------------------------------- Z_Biff5E - - { - switch( nOpcode ) - { - case EXC_ID5_BOF: // BOF [ 5] - Bof5(); - NewTable(); - switch( pExcRoot->eDateiTyp ) - { - case Biff5: - case Biff5M4: - eCurrent = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch - nBofLevel = 0; - aIn.StoreGlobalPosition(); // store position - break; - case Biff5C: // chart sheet - GetCurrSheetDrawing().ReadTabChart( maStrm ); - Eof(); - GetTracer().TraceChartOnlySheet(); - break; - case Biff5V: - default: - rD.SetVisible( GetCurrScTab(), false ); - ePrev = eCurrent; - eCurrent = Z_Biffn0; - } - OSL_ENSURE( pExcRoot->eDateiTyp != Biff5W, - "+ImportExcel::Read(): Doppel-Whopper-Workbook!" ); - - break; - } - - } - break; - case Z_Biffn0: // --------------------------------- Z_Biffn0 - + } + break; + case Z_Biffn0: // --------------------------------- Z_Biffn0 - + { + switch( nOpcode ) { - switch( nOpcode ) - { - case 0x0A: // EOF [ 2345] - eCurrent = ePrev; - IncCurrScTab(); - break; - } - + case 0x0A: // EOF [ 2345] + eCurrent = ePrev; + IncCurrScTab(); + break; } - break; - case Z_End: // ----------------------------------- Z_End - - OSL_FAIL( "*ImportExcel::Read(): Not possible state!" ); - break; - default: OSL_FAIL( "-ImportExcel::Read(): state forgotten!" ); } - } + break; - if( eLastErr == ERRCODE_NONE ) - { - pProgress.reset(); - - GetDocImport().finalize(); - if (!utl::ConfigManager::IsFuzzing()) - AdjustRowHeight(); - PostDocLoad(); - - rD.CalcAfterLoad(false); - - const XclImpAddressConverter& rAddrConv = GetAddressConverter(); - if( rAddrConv.IsTabTruncated() ) - eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW; - else if( bTabTruncated || rAddrConv.IsRowTruncated() ) - eLastErr = SCWARN_IMPORT_ROW_OVERFLOW; - else if( rAddrConv.IsColTruncated() ) - eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW; + case Z_End: // ----------------------------------- Z_End - + OSL_FAIL( "*ImportExcel::Read(): Not possible state!" ); + break; + default: OSL_FAIL( "-ImportExcel::Read(): state forgotten!" ); } } - catch (const SvStreamEOFException&) + + if( eLastErr == ERRCODE_NONE ) { - SAL_WARN("sc", "EOF"); - return ERRCODE_IO_CANTREAD; + pProgress.reset(); + + GetDocImport().finalize(); + if (!utl::ConfigManager::IsFuzzing()) + AdjustRowHeight(); + PostDocLoad(); + + rD.CalcAfterLoad(false); + + const XclImpAddressConverter& rAddrConv = GetAddressConverter(); + if( rAddrConv.IsTabTruncated() ) + eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW; + else if( bTabTruncated || rAddrConv.IsRowTruncated() ) + eLastErr = SCWARN_IMPORT_ROW_OVERFLOW; + else if( rAddrConv.IsColTruncated() ) + eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW; } + return eLastErr; } @@ -859,410 +852,402 @@ ErrCode ImportExcel8::Read() std::vector aCodeNames; std::vector < SCTAB > nTabsWithNoCodeName; - try - { - sal_uInt16 nRecId = 0; + sal_uInt16 nRecId = 0; - for (; eCurrent != EXC_STATE_END; mnLastRecId = nRecId) + for (; eCurrent != EXC_STATE_END; mnLastRecId = nRecId) + { + if( eCurrent == EXC_STATE_BEFORE_SHEET ) { - if( eCurrent == EXC_STATE_BEFORE_SHEET ) + sal_uInt16 nScTab = GetCurrScTab(); + if( nScTab < maSheetOffsets.size() ) { - sal_uInt16 nScTab = GetCurrScTab(); - if( nScTab < maSheetOffsets.size() ) - { - nProgressBaseSize += (maStrm.GetSvStreamPos() - nProgressBasePos); - nProgressBasePos = maSheetOffsets[ nScTab ]; + nProgressBaseSize += (maStrm.GetSvStreamPos() - nProgressBasePos); + nProgressBasePos = maSheetOffsets[ nScTab ]; - bool bValid = TryStartNextRecord(aIn, nProgressBasePos); - if (!bValid) - { - // Safeguard ourselves from potential infinite loop. - eCurrent = EXC_STATE_END; - } + bool bValid = TryStartNextRecord(aIn, nProgressBasePos); + if (!bValid) + { + // Safeguard ourselves from potential infinite loop. + eCurrent = EXC_STATE_END; + } - // import only 256 sheets - if( nScTab > GetScMaxPos().Tab() ) - { - if( maStrm.GetRecId() != EXC_ID_EOF ) - XclTools::SkipSubStream( maStrm ); - // #i29930# show warning box - GetAddressConverter().CheckScTab( nScTab ); - eCurrent = EXC_STATE_END; - } + // import only 256 sheets + if( nScTab > GetScMaxPos().Tab() ) + { + if( maStrm.GetRecId() != EXC_ID_EOF ) + XclTools::SkipSubStream( maStrm ); + // #i29930# show warning box + GetAddressConverter().CheckScTab( nScTab ); + eCurrent = EXC_STATE_END; + } + else + { + // #i109800# SHEET record may point to any record inside the + // sheet substream + bool bIsBof = maStrm.GetRecId() == EXC_ID5_BOF; + if( bIsBof ) + Bof5(); // read the BOF record else + pExcRoot->eDateiTyp = Biff8; // on missing BOF, assume a standard worksheet + NewTable(); + switch( pExcRoot->eDateiTyp ) { - // #i109800# SHEET record may point to any record inside the - // sheet substream - bool bIsBof = maStrm.GetRecId() == EXC_ID5_BOF; - if( bIsBof ) - Bof5(); // read the BOF record - else - pExcRoot->eDateiTyp = Biff8; // on missing BOF, assume a standard worksheet - NewTable(); - switch( pExcRoot->eDateiTyp ) - { - case Biff8: // worksheet - case Biff8M4: // macro sheet - eCurrent = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch - // go to next record - if( bIsBof ) maStrm.StartNextRecord(); - maStrm.StoreGlobalPosition(); - break; - case Biff8C: // chart sheet - GetCurrSheetDrawing().ReadTabChart( maStrm ); - Eof(); - GetTracer().TraceChartOnlySheet(); - break; - case Biff8W: // workbook - OSL_FAIL( "ImportExcel8::Read - double workbook globals" ); - [[fallthrough]]; - case Biff8V: // VB module - default: - // TODO: do not create a sheet in the Calc document - rD.SetVisible( nScTab, false ); - XclTools::SkipSubStream( maStrm ); - IncCurrScTab(); - } + case Biff8: // worksheet + case Biff8M4: // macro sheet + eCurrent = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch + // go to next record + if( bIsBof ) maStrm.StartNextRecord(); + maStrm.StoreGlobalPosition(); + break; + case Biff8C: // chart sheet + GetCurrSheetDrawing().ReadTabChart( maStrm ); + Eof(); + GetTracer().TraceChartOnlySheet(); + break; + case Biff8W: // workbook + OSL_FAIL( "ImportExcel8::Read - double workbook globals" ); + [[fallthrough]]; + case Biff8V: // VB module + default: + // TODO: do not create a sheet in the Calc document + rD.SetVisible( nScTab, false ); + XclTools::SkipSubStream( maStrm ); + IncCurrScTab(); } } - else - eCurrent = EXC_STATE_END; } else - aIn.StartNextRecord(); + eCurrent = EXC_STATE_END; + } + else + aIn.StartNextRecord(); - if( !aIn.IsValid() ) + if( !aIn.IsValid() ) + { + // #i63591# finalize table if EOF is missing + switch( eCurrent ) { - // #i63591# finalize table if EOF is missing - switch( eCurrent ) - { - case EXC_STATE_SHEET_PRE: - eCurrent = EXC_STATE_SHEET; - aIn.SeekGlobalPosition(); - continue; // next iteration in while loop - case EXC_STATE_SHEET: - Eof(); - eCurrent = EXC_STATE_END; - break; - default: - eCurrent = EXC_STATE_END; - } + case EXC_STATE_SHEET_PRE: + eCurrent = EXC_STATE_SHEET; + aIn.SeekGlobalPosition(); + continue; // next iteration in while loop + case EXC_STATE_SHEET: + Eof(); + eCurrent = EXC_STATE_END; + break; + default: + eCurrent = EXC_STATE_END; } + } - if( eCurrent == EXC_STATE_END ) - break; + if( eCurrent == EXC_STATE_END ) + break; - if( eCurrent != EXC_STATE_SHEET_PRE && eCurrent != EXC_STATE_GLOBALS_PRE ) - pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos ); + if( eCurrent != EXC_STATE_SHEET_PRE && eCurrent != EXC_STATE_GLOBALS_PRE ) + pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos ); - nRecId = aIn.GetRecId(); + nRecId = aIn.GetRecId(); - /* #i39464# Ignore records between USERSVIEWBEGIN and USERSVIEWEND - completely (user specific view settings). Otherwise view settings - and filters are loaded multiple times, which at least causes - problems in auto-filters. */ - switch( nRecId ) - { - case EXC_ID_USERSVIEWBEGIN: - OSL_ENSURE( !bInUserView, "ImportExcel8::Read - nested user view settings" ); - bInUserView = true; - break; - case EXC_ID_USERSVIEWEND: - OSL_ENSURE( bInUserView, "ImportExcel8::Read - not in user view settings" ); - bInUserView = false; - break; - } + /* #i39464# Ignore records between USERSVIEWBEGIN and USERSVIEWEND + completely (user specific view settings). Otherwise view settings + and filters are loaded multiple times, which at least causes + problems in auto-filters. */ + switch( nRecId ) + { + case EXC_ID_USERSVIEWBEGIN: + OSL_ENSURE( !bInUserView, "ImportExcel8::Read - nested user view settings" ); + bInUserView = true; + break; + case EXC_ID_USERSVIEWEND: + OSL_ENSURE( bInUserView, "ImportExcel8::Read - not in user view settings" ); + bInUserView = false; + break; + } - if( !bInUserView ) switch( eCurrent ) - { + if( !bInUserView ) switch( eCurrent ) + { - // before workbook globals: wait for initial workbook globals BOF - case EXC_STATE_BEFORE_GLOBALS: + // before workbook globals: wait for initial workbook globals BOF + case EXC_STATE_BEFORE_GLOBALS: + { + if( nRecId == EXC_ID5_BOF ) { - if( nRecId == EXC_ID5_BOF ) + OSL_ENSURE( GetBiff() == EXC_BIFF8, "ImportExcel8::Read - wrong BIFF version" ); + Bof5(); + if( pExcRoot->eDateiTyp == Biff8W ) { - OSL_ENSURE( GetBiff() == EXC_BIFF8, "ImportExcel8::Read - wrong BIFF version" ); - Bof5(); - if( pExcRoot->eDateiTyp == Biff8W ) - { - eCurrent = EXC_STATE_GLOBALS_PRE; - maStrm.StoreGlobalPosition(); - nBdshtTab = 0; - } - else if( pExcRoot->eDateiTyp == Biff8 ) - { - // #i62752# possible to have BIFF8 sheet without globals - NewTable(); - eCurrent = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch - bSheetHasCodeName = false; // reset - aIn.StoreGlobalPosition(); - } + eCurrent = EXC_STATE_GLOBALS_PRE; + maStrm.StoreGlobalPosition(); + nBdshtTab = 0; } - } - break; - - // prefetch for workbook globals - case EXC_STATE_GLOBALS_PRE: - { - switch( nRecId ) + else if( pExcRoot->eDateiTyp == Biff8 ) { - case EXC_ID_EOF: - case EXC_ID_EXTSST: - /* #i56376# evil hack: if EOF for globals is missing, - simulate it. This hack works only for the bugdoc - given in the issue, where the sheet substreams - start directly after the EXTSST record. A future - implementation should be more robust against - missing EOFs. */ - if( (nRecId == EXC_ID_EOF) || - ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) ) - { - eCurrent = EXC_STATE_GLOBALS; - aIn.SeekGlobalPosition(); - } - break; - case 0x12: DocProtect(); break; // PROTECT [ 5678] - case 0x13: DocPassword(); break; - case 0x19: WinProtection(); break; - case 0x2F: // FILEPASS [ 2345 ] - eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); - if( eLastErr != ERRCODE_NONE ) - eCurrent = EXC_STATE_END; - break; - case EXC_ID_FILESHARING: ReadFileSharing(); break; - case 0x3D: Window1(); break; - case 0x42: Codepage(); break; // CODEPAGE [ 2345 ] - case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5 ] - case 0x8C: Country(); break; // COUNTRY [ 345 ] - - // PALETTE follows XFs, but already needed while reading the XFs - case EXC_ID_PALETTE: rPal.ReadPalette( maStrm ); break; + // #i62752# possible to have BIFF8 sheet without globals + NewTable(); + eCurrent = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch + bSheetHasCodeName = false; // reset + aIn.StoreGlobalPosition(); } } - break; + } + break; - // workbook globals - case EXC_STATE_GLOBALS: + // prefetch for workbook globals + case EXC_STATE_GLOBALS_PRE: + { + switch( nRecId ) { - switch( nRecId ) - { - case EXC_ID_EOF: - case EXC_ID_EXTSST: - /* #i56376# evil hack: if EOF for globals is missing, - simulate it. This hack works only for the bugdoc - given in the issue, where the sheet substreams - start directly after the EXTSST record. A future - implementation should be more robust against - missing EOFs. */ - if( (nRecId == EXC_ID_EOF) || - ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) ) - { - rNumFmtBfr.CreateScFormats(); - rXFBfr.CreateUserStyles(); - rPTableMgr.ReadPivotCaches( maStrm ); - rNameMgr.ConvertAllTokens(); - eCurrent = EXC_STATE_BEFORE_SHEET; - } + case EXC_ID_EOF: + case EXC_ID_EXTSST: + /* #i56376# evil hack: if EOF for globals is missing, + simulate it. This hack works only for the bugdoc + given in the issue, where the sheet substreams + start directly after the EXTSST record. A future + implementation should be more robust against + missing EOFs. */ + if( (nRecId == EXC_ID_EOF) || + ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) ) + { + eCurrent = EXC_STATE_GLOBALS; + aIn.SeekGlobalPosition(); + } break; - case 0x0E: Precision(); break; // PRECISION - case 0x22: Rec1904(); break; // 1904 [ 2345 ] - case 0x56: break; // BUILTINFMTCNT[ 34 ] - case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ] - case 0xD3: SetHasBasic(); break; - case 0xDE: Olesize(); break; - - case EXC_ID_CODENAME: ReadCodeName( aIn, true ); break; - case EXC_ID_USESELFS: ReadUsesElfs(); break; - - case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break; - case EXC_ID4_FORMAT: rNumFmtBfr.ReadFormat( maStrm ); break; - case EXC_ID5_XF: rXFBfr.ReadXF( maStrm ); break; - case EXC_ID_STYLE: rXFBfr.ReadStyle( maStrm ); break; - - case EXC_ID_SST: rSst.ReadSst( maStrm ); break; - case EXC_ID_TABID: rTabInfo.ReadTabid( maStrm ); break; - case EXC_ID_NAME: rNameMgr.ReadName( maStrm ); break; - - case EXC_ID_EXTERNSHEET: rLinkMgr.ReadExternsheet( maStrm ); break; - case EXC_ID_SUPBOOK: rLinkMgr.ReadSupbook( maStrm ); break; - case EXC_ID_XCT: rLinkMgr.ReadXct( maStrm ); break; - case EXC_ID_CRN: rLinkMgr.ReadCrn( maStrm ); break; - case EXC_ID_EXTERNNAME: rLinkMgr.ReadExternname( maStrm, pFormConv.get() ); break; - - case EXC_ID_MSODRAWINGGROUP:rObjMgr.ReadMsoDrawingGroup( maStrm ); break; - - case EXC_ID_SXIDSTM: rPTableMgr.ReadSxidstm( maStrm ); break; - case EXC_ID_SXVS: rPTableMgr.ReadSxvs( maStrm ); break; - case EXC_ID_DCONREF: rPTableMgr.ReadDconref( maStrm ); break; - case EXC_ID_DCONNAME: rPTableMgr.ReadDConName( maStrm ); break; - } + case 0x12: DocProtect(); break; // PROTECT [ 5678] + case 0x13: DocPassword(); break; + case 0x19: WinProtection(); break; + case 0x2F: // FILEPASS [ 2345 ] + eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm ); + if( eLastErr != ERRCODE_NONE ) + eCurrent = EXC_STATE_END; + break; + case EXC_ID_FILESHARING: ReadFileSharing(); break; + case 0x3D: Window1(); break; + case 0x42: Codepage(); break; // CODEPAGE [ 2345 ] + case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5 ] + case 0x8C: Country(); break; // COUNTRY [ 345 ] + + // PALETTE follows XFs, but already needed while reading the XFs + case EXC_ID_PALETTE: rPal.ReadPalette( maStrm ); break; + } + } + break; + // workbook globals + case EXC_STATE_GLOBALS: + { + switch( nRecId ) + { + case EXC_ID_EOF: + case EXC_ID_EXTSST: + /* #i56376# evil hack: if EOF for globals is missing, + simulate it. This hack works only for the bugdoc + given in the issue, where the sheet substreams + start directly after the EXTSST record. A future + implementation should be more robust against + missing EOFs. */ + if( (nRecId == EXC_ID_EOF) || + ((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) ) + { + rNumFmtBfr.CreateScFormats(); + rXFBfr.CreateUserStyles(); + rPTableMgr.ReadPivotCaches( maStrm ); + rNameMgr.ConvertAllTokens(); + eCurrent = EXC_STATE_BEFORE_SHEET; + } + break; + case 0x0E: Precision(); break; // PRECISION + case 0x22: Rec1904(); break; // 1904 [ 2345 ] + case 0x56: break; // BUILTINFMTCNT[ 34 ] + case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ] + case 0xD3: SetHasBasic(); break; + case 0xDE: Olesize(); break; + + case EXC_ID_CODENAME: ReadCodeName( aIn, true ); break; + case EXC_ID_USESELFS: ReadUsesElfs(); break; + + case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break; + case EXC_ID4_FORMAT: rNumFmtBfr.ReadFormat( maStrm ); break; + case EXC_ID5_XF: rXFBfr.ReadXF( maStrm ); break; + case EXC_ID_STYLE: rXFBfr.ReadStyle( maStrm ); break; + + case EXC_ID_SST: rSst.ReadSst( maStrm ); break; + case EXC_ID_TABID: rTabInfo.ReadTabid( maStrm ); break; + case EXC_ID_NAME: rNameMgr.ReadName( maStrm ); break; + + case EXC_ID_EXTERNSHEET: rLinkMgr.ReadExternsheet( maStrm ); break; + case EXC_ID_SUPBOOK: rLinkMgr.ReadSupbook( maStrm ); break; + case EXC_ID_XCT: rLinkMgr.ReadXct( maStrm ); break; + case EXC_ID_CRN: rLinkMgr.ReadCrn( maStrm ); break; + case EXC_ID_EXTERNNAME: rLinkMgr.ReadExternname( maStrm, pFormConv.get() ); break; + + case EXC_ID_MSODRAWINGGROUP:rObjMgr.ReadMsoDrawingGroup( maStrm ); break; + + case EXC_ID_SXIDSTM: rPTableMgr.ReadSxidstm( maStrm ); break; + case EXC_ID_SXVS: rPTableMgr.ReadSxvs( maStrm ); break; + case EXC_ID_DCONREF: rPTableMgr.ReadDconref( maStrm ); break; + case EXC_ID_DCONNAME: rPTableMgr.ReadDConName( maStrm ); break; } - break; - // prefetch for worksheet - case EXC_STATE_SHEET_PRE: + } + break; + + // prefetch for worksheet + case EXC_STATE_SHEET_PRE: + { + switch( nRecId ) { - switch( nRecId ) - { - // skip chart substream - case EXC_ID2_BOF: - case EXC_ID3_BOF: - case EXC_ID4_BOF: - case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break; + // skip chart substream + case EXC_ID2_BOF: + case EXC_ID3_BOF: + case EXC_ID4_BOF: + case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break; - case EXC_ID_WINDOW2: rTabViewSett.ReadWindow2( maStrm, false );break; - case EXC_ID_SCL: rTabViewSett.ReadScl( maStrm ); break; - case EXC_ID_PANE: rTabViewSett.ReadPane( maStrm ); break; - case EXC_ID_SELECTION: rTabViewSett.ReadSelection( maStrm ); break; + case EXC_ID_WINDOW2: rTabViewSett.ReadWindow2( maStrm, false );break; + case EXC_ID_SCL: rTabViewSett.ReadScl( maStrm ); break; + case EXC_ID_PANE: rTabViewSett.ReadPane( maStrm ); break; + case EXC_ID_SELECTION: rTabViewSett.ReadSelection( maStrm ); break; - case EXC_ID2_DIMENSIONS: - case EXC_ID3_DIMENSIONS: ReadDimensions(); break; + case EXC_ID2_DIMENSIONS: + case EXC_ID3_DIMENSIONS: ReadDimensions(); break; - case EXC_ID_CODENAME: ReadCodeName( aIn, false ); bSheetHasCodeName = true; break; + case EXC_ID_CODENAME: ReadCodeName( aIn, false ); bSheetHasCodeName = true; break; - case 0x0A: // EOF [ 2345 ] + case 0x0A: // EOF [ 2345 ] + { + eCurrent = EXC_STATE_SHEET; + OUString sName; + GetDoc().GetName( GetCurrScTab(), sName ); + if ( !bSheetHasCodeName ) { - eCurrent = EXC_STATE_SHEET; - OUString sName; - GetDoc().GetName( GetCurrScTab(), sName ); - if ( !bSheetHasCodeName ) - { - nTabsWithNoCodeName.push_back( GetCurrScTab() ); - } - else - { - OUString sCodeName; - GetDoc().GetCodeName( GetCurrScTab(), sCodeName ); - aCodeNames.push_back( sCodeName ); - } - - bSheetHasCodeName = false; // reset - - aIn.SeekGlobalPosition(); // and back to old position - break; + nTabsWithNoCodeName.push_back( GetCurrScTab() ); } - case 0x12: SheetProtect(); break; - case 0x13: SheetPassword(); break; - case 0x42: Codepage(); break; // CODEPAGE [ 2345 ] - case 0x55: DefColWidth(); break; - case 0x7D: Colinfo(); break; // COLINFO [ 345 ] - case 0x81: Wsbool(); break; // WSBOOL [ 2345 ] - case 0x8C: Country(); break; // COUNTRY [ 345 ] - case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45 ] - case 0x9B: FilterMode(); break; // FILTERMODE - case EXC_ID_AUTOFILTERINFO: AutoFilterInfo(); break;// AUTOFILTERINFO - case EXC_ID_AUTOFILTER: AutoFilter(); break; // AUTOFILTER - case 0x0208: Row34(); break; // ROW [ 34 ] - case EXC_ID2_ARRAY: - case EXC_ID3_ARRAY: Array34(); break; // ARRAY [ 34 ] - case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345 ] - case 0x0867: FeatHdr(); break; // FEATHDR - case 0x0868: Feat(); break; // FEAT + else + { + OUString sCodeName; + GetDoc().GetCodeName( GetCurrScTab(), sCodeName ); + aCodeNames.push_back( sCodeName ); + } + + bSheetHasCodeName = false; // reset + + aIn.SeekGlobalPosition(); // and back to old position + break; } + case 0x12: SheetProtect(); break; + case 0x13: SheetPassword(); break; + case 0x42: Codepage(); break; // CODEPAGE [ 2345 ] + case 0x55: DefColWidth(); break; + case 0x7D: Colinfo(); break; // COLINFO [ 345 ] + case 0x81: Wsbool(); break; // WSBOOL [ 2345 ] + case 0x8C: Country(); break; // COUNTRY [ 345 ] + case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45 ] + case 0x9B: FilterMode(); break; // FILTERMODE + case EXC_ID_AUTOFILTERINFO: AutoFilterInfo(); break;// AUTOFILTERINFO + case EXC_ID_AUTOFILTER: AutoFilter(); break; // AUTOFILTER + case 0x0208: Row34(); break; // ROW [ 34 ] + case EXC_ID2_ARRAY: + case EXC_ID3_ARRAY: Array34(); break; // ARRAY [ 34 ] + case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345 ] + case 0x0867: FeatHdr(); break; // FEATHDR + case 0x0868: Feat(); break; // FEAT } - break; + } + break; - // worksheet - case EXC_STATE_SHEET: + // worksheet + case EXC_STATE_SHEET: + { + switch( nRecId ) { - switch( nRecId ) - { - // skip unknown substreams - case EXC_ID2_BOF: - case EXC_ID3_BOF: - case EXC_ID4_BOF: - case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break; - - case EXC_ID_EOF: Eof(); eCurrent = EXC_STATE_BEFORE_SHEET; break; - - case EXC_ID2_BLANK: - case EXC_ID3_BLANK: ReadBlank(); break; - case EXC_ID2_INTEGER: ReadInteger(); break; - case EXC_ID2_NUMBER: - case EXC_ID3_NUMBER: ReadNumber(); break; - case EXC_ID2_LABEL: - case EXC_ID3_LABEL: ReadLabel(); break; - case EXC_ID2_BOOLERR: - case EXC_ID3_BOOLERR: ReadBoolErr(); break; - case EXC_ID_RK: ReadRk(); break; - - case EXC_ID2_FORMULA: - case EXC_ID3_FORMULA: - case EXC_ID4_FORMULA: Formula25(); break; - case EXC_ID_SHRFMLA: Shrfmla(); break; - case 0x000C: Calccount(); break; // CALCCOUNT - case 0x0010: Delta(); break; // DELTA - case 0x0011: Iteration(); break; // ITERATION - case 0x007E: - case 0x00AE: Scenman(); break; // SCENMAN - case 0x00AF: Scenario(); break; // SCENARIO - case 0x00BD: Mulrk(); break; // MULRK [ 5 ] - case 0x00BE: Mulblank(); break; // MULBLANK [ 5 ] - case 0x00D6: Rstring(); break; // RSTRING [ 5 ] - case 0x00E5: Cellmerging(); break; // CELLMERGING - case 0x00FD: Labelsst(); break; // LABELSST [ 8 ] - case 0x0236: TableOp(); break; // TABLE - - case EXC_ID_HORPAGEBREAKS: - case EXC_ID_VERPAGEBREAKS: rPageSett.ReadPageBreaks( maStrm ); break; - case EXC_ID_HEADER: - case EXC_ID_FOOTER: rPageSett.ReadHeaderFooter( maStrm ); break; - case EXC_ID_LEFTMARGIN: - case EXC_ID_RIGHTMARGIN: - case EXC_ID_TOPMARGIN: - case EXC_ID_BOTTOMMARGIN: rPageSett.ReadMargin( maStrm ); break; - case EXC_ID_PRINTHEADERS: rPageSett.ReadPrintHeaders( maStrm ); break; - case EXC_ID_PRINTGRIDLINES: rPageSett.ReadPrintGridLines( maStrm ); break; - case EXC_ID_HCENTER: - case EXC_ID_VCENTER: rPageSett.ReadCenter( maStrm ); break; - case EXC_ID_SETUP: rPageSett.ReadSetup( maStrm ); break; - case EXC_ID8_IMGDATA: rPageSett.ReadImgData( maStrm ); break; - - case EXC_ID_MSODRAWING: GetCurrSheetDrawing().ReadMsoDrawing( maStrm ); break; - // #i61786# weird documents: OBJ without MSODRAWING -> read in BIFF5 format - case EXC_ID_OBJ: GetCurrSheetDrawing().ReadObj( maStrm ); break; - case EXC_ID_NOTE: GetCurrSheetDrawing().ReadNote( maStrm ); break; - - case EXC_ID_HLINK: XclImpHyperlink::ReadHlink( maStrm ); break; - case EXC_ID_LABELRANGES: XclImpLabelranges::ReadLabelranges( maStrm ); break; - - case EXC_ID_CONDFMT: rCondFmtMgr.ReadCondfmt( maStrm ); break; - case EXC_ID_CF: rCondFmtMgr.ReadCF( maStrm ); break; - - case EXC_ID_DVAL: XclImpValidationManager::ReadDval( maStrm ); break; - case EXC_ID_DV: rValidMgr.ReadDV( maStrm ); break; - - case EXC_ID_QSI: rWQBfr.ReadQsi( maStrm ); break; - case EXC_ID_WQSTRING: rWQBfr.ReadWqstring( maStrm ); break; - case EXC_ID_PQRY: rWQBfr.ReadParamqry( maStrm ); break; - case EXC_ID_WQSETT: rWQBfr.ReadWqsettings( maStrm ); break; - case EXC_ID_WQTABLES: rWQBfr.ReadWqtables( maStrm ); break; - - case EXC_ID_SXVIEW: rPTableMgr.ReadSxview( maStrm ); break; - case EXC_ID_SXVD: rPTableMgr.ReadSxvd( maStrm ); break; - case EXC_ID_SXVI: rPTableMgr.ReadSxvi( maStrm ); break; - case EXC_ID_SXIVD: rPTableMgr.ReadSxivd( maStrm ); break; - case EXC_ID_SXPI: rPTableMgr.ReadSxpi( maStrm ); break; - case EXC_ID_SXDI: rPTableMgr.ReadSxdi( maStrm ); break; - case EXC_ID_SXVDEX: rPTableMgr.ReadSxvdex( maStrm ); break; - case EXC_ID_SXEX: rPTableMgr.ReadSxex( maStrm ); break; - case EXC_ID_SHEETEXT: rTabViewSett.ReadTabBgColor( maStrm, rPal ); break; - case EXC_ID_SXVIEWEX9: rPTableMgr.ReadSxViewEx9( maStrm ); break; - case EXC_ID_SXADDL: rPTableMgr.ReadSxAddl( maStrm ); break; - } + // skip unknown substreams + case EXC_ID2_BOF: + case EXC_ID3_BOF: + case EXC_ID4_BOF: + case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break; + + case EXC_ID_EOF: Eof(); eCurrent = EXC_STATE_BEFORE_SHEET; break; + + case EXC_ID2_BLANK: + case EXC_ID3_BLANK: ReadBlank(); break; + case EXC_ID2_INTEGER: ReadInteger(); break; + case EXC_ID2_NUMBER: + case EXC_ID3_NUMBER: ReadNumber(); break; + case EXC_ID2_LABEL: + case EXC_ID3_LABEL: ReadLabel(); break; + case EXC_ID2_BOOLERR: + case EXC_ID3_BOOLERR: ReadBoolErr(); break; + case EXC_ID_RK: ReadRk(); break; + + case EXC_ID2_FORMULA: + case EXC_ID3_FORMULA: + case EXC_ID4_FORMULA: Formula25(); break; + case EXC_ID_SHRFMLA: Shrfmla(); break; + case 0x000C: Calccount(); break; // CALCCOUNT + case 0x0010: Delta(); break; // DELTA + case 0x0011: Iteration(); break; // ITERATION + case 0x007E: + case 0x00AE: Scenman(); break; // SCENMAN + case 0x00AF: Scenario(); break; // SCENARIO + case 0x00BD: Mulrk(); break; // MULRK [ 5 ] + case 0x00BE: Mulblank(); break; // MULBLANK [ 5 ] + case 0x00D6: Rstring(); break; // RSTRING [ 5 ] + case 0x00E5: Cellmerging(); break; // CELLMERGING + case 0x00FD: Labelsst(); break; // LABELSST [ 8 ] + case 0x0236: TableOp(); break; // TABLE + + case EXC_ID_HORPAGEBREAKS: + case EXC_ID_VERPAGEBREAKS: rPageSett.ReadPageBreaks( maStrm ); break; + case EXC_ID_HEADER: + case EXC_ID_FOOTER: rPageSett.ReadHeaderFooter( maStrm ); break; + case EXC_ID_LEFTMARGIN: + case EXC_ID_RIGHTMARGIN: + case EXC_ID_TOPMARGIN: + case EXC_ID_BOTTOMMARGIN: rPageSett.ReadMargin( maStrm ); break; + case EXC_ID_PRINTHEADERS: rPageSett.ReadPrintHeaders( maStrm ); break; + case EXC_ID_PRINTGRIDLINES: rPageSett.ReadPrintGridLines( maStrm ); break; + case EXC_ID_HCENTER: + case EXC_ID_VCENTER: rPageSett.ReadCenter( maStrm ); break; + case EXC_ID_SETUP: rPageSett.ReadSetup( maStrm ); break; + case EXC_ID8_IMGDATA: rPageSett.ReadImgData( maStrm ); break; + + case EXC_ID_MSODRAWING: GetCurrSheetDrawing().ReadMsoDrawing( maStrm ); break; + // #i61786# weird documents: OBJ without MSODRAWING -> read in BIFF5 format + case EXC_ID_OBJ: GetCurrSheetDrawing().ReadObj( maStrm ); break; + case EXC_ID_NOTE: GetCurrSheetDrawing().ReadNote( maStrm ); break; + + case EXC_ID_HLINK: XclImpHyperlink::ReadHlink( maStrm ); break; + case EXC_ID_LABELRANGES: XclImpLabelranges::ReadLabelranges( maStrm ); break; + + case EXC_ID_CONDFMT: rCondFmtMgr.ReadCondfmt( maStrm ); break; + case EXC_ID_CF: rCondFmtMgr.ReadCF( maStrm ); break; + + case EXC_ID_DVAL: XclImpValidationManager::ReadDval( maStrm ); break; + case EXC_ID_DV: rValidMgr.ReadDV( maStrm ); break; + + case EXC_ID_QSI: rWQBfr.ReadQsi( maStrm ); break; + case EXC_ID_WQSTRING: rWQBfr.ReadWqstring( maStrm ); break; + case EXC_ID_PQRY: rWQBfr.ReadParamqry( maStrm ); break; + case EXC_ID_WQSETT: rWQBfr.ReadWqsettings( maStrm ); break; + case EXC_ID_WQTABLES: rWQBfr.ReadWqtables( maStrm ); break; + + case EXC_ID_SXVIEW: rPTableMgr.ReadSxview( maStrm ); break; + case EXC_ID_SXVD: rPTableMgr.ReadSxvd( maStrm ); break; + case EXC_ID_SXVI: rPTableMgr.ReadSxvi( maStrm ); break; + case EXC_ID_SXIVD: rPTableMgr.ReadSxivd( maStrm ); break; + case EXC_ID_SXPI: rPTableMgr.ReadSxpi( maStrm ); break; + case EXC_ID_SXDI: rPTableMgr.ReadSxdi( maStrm ); break; + case EXC_ID_SXVDEX: rPTableMgr.ReadSxvdex( maStrm ); break; + case EXC_ID_SXEX: rPTableMgr.ReadSxex( maStrm ); break; + case EXC_ID_SHEETEXT: rTabViewSett.ReadTabBgColor( maStrm, rPal ); break; + case EXC_ID_SXVIEWEX9: rPTableMgr.ReadSxViewEx9( maStrm ); break; + case EXC_ID_SXADDL: rPTableMgr.ReadSxAddl( maStrm ); break; } - break; - - default:; } + break; + + default:; } } - catch (const SvStreamEOFException&) - { - SAL_WARN("sc", "EOF"); - eLastErr = ERRCODE_IO_CANTREAD; - } if( eLastErr == ERRCODE_NONE ) { diff --git a/sc/source/filter/excel/xistream.cxx b/sc/source/filter/excel/xistream.cxx index 0736a55d152f..f9c79325f39f 100644 --- a/sc/source/filter/excel/xistream.cxx +++ b/sc/source/filter/excel/xistream.cxx @@ -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; } diff --git a/sc/source/filter/excel/xltoolbar.cxx b/sc/source/filter/excel/xltoolbar.cxx index d6b8dbac8704..87f22f630843 100644 --- a/sc/source/filter/excel/xltoolbar.cxx +++ b/sc/source/filter/excel/xltoolbar.cxx @@ -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) diff --git a/sc/source/filter/lotus/lotread.cxx b/sc/source/filter/lotus/lotread.cxx index 0fa8a1fb63d1..f28a783849fb 100644 --- a/sc/source/filter/lotus/lotread.cxx +++ b/sc/source/filter/lotus/lotread.cxx @@ -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: */ diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx index af3544967711..3e6756767eac 100644 --- a/sc/source/filter/qpro/qpro.cxx +++ b/sc/source/filter/qpro/qpro.cxx @@ -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; } diff --git a/sd/qa/unit/data/ppt/fail/hang-14.ppt b/sd/qa/unit/data/ppt/fail/hang-14.ppt deleted file mode 100644 index 8dd397bb3649..000000000000 Binary files a/sd/qa/unit/data/ppt/fail/hang-14.ppt and /dev/null differ diff --git a/sd/qa/unit/data/ppt/fail/hang-21.ppt b/sd/qa/unit/data/ppt/fail/hang-21.ppt deleted file mode 100644 index 99cf49f8d1e5..000000000000 Binary files a/sd/qa/unit/data/ppt/fail/hang-21.ppt and /dev/null differ diff --git a/sd/qa/unit/data/ppt/fail/ofz14989-1.ppt b/sd/qa/unit/data/ppt/fail/ofz14989-1.ppt deleted file mode 100644 index b470ebecdb49..000000000000 Binary files a/sd/qa/unit/data/ppt/fail/ofz14989-1.ppt and /dev/null differ diff --git a/sd/qa/unit/data/ppt/pass/hang-14.ppt b/sd/qa/unit/data/ppt/pass/hang-14.ppt new file mode 100644 index 000000000000..8dd397bb3649 Binary files /dev/null and b/sd/qa/unit/data/ppt/pass/hang-14.ppt differ diff --git a/sd/qa/unit/data/ppt/pass/hang-21.ppt b/sd/qa/unit/data/ppt/pass/hang-21.ppt new file mode 100644 index 000000000000..99cf49f8d1e5 Binary files /dev/null and b/sd/qa/unit/data/ppt/pass/hang-21.ppt differ diff --git a/sd/qa/unit/data/ppt/pass/ofz14989-1.ppt b/sd/qa/unit/data/ppt/pass/ofz14989-1.ppt new file mode 100644 index 000000000000..b470ebecdb49 Binary files /dev/null and b/sd/qa/unit/data/ppt/pass/ofz14989-1.ppt differ diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx index f9831e0969e7..9bead8c515c1 100644 --- a/sd/source/filter/ppt/pptin.cxx +++ b/sd/source/filter/ppt/pptin.cxx @@ -2773,15 +2773,8 @@ ImplSdPPTImport::ReadFormControl( tools::SvRef& rSrc1, css::uno::Ref extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool ImportPPT( SdDrawDocument* pDocument, SvStream& rDocStream, SotStorage& rStorage, SfxMedium& rMedium ) { - try - { - std::unique_ptr pImport( new SdPPTImport( pDocument, rDocStream, rStorage, rMedium )); - return pImport->Import(); - } - catch(SvStreamEOFException&) - { - return false; - } + std::unique_ptr pImport( new SdPPTImport( pDocument, rDocStream, rStorage, rMedium )); + return pImport->Import(); } extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportPPT(SvStream &rStream) diff --git a/sfx2/source/doc/oleprops.cxx b/sfx2/source/doc/oleprops.cxx index a9e2b9b8a874..ee1927522e05 100644 --- a/sfx2/source/doc/oleprops.cxx +++ b/sfx2/source/doc/oleprops.cxx @@ -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 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 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) { - 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; } } diff --git a/sot/source/sdstor/stg.cxx b/sot/source/sdstor/stg.cxx index 73a19719f86e..398e3fdb53d1 100644 --- a/sot/source/sdstor/stg.cxx +++ b/sot/source/sdstor/stg.cxx @@ -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(); diff --git a/sot/source/sdstor/stgelem.cxx b/sot/source/sdstor/stgelem.cxx index 3b946f4c77b4..ff41d8d70f9c 100644 --- a/sot/source/sdstor/stgelem.cxx +++ b/sot/source/sdstor/stgelem.cxx @@ -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()) diff --git a/sot/source/sdstor/stgio.cxx b/sot/source/sdstor/stgio.cxx index c4294924697a..7d90c490c634 100644 --- a/sot/source/sdstor/stgio.cxx +++ b/sot/source/sdstor/stgio.cxx @@ -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(); diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx index 72c3bed94edb..43602a491d03 100644 --- a/starmath/source/mathtype.cxx +++ b/starmath/source/mathtype.cxx @@ -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 ); - - if (nVersion > 3) // allow only supported versions of MathType to be parsed - return false; + 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; + + 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; } diff --git a/sw/qa/core/data/ww5/fail/crash-1.doc b/sw/qa/core/data/ww5/fail/crash-1.doc deleted file mode 100644 index 5b94b9a5584b..000000000000 Binary files a/sw/qa/core/data/ww5/fail/crash-1.doc and /dev/null differ diff --git a/sw/qa/core/data/ww5/fail/hang-1.doc b/sw/qa/core/data/ww5/fail/hang-1.doc deleted file mode 100644 index 603372406e18..000000000000 Binary files a/sw/qa/core/data/ww5/fail/hang-1.doc and /dev/null differ diff --git a/sw/qa/core/data/ww5/fail/hang-3.doc b/sw/qa/core/data/ww5/fail/hang-3.doc deleted file mode 100644 index 14fbaa60637d..000000000000 Binary files a/sw/qa/core/data/ww5/fail/hang-3.doc and /dev/null differ diff --git a/sw/qa/core/data/ww5/pass/crash-1.doc b/sw/qa/core/data/ww5/pass/crash-1.doc new file mode 100644 index 000000000000..5b94b9a5584b Binary files /dev/null and b/sw/qa/core/data/ww5/pass/crash-1.doc differ diff --git a/sw/qa/core/data/ww5/pass/hang-1.doc b/sw/qa/core/data/ww5/pass/hang-1.doc new file mode 100644 index 000000000000..603372406e18 Binary files /dev/null and b/sw/qa/core/data/ww5/pass/hang-1.doc differ diff --git a/sw/qa/core/data/ww5/pass/hang-3.doc b/sw/qa/core/data/ww5/pass/hang-3.doc new file mode 100644 index 000000000000..14fbaa60637d Binary files /dev/null and b/sw/qa/core/data/ww5/pass/hang-3.doc differ diff --git a/sw/qa/core/data/ww6/fail/crash-3.doc b/sw/qa/core/data/ww6/fail/crash-3.doc deleted file mode 100644 index 8646b7ac5d34..000000000000 Binary files a/sw/qa/core/data/ww6/fail/crash-3.doc and /dev/null differ diff --git a/sw/qa/core/data/ww6/pass/crash-3.doc b/sw/qa/core/data/ww6/pass/crash-3.doc new file mode 100644 index 000000000000..8646b7ac5d34 Binary files /dev/null and b/sw/qa/core/data/ww6/pass/crash-3.doc differ diff --git a/sw/qa/core/data/ww8/fail/CVE-2008-4841-1.doc b/sw/qa/core/data/ww8/fail/CVE-2008-4841-1.doc deleted file mode 100644 index 37b994534167..000000000000 Binary files a/sw/qa/core/data/ww8/fail/CVE-2008-4841-1.doc and /dev/null differ diff --git a/sw/qa/core/data/ww8/fail/CVE-2009-0259-1.doc b/sw/qa/core/data/ww8/fail/CVE-2009-0259-1.doc deleted file mode 100644 index 37b994534167..000000000000 Binary files a/sw/qa/core/data/ww8/fail/CVE-2009-0259-1.doc and /dev/null differ diff --git a/sw/qa/core/data/ww8/fail/CVE-2010-3454-1.doc b/sw/qa/core/data/ww8/fail/CVE-2010-3454-1.doc deleted file mode 100644 index 9bbadc09476c..000000000000 Binary files a/sw/qa/core/data/ww8/fail/CVE-2010-3454-1.doc and /dev/null differ diff --git a/sw/qa/core/data/ww8/fail/CVE-2014-6356-1.doc b/sw/qa/core/data/ww8/fail/CVE-2014-6356-1.doc deleted file mode 100644 index a28729498ca6..000000000000 Binary files a/sw/qa/core/data/ww8/fail/CVE-2014-6356-1.doc and /dev/null differ diff --git a/sw/qa/core/data/ww8/fail/CVE-2015-0064-1.doc b/sw/qa/core/data/ww8/fail/CVE-2015-0064-1.doc deleted file mode 100644 index 21263d591b3a..000000000000 Binary files a/sw/qa/core/data/ww8/fail/CVE-2015-0064-1.doc and /dev/null differ diff --git a/sw/qa/core/data/ww8/fail/EDB-14092-1.doc b/sw/qa/core/data/ww8/fail/EDB-14092-1.doc deleted file mode 100644 index a9caf97f72b7..000000000000 Binary files a/sw/qa/core/data/ww8/fail/EDB-14092-1.doc and /dev/null differ diff --git a/sw/qa/core/data/ww8/fail/ofz18534-1.doc b/sw/qa/core/data/ww8/fail/ofz18534-1.doc deleted file mode 100644 index 6b50fdd6d419..000000000000 Binary files a/sw/qa/core/data/ww8/fail/ofz18534-1.doc and /dev/null differ diff --git a/sw/qa/core/data/ww8/fail/ofz7322-1.doc b/sw/qa/core/data/ww8/fail/ofz7322-1.doc deleted file mode 100644 index 5f4858849acf..000000000000 Binary files a/sw/qa/core/data/ww8/fail/ofz7322-1.doc and /dev/null differ diff --git a/sw/qa/core/data/ww8/pass/CVE-2008-4841-1.doc b/sw/qa/core/data/ww8/pass/CVE-2008-4841-1.doc new file mode 100644 index 000000000000..37b994534167 Binary files /dev/null and b/sw/qa/core/data/ww8/pass/CVE-2008-4841-1.doc differ diff --git a/sw/qa/core/data/ww8/pass/CVE-2009-0259-1.doc b/sw/qa/core/data/ww8/pass/CVE-2009-0259-1.doc new file mode 100644 index 000000000000..37b994534167 Binary files /dev/null and b/sw/qa/core/data/ww8/pass/CVE-2009-0259-1.doc differ diff --git a/sw/qa/core/data/ww8/pass/CVE-2010-3454-1.doc b/sw/qa/core/data/ww8/pass/CVE-2010-3454-1.doc new file mode 100644 index 000000000000..9bbadc09476c Binary files /dev/null and b/sw/qa/core/data/ww8/pass/CVE-2010-3454-1.doc differ diff --git a/sw/qa/core/data/ww8/pass/CVE-2014-6356-1.doc b/sw/qa/core/data/ww8/pass/CVE-2014-6356-1.doc new file mode 100644 index 000000000000..a28729498ca6 Binary files /dev/null and b/sw/qa/core/data/ww8/pass/CVE-2014-6356-1.doc differ diff --git a/sw/qa/core/data/ww8/pass/CVE-2015-0064-1.doc b/sw/qa/core/data/ww8/pass/CVE-2015-0064-1.doc new file mode 100644 index 000000000000..21263d591b3a Binary files /dev/null and b/sw/qa/core/data/ww8/pass/CVE-2015-0064-1.doc differ diff --git a/sw/qa/core/data/ww8/pass/EDB-14092-1.doc b/sw/qa/core/data/ww8/pass/EDB-14092-1.doc new file mode 100644 index 000000000000..a9caf97f72b7 Binary files /dev/null and b/sw/qa/core/data/ww8/pass/EDB-14092-1.doc differ diff --git a/sw/qa/core/data/ww8/pass/ofz18534-1.doc b/sw/qa/core/data/ww8/pass/ofz18534-1.doc new file mode 100644 index 000000000000..6b50fdd6d419 Binary files /dev/null and b/sw/qa/core/data/ww8/pass/ofz18534-1.doc differ diff --git a/sw/qa/core/data/ww8/pass/ofz7322-1.doc b/sw/qa/core/data/ww8/pass/ofz7322-1.doc new file mode 100644 index 000000000000..5f4858849acf Binary files /dev/null and b/sw/qa/core/data/ww8/pass/ofz7322-1.doc differ diff --git a/sw/source/filter/html/htmlreqifreader.cxx b/sw/source/filter/html/htmlreqifreader.cxx index 09ba240c13ff..d656f51bc0cb 100644 --- a/sw/source/filter/html/htmlreqifreader.cxx +++ b/sw/source/filter/html/htmlreqifreader.cxx @@ -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 pStorage = new SotStorage(rOle2); - tools::SvRef 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 aBuffer(nSize); - xOle2Presentation->ReadBytes(aBuffer.data(), aBuffer.size()); - rPresentationData.WriteBytes(aBuffer.data(), aBuffer.size()); + tools::SvRef pStorage = new SotStorage(rOle2); + tools::SvRef 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; - return true; - } - catch (SvStreamEOFException&) - { + // 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 aBuffer(nSize); + xOle2Presentation->ReadBytes(aBuffer.data(), aBuffer.size()); + rPresentationData.WriteBytes(aBuffer.data(), aBuffer.size()); + + return true; } /** diff --git a/tools/qa/cppunit/test_stream.cxx b/tools/qa/cppunit/test_stream.cxx index b58d1f07aaa5..d8e4d1ef71e1 100644 --- a/tools/qa/cppunit/test_stream.cxx +++ b/tools/qa/cppunit/test_stream.cxx @@ -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(0x1122), tools_b); + iss.clear(); iss.seekg(0); CPPUNIT_ASSERT(iss.good()); diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 0feae91ece83..f807a56cf52f 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -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: */ diff --git a/vcl/qa/cppunit/graphicfilter/data/png/fail/invalid-chunk.png b/vcl/qa/cppunit/graphicfilter/data/png/fail/invalid-chunk.png deleted file mode 100644 index 1c45c7689ec9..000000000000 Binary files a/vcl/qa/cppunit/graphicfilter/data/png/fail/invalid-chunk.png and /dev/null differ diff --git a/vcl/qa/cppunit/graphicfilter/data/png/pass/invalid-chunk.png b/vcl/qa/cppunit/graphicfilter/data/png/pass/invalid-chunk.png new file mode 100644 index 000000000000..1c45c7689ec9 Binary files /dev/null and b/vcl/qa/cppunit/graphicfilter/data/png/pass/invalid-chunk.png differ diff --git a/vcl/qa/cppunit/graphicfilter/data/svm/fail/leak-1.svm b/vcl/qa/cppunit/graphicfilter/data/svm/fail/leak-1.svm deleted file mode 100644 index 14dbea080936..000000000000 Binary files a/vcl/qa/cppunit/graphicfilter/data/svm/fail/leak-1.svm and /dev/null differ diff --git a/vcl/qa/cppunit/graphicfilter/data/svm/pass/leak-1.svm b/vcl/qa/cppunit/graphicfilter/data/svm/pass/leak-1.svm new file mode 100644 index 000000000000..14dbea080936 Binary files /dev/null and b/vcl/qa/cppunit/graphicfilter/data/svm/pass/leak-1.svm differ diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx index 08f821d37ac9..bb5bf5e94fb0 100644 --- a/vcl/source/bitmap/dibtools.cxx +++ b/vcl/source/bitmap/dibtools.cxx @@ -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) diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 36290a229f36..d6b1f9e5777a 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -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 { diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 987948917536..a40e54002cff 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -108,75 +108,70 @@ bool GraphicDescriptor::ImpDetectBMP( SvStream& rStm, bool bExtendedInfo ) sal_uInt16 nTemp16 = 0; bool bRet = false; sal_Int32 nStmPos = rStm.Tell(); - try + + rStm.SetEndian( SvStreamEndian::LITTLE ); + rStm.ReadUInt16( nTemp16 ); + + // OS/2-BitmapArray + if ( nTemp16 == 0x4142 ) { - rStm.SetEndian( SvStreamEndian::LITTLE ); + rStm.SeekRel( 0x0c ); rStm.ReadUInt16( nTemp16 ); + } - // OS/2-BitmapArray - if ( nTemp16 == 0x4142 ) - { - rStm.SeekRel( 0x0c ); - rStm.ReadUInt16( nTemp16 ); - } + // Bitmap + if ( nTemp16 == 0x4d42 ) + { + nFormat = GraphicFileFormat::BMP; + bRet = true; - // Bitmap - if ( nTemp16 == 0x4d42 ) + if ( bExtendedInfo ) { - nFormat = GraphicFileFormat::BMP; - bRet = true; + sal_uInt32 nTemp32; + sal_uInt32 nCompression; - if ( bExtendedInfo ) - { - sal_uInt32 nTemp32; - sal_uInt32 nCompression; - - // up to first info - rStm.SeekRel( 0x10 ); + // up to first info + rStm.SeekRel( 0x10 ); - // Pixel width - rStm.ReadUInt32( nTemp32 ); - aPixSize.setWidth( nTemp32 ); + // Pixel width + rStm.ReadUInt32( nTemp32 ); + aPixSize.setWidth( nTemp32 ); - // Pixel height - rStm.ReadUInt32( nTemp32 ); - aPixSize.setHeight( nTemp32 ); + // Pixel height + rStm.ReadUInt32( nTemp32 ); + aPixSize.setHeight( nTemp32 ); - // Planes - rStm.ReadUInt16( nTemp16 ); - nPlanes = nTemp16; + // Planes + rStm.ReadUInt16( nTemp16 ); + nPlanes = nTemp16; - // BitCount - rStm.ReadUInt16( nTemp16 ); - nBitsPerPixel = nTemp16; + // BitCount + rStm.ReadUInt16( nTemp16 ); + nBitsPerPixel = nTemp16; - // Compression - rStm.ReadUInt32( nTemp32 ); - nCompression = nTemp32; + // Compression + rStm.ReadUInt32( nTemp32 ); + nCompression = nTemp32; - // logical width - rStm.SeekRel( 4 ); - rStm.ReadUInt32( nTemp32 ); - if ( nTemp32 ) - aLogSize.setWidth( ( aPixSize.Width() * 100000 ) / nTemp32 ); + // logical width + rStm.SeekRel( 4 ); + rStm.ReadUInt32( nTemp32 ); + if ( nTemp32 ) + aLogSize.setWidth( ( aPixSize.Width() * 100000 ) / nTemp32 ); - // logical height - rStm.ReadUInt32( nTemp32 ); - if ( nTemp32 ) - aLogSize.setHeight( ( aPixSize.Height() * 100000 ) / nTemp32 ); + // logical height + rStm.ReadUInt32( nTemp32 ); + if ( nTemp32 ) + aLogSize.setHeight( ( aPixSize.Height() * 100000 ) / nTemp32 ); - // further validation, check for rational values - if ( ( nBitsPerPixel > 24 ) || ( nCompression > 3 ) ) - { - nFormat = GraphicFileFormat::NOT; - bRet = false; - } + // further validation, check for rational values + if ( ( nBitsPerPixel > 24 ) || ( nCompression > 3 ) ) + { + nFormat = GraphicFileFormat::NOT; + bRet = false; } } } - catch(SvStreamEOFException&) - { - } rStm.Seek( nStmPos ); return bRet; } @@ -188,42 +183,36 @@ bool GraphicDescriptor::ImpDetectGIF( SvStream& rStm, bool bExtendedInfo ) sal_Int32 nStmPos = rStm.Tell(); rStm.SetEndian( SvStreamEndian::LITTLE ); - try - { - rStm.ReadUInt32( n32 ); + rStm.ReadUInt32( n32 ); - if ( n32 == 0x38464947 ) + if ( n32 == 0x38464947 ) + { + sal_uInt16 n16 = 0; + rStm.ReadUInt16( n16 ); + if ( ( n16 == 0x6137 ) || ( n16 == 0x6139 ) ) { - sal_uInt16 n16 = 0; - rStm.ReadUInt16( n16 ); - if ( ( n16 == 0x6137 ) || ( n16 == 0x6139 ) ) - { - nFormat = GraphicFileFormat::GIF; + nFormat = GraphicFileFormat::GIF; + bRet = true; - if ( bExtendedInfo ) - { - sal_uInt16 nTemp16 = 0; - sal_uInt8 cByte = 0; + if ( bExtendedInfo ) + { + sal_uInt16 nTemp16 = 0; + sal_uInt8 cByte = 0; - // Pixel width - rStm.ReadUInt16( nTemp16 ); - aPixSize.setWidth( nTemp16 ); + // Pixel width + rStm.ReadUInt16( nTemp16 ); + aPixSize.setWidth( nTemp16 ); - // Pixel height - rStm.ReadUInt16( nTemp16 ); - aPixSize.setHeight( nTemp16 ); + // Pixel height + rStm.ReadUInt16( nTemp16 ); + aPixSize.setHeight( nTemp16 ); - // Bits/Pixel - rStm.ReadUChar( cByte ); - nBitsPerPixel = ( ( cByte & 112 ) >> 4 ) + 1; - } - bRet = true; + // Bits/Pixel + rStm.ReadUChar( cByte ); + nBitsPerPixel = ( ( cByte & 112 ) >> 4 ) + 1; } } } - catch(SvStreamEOFException&) - { - } rStm.Seek( nStmPos ); return bRet; } @@ -260,169 +249,163 @@ bool GraphicDescriptor::ImpDetectJPG( SvStream& rStm, bool bExtendedInfo ) bool bRet = false; sal_Int32 nStmPos = rStm.Tell(); - try - { - rStm.SetEndian( SvStreamEndian::BIG ); - rStm.ReadUInt32( nTemp32 ); + rStm.SetEndian( SvStreamEndian::BIG ); + rStm.ReadUInt32( nTemp32 ); - // compare upper 24 bits - if( 0xffd8ff00 == ( nTemp32 & 0xffffff00 ) ) - { - nFormat = GraphicFileFormat::JPG; - bRet = true; + // compare upper 24 bits + if( 0xffd8ff00 == ( nTemp32 & 0xffffff00 ) ) + { + nFormat = GraphicFileFormat::JPG; + bRet = true; - if ( bExtendedInfo ) - { - rStm.SeekRel( -2 ); + if ( bExtendedInfo ) + { + rStm.SeekRel( -2 ); - ErrCode nError( rStm.GetError() ); + ErrCode nError( rStm.GetError() ); - bool bScanFailure = false; - bool bScanFinished = false; - MapMode aMap; + bool bScanFailure = false; + bool bScanFinished = false; + MapMode aMap; - while (!bScanFailure && !bScanFinished && rStm.good()) + while (!bScanFailure && !bScanFinished && rStm.good()) + { + sal_uInt8 nMarker = ImpDetectJPG_GetNextMarker( rStm ); + switch( nMarker ) { - sal_uInt8 nMarker = ImpDetectJPG_GetNextMarker( rStm ); - switch( nMarker ) + // fixed size marker, not having a two byte length parameter + case 0xd0 : // RST0 + case 0xd1 : + case 0xd2 : + case 0xd3 : + case 0xd4 : + case 0xd5 : + case 0xd6 : + case 0xd7 : // RST7 + case 0x01 : // TEM + break; + + case 0xd8 : // SOI (has already been checked, there should not be a second one) + case 0x00 : // marker is invalid, we should stop now + bScanFailure = true; + break; + + case 0xd9 : // EOI + bScanFinished = true; + break; + + // per default we assume marker segments containing a length parameter + default : { - // fixed size marker, not having a two byte length parameter - case 0xd0 : // RST0 - case 0xd1 : - case 0xd2 : - case 0xd3 : - case 0xd4 : - case 0xd5 : - case 0xd6 : - case 0xd7 : // RST7 - case 0x01 : // TEM - break; + sal_uInt16 nLength = 0; + rStm.ReadUInt16( nLength ); - case 0xd8 : // SOI (has already been checked, there should not be a second one) - case 0x00 : // marker is invalid, we should stop now + if ( nLength < 2 ) bScanFailure = true; - break; - - case 0xd9 : // EOI - bScanFinished = true; - break; - - // per default we assume marker segments containing a length parameter - default : + else { - sal_uInt16 nLength = 0; - rStm.ReadUInt16( nLength ); - - if ( nLength < 2 ) - bScanFailure = true; - else + sal_uInt32 nNextMarkerPos = rStm.Tell() + nLength - 2; + switch( nMarker ) { - sal_uInt32 nNextMarkerPos = rStm.Tell() + nLength - 2; - switch( nMarker ) + case 0xe0 : // APP0 Marker { - case 0xe0 : // APP0 Marker + if ( nLength == 16 ) { - if ( nLength == 16 ) + sal_Int32 nIdentifier = 0; + rStm.ReadInt32( nIdentifier ); + if ( nIdentifier == 0x4a464946 ) // JFIF Identifier { - sal_Int32 nIdentifier = 0; - rStm.ReadInt32( nIdentifier ); - if ( nIdentifier == 0x4a464946 ) // JFIF Identifier + sal_uInt8 nStringTerminator = 0; + sal_uInt8 nMajorRevision = 0; + sal_uInt8 nMinorRevision = 0; + sal_uInt8 nUnits = 0; + sal_uInt16 nHorizontalResolution = 0; + sal_uInt16 nVerticalResolution = 0; + sal_uInt8 nHorzThumbnailPixelCount = 0; + sal_uInt8 nVertThumbnailPixelCount = 0; + + rStm.ReadUChar( nStringTerminator ) + .ReadUChar( nMajorRevision ) + .ReadUChar( nMinorRevision ) + .ReadUChar( nUnits ) + .ReadUInt16( nHorizontalResolution ) + .ReadUInt16( nVerticalResolution ) + .ReadUChar( nHorzThumbnailPixelCount ) + .ReadUChar( nVertThumbnailPixelCount ); + + // setting the logical size + if ( nUnits && nHorizontalResolution && nVerticalResolution ) { - sal_uInt8 nStringTerminator = 0; - sal_uInt8 nMajorRevision = 0; - sal_uInt8 nMinorRevision = 0; - sal_uInt8 nUnits = 0; - sal_uInt16 nHorizontalResolution = 0; - sal_uInt16 nVerticalResolution = 0; - sal_uInt8 nHorzThumbnailPixelCount = 0; - sal_uInt8 nVertThumbnailPixelCount = 0; - - rStm.ReadUChar( nStringTerminator ) - .ReadUChar( nMajorRevision ) - .ReadUChar( nMinorRevision ) - .ReadUChar( nUnits ) - .ReadUInt16( nHorizontalResolution ) - .ReadUInt16( nVerticalResolution ) - .ReadUChar( nHorzThumbnailPixelCount ) - .ReadUChar( nVertThumbnailPixelCount ); - - // setting the logical size - if ( nUnits && nHorizontalResolution && nVerticalResolution ) - { - aMap.SetMapUnit( nUnits == 1 ? MapUnit::MapInch : MapUnit::MapCM ); - aMap.SetScaleX( Fraction( 1, nHorizontalResolution ) ); - aMap.SetScaleY( Fraction( 1, nVerticalResolution ) ); - aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap, MapMode( MapUnit::Map100thMM ) ); - } + aMap.SetMapUnit( nUnits == 1 ? MapUnit::MapInch : MapUnit::MapCM ); + aMap.SetScaleX( Fraction( 1, nHorizontalResolution ) ); + aMap.SetScaleY( Fraction( 1, nVerticalResolution ) ); + aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap, MapMode( MapUnit::Map100thMM ) ); } } } - break; - - // Start of Frame Markers - case 0xc0 : // SOF0 - case 0xc1 : // SOF1 - case 0xc2 : // SOF2 - case 0xc3 : // SOF3 - case 0xc5 : // SOF5 - case 0xc6 : // SOF6 - case 0xc7 : // SOF7 - case 0xc9 : // SOF9 - case 0xca : // SOF10 - case 0xcb : // SOF11 - case 0xcd : // SOF13 - case 0xce : // SOF14 - case 0xcf : // SOF15 - { - sal_uInt8 nSamplePrecision = 0; - sal_uInt16 nNumberOfLines = 0; - sal_uInt16 nSamplesPerLine = 0; - sal_uInt8 nNumberOfImageComponents = 0; - sal_uInt8 nComponentsIdentifier = 0; - sal_uInt8 nSamplingFactor = 0; - sal_uInt8 nQuantizationTableDestinationSelector = 0; - rStm.ReadUChar( nSamplePrecision ) - .ReadUInt16( nNumberOfLines ) - .ReadUInt16( nSamplesPerLine ) - .ReadUChar( nNumberOfImageComponents ) - .ReadUChar( nComponentsIdentifier ) - .ReadUChar( nSamplingFactor ) - .ReadUChar( nQuantizationTableDestinationSelector ); - mnNumberOfImageComponents = nNumberOfImageComponents; - - // nSamplingFactor (lower nibble: vertical, - // upper nibble: horizontal) is unused - - aPixSize.setHeight( nNumberOfLines ); - aPixSize.setWidth( nSamplesPerLine ); - nBitsPerPixel = ( nNumberOfImageComponents == 3 ? 24 : nNumberOfImageComponents == 1 ? 8 : 0 ); - nPlanes = 1; - - if (aMap.GetMapUnit() != MapUnit::MapPixel) - // We already know the DPI, but the - // pixel size arrived later, so do the - // conversion again. - aLogSize = OutputDevice::LogicToLogic( - aPixSize, aMap, MapMode(MapUnit::Map100thMM)); - - bScanFinished = true; - } - break; } - rStm.Seek( nNextMarkerPos ); + break; + + // Start of Frame Markers + case 0xc0 : // SOF0 + case 0xc1 : // SOF1 + case 0xc2 : // SOF2 + case 0xc3 : // SOF3 + case 0xc5 : // SOF5 + case 0xc6 : // SOF6 + case 0xc7 : // SOF7 + case 0xc9 : // SOF9 + case 0xca : // SOF10 + case 0xcb : // SOF11 + case 0xcd : // SOF13 + case 0xce : // SOF14 + case 0xcf : // SOF15 + { + sal_uInt8 nSamplePrecision = 0; + sal_uInt16 nNumberOfLines = 0; + sal_uInt16 nSamplesPerLine = 0; + sal_uInt8 nNumberOfImageComponents = 0; + sal_uInt8 nComponentsIdentifier = 0; + sal_uInt8 nSamplingFactor = 0; + sal_uInt8 nQuantizationTableDestinationSelector = 0; + rStm.ReadUChar( nSamplePrecision ) + .ReadUInt16( nNumberOfLines ) + .ReadUInt16( nSamplesPerLine ) + .ReadUChar( nNumberOfImageComponents ) + .ReadUChar( nComponentsIdentifier ) + .ReadUChar( nSamplingFactor ) + .ReadUChar( nQuantizationTableDestinationSelector ); + mnNumberOfImageComponents = nNumberOfImageComponents; + + // nSamplingFactor (lower nibble: vertical, + // upper nibble: horizontal) is unused + + aPixSize.setHeight( nNumberOfLines ); + aPixSize.setWidth( nSamplesPerLine ); + nBitsPerPixel = ( nNumberOfImageComponents == 3 ? 24 : nNumberOfImageComponents == 1 ? 8 : 0 ); + nPlanes = 1; + + if (aMap.GetMapUnit() != MapUnit::MapPixel) + // We already know the DPI, but the + // pixel size arrived later, so do the + // conversion again. + aLogSize = OutputDevice::LogicToLogic( + aPixSize, aMap, MapMode(MapUnit::Map100thMM)); + + bScanFinished = true; + } + break; } + rStm.Seek( nNextMarkerPos ); } - break; } + break; } - rStm.SetError( nError ); } + rStm.SetError( nError ); } } - catch(SvStreamEOFException&) - { - } rStm.Seek( nStmPos ); return bRet; } @@ -432,29 +415,23 @@ bool GraphicDescriptor::ImpDetectPCD( SvStream& rStm, bool ) bool bRet = false; sal_Int32 nStmPos = rStm.Tell(); - try - { - rStm.SetEndian( SvStreamEndian::LITTLE ); + rStm.SetEndian( SvStreamEndian::LITTLE ); - sal_uInt32 nTemp32 = 0; - sal_uInt16 nTemp16 = 0; - sal_uInt8 cByte = 0; + sal_uInt32 nTemp32 = 0; + sal_uInt16 nTemp16 = 0; + sal_uInt8 cByte = 0; - rStm.SeekRel( 2048 ); - rStm.ReadUInt32( nTemp32 ); - rStm.ReadUInt16( nTemp16 ); - rStm.ReadUChar( cByte ); + rStm.SeekRel( 2048 ); + rStm.ReadUInt32( nTemp32 ); + rStm.ReadUInt16( nTemp16 ); + rStm.ReadUChar( cByte ); - if ( ( nTemp32 == 0x5f444350 ) && - ( nTemp16 == 0x5049 ) && - ( cByte == 0x49 ) ) - { - nFormat = GraphicFileFormat::PCD; - bRet = true; - } - } - catch(SvStreamEOFException&) + if ( ( nTemp32 == 0x5f444350 ) && + ( nTemp16 == 0x5049 ) && + ( cByte == 0x49 ) ) { + nFormat = GraphicFileFormat::PCD; + bRet = true; } rStm.Seek( nStmPos ); return bRet; @@ -471,73 +448,67 @@ bool GraphicDescriptor::ImpDetectPCX( SvStream& rStm ) sal_uInt8 cByte = 0; sal_Int32 nStmPos = rStm.Tell(); - try + rStm.SetEndian( SvStreamEndian::LITTLE ); + rStm.ReadUChar( cByte ); + + if ( cByte == 0x0a ) { - rStm.SetEndian( SvStreamEndian::LITTLE ); - rStm.ReadUChar( cByte ); + nFormat = GraphicFileFormat::PCX; - if ( cByte == 0x0a ) - { - nFormat = GraphicFileFormat::PCX; + rStm.SeekRel( 1 ); - rStm.SeekRel( 1 ); + // compression + rStm.ReadUChar( cByte ); - // compression + bRet = (cByte==0 || cByte ==1); + if (bRet) + { + sal_uInt16 nTemp16; + sal_uInt16 nXmin; + sal_uInt16 nXmax; + sal_uInt16 nYmin; + sal_uInt16 nYmax; + sal_uInt16 nDPIx; + sal_uInt16 nDPIy; + + // Bits/Pixel rStm.ReadUChar( cByte ); + nBitsPerPixel = cByte; - bRet = (cByte==0 || cByte ==1); - if (bRet) - { - sal_uInt16 nTemp16; - sal_uInt16 nXmin; - sal_uInt16 nXmax; - sal_uInt16 nYmin; - sal_uInt16 nYmax; - sal_uInt16 nDPIx; - sal_uInt16 nDPIy; - - // Bits/Pixel - rStm.ReadUChar( cByte ); - nBitsPerPixel = cByte; - - // image dimensions - rStm.ReadUInt16( nTemp16 ); - nXmin = nTemp16; - rStm.ReadUInt16( nTemp16 ); - nYmin = nTemp16; - rStm.ReadUInt16( nTemp16 ); - nXmax = nTemp16; - rStm.ReadUInt16( nTemp16 ); - nYmax = nTemp16; + // image dimensions + rStm.ReadUInt16( nTemp16 ); + nXmin = nTemp16; + rStm.ReadUInt16( nTemp16 ); + nYmin = nTemp16; + rStm.ReadUInt16( nTemp16 ); + nXmax = nTemp16; + rStm.ReadUInt16( nTemp16 ); + nYmax = nTemp16; - aPixSize.setWidth( nXmax - nXmin + 1 ); - aPixSize.setHeight( nYmax - nYmin + 1 ); + aPixSize.setWidth( nXmax - nXmin + 1 ); + aPixSize.setHeight( nYmax - nYmin + 1 ); - // resolution - rStm.ReadUInt16( nTemp16 ); - nDPIx = nTemp16; - rStm.ReadUInt16( nTemp16 ); - nDPIy = nTemp16; + // resolution + rStm.ReadUInt16( nTemp16 ); + nDPIx = nTemp16; + rStm.ReadUInt16( nTemp16 ); + nDPIy = nTemp16; - // set logical size - MapMode aMap( MapUnit::MapInch, Point(), - Fraction( 1, nDPIx ), Fraction( 1, nDPIy ) ); - aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap, - MapMode( MapUnit::Map100thMM ) ); + // set logical size + MapMode aMap( MapUnit::MapInch, Point(), + Fraction( 1, nDPIx ), Fraction( 1, nDPIy ) ); + aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap, + MapMode( MapUnit::Map100thMM ) ); - // number of color planes - cByte = 5; // Illegal value in case of EOF. - rStm.SeekRel( 49 ); - rStm.ReadUChar( cByte ); - nPlanes = cByte; + // number of color planes + cByte = 5; // Illegal value in case of EOF. + rStm.SeekRel( 49 ); + rStm.ReadUChar( cByte ); + nPlanes = cByte; - bRet = (nPlanes<=4); - } + bRet = (nPlanes<=4); } } - catch(SvStreamEOFException&) - { - } rStm.Seek( nStmPos ); return bRet; @@ -549,115 +520,109 @@ bool GraphicDescriptor::ImpDetectPNG( SvStream& rStm, bool bExtendedInfo ) bool bRet = false; sal_Int32 nStmPos = rStm.Tell(); - try + rStm.SetEndian( SvStreamEndian::BIG ); + rStm.ReadUInt32( nTemp32 ); + + if ( nTemp32 == 0x89504e47 ) { - rStm.SetEndian( SvStreamEndian::BIG ); rStm.ReadUInt32( nTemp32 ); - - if ( nTemp32 == 0x89504e47 ) + if ( nTemp32 == 0x0d0a1a0a ) { - rStm.ReadUInt32( nTemp32 ); - if ( nTemp32 == 0x0d0a1a0a ) - { - nFormat = GraphicFileFormat::PNG; - bRet = true; + nFormat = GraphicFileFormat::PNG; + bRet = true; - if ( bExtendedInfo ) - { - do { - sal_uInt8 cByte = 0; + if ( bExtendedInfo ) + { + do { + sal_uInt8 cByte = 0; - // IHDR-Chunk - rStm.SeekRel( 8 ); + // IHDR-Chunk + rStm.SeekRel( 8 ); - // width - rStm.ReadUInt32( nTemp32 ); - if (!rStm.good()) - break; - aPixSize.setWidth( nTemp32 ); + // width + rStm.ReadUInt32( nTemp32 ); + if (!rStm.good()) + break; + aPixSize.setWidth( nTemp32 ); - // height - rStm.ReadUInt32( nTemp32 ); - if (!rStm.good()) - break; - aPixSize.setHeight( nTemp32 ); + // height + rStm.ReadUInt32( nTemp32 ); + if (!rStm.good()) + break; + aPixSize.setHeight( nTemp32 ); - // Bits/Pixel - rStm.ReadUChar( cByte ); - if (!rStm.good()) - break; - nBitsPerPixel = cByte; + // Bits/Pixel + rStm.ReadUChar( cByte ); + if (!rStm.good()) + break; + nBitsPerPixel = cByte; - // Colour type - check whether it supports alpha values - sal_uInt8 cColType = 0; - rStm.ReadUChar( cColType ); - if (!rStm.good()) - break; - bIsAlpha = bIsTransparent = ( cColType == 4 || cColType == 6 ); + // Colour type - check whether it supports alpha values + sal_uInt8 cColType = 0; + rStm.ReadUChar( cColType ); + if (!rStm.good()) + break; + bIsAlpha = bIsTransparent = ( cColType == 4 || cColType == 6 ); - // Planes always 1; - // compression always - nPlanes = 1; + // Planes always 1; + // compression always + nPlanes = 1; - sal_uInt32 nLen32 = 0; - nTemp32 = 0; + sal_uInt32 nLen32 = 0; + nTemp32 = 0; - rStm.SeekRel( 7 ); + rStm.SeekRel( 7 ); - // read up to the start of the image - rStm.ReadUInt32( nLen32 ); - rStm.ReadUInt32( nTemp32 ); - while( ( nTemp32 != 0x49444154 ) && rStm.good() ) + // read up to the start of the image + rStm.ReadUInt32( nLen32 ); + rStm.ReadUInt32( nTemp32 ); + while( ( nTemp32 != 0x49444154 ) && rStm.good() ) + { + if ( nTemp32 == 0x70485973 ) // physical pixel dimensions { - if ( nTemp32 == 0x70485973 ) // physical pixel dimensions - { - sal_uLong nXRes; - sal_uLong nYRes; - - // horizontal resolution - nTemp32 = 0; - rStm.ReadUInt32( nTemp32 ); - nXRes = nTemp32; + sal_uLong nXRes; + sal_uLong nYRes; - // vertical resolution - nTemp32 = 0; - rStm.ReadUInt32( nTemp32 ); - nYRes = nTemp32; - - // unit - cByte = 0; - rStm.ReadUChar( cByte ); + // horizontal resolution + nTemp32 = 0; + rStm.ReadUInt32( nTemp32 ); + nXRes = nTemp32; - if ( cByte ) - { - if ( nXRes ) - aLogSize.setWidth( (aPixSize.Width() * 100000) / nXRes ); + // vertical resolution + nTemp32 = 0; + rStm.ReadUInt32( nTemp32 ); + nYRes = nTemp32; - if ( nYRes ) - aLogSize.setHeight( (aPixSize.Height() * 100000) / nYRes ); - } + // unit + cByte = 0; + rStm.ReadUChar( cByte ); - nLen32 -= 9; - } - else if ( nTemp32 == 0x74524e53 ) // transparency + if ( cByte ) { - bIsTransparent = true; - bIsAlpha = ( cColType != 0 && cColType != 2 ); + if ( nXRes ) + aLogSize.setWidth( (aPixSize.Width() * 100000) / nXRes ); + + if ( nYRes ) + aLogSize.setHeight( (aPixSize.Height() * 100000) / nYRes ); } - // skip forward to next chunk - rStm.SeekRel( 4 + nLen32 ); - rStm.ReadUInt32( nLen32 ); - rStm.ReadUInt32( nTemp32 ); + nLen32 -= 9; } - } while (false); - } + else if ( nTemp32 == 0x74524e53 ) // transparency + { + bIsTransparent = true; + bIsAlpha = ( cColType != 0 && cColType != 2 ); + } + + // skip forward to next chunk + rStm.SeekRel( 4 + nLen32 ); + rStm.ReadUInt32( nLen32 ); + rStm.ReadUInt32( nTemp32 ); + } + } while (false); } } } - catch(SvStreamEOFException&) - { - } rStm.Seek( nStmPos ); return bRet; } @@ -669,130 +634,124 @@ bool GraphicDescriptor::ImpDetectTIF( SvStream& rStm, bool bExtendedInfo ) sal_uInt8 cByte2 = 1; sal_Int32 nStmPos = rStm.Tell(); - try + rStm.ReadUChar( cByte1 ); + rStm.ReadUChar( cByte2 ); + if ( cByte1 == cByte2 ) { - rStm.ReadUChar( cByte1 ); - rStm.ReadUChar( cByte2 ); - if ( cByte1 == cByte2 ) + bool bDetectOk = false; + + if ( cByte1 == 0x49 ) + { + rStm.SetEndian( SvStreamEndian::LITTLE ); + bDetectOk = true; + } + else if ( cByte1 == 0x4d ) { - bool bDetectOk = false; + rStm.SetEndian( SvStreamEndian::BIG ); + bDetectOk = true; + } - if ( cByte1 == 0x49 ) - { - rStm.SetEndian( SvStreamEndian::LITTLE ); - bDetectOk = true; - } - else if ( cByte1 == 0x4d ) - { - rStm.SetEndian( SvStreamEndian::BIG ); - bDetectOk = true; - } + if ( bDetectOk ) + { + sal_uInt16 nTemp16 = 0; - if ( bDetectOk ) + rStm.ReadUInt16( nTemp16 ); + if ( nTemp16 == 0x2a ) { - sal_uInt16 nTemp16 = 0; + nFormat = GraphicFileFormat::TIF; + bRet = true; - rStm.ReadUInt16( nTemp16 ); - if ( nTemp16 == 0x2a ) + if ( bExtendedInfo ) { - nFormat = GraphicFileFormat::TIF; - bRet = true; + sal_uLong nCount; + sal_uLong nMax = DATA_SIZE - 48; + sal_uInt32 nTemp32 = 0; - if ( bExtendedInfo ) - { - sal_uLong nCount; - sal_uLong nMax = DATA_SIZE - 48; - sal_uInt32 nTemp32 = 0; + // Offset of the first IFD + rStm.ReadUInt32( nTemp32 ); + nCount = nTemp32 + 2; + rStm.SeekRel( nCount - 0x08 ); - // Offset of the first IFD - rStm.ReadUInt32( nTemp32 ); - nCount = nTemp32 + 2; - rStm.SeekRel( nCount - 0x08 ); + if ( nCount < nMax ) + { + bool bOk = false; - if ( nCount < nMax ) + // read tags till we find Tag256 ( Width ) + // do not read more bytes than DATA_SIZE + rStm.ReadUInt16( nTemp16 ); + while ( nTemp16 != 256 ) { - bool bOk = false; + bOk = nCount < nMax; + if ( !bOk ) + { + break; + } + rStm.SeekRel( 10 ); + rStm.ReadUInt16( nTemp16 ); + nCount += 12; + } - // read tags till we find Tag256 ( Width ) - // do not read more bytes than DATA_SIZE + if ( bOk ) + { + // width rStm.ReadUInt16( nTemp16 ); - while ( nTemp16 != 256 ) + rStm.SeekRel( 4 ); + if ( nTemp16 == 3 ) { - bOk = nCount < nMax; - if ( !bOk ) - { - break; - } - rStm.SeekRel( 10 ); rStm.ReadUInt16( nTemp16 ); - nCount += 12; + aPixSize.setWidth( nTemp16 ); + rStm.SeekRel( 2 ); + } + else + { + rStm.ReadUInt32( nTemp32 ); + aPixSize.setWidth( nTemp32 ); } - if ( bOk ) + // height + rStm.SeekRel( 2 ); + rStm.ReadUInt16( nTemp16 ); + rStm.SeekRel( 4 ); + if ( nTemp16 == 3 ) { - // width rStm.ReadUInt16( nTemp16 ); - rStm.SeekRel( 4 ); - if ( nTemp16 == 3 ) - { - rStm.ReadUInt16( nTemp16 ); - aPixSize.setWidth( nTemp16 ); - rStm.SeekRel( 2 ); - } - else - { - rStm.ReadUInt32( nTemp32 ); - aPixSize.setWidth( nTemp32 ); - } - - // height + aPixSize.setHeight( nTemp16 ); rStm.SeekRel( 2 ); - rStm.ReadUInt16( nTemp16 ); - rStm.SeekRel( 4 ); - if ( nTemp16 == 3 ) - { - rStm.ReadUInt16( nTemp16 ); - aPixSize.setHeight( nTemp16 ); - rStm.SeekRel( 2 ); - } - else - { - rStm.ReadUInt32( nTemp32 ); - aPixSize.setHeight( nTemp32 ); - } + } + else + { + rStm.ReadUInt32( nTemp32 ); + aPixSize.setHeight( nTemp32 ); + } - // Bits/Pixel + // Bits/Pixel + rStm.ReadUInt16( nTemp16 ); + if ( nTemp16 == 258 ) + { + rStm.SeekRel( 6 ); rStm.ReadUInt16( nTemp16 ); - if ( nTemp16 == 258 ) - { - rStm.SeekRel( 6 ); - rStm.ReadUInt16( nTemp16 ); - nBitsPerPixel = nTemp16; - rStm.SeekRel( 2 ); - } - else - rStm.SeekRel( -2 ); + nBitsPerPixel = nTemp16; + rStm.SeekRel( 2 ); + } + else + rStm.SeekRel( -2 ); - // compression - rStm.ReadUInt16( nTemp16 ); - if ( nTemp16 == 259 ) - { - rStm.SeekRel( 6 ); - rStm.ReadUInt16( nTemp16 ); // compression - rStm.SeekRel( 2 ); - } - else - rStm.SeekRel( -2 ); + // compression + rStm.ReadUInt16( nTemp16 ); + if ( nTemp16 == 259 ) + { + rStm.SeekRel( 6 ); + rStm.ReadUInt16( nTemp16 ); // compression + rStm.SeekRel( 2 ); } + else + rStm.SeekRel( -2 ); } } } } } } - catch(SvStreamEOFException&) - { - } rStm.Seek( nStmPos ); return bRet; } @@ -825,16 +784,10 @@ bool GraphicDescriptor::ImpDetectPBM( SvStream& rStm, bool ) else { sal_Int32 nStmPos = rStm.Tell(); - try - { - sal_uInt8 nFirst = 0, nSecond = 0; - rStm.ReadUChar( nFirst ).ReadUChar( nSecond ); - if ( nFirst == 'P' && ( ( nSecond == '1' ) || ( nSecond == '4' ) ) ) - bRet = true; - } - catch(SvStreamEOFException&) - { - } + sal_uInt8 nFirst = 0, nSecond = 0; + rStm.ReadUChar( nFirst ).ReadUChar( nSecond ); + if ( nFirst == 'P' && ( ( nSecond == '1' ) || ( nSecond == '4' ) ) ) + bRet = true; rStm.Seek( nStmPos ); } @@ -854,15 +807,9 @@ bool GraphicDescriptor::ImpDetectPGM( SvStream& rStm, bool ) { sal_uInt8 nFirst = 0, nSecond = 0; sal_Int32 nStmPos = rStm.Tell(); - try - { - rStm.ReadUChar( nFirst ).ReadUChar( nSecond ); - if ( nFirst == 'P' && ( ( nSecond == '2' ) || ( nSecond == '5' ) ) ) - bRet = true; - } - catch(SvStreamEOFException&) - { - } + rStm.ReadUChar( nFirst ).ReadUChar( nSecond ); + if ( nFirst == 'P' && ( ( nSecond == '2' ) || ( nSecond == '5' ) ) ) + bRet = true; rStm.Seek( nStmPos ); } @@ -882,15 +829,9 @@ bool GraphicDescriptor::ImpDetectPPM( SvStream& rStm, bool ) { sal_uInt8 nFirst = 0, nSecond = 0; sal_Int32 nStmPos = rStm.Tell(); - try - { - rStm.ReadUChar( nFirst ).ReadUChar( nSecond ); - if ( nFirst == 'P' && ( ( nSecond == '3' ) || ( nSecond == '6' ) ) ) - bRet = true; - } - catch(SvStreamEOFException&) - { - } + rStm.ReadUChar( nFirst ).ReadUChar( nSecond ); + if ( nFirst == 'P' && ( ( nSecond == '3' ) || ( nSecond == '6' ) ) ) + bRet = true; rStm.Seek( nStmPos ); } @@ -905,18 +846,12 @@ bool GraphicDescriptor::ImpDetectRAS( SvStream& rStm, bool ) sal_uInt32 nMagicNumber = 0; bool bRet = false; sal_Int32 nStmPos = rStm.Tell(); - try - { - rStm.SetEndian( SvStreamEndian::BIG ); - rStm.ReadUInt32( nMagicNumber ); - if ( nMagicNumber == 0x59a66a95 ) - { - nFormat = GraphicFileFormat::RAS; - bRet = true; - } - } - catch(SvStreamEOFException&) + rStm.SetEndian( SvStreamEndian::BIG ); + rStm.ReadUInt32( nMagicNumber ); + if ( nMagicNumber == 0x59a66a95 ) { + nFormat = GraphicFileFormat::RAS; + bRet = true; } rStm.Seek( nStmPos ); return bRet; @@ -937,56 +872,50 @@ bool GraphicDescriptor::ImpDetectPSD( SvStream& rStm, bool bExtendedInfo ) sal_uInt32 nMagicNumber = 0; sal_Int32 nStmPos = rStm.Tell(); - try + rStm.SetEndian( SvStreamEndian::BIG ); + rStm.ReadUInt32( nMagicNumber ); + if ( nMagicNumber == 0x38425053 ) { - rStm.SetEndian( SvStreamEndian::BIG ); - rStm.ReadUInt32( nMagicNumber ); - if ( nMagicNumber == 0x38425053 ) + sal_uInt16 nVersion = 0; + rStm.ReadUInt16( nVersion ); + if ( nVersion == 1 ) { - sal_uInt16 nVersion = 0; - rStm.ReadUInt16( nVersion ); - if ( nVersion == 1 ) + bRet = true; + if ( bExtendedInfo ) { - bRet = true; - if ( bExtendedInfo ) + sal_uInt16 nChannels = 0; + sal_uInt32 nRows = 0; + sal_uInt32 nColumns = 0; + sal_uInt16 nDepth = 0; + sal_uInt16 nMode = 0; + rStm.SeekRel( 6 ); // Pad + rStm.ReadUInt16( nChannels ).ReadUInt32( nRows ).ReadUInt32( nColumns ).ReadUInt16( nDepth ).ReadUInt16( nMode ); + if ( ( nDepth == 1 ) || ( nDepth == 8 ) || ( nDepth == 16 ) ) { - sal_uInt16 nChannels = 0; - sal_uInt32 nRows = 0; - sal_uInt32 nColumns = 0; - sal_uInt16 nDepth = 0; - sal_uInt16 nMode = 0; - rStm.SeekRel( 6 ); // Pad - rStm.ReadUInt16( nChannels ).ReadUInt32( nRows ).ReadUInt32( nColumns ).ReadUInt16( nDepth ).ReadUInt16( nMode ); - if ( ( nDepth == 1 ) || ( nDepth == 8 ) || ( nDepth == 16 ) ) + nBitsPerPixel = ( nDepth == 16 ) ? 8 : nDepth; + switch ( nChannels ) { - nBitsPerPixel = ( nDepth == 16 ) ? 8 : nDepth; - switch ( nChannels ) - { - case 4 : - case 3 : - nBitsPerPixel = 24; - [[fallthrough]]; - case 2 : - case 1 : - aPixSize.setWidth( nColumns ); - aPixSize.setHeight( nRows ); - break; - default: - bRet = false; - } + case 4 : + case 3 : + nBitsPerPixel = 24; + [[fallthrough]]; + case 2 : + case 1 : + aPixSize.setWidth( nColumns ); + aPixSize.setHeight( nRows ); + break; + default: + bRet = false; } - else - bRet = false; } + else + bRet = false; } } - - if ( bRet ) - nFormat = GraphicFileFormat::PSD; - } - catch(SvStreamEOFException&) - { } + + if ( bRet ) + nFormat = GraphicFileFormat::PSD; rStm.Seek( nStmPos ); return bRet; } @@ -999,23 +928,17 @@ bool GraphicDescriptor::ImpDetectEPS( SvStream& rStm, bool ) bool bRet = false; sal_Int32 nStmPos = rStm.Tell(); - try - { - rStm.SetEndian( SvStreamEndian::BIG ); - rStm.ReadUInt32( nFirstLong ); - rStm.SeekRel( -4 ); - rStm.ReadBytes( &nFirstBytes, 20 ); - - if ( ( nFirstLong == 0xC5D0D3C6 ) || aPathExt.startsWith( "eps" ) || - ( ImplSearchEntry( nFirstBytes, reinterpret_cast("%!PS-Adobe"), 10, 10 ) - && ImplSearchEntry( &nFirstBytes[15], reinterpret_cast("EPS"), 3, 3 ) ) ) - { - nFormat = GraphicFileFormat::EPS; - bRet = true; - } - } - catch(SvStreamEOFException&) + rStm.SetEndian( SvStreamEndian::BIG ); + rStm.ReadUInt32( nFirstLong ); + rStm.SeekRel( -4 ); + rStm.ReadBytes( &nFirstBytes, 20 ); + + if ( ( nFirstLong == 0xC5D0D3C6 ) || aPathExt.startsWith( "eps" ) || + ( ImplSearchEntry( nFirstBytes, reinterpret_cast("%!PS-Adobe"), 10, 10 ) + && ImplSearchEntry( &nFirstBytes[15], reinterpret_cast("EPS"), 3, 3 ) ) ) { + nFormat = GraphicFileFormat::EPS; + bRet = true; } rStm.Seek( nStmPos ); return bRet; @@ -1047,17 +970,11 @@ bool GraphicDescriptor::ImpDetectPCT( SvStream& rStm, bool ) else { sal_uInt64 const nStreamPos = rStm.Tell(); - try - { - sal_uInt64 const nStreamLen = rStm.remainingSize(); - if (isPCT(rStm, nStreamPos, nStreamLen)) - { - bRet = true; - nFormat = GraphicFileFormat::PCT; - } - } - catch(SvStreamEOFException&) + sal_uInt64 const nStreamLen = rStm.remainingSize(); + if (isPCT(rStm, nStreamPos, nStreamLen)) { + bRet = true; + nFormat = GraphicFileFormat::PCT; } rStm.Seek(nStreamPos); } @@ -1071,79 +988,73 @@ bool GraphicDescriptor::ImpDetectSVM( SvStream& rStm, bool bExtendedInfo ) bool bRet = false; sal_Int32 nStmPos = rStm.Tell(); - try + rStm.SetEndian( SvStreamEndian::LITTLE ); + rStm.ReadUInt32( n32 ); + if ( n32 == 0x44475653 ) { - rStm.SetEndian( SvStreamEndian::LITTLE ); - rStm.ReadUInt32( n32 ); - if ( n32 == 0x44475653 ) + sal_uInt8 cByte = 0; + rStm.ReadUChar( cByte ); + if ( cByte == 0x49 ) { - sal_uInt8 cByte = 0; - rStm.ReadUChar( cByte ); - if ( cByte == 0x49 ) + nFormat = GraphicFileFormat::SVM; + bRet = true; + + if ( bExtendedInfo ) { - nFormat = GraphicFileFormat::SVM; - bRet = true; + sal_uInt32 nTemp32; + sal_uInt16 nTemp16; - if ( bExtendedInfo ) - { - sal_uInt32 nTemp32; - sal_uInt16 nTemp16; + rStm.SeekRel( 0x04 ); - rStm.SeekRel( 0x04 ); + // width + nTemp32 = 0; + rStm.ReadUInt32( nTemp32 ); + aLogSize.setWidth( nTemp32 ); - // width - nTemp32 = 0; - rStm.ReadUInt32( nTemp32 ); - aLogSize.setWidth( nTemp32 ); + // height + nTemp32 = 0; + rStm.ReadUInt32( nTemp32 ); + aLogSize.setHeight( nTemp32 ); - // height - nTemp32 = 0; - rStm.ReadUInt32( nTemp32 ); - aLogSize.setHeight( nTemp32 ); - - // read MapUnit and determine PrefSize - nTemp16 = 0; - rStm.ReadUInt16( nTemp16 ); - aLogSize = OutputDevice::LogicToLogic( aLogSize, - MapMode( static_cast(nTemp16) ), - MapMode( MapUnit::Map100thMM ) ); - } + // read MapUnit and determine PrefSize + nTemp16 = 0; + rStm.ReadUInt16( nTemp16 ); + aLogSize = OutputDevice::LogicToLogic( aLogSize, + MapMode( static_cast(nTemp16) ), + MapMode( MapUnit::Map100thMM ) ); } } - else + } + else + { + rStm.SeekRel( -4 ); + n32 = 0; + rStm.ReadUInt32( n32 ); + + if( n32 == 0x4D4C4356 ) { - rStm.SeekRel( -4 ); - n32 = 0; - rStm.ReadUInt32( n32 ); + sal_uInt16 nTmp16 = 0; - if( n32 == 0x4D4C4356 ) - { - sal_uInt16 nTmp16 = 0; + rStm.ReadUInt16( nTmp16 ); - rStm.ReadUInt16( nTmp16 ); + if( nTmp16 == 0x4654 ) + { + nFormat = GraphicFileFormat::SVM; + bRet = true; - if( nTmp16 == 0x4654 ) + if( bExtendedInfo ) { - nFormat = GraphicFileFormat::SVM; - bRet = true; + MapMode aMapMode; - if( bExtendedInfo ) - { - MapMode aMapMode; - - rStm.SeekRel( 0x06 ); - ReadMapMode( rStm, aMapMode ); - TypeSerializer aSerializer(rStm); - aSerializer.readSize(aLogSize); - aLogSize = OutputDevice::LogicToLogic( aLogSize, aMapMode, MapMode( MapUnit::Map100thMM ) ); - } + rStm.SeekRel( 0x06 ); + ReadMapMode( rStm, aMapMode ); + TypeSerializer aSerializer(rStm); + aSerializer.readSize(aLogSize); + aLogSize = OutputDevice::LogicToLogic( aLogSize, aMapMode, MapMode( MapUnit::Map100thMM ) ); } } } } - catch(SvStreamEOFException&) - { - } rStm.Seek( nStmPos ); return bRet; } @@ -1163,50 +1074,44 @@ bool GraphicDescriptor::ImpDetectEMF( SvStream& rStm, bool bExtendedInfo ) bool bRet = false; sal_Int32 nStmPos = rStm.Tell(); - try - { - rStm.SetEndian( SvStreamEndian::LITTLE ); - rStm.ReadUInt32( nRecordType ); + rStm.SetEndian( SvStreamEndian::LITTLE ); + rStm.ReadUInt32( nRecordType ); - if ( nRecordType == 0x00000001 ) + if ( nRecordType == 0x00000001 ) + { + sal_uInt32 nHeaderSize = 0; + sal_Int32 nBoundLeft = 0, nBoundTop = 0, nBoundRight = 0, nBoundBottom = 0; + sal_Int32 nFrameLeft = 0, nFrameTop = 0, nFrameRight = 0, nFrameBottom = 0; + sal_uInt32 nSignature = 0; + + rStm.ReadUInt32( nHeaderSize ); + rStm.ReadInt32( nBoundLeft ); + rStm.ReadInt32( nBoundTop ); + rStm.ReadInt32( nBoundRight ); + rStm.ReadInt32( nBoundBottom ); + rStm.ReadInt32( nFrameLeft ); + rStm.ReadInt32( nFrameTop ); + rStm.ReadInt32( nFrameRight ); + rStm.ReadInt32( nFrameBottom ); + rStm.ReadUInt32( nSignature ); + + if ( nSignature == 0x464d4520 ) { - sal_uInt32 nHeaderSize = 0; - sal_Int32 nBoundLeft = 0, nBoundTop = 0, nBoundRight = 0, nBoundBottom = 0; - sal_Int32 nFrameLeft = 0, nFrameTop = 0, nFrameRight = 0, nFrameBottom = 0; - sal_uInt32 nSignature = 0; - - rStm.ReadUInt32( nHeaderSize ); - rStm.ReadInt32( nBoundLeft ); - rStm.ReadInt32( nBoundTop ); - rStm.ReadInt32( nBoundRight ); - rStm.ReadInt32( nBoundBottom ); - rStm.ReadInt32( nFrameLeft ); - rStm.ReadInt32( nFrameTop ); - rStm.ReadInt32( nFrameRight ); - rStm.ReadInt32( nFrameBottom ); - rStm.ReadUInt32( nSignature ); - - if ( nSignature == 0x464d4520 ) - { - nFormat = GraphicFileFormat::EMF; - bRet = true; + nFormat = GraphicFileFormat::EMF; + bRet = true; - if ( bExtendedInfo ) - { - // size in pixels - aPixSize.setWidth( nBoundRight - nBoundLeft + 1 ); - aPixSize.setHeight( nBoundBottom - nBoundTop + 1 ); + if ( bExtendedInfo ) + { + // size in pixels + aPixSize.setWidth( nBoundRight - nBoundLeft + 1 ); + aPixSize.setHeight( nBoundBottom - nBoundTop + 1 ); - // size in 0.01mm units - aLogSize.setWidth( nFrameRight - nFrameLeft + 1 ); - aLogSize.setHeight( nFrameBottom - nFrameTop + 1 ); - } + // size in 0.01mm units + aLogSize.setWidth( nFrameRight - nFrameLeft + 1 ); + aLogSize.setHeight( nFrameBottom - nFrameTop + 1 ); } } } - catch(SvStreamEOFException&) - { - } rStm.Seek( nStmPos ); return bRet; diff --git a/vcl/source/filter/itiff/itiff.cxx b/vcl/source/filter/itiff/itiff.cxx index 674b5f3656dd..21dc6a4adfe8 100644 --- a/vcl/source/filter/itiff/itiff.cxx +++ b/vcl/source/filter/itiff/itiff.cxx @@ -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; diff --git a/vcl/source/filter/png/pngread.cxx b/vcl/source/filter/png/pngread.cxx index 19a50e9ae822..8b3f777c6ac5 100644 --- a/vcl/source/filter/png/pngread.cxx +++ b/vcl/source/filter/png/pngread.cxx @@ -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() ) - { - rChunkData.aData.resize( mnChunkLen ); + // get the next chunk from the stream - sal_Int32 nBytesRead = 0; - do - { - sal_uInt8& rPtr = rChunkData.aData[nBytesRead]; - nBytesRead += mrPNGStream.ReadBytes(&rPtr, mnChunkLen - nBytesRead); - } while (nBytesRead < mnChunkLen && mrPNGStream.good()); + // 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; - 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; - } - else + 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() ) { - // the next chunk was already read - mnChunkType = (*maChunkIter).nType; - mnChunkLen = (*maChunkIter).aData.size(); - maDataIter = (*maChunkIter).aData.begin(); - } + rChunkData.aData.resize( mnChunkLen ); + + sal_Int32 nBytesRead = 0; + do + { + sal_uInt8& rPtr = rChunkData.aData[nBytesRead]; + nBytesRead += mrPNGStream.ReadBytes(&rPtr, mnChunkLen - nBytesRead); + } while (nBytesRead < mnChunkLen && mrPNGStream.good()); - ++maChunkIter; - return mnChunkType != PNGCHUNK_IEND; + 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; } - 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() diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 30db3e932bb9..794d5ca68a22 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1117,34 +1117,27 @@ bool ImpGraphic::swapInContent(SvStream& rStream) sal_Int32 nType; sal_Int32 nLength; - try - { - rStream.ReadUInt32(nId); + rStream.ReadUInt32(nId); - // check version - if (SWAP_FORMAT_ID != nId) - { - SAL_WARN("vcl", "Incompatible swap file!"); - return false; - } + // check version + if (SWAP_FORMAT_ID != nId) + { + SAL_WARN("vcl", "Incompatible swap file!"); + return false; + } - rStream.ReadInt32(nType); - rStream.ReadInt32(nLength); + rStream.ReadInt32(nType); + rStream.ReadInt32(nLength); - meType = static_cast(nType); + meType = static_cast(nType); - if (meType == GraphicType::NONE || meType == GraphicType::Default) - { - return true; - } - else - { - bRet = swapInGraphic(rStream); - } + if (meType == GraphicType::NONE || meType == GraphicType::Default) + { + return true; } - catch (const SvStreamEOFException&) + else { - SAL_WARN("vcl", "EOF"); + bRet = swapInGraphic(rStream); } return bRet; -- cgit