--- sc/inc/attarray.hxx (revision 1389681) +++ sc/inc/attarray.hxx (working copy) @@ -166,6 +166,7 @@ sal_Bool GetFirstVisibleAttr( SCROW& rFirstRow ) const; sal_Bool GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const; + sal_Bool GetLastAttr( SCROW& rLastRow, SCROW nLastData ) const; sal_Bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const; sal_Bool IsVisibleEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW nEndRow ) const; --- sc/inc/column.hxx (revision 1389681) +++ sc/inc/column.hxx (working copy) @@ -171,6 +171,7 @@ sal_Bool GetFirstVisibleAttr( SCROW& rFirstRow ) const; sal_Bool GetLastVisibleAttr( SCROW& rLastRow ) const; + sal_Bool GetLastAttr( SCROW& rLastRow ) const; sal_Bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const; sal_Bool IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow = 0, SCROW nEndRow = MAXROW ) const; --- sc/inc/document.hxx (revision 1389681) +++ sc/inc/document.hxx (working copy) @@ -956,6 +956,7 @@ SCROW& rEndRow, sal_Bool bNotes = sal_True ) const; void InvalidateTableArea(); + SC_DLLPUBLIC void GetLastAttrCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const; SC_DLLPUBLIC sal_Bool GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const; --- sc/inc/table.hxx (revision 1389681) +++ sc/inc/table.hxx (working copy) @@ -418,6 +418,7 @@ sal_Bool GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol, SCROW& rEndRow, sal_Bool bNotes ) const; + void GetLastAttrCell( SCCOL& rEndCol, SCROW& rEndRow ) const; sal_Bool GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const; void ExtendPrintArea( OutputDevice* pDev, --- sc/source/core/data/attarray.cxx (revision 1389681) +++ sc/source/core/data/attarray.cxx (working copy) @@ -1920,7 +1920,31 @@ return bFound; } +sal_Bool ScAttrArray::GetLastAttr( SCROW& rLastRow, SCROW nLastData ) const +{ + if ( nLastData == MAXROW ) + { + 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].nRow > nLastData) + { + bFound = sal_True; + rLastRow = pData[nStartPos].nRow; + } + else + rLastRow = nLastData; + return bFound; +} + sal_Bool ScAttrArray::HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const { SCSIZE nIndex; --- sc/source/core/data/column2.cxx (revision 1389681) +++ sc/source/core/data/column2.cxx (working copy) @@ -1564,6 +1564,19 @@ return sal_False; } +sal_Bool ScColumn::GetLastAttr( SCROW& rLastRow ) const +{ + if ( pAttrArray ) + { + // Row of last cell is needed, always including notes, 0 if none. + SCROW nLastData = GetLastVisDataPos( sal_True ); + return pAttrArray->GetLastAttr( rLastRow, nLastData ); + } + else + { + return sal_False; + } +} sal_Bool ScColumn::HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const { if (pAttrArray) --- sc/source/core/data/documen4.cxx (revision 1389681) +++ sc/source/core/data/documen4.cxx (working copy) @@ -417,6 +417,13 @@ } } +void ScDocument::GetLastAttrCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const +{ + if ( ValidTab( nTab ) && pTab[nTab] ) + { + pTab[nTab]->GetLastAttrCell( rEndCol, rEndRow ); + } +} sal_Int32 ScDocument::GetMaxStringLen( SCTAB nTab, SCCOL nCol, SCROW nRowStart, SCROW nRowEnd, CharSet eCharSet ) const { --- sc/source/core/data/table1.cxx (revision 1389681) +++ sc/source/core/data/table1.cxx (working copy) @@ -432,6 +432,26 @@ return bRet; } +void ScTable::GetLastAttrCell( SCCOL& rEndCol, SCROW& rEndRow ) const +{ + SCCOL nMaxX = 0; + SCROW nMaxY = 0; + SCCOL i; + for ( i = 0; i <= MAXCOL; i++ ) + { + SCROW nLastRow; + if ( aCol[i].GetLastAttr( nLastRow ) ) + { + nMaxX = i; + if ( nLastRow > nMaxY ) + nMaxY = nLastRow; + } + else if( nLastRow > nMaxY && nLastRow > 0 && nLastRow <= MAXROW) + nMaxY = nLastRow; + } + rEndCol = nMaxX; + rEndRow = nMaxY; +} /* vorher: sal_Bool bFound = sal_False; --- sc/source/filter/excel/xetable.cxx (revision 1389681) +++ sc/source/filter/excel/xetable.cxx (working copy) @@ -2358,6 +2358,16 @@ // range for cell iterator SCCOL nLastIterScCol = nMaxScCol; SCROW nLastIterScRow = ulimit_cast< SCROW >( nLastUsedScRow + 128, nMaxScRow ); + // modified for 119707 by zhanglu + SCCOL rEndColAtt = 0; + SCROW rEndRowAtt = 0; + rDoc.GetLastAttrCellArea( nScTab, rEndColAtt,rEndRowAtt ); + if( rEndRowAtt > nLastIterScRow ) + nLastIterScRow = rEndRowAtt; + + if (nLastIterScRow > nMaxScRow) + nLastIterScRow = nMaxScRow; + // modified for 119707 end ScUsedAreaIterator aIt( &rDoc, nScTab, 0, 0, nLastIterScCol, nLastIterScRow ); // activate the correct segment and sub segment at the progress bar