sc/source/filter/inc/worksheetsettings.hxx | 7 +++++ sc/source/filter/oox/worksheetfragment.cxx | 8 +++++ sc/source/filter/oox/worksheetsettings.cxx | 39 +++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+)
New commits: commit 477050b3c00038883d03c979a150fdb720809c1b Author: Eike Rathke <er...@redhat.com> Date: Tue Apr 8 12:33:04 2014 +0200 read title/name first to easier spot and identify ranges Change-Id: I62befc64e833c6b28688bac1548f7b56bd001402 diff --git a/sc/source/filter/oox/worksheetsettings.cxx b/sc/source/filter/oox/worksheetsettings.cxx index a5f8634..01804dc 100644 --- a/sc/source/filter/oox/worksheetsettings.cxx +++ b/sc/source/filter/oox/worksheetsettings.cxx @@ -137,6 +137,7 @@ void WorksheetSettings::importProtectedRanges( const AttributeList& rAttribs ) void WorksheetSettings::importProtectedRange( const AttributeList& rAttribs ) { ScEnhancedProtection aProt; + aProt.maTitle = rAttribs.getString( XML_name, OUString()); /* XXX ECMA-376/OOXML XMLSchema and ISO/IEC 29500 say 'securityDescriptor' * would be an element, but Excel2013 stores it as attribute. */ aProt.maSecurityDescriptorXML = rAttribs.getString( XML_securityDescriptor, OUString()); @@ -145,7 +146,6 @@ void WorksheetSettings::importProtectedRange( const AttributeList& rAttribs ) * similar to BIFF. OOXML XMLschema and ISO/IEC 29500 instead define * 'algorithmName', 'hashValue', 'saltValue' and 'spinCount'. */ aProt.mnPasswordVerifier = rAttribs.getIntegerHex( XML_password, 0); - aProt.maTitle = rAttribs.getString( XML_name, OUString()); OUString aRefs( rAttribs.getString( XML_sqref, OUString())); if (!aRefs.isEmpty()) { commit 40a61d93ade494fa98c23a9fd8776c8dadf8f30f Author: Eike Rathke <er...@redhat.com> Date: Tue Apr 8 12:27:15 2014 +0200 read protectedRanges and protectedRange elements from OOXML Change-Id: I3f62deb1ee9adeda5afaf5dd13cbe1cabff0805c diff --git a/sc/source/filter/inc/worksheetsettings.hxx b/sc/source/filter/inc/worksheetsettings.hxx index 02877c7..274f670 100644 --- a/sc/source/filter/inc/worksheetsettings.hxx +++ b/sc/source/filter/inc/worksheetsettings.hxx @@ -22,6 +22,7 @@ #include "richstring.hxx" #include "worksheethelper.hxx" +#include "tabprotection.hxx" namespace oox { namespace xls { @@ -60,6 +61,8 @@ struct SheetProtectionModel bool mbPivotTables; /// True = pivot tables locked. bool mbSelectUnlocked; /// True = select unlocked cells locked. + ::std::vector< ScEnhancedProtection > maEnhancedProtections; + explicit SheetProtectionModel(); }; @@ -78,6 +81,10 @@ public: void importOutlinePr( const AttributeList& rAttribs ); /** Imports protection settings from the sheetProtection element. */ void importSheetProtection( const AttributeList& rAttribs ); + /** Imports enhanced protection settings from the protectedRanges element. */ + void importProtectedRanges( const AttributeList& rAttribs ); + /** Imports enhanced protection settings from the protectedRange element. */ + void importProtectedRange( const AttributeList& rAttribs ); /** Imports protection settings from the sheetProtection element of a chart sheet. */ void importChartProtection( const AttributeList& rAttribs ); /** Imports phonetic settings from the phoneticPr element. */ diff --git a/sc/source/filter/oox/worksheetfragment.cxx b/sc/source/filter/oox/worksheetfragment.cxx index 05f8b8c..6a37532 100644 --- a/sc/source/filter/oox/worksheetfragment.cxx +++ b/sc/source/filter/oox/worksheetfragment.cxx @@ -245,6 +245,7 @@ ContextHandlerRef WorksheetFragment::onCreateContext( sal_Int32 nElement, const case XLS_TOKEN( dimension ): importDimension( rAttribs ); break; case XLS_TOKEN( sheetFormatPr ): importSheetFormatPr( rAttribs ); break; case XLS_TOKEN( sheetProtection ): getWorksheetSettings().importSheetProtection( rAttribs ); break; + case XLS_TOKEN( protectedRanges ): getWorksheetSettings().importProtectedRanges( rAttribs ); return this; case XLS_TOKEN( phoneticPr ): getWorksheetSettings().importPhoneticPr( rAttribs ); break; case XLS_TOKEN( printOptions ): getPageSettings().importPrintOptions( rAttribs ); break; case XLS_TOKEN( pageMargins ): getPageSettings().importPageMargins( rAttribs ); break; @@ -295,6 +296,13 @@ ContextHandlerRef WorksheetFragment::onCreateContext( sal_Int32 nElement, const if( nElement == XLS_TOKEN( brk ) ) importBrk( rAttribs, false ); break; + case XLS_TOKEN( protectedRanges ): + switch( nElement ) + { + case XLS_TOKEN( protectedRange ): getWorksheetSettings().importProtectedRange( rAttribs ); return this; + } + break; + case XLS_TOKEN( headerFooter ): switch( nElement ) { diff --git a/sc/source/filter/oox/worksheetsettings.cxx b/sc/source/filter/oox/worksheetsettings.cxx index e58b41d..a5f8634 100644 --- a/sc/source/filter/oox/worksheetsettings.cxx +++ b/sc/source/filter/oox/worksheetsettings.cxx @@ -28,6 +28,7 @@ #include "workbooksettings.hxx" #include "tabprotection.hxx" #include "document.hxx" +#include "convuno.hxx" namespace oox { namespace xls { @@ -128,6 +129,42 @@ void WorksheetSettings::importSheetProtection( const AttributeList& rAttribs ) maSheetProt.mbSelectUnlocked = rAttribs.getBool( XML_selectUnlockedCells, false ); } +void WorksheetSettings::importProtectedRanges( const AttributeList& rAttribs ) +{ + (void)rAttribs; // no attribs known (yet?) +} + +void WorksheetSettings::importProtectedRange( const AttributeList& rAttribs ) +{ + ScEnhancedProtection aProt; + /* XXX ECMA-376/OOXML XMLSchema and ISO/IEC 29500 say 'securityDescriptor' + * would be an element, but Excel2013 stores it as attribute. */ + aProt.maSecurityDescriptorXML = rAttribs.getString( XML_securityDescriptor, OUString()); + /* XXX ECMA-376/OOXML or ISO/IEC 29500 do not even mention a 'password' + * attribute here (or anywhere else), but this is what Excel2013 writes, + * similar to BIFF. OOXML XMLschema and ISO/IEC 29500 instead define + * 'algorithmName', 'hashValue', 'saltValue' and 'spinCount'. */ + aProt.mnPasswordVerifier = rAttribs.getIntegerHex( XML_password, 0); + aProt.maTitle = rAttribs.getString( XML_name, OUString()); + OUString aRefs( rAttribs.getString( XML_sqref, OUString())); + if (!aRefs.isEmpty()) + { + ApiCellRangeList aRangeList; + getAddressConverter().convertToCellRangeList( aRangeList, aRefs, getSheetIndex(), true ); + if (!aRangeList.empty()) + { + ScRangeList* pRangeList = aProt.maRangeList = new ScRangeList; + for (ApiCellRangeList::const_iterator itr( aRangeList.begin()), end( aRangeList.end()); itr != end; ++itr) + { + ScRange aRange; + ScUnoConversion::FillScRange( aRange, *itr); + pRangeList->Append( aRange); + } + } + } + maSheetProt.maEnhancedProtections.push_back( aProt); +} + void WorksheetSettings::importChartProtection( const AttributeList& rAttribs ) { maSheetProt.mnPasswordHash = CodecHelper::getPasswordHash( rAttribs, XML_password ); @@ -229,6 +266,8 @@ void WorksheetSettings::finalizeImport() aProtect.setOption( ScTableProtection::PIVOT_TABLES, !maSheetProt.mbPivotTables ); aProtect.setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, !maSheetProt.mbSelectUnlocked ); + aProtect.setEnhancedProtection( maSheetProt.maEnhancedProtections); + getScDocument().SetTabProtection( getSheetIndex(), &aProtect ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits