summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2013-08-28 15:10:18 +0000
committerHerbert Dürr <hdu@apache.org>2013-08-28 15:10:18 +0000
commita2aee2521b93c815612cd115280e4d890a22ece8 (patch)
treee961c8a7ec081c510c8f65085a99a923c5956a3f /sc
parent6c75da5f99a5654f486b0512d69294d14a7a17c3 (diff)
#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
Notes
Notes: reject: see 7ca23c541b20b0538a89229c70a9041b90fbc2d4
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/patattr.hxx4
-rw-r--r--sc/source/core/data/attarray.cxx41
-rw-r--r--sc/source/core/data/patattr.cxx13
3 files changed, 43 insertions, 15 deletions
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index a86e153a04f5..237889d156c9 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -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 */
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 72fc50662ee9..78e15940dfd3 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -1927,21 +1927,38 @@ sal_Bool ScAttrArray::GetLastAttr( SCROW& rLastRow, SCROW nLastData ) const
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)
+
+ // 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 )
{
- bFound = sal_True;
- rLastRow = pData[nStartPos].nRow;
+ 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;
}
- else
- rLastRow = nLastData;
+
return bFound;
}
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 5dc7d8b0d583..a8be9629254b 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -1144,6 +1144,19 @@ sal_Bool ScPatternAttr::IsVisibleEqual( const ScPatternAttr& rOther ) const
//! 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 );