[Libreoffice-commits] core.git: Branch 'aoo/trunk' - sc/inc sc/source
Herbert Dürr
hdu at apache.org
Wed Aug 28 09:08:06 PDT 2013
sc/inc/patattr.hxx | 4 ---
sc/source/core/data/attarray.cxx | 41 +++++++++++++++++++++++++++------------
sc/source/core/data/patattr.cxx | 13 ++++++++++++
3 files changed, 43 insertions(+), 15 deletions(-)
New commits:
commit a2aee2521b93c815612cd115280e4d890a22ece8
Author: Herbert Dürr <hdu at apache.org>
Date: Wed Aug 28 15:10:18 2013 +0000
#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 at hotmail.com
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index a86e153..237889d 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 72fc506..78e1594 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 5dc7d8b..a8be962 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 );
More information about the Libreoffice-commits
mailing list