Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Row heights when exporting xls ( and xlsx ) documents seems quite broken, some are exported (sometimes) others not but always it seems the result is not so nice. There is more detail in and test document in https://bugs.freedesktop.org/show_bug.cgi?id=50304

Noel

From 20568927db07e850a1a2ac71a6a7e90fea104e57 Mon Sep 17 00:00:00 2001
From: Noel Power <noel.power@novell.com>
Date: Thu, 24 May 2012 12:44:19 +0100
Subject: [PATCH 1/7] fix excel row height export problems ( I hope ) fdo#50304

Change-Id: I43ddb32ecba36107f5973fa5dcf2499cd1330668
---
 sc/source/filter/excel/xetable.cxx |   53 +++++++++++++++++++++++++----------
 1 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index b316618..d77c1e4 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2031,22 +2031,41 @@ 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
-    for (itr = itrBeg; itr != itrEnd; ++itr)
+    bool bSearchExisting = ( maRowMap.size() >= (  GetMaxPos().Row() - maRowMap.size() ) );
+    if ( bSearchExisting )
     {
-        const RowRef& rRow = itr->second;
-        if (rRow->IsDefaultable())
+        for (itr = itrBeg; itr != itrEnd; ++itr)
         {
-            XclExpDefaultRowData aDefData( *rRow );
-            size_t& rnDefCount = aDefRowMap[ aDefData ];
-            ++rnDefCount;
-            if( rnDefCount > nMaxDefCount )
+            const RowRef& rRow = itr->second;
+            if (rRow->IsDefaultable())
             {
-                nMaxDefCount = rnDefCount;
-                aMaxDefData = aDefData;
+                XclExpDefaultRowData aDefData( *rRow );
+                size_t& rnDefCount = aDefRowMap[ aDefData ];
+                ++rnDefCount;
+                if( rnDefCount > nMaxDefCount )
+                {
+                    nMaxDefCount = rnDefCount;
+                    aMaxDefData = aDefData;
+                }
+            }
+        }
+    }
+    else
+    {
+        // find a suitable unused row to get the default height from,
+        // searching backwards from max row
+        for ( SCROW nRow = GetMaxPos().Row(); nRow >= 0; --nRow )
+        {
+            if ( maRowMap.find( nRow ) == maRowMap.end() )
+            {
+                // 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;
             }
         }
     }
-
     // return the default row format to caller
     rDefRowData = aMaxDefData;
 
@@ -2148,13 +2167,17 @@ 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();
+    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() )
+        {
+            RowRef p(new XclExpRow(GetRoot(), nFrom, maOutlineBfr, bRowAlwaysEmpty));
+            maRowMap.insert(RowMap::value_type(nFrom, p));
+        }
     }
+    itr = maRowMap.find(nXclRow);
     return *itr->second;
 }
 
-- 
1.7.3.4



Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.