Index: sc/inc/attarray.hxx =================================================================== --- sc/inc/attarray.hxx (revision 1389681) +++ sc/inc/attarray.hxx (working copy) @@ -166,6 +166,10 @@ sal_Bool GetFirstVisibleAttr( SCROW& rFirstRow ) const; sal_Bool GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const; + /* + Get the last cell's row number , which have visual atribute or visual data in attribute list + */ + 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; Index: sc/inc/column.hxx =================================================================== --- sc/inc/column.hxx (revision 1389681) +++ sc/inc/column.hxx (working copy) @@ -171,6 +171,10 @@ sal_Bool GetFirstVisibleAttr( SCROW& rFirstRow ) const; sal_Bool GetLastVisibleAttr( SCROW& rLastRow ) const; + /* + Get the last cell's row number , which have visual atribute or visual data in a column + */ + 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; Index: sc/inc/document.hxx =================================================================== --- sc/inc/document.hxx (revision 1389681) +++ sc/inc/document.hxx (working copy) @@ -956,6 +956,10 @@ SCROW& rEndRow, sal_Bool bNotes = sal_True ) const; void InvalidateTableArea(); + /* + Get the last cell's row number , which have visual atribute or visual data in specific table + */ + SC_DLLPUBLIC void GetLastAttrCell( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const; SC_DLLPUBLIC sal_Bool GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const; Index: sc/inc/table.hxx =================================================================== --- sc/inc/table.hxx (revision 1389681) +++ sc/inc/table.hxx (working copy) @@ -418,6 +418,10 @@ sal_Bool GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol, SCROW& rEndRow, sal_Bool bNotes ) const; + /* + Get the last cell's postion, which has visual attribute or data and has max row number among all columns. + */ + void GetLastAttrCell( SCCOL& rEndCol, SCROW& rEndRow ) const; sal_Bool GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const; void ExtendPrintArea( OutputDevice* pDev, Index: sc/source/core/data/attarray.cxx =================================================================== --- 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; Index: sc/source/core/data/column2.cxx =================================================================== --- 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) Index: sc/source/core/data/documen4.cxx =================================================================== --- sc/source/core/data/documen4.cxx (revision 1389681) +++ sc/source/core/data/documen4.cxx (working copy) @@ -417,6 +417,14 @@ } } +void ScDocument::GetLastAttrCell( 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 { Index: sc/source/core/data/table1.cxx =================================================================== --- sc/source/core/data/table1.cxx (revision 1389681) +++ sc/source/core/data/table1.cxx (working copy) @@ -432,6 +432,24 @@ 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; + aCol[i].GetLastAttr( nLastRow ); + if ( nLastRow > nMaxY && nLastRow > 0 && nLastRow <= MAXROW ) + { + nMaxY = nLastRow; + nMaxX = i; + } + } + rEndCol = nMaxX; + rEndRow = nMaxY; +} /* vorher: sal_Bool bFound = sal_False; Index: sc/source/filter/excel/xetable.cxx =================================================================== --- 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.GetLastAttrCell( nScTab, rEndColAtt,rEndRowAtt ); // To get the real last cell's row number, which has visual data or attribute. + 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