sc/inc/tabprotection.hxx | 19 ++++++++++++++ sc/source/core/data/tabprotection.cxx | 44 ++++++++++++++++++++++++++++++++++ sc/source/filter/excel/xicontent.cxx | 39 +++++++++++++++++++++++++++--- sc/source/filter/inc/xicontent.hxx | 6 +++- 4 files changed, 103 insertions(+), 5 deletions(-)
New commits: commit 273195cb0a237142dd8885529688325438f27281 Author: Eike Rathke <[email protected]> Date: Thu Mar 20 13:00:48 2014 +0100 stuff Excel enhanced protection read into ScTableProtection Change-Id: I06db8f7466f5baddc55ea9cb117bb8a222de0c01 diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx index 4edbff6..bc27a29 100644 --- a/sc/source/filter/excel/xicontent.cxx +++ b/sc/source/filter/excel/xicontent.cxx @@ -74,11 +74,29 @@ const XclRef8U & XclRef8U::read( XclImpStream & rStrm ) return *this; } -ScRange XclRef8U::convertToScRange( SCTAB nTab ) +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 ======================================================== @@ -1302,8 +1320,6 @@ 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) ); @@ -1322,8 +1338,23 @@ 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); + } + // all done. now commit. - GetDoc().SetTabProtection(itr->first, pProtect.get()); + GetDoc().SetTabProtection(nTab, pProtect.get()); } } diff --git a/sc/source/filter/inc/xicontent.hxx b/sc/source/filter/inc/xicontent.hxx index 72ed76915..86142ec 100644 --- a/sc/source/filter/inc/xicontent.hxx +++ b/sc/source/filter/inc/xicontent.hxx @@ -31,6 +31,8 @@ #include <boost/ptr_container/ptr_vector.hpp> #include <boost/noncopyable.hpp> +class ScEnhancedProtection; + /* ============================================================================ Classes to import the big Excel document contents (related to several cells or globals for the document). @@ -52,7 +54,7 @@ struct XclRef8U sal_uInt16 mnCol2; const XclRef8U & read( XclImpStream & rStrm ); - ScRange convertToScRange( SCTAB nTab ); + ScRange convertToScRange( SCTAB nTab ) const; }; /** Feat ISFPROTECTION refs plus FeatProtection */ @@ -63,6 +65,8 @@ struct XclEnhancedProtection sal_uInt32 mnPasswordVerifier; OUString maTitle; ::std::vector< sal_uInt8 > maSecurityDescriptor; // raw data + + ScEnhancedProtection convertToScEnhancedProtection( SCTAB nTab ) const; }; // Shared string table ======================================================== commit 6daff4ed350b6b2493f36290a00892a9584e786f Author: Eike Rathke <[email protected]> Date: Thu Mar 20 11:23:48 2014 +0100 range list might be nil, who knows Change-Id: Iee5554f1b51db0f6dc22ccbed743ae431bb895f6 diff --git a/sc/source/core/data/tabprotection.cxx b/sc/source/core/data/tabprotection.cxx index 10eef3c..7accb27 100644 --- a/sc/source/core/data/tabprotection.cxx +++ b/sc/source/core/data/tabprotection.cxx @@ -374,7 +374,8 @@ bool ScTableProtectionImpl::updateReference( UpdateRefMode eMode, ScDocument* pD for (::std::vector<ScEnhancedProtection>::iterator it(maEnhancedProtection.begin()); it != maEnhancedProtection.end(); ++it) { - bChanged |= (*it).maRangeList->UpdateReference( eMode, pDoc, rWhere, nDx, nDy, nDz); + if ((*it).maRangeList.Is()) + bChanged |= (*it).maRangeList->UpdateReference( eMode, pDoc, rWhere, nDx, nDy, nDz); } return bChanged; } commit 9cee6a45632623d3d7e5a574128940f96d8c926b Author: Eike Rathke <[email protected]> Date: Thu Mar 20 10:16:50 2014 +0100 added ScEnhancedProtection to ScTableProtection Change-Id: Id6a444bd01873e30ea1522aaf3b951f4d5adc261 diff --git a/sc/inc/tabprotection.hxx b/sc/inc/tabprotection.hxx index 7703ffb..a32f50f 100644 --- a/sc/inc/tabprotection.hxx +++ b/sc/inc/tabprotection.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include "global.hxx" +#include "rangelst.hxx" #include <boost/shared_ptr.hpp> class ScDocument; @@ -110,6 +111,19 @@ private: ::boost::shared_ptr<ScTableProtectionImpl> mpImpl; }; +/** Container for the Excel EnhancedProtection feature. + */ +struct ScEnhancedProtection +{ + ScRangeListRef maRangeList; + sal_uInt32 mnAreserved; + sal_uInt32 mnPasswordVerifier; + OUString maTitle; + ::std::vector< sal_uInt8 > maSecurityDescriptor; // raw data + + ScEnhancedProtection() : mnAreserved(0), mnPasswordVerifier(0) {} +}; + /** sheet protection state container * * This class stores sheet's protection state: 1) whether the protection @@ -163,6 +177,11 @@ public: bool isOptionEnabled(Option eOption) const; void setOption(Option eOption, bool bEnabled); + void setEnhancedProtection( const ::std::vector< ScEnhancedProtection > & rProt ); + const ::std::vector< ScEnhancedProtection > & getEnhancedProtection() const; + bool updateReference( UpdateRefMode, ScDocument*, const ScRange& rWhere, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ); + + private: ::boost::shared_ptr<ScTableProtectionImpl> mpImpl; }; diff --git a/sc/source/core/data/tabprotection.cxx b/sc/source/core/data/tabprotection.cxx index c030d32..10eef3c 100644 --- a/sc/source/core/data/tabprotection.cxx +++ b/sc/source/core/data/tabprotection.cxx @@ -117,6 +117,10 @@ public: bool isOptionEnabled(SCSIZE nOptId) const; void setOption(SCSIZE nOptId, bool bEnabled); + void setEnhancedProtection( const ::std::vector< ScEnhancedProtection > & rProt ); + const ::std::vector< ScEnhancedProtection > & getEnhancedProtection() const; + bool updateReference( UpdateRefMode, ScDocument*, const ScRange& rWhere, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ); + private: OUString maPassText; ::com::sun::star::uno::Sequence<sal_Int8> maPassHash; @@ -125,6 +129,7 @@ private: bool mbProtected; ScPasswordHash meHash1; ScPasswordHash meHash2; + ::std::vector< ScEnhancedProtection > maEnhancedProtection; }; Sequence<sal_Int8> ScTableProtectionImpl::hashPassword(const OUString& aPassText, ScPasswordHash eHash) @@ -352,6 +357,27 @@ void ScTableProtectionImpl::setOption(SCSIZE nOptId, bool bEnabled) maOptions[nOptId] = bEnabled; } +void ScTableProtectionImpl::setEnhancedProtection( const ::std::vector< ScEnhancedProtection > & rProt ) +{ + maEnhancedProtection = rProt; +} + +const ::std::vector< ScEnhancedProtection > & ScTableProtectionImpl::getEnhancedProtection() const +{ + return maEnhancedProtection; +} + +bool ScTableProtectionImpl::updateReference( UpdateRefMode eMode, ScDocument* pDoc, + const ScRange& rWhere, SCsCOL nDx, SCsROW nDy, SCsTAB nDz ) +{ + bool bChanged = false; + for (::std::vector<ScEnhancedProtection>::iterator it(maEnhancedProtection.begin()); + it != maEnhancedProtection.end(); ++it) + { + bChanged |= (*it).maRangeList->UpdateReference( eMode, pDoc, rWhere, nDx, nDy, nDz); + } + return bChanged; +} ScDocProtection::ScDocProtection() : @@ -505,4 +531,21 @@ void ScTableProtection::setOption(Option eOption, bool bEnabled) { mpImpl->setOption(eOption, bEnabled); } + +void ScTableProtection::setEnhancedProtection( const ::std::vector< ScEnhancedProtection > & rProt ) +{ + mpImpl->setEnhancedProtection(rProt); +} + +const ::std::vector< ScEnhancedProtection > & ScTableProtection::getEnhancedProtection() const +{ + return mpImpl->getEnhancedProtection(); +} + +bool ScTableProtection::updateReference( UpdateRefMode eMode, ScDocument* pDoc, const ScRange& rWhere, + SCsCOL nDx, SCsROW nDy, SCsTAB nDz ) +{ + return mpImpl->updateReference( eMode, pDoc, rWhere, nDx, nDy, nDz); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
