diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2009-10-05 15:44:04 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2009-10-05 15:44:04 -0400 |
commit | dbb2e06e642e1d4402c44569fea6d6a792eb88e4 (patch) | |
tree | 7560d6b0b755071062f22dcd785bf30eecf36238 | |
parent | 4d4be60ad4dfc84b85b0ea1d4b21b8d74212673d (diff) |
Properly encrypt zero bytes inside conditional formatting records.
* patches/dev300/apply:
* patches/dev300/calc-xls-export-encryption-condfmt-fix.diff: writing
raw zero bytes without encrypting them caused the saved xls document
to crash certain versions of Excel upon opening it. All versions of
Excel up to Excel XP (without service packs) were affected.
(n#541058)
-rw-r--r-- | patches/dev300/apply | 3 | ||||
-rw-r--r-- | patches/dev300/calc-xls-export-encryption-condfmt-fix.diff | 63 |
2 files changed, 66 insertions, 0 deletions
diff --git a/patches/dev300/apply b/patches/dev300/apply index bd960bc38..c43d6d1c5 100644 --- a/patches/dev300/apply +++ b/patches/dev300/apply @@ -3438,6 +3438,9 @@ calc-selection-protected-cells.diff, n#542024, kohei calc-general-type-auto-decimal-sc.diff, n#541973, kohei calc-general-type-auto-decimal-svtools.diff, n#541973, kohei +# Correctly encrypt zero bytes in the conditional formatting records. +calc-xls-export-encryption-condfmt-fix.diff, n#541058, kohei + [ AutoLayout ] sd-layoutcode.diff, cocofan offapi-layoutcode.diff, cocofan diff --git a/patches/dev300/calc-xls-export-encryption-condfmt-fix.diff b/patches/dev300/calc-xls-export-encryption-condfmt-fix.diff new file mode 100644 index 000000000..5f834e206 --- /dev/null +++ b/patches/dev300/calc-xls-export-encryption-condfmt-fix.diff @@ -0,0 +1,63 @@ +diff --git sc/source/filter/excel/xecontent.cxx sc/source/filter/excel/xecontent.cxx +index ae987eb..4575fca 100644 +--- sc/source/filter/excel/xecontent.cxx ++++ sc/source/filter/excel/xecontent.cxx +@@ -761,19 +761,19 @@ void XclExpCFImpl::WriteBody( XclExpStream& rStrm ) + // font used flag for underline -> 0 = used, 1 = default + sal_uInt32 nFontFlags3 = mbUnderlUsed ? 0 : EXC_CF_FONT_UNDERL; + +- rStrm.WriteZeroBytes( 64 ); ++ rStrm.WriteZeroBytesToRecord( 64 ); + rStrm << nHeight + << nStyle + << maFontData.mnWeight + << EXC_FONTESC_NONE + << maFontData.mnUnderline; +- rStrm.WriteZeroBytes( 3 ); ++ rStrm.WriteZeroBytesToRecord( 3 ); + rStrm << nColor + << sal_uInt32( 0 ) + << nFontFlags1 + << EXC_CF_FONT_ESCAPEM // escapement never used -> set the flag + << nFontFlags3; +- rStrm.WriteZeroBytes( 16 ); ++ rStrm.WriteZeroBytesToRecord( 16 ); + rStrm << sal_uInt16( 1 ); // must be 1 + } + +diff --git sc/source/filter/excel/xestream.cxx sc/source/filter/excel/xestream.cxx +index 0f8262c..2d10d80 100644 +--- sc/source/filter/excel/xestream.cxx ++++ sc/source/filter/excel/xestream.cxx +@@ -258,6 +258,17 @@ void XclExpStream::WriteZeroBytes( sal_Size nBytes ) + WriteRawZeroBytes( nBytes ); + } + ++void XclExpStream::WriteZeroBytesToRecord( sal_Size nBytes ) ++{ ++ if (!mbInRec) ++ // not in record. ++ return; ++ ++ sal_uInt8 nZero = 0; ++ for (sal_Size i = 0; i < nBytes; ++i) ++ *this << nZero; ++} ++ + sal_Size XclExpStream::CopyFromStream( SvStream& rInStrm, sal_Size nBytes ) + { + sal_Size nStrmPos = rInStrm.Tell(); +diff --git sc/source/filter/inc/xestream.hxx sc/source/filter/inc/xestream.hxx +index 84bf4ce..aaa56b2 100644 +--- sc/source/filter/inc/xestream.hxx ++++ sc/source/filter/inc/xestream.hxx +@@ -126,6 +126,9 @@ public: + sal_Size Write( const void* pData, sal_Size nBytes ); + /** Writes a sequence of nBytes zero bytes (respects slice setting). */ + void WriteZeroBytes( sal_Size nBytes ); ++ ++ void WriteZeroBytesToRecord( sal_Size nBytes ); ++ + /** Copies nBytes bytes from current position of the stream rInStrm. + @descr Omitting the second parameter means: read to end of stream. */ + sal_Size CopyFromStream( SvStream& rInStrm, sal_Size nBytes = STREAM_SEEK_TO_END ); |