[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Fri Mar 21 10:49:20 PDT 2014


 sc/source/filter/excel/excimp8.cxx   |   14 ++++++---
 sc/source/filter/excel/xicontent.cxx |   51 ++---------------------------------
 sc/source/filter/excel/xladdress.cxx |    7 +++-
 sc/source/filter/inc/xicontent.hxx   |   30 ++------------------
 sc/source/filter/inc/xladdress.hxx   |    2 -
 5 files changed, 21 insertions(+), 83 deletions(-)

New commits:
commit 0f2414d82c0a4b4aca9ef040d617dcc7554a8fc5
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Mar 21 18:46:37 2014 +0100

    refactored to use XclRangeList and XclImpAddressConverter
    
    Change-Id: If0455f0243aace784c704e234469709e6da4542f

diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 4ffc326..2a52df8 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -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.
diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx
index bc27a29..bb5ec44 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -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());
     }
 }
 
diff --git a/sc/source/filter/excel/xladdress.cxx b/sc/source/filter/excel/xladdress.cxx
index 694e1e0..237d0f7 100644
--- a/sc/source/filter/excel/xladdress.cxx
+++ b/sc/source/filter/excel/xladdress.cxx
@@ -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 )
diff --git a/sc/source/filter/inc/xicontent.hxx b/sc/source/filter/inc/xicontent.hxx
index 3d4f5fc..d3668d4 100644
--- a/sc/source/filter/inc/xicontent.hxx
+++ b/sc/source/filter/inc/xicontent.hxx
@@ -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);
diff --git a/sc/source/filter/inc/xladdress.hxx b/sc/source/filter/inc/xladdress.hxx
index fb2a366..9748885 100644
--- a/sc/source/filter/inc/xladdress.hxx
+++ b/sc/source/filter/inc/xladdress.hxx
@@ -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;


More information about the Libreoffice-commits mailing list