Kaydet (Commit) 0f2414d8 authored tarafından Eike Rathke's avatar Eike Rathke

refactored to use XclRangeList and XclImpAddressConverter

Change-Id: If0455f0243aace784c704e234469709e6da4542f
üst 5ff0e274
......@@ -354,12 +354,16 @@ void ImportExcel8::Feat( void )
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)
ScEnhancedProtection aProt;
if (nCref)
{
aProt.maRefs.push_back( aRef.read( aIn));
XclRangeList aRefs;
aRefs.Read( aIn, true, nCref);
if (!aRefs.empty())
{
aProt.maRangeList = new ScRangeList;
GetAddressConverter().ConvertRangeList( *aProt.maRangeList, aRefs, GetCurrScTab(), false);
}
}
// FeatProtection structure follows in record.
......
......@@ -65,39 +65,6 @@ 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 ) const
{
return ScRange( mnCol1, mnRow1, nTab, mnCol2, mnRow2, nTab);
}
ScEnhancedProtection XclEnhancedProtection::convertToScEnhancedProtection( SCTAB nTab ) const
{
ScEnhancedProtection aProt;
if (!maRefs.empty())
{
aProt.maRangeList = new ScRangeList;
for (::std::vector<XclRef8U>::const_iterator it(maRefs.begin()), itEnd(maRefs.end()); it != itEnd; ++it)
{
aProt.maRangeList->Append( it->convertToScRange( nTab));
}
}
aProt.mnAreserved = mnAreserved;
aProt.mnPasswordVerifier = mnPasswordVerifier;
aProt.maTitle = maTitle;
aProt.maSecurityDescriptor = maSecurityDescriptor;
return aProt;
}
// Shared string table ========================================================
XclImpSst::XclImpSst( const XclImpRoot& rRoot ) :
......@@ -1280,7 +1247,7 @@ void XclImpSheetProtectBuffer::ReadOptions( XclImpStream& rStrm, SCTAB nTab )
pSheet->mnOptions = nOptions;
}
void XclImpSheetProtectBuffer::AppendEnhancedProtection( const XclEnhancedProtection & rProt, SCTAB nTab )
void XclImpSheetProtectBuffer::AppendEnhancedProtection( const ScEnhancedProtection & rProt, SCTAB nTab )
{
Sheet* pSheet = GetSheetItem(nTab);
if (pSheet)
......@@ -1338,23 +1305,11 @@ void XclImpSheetProtectBuffer::Apply() const
pProtect->setOption( ScTableProtection::PIVOT_TABLES, (nOptions & 0x2000) );
pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, (nOptions & 0x4000) );
SCTAB nTab = itr->first;
// Enhanced protection containing editable ranges and permissions.
if (!itr->second.maEnhancedProtections.empty())
{
::std::vector<ScEnhancedProtection> aProtections;
for (::std::vector<XclEnhancedProtection>::const_iterator
it(itr->second.maEnhancedProtections.begin()), itEnd(itr->second.maEnhancedProtections.end());
it != itEnd; ++it)
{
aProtections.push_back( it->convertToScEnhancedProtection( nTab));
}
pProtect->setEnhancedProtection( aProtections);
}
pProtect->setEnhancedProtection( itr->second.maEnhancedProtections);
// all done. now commit.
GetDoc().SetTabProtection(nTab, pProtect.get());
GetDoc().SetTabProtection(itr->first, pProtect.get());
}
}
......
......@@ -93,10 +93,13 @@ XclRange XclRangeList::GetEnclosingRange() const
return aXclRange;
}
void XclRangeList::Read( XclImpStream& rStrm, bool bCol16Bit )
void XclRangeList::Read( XclImpStream& rStrm, bool bCol16Bit, sal_uInt16 nRefs )
{
sal_uInt16 nCount;
rStrm >> nCount;
if (nRefs)
nCount = nRefs;
else
rStrm >> nCount;
size_t nOldSize = size();
resize( nOldSize + nCount );
for( iterator aIt = begin() + nOldSize; rStrm.IsValid() && (nCount > 0); --nCount, ++aIt )
......
......@@ -26,13 +26,12 @@
#include "xistring.hxx"
#include "xiroot.hxx"
#include "validat.hxx"
#include "tabprotection.hxx"
#include <map>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/noncopyable.hpp>
struct ScEnhancedProtection;
/* ============================================================================
Classes to import the big Excel document contents (related to several cells or
globals for the document).
......@@ -46,29 +45,6 @@ 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 ) const;
};
/** 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
ScEnhancedProtection convertToScEnhancedProtection( SCTAB nTab ) const;
};
// Shared string table ========================================================
/** The SST (shared string table) contains all strings used in a BIFF8 file.
......@@ -330,7 +306,7 @@ public:
void ReadOptions( XclImpStream& rStrm, SCTAB nTab );
void AppendEnhancedProtection( const XclEnhancedProtection & rProt, SCTAB nTab );
void AppendEnhancedProtection( const ScEnhancedProtection & rProt, SCTAB nTab );
void ReadPasswordHash( XclImpStream& rStrm, SCTAB nTab );
......@@ -342,7 +318,7 @@ private:
bool mbProtected;
sal_uInt16 mnPasswordHash;
sal_uInt16 mnOptions;
::std::vector< XclEnhancedProtection > maEnhancedProtections;
::std::vector< ScEnhancedProtection > maEnhancedProtections;
Sheet();
Sheet(const Sheet& r);
......
......@@ -126,7 +126,7 @@ public:
XclRange GetEnclosingRange() const;
void Read( XclImpStream& rStrm, bool bCol16Bit = true );
void Read( XclImpStream& rStrm, bool bCol16Bit = true, sal_uInt16 nRefs = 0 );
void Write( XclExpStream& rStrm, bool bCol16Bit = true ) const;
void WriteSubList( XclExpStream& rStrm,
size_t nBegin, size_t nCount, bool bCol16Bit = true ) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment