You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by hd...@apache.org on 2013/08/28 17:14:14 UTC

svn commit: r1518259 - in /openoffice/branches/AOO401: ./ main/sc/inc/patattr.hxx main/sc/source/core/data/attarray.cxx main/sc/source/core/data/patattr.cxx

Author: hdu
Date: Wed Aug 28 15:14:14 2013
New Revision: 1518259

URL: http://svn.apache.org/r1518259
Log:
#i122827# fix the performance regression in xls saving introduced by #i119707#

by correcting the calculation of the last row with visible attributes

Patch by: Yan Peng Guo
Debugged by: Herbert Duerr
Found by: k.wehrlin@hotmail.com

Modified:
    openoffice/branches/AOO401/   (props changed)
    openoffice/branches/AOO401/main/sc/inc/patattr.hxx
    openoffice/branches/AOO401/main/sc/source/core/data/attarray.cxx
    openoffice/branches/AOO401/main/sc/source/core/data/patattr.cxx

Propchange: openoffice/branches/AOO401/
------------------------------------------------------------------------------
  Merged /openoffice/trunk:r1518253

Modified: openoffice/branches/AOO401/main/sc/inc/patattr.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/inc/patattr.hxx?rev=1518259&r1=1518258&r2=1518259&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/inc/patattr.hxx (original)
+++ openoffice/branches/AOO401/main/sc/inc/patattr.hxx Wed Aug 28 15:14:14 2013
@@ -19,8 +19,6 @@
  * 
  *************************************************************/
 
-
-
 #ifndef SC_SCPATATR_HXX
 #define SC_SCPATATR_HXX
 
@@ -38,7 +36,6 @@ class ScStyleSheet;
 class SvNumberFormatter;
 class ScDocument;
 
-
 //	how to treat COL_AUTO in GetFont:
 
 enum ScAutoFontColorMode
@@ -125,6 +122,7 @@ public:
 
 	sal_Bool					IsVisible() const;
 	sal_Bool					IsVisibleEqual( const ScPatternAttr& rOther ) const;
+	sal_Bool					IsEqual( const ScPatternAttr& rOther ) const;
 
                             /** If font is an old symbol font StarBats/StarMath
                                 with text encoding RTL_TEXTENC_SYMBOL */

Modified: openoffice/branches/AOO401/main/sc/source/core/data/attarray.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/core/data/attarray.cxx?rev=1518259&r1=1518258&r2=1518259&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/core/data/attarray.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/core/data/attarray.cxx Wed Aug 28 15:14:14 2013
@@ -1927,21 +1927,38 @@ sal_Bool ScAttrArray::GetLastAttr( SCROW
         rLastRow = MAXROW;
         return sal_True;
     }
-	sal_Bool bFound = sal_False;
-    SCSIZE nEndPos = nCount - 1;
-    SCSIZE nStartPos = nEndPos;
-    while ( nStartPos > 0 && pData[nStartPos-1].nRow > nLastData &&
-            !pData[nStartPos].pPattern->IsVisible() )
-        --nStartPos;
-	if(nStartPos == 0 && !pData[nStartPos].pPattern->IsVisible()) // add this condition for handle only default pattern in one colume
-		rLastRow = nLastData;
-	else if(nStartPos >= 0 && pData[nStartPos].nRow > nLastData)
-	{
-		bFound = sal_True;
-		rLastRow = pData[nStartPos].nRow;
-	}
-	else
-		rLastRow = nLastData;
+
+    sal_Bool bFound = sal_False;
+
+    // Loop backwards from the end instead of using Search, assuming that
+    // there usually aren't many attributes below the last cell.
+    SCSIZE nPos = nCount;
+    while ( nPos > 0 && pData[nPos - 1].nRow > nLastData )
+    {
+        SCSIZE nEndPos = nPos - 1;
+        SCSIZE nStartPos = nEndPos;
+        while ( nStartPos > 0 && pData[nStartPos - 1].nRow > nLastData &&
+                pData[nStartPos - 1].pPattern->IsEqual( *pData[nStartPos].pPattern ) )
+            --nStartPos;
+
+        SCROW nAttrStartRow = ( nStartPos > 0 ) ? ( pData[nStartPos - 1].nRow + 1 ) : 0;
+        if ( nAttrStartRow <= nLastData )
+            nAttrStartRow = nLastData + 1;
+        SCROW nAttrSize = pData[nEndPos].nRow + 1 - nAttrStartRow;
+        if ( nAttrSize >= SC_VISATTR_STOP )
+        {
+            bFound = sal_False;
+        }
+        else if ( !bFound )
+        {
+            rLastRow = pData[nEndPos].nRow;
+            bFound = sal_True;
+        }
+
+        // look further from the top of the range.
+        nPos = nStartPos;
+    }
+
     return bFound;
 }
 

Modified: openoffice/branches/AOO401/main/sc/source/core/data/patattr.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/sc/source/core/data/patattr.cxx?rev=1518259&r1=1518258&r2=1518259&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/sc/source/core/data/patattr.cxx (original)
+++ openoffice/branches/AOO401/main/sc/source/core/data/patattr.cxx Wed Aug 28 15:14:14 2013
@@ -1144,6 +1144,19 @@ sal_Bool ScPatternAttr::IsVisibleEqual( 
 	//!		auch hier nur wirklich sichtbare Werte testen !!!
 }
 
+sal_Bool ScPatternAttr::IsEqual( const ScPatternAttr& rOther ) const
+{
+	const SfxItemSet& rThisSet = GetItemSet();
+	const SfxItemSet& rOtherSet = rOther.GetItemSet();
+
+	return OneEqual( rThisSet, rOtherSet, ATTR_BACKGROUND ) &&
+			OneEqual( rThisSet, rOtherSet, ATTR_BORDER ) &&
+			OneEqual( rThisSet, rOtherSet, ATTR_BORDER_TLBR ) &&
+			OneEqual( rThisSet, rOtherSet, ATTR_BORDER_BLTR ) &&
+			OneEqual( rThisSet, rOtherSet, ATTR_VALUE_FORMAT ) &&
+			OneEqual( rThisSet, rOtherSet, ATTR_SHADOW );
+}
+
 const String* ScPatternAttr::GetStyleName() const
 {
 	return pName ? pName : ( pStyle ? &pStyle->GetName() : NULL );