sc/source/filter/excel/excimp8.cxx | 74 ++++++++++++++++++++++++++++++++++- sc/source/filter/excel/read.cxx | 3 - sc/source/filter/excel/xicontent.cxx | 37 +++++++++++------ sc/source/filter/inc/excimp8.hxx | 3 - sc/source/filter/inc/xicontent.hxx | 24 +++++++++++ sc/source/filter/inc/xlconst.hxx | 6 ++ 6 files changed, 131 insertions(+), 16 deletions(-)
New commits: commit 35494ca3b3b5ec69322a0ecc29b676c89766f608 Author: Eike Rathke <er...@redhat.com> Date: Tue Mar 18 23:36:39 2014 +0100 MS-XLS documentation uses big-endian bit diagrams ... so if it says leftmost bit 0 then test for high bit. Change-Id: I260ff09fff66918da887742b5d177715e59548c2 diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index 84174b1..c5008ef 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -367,7 +367,7 @@ void ImportExcel8::Feat( void ) aProt.mnAreserved = aIn.ReaduInt32(); aProt.mnPasswordVerifier = aIn.ReaduInt32(); aProt.maTitle = aIn.ReadUniString(); - if ((aProt.mnAreserved & 1) == 1) + if ((aProt.mnAreserved & 0x80000000) == 0x80000000) { sal_uInt32 nCbSD = aIn.ReaduInt32(); // TODO: could here be some sanity check applied to not allocate 4GB? commit 2864bcdf49e916bd532c7ba0c4e678df9dc52e8f Author: Eike Rathke <er...@redhat.com> Date: Tue Mar 18 23:06:39 2014 +0100 start reading 0x0868 FEAT enhanced protection feature Change-Id: Id38a7629ea5ed4bbb1a7d696926335ce0bdec6a6 diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index e806999..84174b1 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -187,6 +187,22 @@ public: } }; + +namespace { + +/** Future Record Type header. + @return whether read rt matches nRecordID + */ +bool readFrtHeader( XclImpStream& rStrm, sal_uInt16 nRecordID ) +{ + sal_uInt16 nRt = rStrm.ReaduInt16(); + rStrm.Ignore(10); // grbitFrt (2 bytes) and reserved (8 bytes) + return nRt == nRecordID; +} + +} + + ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) : ImportExcel( rImpData, rStrm ) { @@ -304,12 +320,12 @@ void ImportExcel8::Labelsst( void ) void ImportExcel8::FeatHdr( void ) { - aIn.Ignore(12); + if (!readFrtHeader( aIn, 0x0867)) + return; // Feature type (isf) can be EXC_ISFPROTECTION, EXC_ISFFEC2 or // EXC_ISFFACTOID. - sal_uInt16 nFeatureType(0); - aIn >> nFeatureType; + sal_uInt16 nFeatureType = aIn.ReaduInt16(); if (nFeatureType != EXC_ISFPROTECTION) // We currently only support import of enhanced protection data. return; @@ -319,6 +335,50 @@ void ImportExcel8::FeatHdr( void ) GetSheetProtectBuffer().ReadOptions( aIn, GetCurrScTab() ); } + +void ImportExcel8::Feat( void ) +{ + if (!readFrtHeader( aIn, 0x0868)) + return; + + // Feature type (isf) can be EXC_ISFPROTECTION, EXC_ISFFEC2 or + // EXC_ISFFACTOID. + sal_uInt16 nFeatureType = aIn.ReaduInt16(); + if (nFeatureType != EXC_ISFPROTECTION) + // We currently only support import of enhanced protection data. + return; + + aIn.Ignore(5); // reserved1 (1 byte) and reserved2 (4 bytes) + + sal_uInt16 nCref = aIn.ReaduInt16(); // number of ref elements + aIn.Ignore(4); // size if EXC_ISFFEC2, else 0 and to be ignored + aIn.Ignore(2); // reserved3 (2 bytes) + + XclEnhancedProtection aProt; + aProt.maRefs.reserve( nCref); + XclRef8U aRef; + for (sal_uInt16 i=0; i < nCref && aIn.IsValid(); ++i) + { + aProt.maRefs.push_back( aRef.read( aIn)); + } + + // FeatProtection structure follows in record. + + aProt.mnAreserved = aIn.ReaduInt32(); + aProt.mnPasswordVerifier = aIn.ReaduInt32(); + aProt.maTitle = aIn.ReadUniString(); + if ((aProt.mnAreserved & 1) == 1) + { + sal_uInt32 nCbSD = aIn.ReaduInt32(); + // TODO: could here be some sanity check applied to not allocate 4GB? + aProt.maSecurityDescriptor.reserve( nCbSD); + aIn.Read( &aProt.maSecurityDescriptor.front(), nCbSD); + } + + GetSheetProtectBuffer().AppendEnhancedProtection( aProt, GetCurrScTab() ); +} + + void ImportExcel8::ReadBasic( void ) { SfxObjectShell* pShell = GetDocShell(); diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx index d3a1e28..16cb97b 100644 --- a/sc/source/filter/excel/read.cxx +++ b/sc/source/filter/excel/read.cxx @@ -1143,6 +1143,7 @@ FltError ImportExcel8::Read( void ) 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; diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx index cd23adb..4edbff6 100644 --- a/sc/source/filter/excel/xicontent.cxx +++ b/sc/source/filter/excel/xicontent.cxx @@ -64,6 +64,22 @@ using ::com::sun::star::uno::Sequence; using ::std::auto_ptr; + +const XclRef8U & XclRef8U::read( XclImpStream & rStrm ) +{ + mnRow1 = rStrm.ReaduInt16(); + mnRow2 = rStrm.ReaduInt16(); + mnCol1 = rStrm.ReaduInt16(); + mnCol2 = rStrm.ReaduInt16(); + return *this; +} + +ScRange XclRef8U::convertToScRange( SCTAB nTab ) +{ + return ScRange( mnCol1, mnRow1, nTab, mnCol2, mnRow2, nTab); +} + + // Shared string table ======================================================== XclImpSst::XclImpSst( const XclImpRoot& rRoot ) : @@ -1246,6 +1262,13 @@ void XclImpSheetProtectBuffer::ReadOptions( XclImpStream& rStrm, SCTAB nTab ) pSheet->mnOptions = nOptions; } +void XclImpSheetProtectBuffer::AppendEnhancedProtection( const XclEnhancedProtection & rProt, SCTAB nTab ) +{ + Sheet* pSheet = GetSheetItem(nTab); + if (pSheet) + pSheet->maEnhancedProtections.push_back( rProt); +} + void XclImpSheetProtectBuffer::ReadPasswordHash( XclImpStream& rStrm, SCTAB nTab ) { sal_uInt16 nHash(0); @@ -1279,6 +1302,8 @@ void XclImpSheetProtectBuffer::Apply() const pProtect->setPasswordHash(aPass, PASSHASH_XL); } + // ranges the protection is applied to + // sheet protection options const sal_uInt16 nOptions = itr->second.mnOptions; pProtect->setOption( ScTableProtection::OBJECTS, (nOptions & 0x0001) ); diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx index 54a5d0f5..f0270fe 100644 --- a/sc/source/filter/inc/excimp8.hxx +++ b/sc/source/filter/inc/excimp8.hxx @@ -59,6 +59,7 @@ public: void Hlink( void ); // 0x01B8 void FeatHdr( void ); // 0x0867 + void Feat( void ); // 0x0868 virtual void EndSheet( void ); virtual void PostDocLoad( void ); diff --git a/sc/source/filter/inc/xicontent.hxx b/sc/source/filter/inc/xicontent.hxx index 4a7f102..72ed76915 100644 --- a/sc/source/filter/inc/xicontent.hxx +++ b/sc/source/filter/inc/xicontent.hxx @@ -44,6 +44,27 @@ globals for the document). - Stream decryption ============================================================================ */ +struct XclRef8U +{ + sal_uInt16 mnRow1; + sal_uInt16 mnRow2; + sal_uInt16 mnCol1; + sal_uInt16 mnCol2; + + const XclRef8U & read( XclImpStream & rStrm ); + ScRange convertToScRange( SCTAB nTab ); +}; + +/** Feat ISFPROTECTION refs plus FeatProtection */ +struct XclEnhancedProtection +{ + ::std::vector< XclRef8U > maRefs; + sal_uInt32 mnAreserved; + sal_uInt32 mnPasswordVerifier; + OUString maTitle; + ::std::vector< sal_uInt8 > maSecurityDescriptor; // raw data +}; + // Shared string table ======================================================== /** The SST (shared string table) contains all strings used in a BIFF8 file. @@ -305,6 +326,8 @@ public: void ReadOptions( XclImpStream& rStrm, SCTAB nTab ); + void AppendEnhancedProtection( const XclEnhancedProtection & rProt, SCTAB nTab ); + void ReadPasswordHash( XclImpStream& rStrm, SCTAB nTab ); void Apply() const; @@ -315,6 +338,7 @@ private: bool mbProtected; sal_uInt16 mnPasswordHash; sal_uInt16 mnOptions; + ::std::vector< XclEnhancedProtection > maEnhancedProtections; Sheet(); Sheet(const Sheet& r); commit a8f2c8c026b2d8d729b87991129ffd59781dbd56 Author: Eike Rathke <er...@redhat.com> Date: Tue Mar 18 16:54:39 2014 +0100 record 0x0867 is not only SheetProtection, generalize to FeatHdr() Change-Id: I9fe0558c013641a902ce5a95c02d37be9729fe38 diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index 2f1bf94..e806999 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -302,8 +302,20 @@ void ImportExcel8::Labelsst( void ) } -void ImportExcel8::SheetProtection( void ) +void ImportExcel8::FeatHdr( void ) { + aIn.Ignore(12); + + // Feature type (isf) can be EXC_ISFPROTECTION, EXC_ISFFEC2 or + // EXC_ISFFACTOID. + sal_uInt16 nFeatureType(0); + aIn >> nFeatureType; + if (nFeatureType != EXC_ISFPROTECTION) + // We currently only support import of enhanced protection data. + return; + + aIn.Ignore(1); // always 1 + GetSheetProtectBuffer().ReadOptions( aIn, GetCurrScTab() ); } diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx index 1b6133c..d3a1e28 100644 --- a/sc/source/filter/excel/read.cxx +++ b/sc/source/filter/excel/read.cxx @@ -1142,7 +1142,7 @@ FltError ImportExcel8::Read( void ) case EXC_ID2_ARRAY: case EXC_ID3_ARRAY: Array34(); break; // ARRAY [ 34 ] case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345 ] - case 0x0867: SheetProtection(); break; // SHEETPROTECTION + case 0x0867: FeatHdr(); break; // FEATHDR } } break; diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx index 31dd52d..cd23adb 100644 --- a/sc/source/filter/excel/xicontent.cxx +++ b/sc/source/filter/excel/xicontent.cxx @@ -1227,18 +1227,6 @@ void XclImpSheetProtectBuffer::ReadProtect( XclImpStream& rStrm, SCTAB nTab ) void XclImpSheetProtectBuffer::ReadOptions( XclImpStream& rStrm, SCTAB nTab ) { - rStrm.Ignore(12); - - // feature type can be either 2 or 4. If 2, this record stores flag for - // enhanced protection, whereas if 4 it stores flag for smart tag. - sal_uInt16 nFeatureType(0); - rStrm >> nFeatureType; - if (nFeatureType != 2) - // We currently only support import of enhanced protection data. - return; - - rStrm.Ignore(1); // always 1 - // The flag size specifies the size of bytes that follows that stores // feature data. If -1 it depends on the feature type imported earlier. // For enhanced protection data, the size is always 4. For the most xls diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx index 54441bd..54a5d0f5 100644 --- a/sc/source/filter/inc/excimp8.hxx +++ b/sc/source/filter/inc/excimp8.hxx @@ -58,7 +58,7 @@ public: void Labelsst( void ); // 0xFD void Hlink( void ); // 0x01B8 - void SheetProtection( void ); // 0x0867 + void FeatHdr( void ); // 0x0867 virtual void EndSheet( void ); virtual void PostDocLoad( void ); diff --git a/sc/source/filter/inc/xlconst.hxx b/sc/source/filter/inc/xlconst.hxx index 7798121..68943d6 100644 --- a/sc/source/filter/inc/xlconst.hxx +++ b/sc/source/filter/inc/xlconst.hxx @@ -256,7 +256,11 @@ const sal_uInt16 EXC_BORDER_MEDIUM = 35; const sal_uInt16 EXC_BORDER_THIN = 15; const sal_uInt16 EXC_BORDER_HAIR = 1; - +// SharedFeatureType enumeration +const sal_uInt16 EXC_ISFPROTECTION = 0x0002; +const sal_uInt16 EXC_ISFFEC2 = 0x0003; +const sal_uInt16 EXC_ISFFACTOID = 0x0004; +const sal_uInt16 EXC_ISFLIST = 0x0005; #endif _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits