[Libreoffice-commits] .: 2 commits - sc/source

Noel Power noelp at kemper.freedesktop.org
Wed Jul 25 10:26:22 PDT 2012


 sc/source/filter/excel/xetable.cxx |   51 ++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 31 deletions(-)

New commits:
commit 4ed0eaca6c14aeb652cbebe18081cc9e7e1444ac
Author: Noel Power <noel.power at novell.com>
Date:   Wed Jul 25 18:23:38 2012 +0100

    hopefully more successful attempt to solve fdo#50304
    
    Change-Id: I86dfff571c14bce97d0851b4093dbc376d8b6ea4

diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index e3967f2..d611077 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2146,14 +2146,26 @@ XclExpDimensions* XclExpRowBuffer::GetDimensions()
 
 XclExpRow& XclExpRowBuffer::GetOrCreateRow( sal_uInt32 nXclRow, bool bRowAlwaysEmpty )
 {
-    RowMap::iterator itr = maRowMap.find(nXclRow);
-    if (itr == maRowMap.end())
+    RowMap::iterator itr = maRowMap.begin();
+    ScDocument& rDoc = GetRoot().GetDoc();
+    SCTAB nScTab = GetRoot().GetCurrScTab();
+    for ( size_t nFrom = maRowMap.size(); nFrom <= nXclRow; ++nFrom )
     {
-        RowRef p(new XclExpRow(GetRoot(), nXclRow, maOutlineBfr, bRowAlwaysEmpty));
-        ::std::pair<RowMap::iterator, bool> r = maRowMap.insert(RowMap::value_type(nXclRow, p));
-        itr = r.first;
+        itr = maRowMap.find(nFrom);
+        if ( itr == maRowMap.end() )
+        {
+            // only create RowMap entries for rows that differ from previous,
+            // or if it is the desired row
+            if ( !nFrom || ( nFrom == nXclRow ) || ( nFrom && ( rDoc.GetRowHeight(nFrom, nScTab, false) != rDoc.GetRowHeight(nFrom-1, nScTab, false) ) ) )
+            {
+                RowRef p(new XclExpRow(GetRoot(), nFrom, maOutlineBfr, bRowAlwaysEmpty));
+                maRowMap.insert(RowMap::value_type(nFrom, p));
+            }
+        }
     }
+    itr = maRowMap.find(nXclRow);
     return *itr->second;
+
 }
 
 // ============================================================================
commit cad1ab1f12b01aa0b364697aa63ee2fb73b96dd2
Author: Noel Power <noel.power at novell.com>
Date:   Tue Jul 24 19:49:49 2012 +0100

    Revert "fix excel row height export problems ( I hope ) fdo#50304"
    
    This reverts commit 9746c6de3a05fe9284d6d6bb2f636bfe912733cd.

diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 69db2be..e3967f2 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2029,41 +2029,22 @@ void XclExpRowBuffer::Finalize( XclExpDefaultRowData& rDefRowData, const ScfUInt
     XclExpDefaultRowData aMaxDefData;
     size_t nMaxDefCount = 0;
     // only look for default format in existing rows, if there are more than unused
-    bool bSearchExisting = ( maRowMap.size() >= (  GetMaxPos().Row() - maRowMap.size() ) );
-    if ( bSearchExisting )
-    {
-        for (itr = itrBeg; itr != itrEnd; ++itr)
-        {
-            const RowRef& rRow = itr->second;
-            if (rRow->IsDefaultable())
-            {
-                XclExpDefaultRowData aDefData( *rRow );
-                size_t& rnDefCount = aDefRowMap[ aDefData ];
-                ++rnDefCount;
-                if( rnDefCount > nMaxDefCount )
-                {
-                    nMaxDefCount = rnDefCount;
-                    aMaxDefData = aDefData;
-                }
-            }
-        }
-    }
-    else
+    for (itr = itrBeg; itr != itrEnd; ++itr)
     {
-        // find a suitable unused row to get the default height from,
-        // searching backwards from max row
-        for ( SCROW nRow = GetMaxPos().Row(); nRow >= 0; --nRow )
+        const RowRef& rRow = itr->second;
+        if (rRow->IsDefaultable())
         {
-            if ( maRowMap.find( nRow ) == maRowMap.end() )
+            XclExpDefaultRowData aDefData( *rRow );
+            size_t& rnDefCount = aDefRowMap[ aDefData ];
+            ++rnDefCount;
+            if( rnDefCount > nMaxDefCount )
             {
-                // use first encountered unused row height as default
-                // I wonder should we do this always ( and abandon the search
-                // of exising rows )
-                aMaxDefData.mnHeight = GetDoc().GetRowHeight(nRow, GetCurrScTab(), false);
-                break;
+                nMaxDefCount = rnDefCount;
+                aMaxDefData = aDefData;
             }
         }
     }
+
     // return the default row format to caller
     rDefRowData = aMaxDefData;
 
@@ -2165,17 +2146,13 @@ XclExpDimensions* XclExpRowBuffer::GetDimensions()
 
 XclExpRow& XclExpRowBuffer::GetOrCreateRow( sal_uInt32 nXclRow, bool bRowAlwaysEmpty )
 {
-    RowMap::iterator itr = maRowMap.begin();
-    for ( size_t nFrom = maRowMap.size(); nFrom <= nXclRow; ++nFrom )
+    RowMap::iterator itr = maRowMap.find(nXclRow);
+    if (itr == maRowMap.end())
     {
-        itr = maRowMap.find(nFrom);
-        if ( itr == maRowMap.end() )
-        {
-            RowRef p(new XclExpRow(GetRoot(), nFrom, maOutlineBfr, bRowAlwaysEmpty));
-            maRowMap.insert(RowMap::value_type(nFrom, p));
-        }
+        RowRef p(new XclExpRow(GetRoot(), nXclRow, maOutlineBfr, bRowAlwaysEmpty));
+        ::std::pair<RowMap::iterator, bool> r = maRowMap.insert(RowMap::value_type(nXclRow, p));
+        itr = r.first;
     }
-    itr = maRowMap.find(nXclRow);
     return *itr->second;
 }
 


More information about the Libreoffice-commits mailing list