no need to call rowHidden and rowFiltered repeatedly, tdf#90659

Change-Id: Ie104a0d6c2ee0a88363fb461762e2bcca00976dd
Reviewed-on: https://gerrit.libreoffice.org/24052
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
This commit is contained in:
Markus Mohrhard 2016-04-13 12:37:10 +02:00
parent ea6196f0a5
commit 44c1cfc7d8
3 changed files with 22 additions and 10 deletions

View file

@ -21,7 +21,7 @@ bool ScXMLCachedRowAttrAccess::Cache::hasCache(sal_Int32 nTab, sal_Int32 nRow) c
ScXMLCachedRowAttrAccess::ScXMLCachedRowAttrAccess(ScDocument* pDoc) :
mpDoc(pDoc) {}
bool ScXMLCachedRowAttrAccess::rowHidden(sal_Int32 nTab, sal_Int32 nRow)
bool ScXMLCachedRowAttrAccess::rowHidden(sal_Int32 nTab, sal_Int32 nRow, sal_Int32& nEndRow)
{
if (!maHidden.hasCache(nTab, nRow))
{
@ -31,10 +31,12 @@ bool ScXMLCachedRowAttrAccess::rowHidden(sal_Int32 nTab, sal_Int32 nRow)
maHidden.mnRow1 = static_cast<sal_Int32>(nRow1);
maHidden.mnRow2 = static_cast<sal_Int32>(nRow2);
}
nEndRow = maHidden.mnRow2;
return maHidden.mbValue;
}
bool ScXMLCachedRowAttrAccess::rowFiltered(sal_Int32 nTab, sal_Int32 nRow)
bool ScXMLCachedRowAttrAccess::rowFiltered(sal_Int32 nTab, sal_Int32 nRow, sal_Int32& nEndRow)
{
if (!maFiltered.hasCache(nTab, nRow))
{
@ -44,6 +46,7 @@ bool ScXMLCachedRowAttrAccess::rowFiltered(sal_Int32 nTab, sal_Int32 nRow)
maFiltered.mnRow1 = static_cast<sal_Int32>(nRow1);
maFiltered.mnRow2 = static_cast<sal_Int32>(nRow2);
}
nEndRow = maFiltered.mnRow2;
return maFiltered.mbValue;
}

View file

@ -34,8 +34,8 @@ class ScXMLCachedRowAttrAccess
public:
explicit ScXMLCachedRowAttrAccess(ScDocument* pDoc);
bool rowHidden(sal_Int32 nTab, sal_Int32 nRow);
bool rowFiltered(sal_Int32 nTab, sal_Int32 nRow);
bool rowHidden(sal_Int32 nTab, sal_Int32 nRow, sal_Int32& nEndRow);
bool rowFiltered(sal_Int32 nTab, sal_Int32 nRow, sal_Int32& nEndRow);
private:
Cache maHidden;
Cache maFiltered;

View file

@ -1429,6 +1429,8 @@ void ScXMLExport::OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, con
bool bFiltered = false;
sal_Int32 nEqualRows(1);
sal_Int32 nEndRow(nStartRow + nRepeatRow);
sal_Int32 nEndRowHidden = nStartRow - 1;
sal_Int32 nEndRowFiltered = nStartRow - 1;
sal_Int32 nRow;
for (nRow = nStartRow; nRow < nEndRow; ++nRow)
{
@ -1437,17 +1439,22 @@ void ScXMLExport::OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, con
nPrevIndex = pRowStyles->GetStyleNameIndex(nTable, nRow);
if (pDoc)
{
bPrevHidden = rRowAttr.rowHidden(nTable, nRow);
bPrevFiltered = rRowAttr.rowFiltered(nTable, nRow);
if (nRow > nEndRowHidden)
bPrevHidden = rRowAttr.rowHidden(nTable, nRow, nEndRowHidden);
if (nRow > nEndRowFiltered)
bPrevFiltered = rRowAttr.rowFiltered(nTable, nRow, nEndRowFiltered);
}
}
else
{
nIndex = pRowStyles->GetStyleNameIndex(nTable, nRow);
if (pDoc)
{
bHidden = rRowAttr.rowHidden(nTable, nRow);
bFiltered = rRowAttr.rowFiltered(nTable, nRow);
if (nRow > nEndRowHidden)
bHidden = rRowAttr.rowHidden(nTable, nRow, nEndRowHidden);
if (nRow > nEndRowFiltered)
bFiltered = rRowAttr.rowFiltered(nTable, nRow, nEndRowFiltered);
}
if (nIndex == nPrevIndex && bHidden == bPrevHidden && bFiltered == bPrevFiltered &&
!(bHasRowHeader && ((nRow == aRowHeaderRange.StartRow) || (nRow - 1 == aRowHeaderRange.EndRow))) &&
@ -1481,8 +1488,10 @@ void ScXMLExport::OpenRow(const sal_Int32 nTable, const sal_Int32 nStartRow, con
bool bFiltered = false;
if (pDoc)
{
bHidden = rRowAttr.rowHidden(nTable, nStartRow);
bFiltered = rRowAttr.rowFiltered(nTable, nStartRow);
sal_Int32 nEndRowHidden;
sal_Int32 nEndRowFiltered;
bHidden = rRowAttr.rowHidden(nTable, nStartRow, nEndRowHidden);
bFiltered = rRowAttr.rowFiltered(nTable, nStartRow, nEndRowFiltered);
}
OpenNewRow(nIndex, nStartRow, 1, bHidden, bFiltered);
}