[Libreoffice-commits] .: 2 commits - sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Thu Aug 25 05:33:11 PDT 2011
sc/source/filter/xml/xmlcelli.cxx | 8 +--
sc/source/filter/xml/xmlsubti.cxx | 83 +++++++++++++++++++-------------------
sc/source/filter/xml/xmlsubti.hxx | 1
3 files changed, 48 insertions(+), 44 deletions(-)
New commits:
commit 5b9005677020c1111259bd0adc292a9b838c2995
Author: Laurent Godard <oooconv at free.fr>
Date: Thu Aug 25 14:19:08 2011 +0200
improve import performance, save last sheet in ScMyTables
calls to ptr_vector::back need way to much time in ScMyTables::AddRow
and ScMyTables::AddColumn, this removes the need to call
ptr_vector::back every time
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 50c169d..a3355be 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -163,7 +163,8 @@ ScMyTables::ScMyTables(ScXMLImport& rTempImport)
nCurrentColStylePos(0),
nCurrentDrawPage( -1 ),
nCurrentXShapes( -1 ),
- nCurrentSheet( -1 )
+ nCurrentSheet( -1 ),
+ pLastTable(NULL)
{
}
@@ -179,6 +180,7 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString&
nCurrentColStylePos = 0;
sCurrentSheetName = sTableName;
maTables.clear();
+ pLastTable = NULL;
++nCurrentSheet;
maProtectionData = rProtectData;
@@ -336,7 +338,7 @@ void ScMyTables::DoMerge(sal_Int32 nCount)
uno::Reference <table::XCellRange> xMergeCellRange;
if (nCount == -1)
{
- const ScMyTableData& r = maTables.back();
+ const ScMyTableData& r = *pLastTable;
xMergeCellRange.set(
xCurrentCellRange->getCellRangeByPosition(
aCellAddress.StartColumn, aCellAddress.StartRow,
@@ -362,8 +364,7 @@ void ScMyTables::InsertRow()
{
table::CellRangeAddress aCellAddress;
sal_Int32 nRow(GetRealCellPos().Row);
- const ScMyTableData& rTab = maTables.back();
- for (sal_Int32 j = 0; j < GetRealCellPos().Column - rTab.GetColumn() - 1; ++j)
+ for (sal_Int32 j = 0; j < GetRealCellPos().Column - pLastTable->GetColumn() - 1; ++j)
{
if (IsMerged(xCurrentCellRange, j, nRow - 1, aCellAddress))
{
@@ -391,7 +392,7 @@ void ScMyTables::NewRow()
if (n <= 1)
return;
- if (maTables[n-1].GetRealRows(maTables[n-1].GetRow()) >
+ if (pLastTable->GetRealRows(pLastTable->GetRow()) >
maTables[n-2].GetRowsPerRow(maTables[n-2].GetRow()) - 1)
{
if (GetRealCellPos().Column > 0)
@@ -413,15 +414,14 @@ void ScMyTables::NewRow()
void ScMyTables::AddRow()
{
- ScMyTableData& rTab = maTables.back();
- rTab.AddRow();
- rTab.SetFirstColumn();
- sal_Int32 nRow = rTab.GetRow();
+ pLastTable->AddRow();
+ pLastTable->SetFirstColumn();
+ sal_Int32 nRow = pLastTable->GetRow();
if (nRow > 0)
NewRow();
- rTab.SetRealRows(
- nRow + 1, rTab.GetRealRows(nRow) + rTab.GetRowsPerRow(nRow));
+ pLastTable->SetRealRows(
+ nRow + 1, pLastTable->GetRealRows(nRow) + pLastTable->GetRowsPerRow(nRow));
}
void ScMyTables::SetRowStyle(const rtl::OUString& rCellStyleName)
@@ -435,7 +435,7 @@ void ScMyTables::InsertColumn()
{
table::CellRangeAddress aCellAddress;
sal_Int32 nCol(GetRealCellPos().Column);
- sal_Int32 n = GetRealCellPos().Row - maTables.back().GetRow() - 1;
+ sal_Int32 n = GetRealCellPos().Row - pLastTable->GetRow() - 1;
for (sal_Int32 j = 0; j <= n; ++j)
{
table::CellRangeAddress aTempCellAddress;
@@ -478,12 +478,11 @@ void ScMyTables::NewColumn(sal_Bool bIsCovered)
if (bIsCovered)
return;
- ScMyTableData& rLastTab = maTables.back();
- sal_Int32 nColCount = rLastTab.GetColCount();
- sal_Int32 nSpannedCols = rLastTab.GetSpannedCols();
+ sal_Int32 nColCount = pLastTable->GetColCount();
+ sal_Int32 nSpannedCols = pLastTable->GetSpannedCols();
if ( (nSpannedCols > nColCount) &&
- (rLastTab.GetRow() == 0) &&
- (rLastTab.GetColumn() == 0) )
+ (pLastTable->GetRow() == 0) &&
+ (pLastTable->GetColumn() == 0) )
{
if (nColCount > 0)
{
@@ -492,17 +491,17 @@ void ScMyTables::NewColumn(sal_Bool bIsCovered)
+ (nSpannedCols % nColCount));
for (sal_Int32 i = 0; i < nColCount - 1; ++i)
{
- rLastTab.SetColsPerCol(i, FirstColsSpanned);
- rLastTab.SetRealCols(i + 1, rLastTab.GetRealCols(i) + FirstColsSpanned);
+ pLastTable->SetColsPerCol(i, FirstColsSpanned);
+ pLastTable->SetRealCols(i + 1, pLastTable->GetRealCols(i) + FirstColsSpanned);
}
- rLastTab.SetColsPerCol(nColCount - 1, LastColSpanned);
- rLastTab.SetRealCols(
- nColCount, rLastTab.GetRealCols(nColCount - 1) + LastColSpanned);
+ pLastTable->SetColsPerCol(nColCount - 1, LastColSpanned);
+ pLastTable->SetRealCols(
+ nColCount, pLastTable->GetRealCols(nColCount - 1) + LastColSpanned);
}
}
- if (rLastTab.GetRealCols(rLastTab.GetColumn()) > nSpannedCols - 1)
+ if (pLastTable->GetRealCols(pLastTable->GetColumn()) > nSpannedCols - 1)
{
- if (rLastTab.GetRow() == 0)
+ if (pLastTable->GetRow() == 0)
{
InsertColumn();
size_t n = maTables.size();
@@ -513,7 +512,7 @@ void ScMyTables::NewColumn(sal_Bool bIsCovered)
maTables[i-1].SetColsPerCol(nColPos,
maTables[i-1].GetColsPerCol(nColPos) +
- rLastTab.GetColsPerCol(rLastTab.GetColumn()));
+ pLastTable->GetColsPerCol(pLastTable->GetColumn()));
maTables[i-1].SetRealCols(
nColPos + 1,
@@ -527,21 +526,20 @@ void ScMyTables::NewColumn(sal_Bool bIsCovered)
void ScMyTables::AddColumn(sal_Bool bIsCovered)
{
- ScMyTableData& rLastTab = maTables.back();
- rLastTab.AddColumn();
- if (rLastTab.GetSubTableSpanned() > 1)
- rLastTab.SetSubTableSpanned(rLastTab.GetSubTableSpanned() - 1);
+ pLastTable->AddColumn();
+ if (pLastTable->GetSubTableSpanned() > 1)
+ pLastTable->SetSubTableSpanned(pLastTable->GetSubTableSpanned() - 1);
else
{
NewColumn(bIsCovered);
- sal_Int32 nCol = rLastTab.GetColumn();
- sal_Int32 nRow = rLastTab.GetRow();
- rLastTab.SetRealCols(
- nCol + 1, rLastTab.GetRealCols(nCol) + rLastTab.GetColsPerCol(nCol));
+ sal_Int32 nCol = pLastTable->GetColumn();
+ sal_Int32 nRow = pLastTable->GetRow();
+ pLastTable->SetRealCols(
+ nCol + 1, pLastTable->GetRealCols(nCol) + pLastTable->GetColsPerCol(nCol));
- if ((!bIsCovered) || (bIsCovered && (rLastTab.GetColsPerCol(nCol) > 1)))
+ if ((!bIsCovered) || (bIsCovered && (pLastTable->GetColsPerCol(nCol) > 1)))
{
- if ((rLastTab.GetRowsPerRow(nRow) > 1) || (rLastTab.GetColsPerCol(nCol) > 1))
+ if ((pLastTable->GetRowsPerRow(nRow) > 1) || (pLastTable->GetColsPerCol(nCol) > 1))
DoMerge();
}
}
@@ -550,6 +548,7 @@ void ScMyTables::AddColumn(sal_Bool bIsCovered)
void ScMyTables::NewTable(sal_Int32 nTempSpannedCols)
{
maTables.push_back(new ScMyTableData(nCurrentSheet));
+ pLastTable = & maTables.back();
if (maTables.size() > 1)
{
@@ -577,13 +576,12 @@ void ScMyTables::NewTable(sal_Int32 nTempSpannedCols)
nTempSpannedCols += nToMerge;
}
- ScMyTableData& rNewTab = maTables.back();
- rNewTab.SetSpannedCols(nTempSpannedCols);
+ pLastTable->SetSpannedCols(nTempSpannedCols);
size_t n = maTables.size();
if (n > 1)
{
- maTables[n-2].SetSubTableSpanned(rNewTab.GetSpannedCols());
+ maTables[n-2].SetSubTableSpanned(pLastTable->GetSpannedCols());
UnMerge();
}
}
@@ -636,7 +634,13 @@ void ScMyTables::DeleteTable()
nCurrentColStylePos = 0;
if (!maTables.empty())
+ {
maTables.pop_back();
+ if (!maTables.empty())
+ pLastTable = &maTables.back();
+ else
+ pLastTable = NULL;
+ }
if (maTables.empty()) // only set the styles if all subtables are importet and the table is finished
{
@@ -705,8 +709,7 @@ table::CellAddress ScMyTables::GetRealCellPos()
void ScMyTables::AddColCount(sal_Int32 nTempColCount)
{
- ScMyTableData& rLastTab = maTables.back();
- rLastTab.SetColCount(rLastTab.GetColCount() + nTempColCount);
+ pLastTable->SetColCount(pLastTable->GetColCount() + nTempColCount);
}
void ScMyTables::AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCellStyleName)
diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx
index bb76dc2..7fa66e6 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -143,6 +143,7 @@ private:
sal_Int16 nCurrentDrawPage;
sal_Int16 nCurrentXShapes;
SCTAB nCurrentSheet;
+ ScMyTableData* pLastTable;
sal_Bool IsMerged (const com::sun::star::uno::Reference <com::sun::star::table::XCellRange>& xCellRange,
const sal_Int32 nCol, const sal_Int32 nRow,
commit bea5d07ed1a50d3bea81de047eb9fe94c7a4e361
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Aug 25 13:05:57 2011 +0200
some minor restructuring, code still needs refactoring
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 468b6e9..74cc5b8 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -781,10 +781,11 @@ void ScXMLTableRowCellContext::EndElement()
rXMLImport.GetTextImport()->ResetCursor();
}
}
- table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos();
+ ScMyTables& rTables = rXMLImport.GetTables();
+ table::CellAddress aCellPos = rTables.GetRealCellPos();
if (aCellPos.Column > 0 && nRepeatedRows > 1)
aCellPos.Row -= (nRepeatedRows - 1);
- uno::Reference<table::XCellRange> xCellRange(rXMLImport.GetTables().GetCurrentXCellRange());
+ uno::Reference<table::XCellRange> xCellRange(rTables.GetCurrentXCellRange());
if (xCellRange.is())
{
if (bIsMerged)
@@ -833,7 +834,6 @@ void ScXMLTableRowCellContext::EndElement()
mxAnnotationData.get() || pDetectiveObjVec || pCellRangeSource)
bIsEmpty = false;
- ScMyTables& rTables = rXMLImport.GetTables();
for (sal_Int32 i = 0; i < nCellsRepeated; ++i)
{
aCurrentPos.Column = aCellPos.Column + i;
@@ -1097,7 +1097,7 @@ void ScXMLTableRowCellContext::EndElement()
{
if (nMatrixCols > 0 && nMatrixRows > 0)
{
- rXMLImport.GetTables().AddMatrixRange(
+ rTables.AddMatrixRange(
aCellPos.Column, aCellPos.Row,
aCellPos.Column + nMatrixCols - 1,
aCellPos.Row + nMatrixRows - 1,
More information about the Libreoffice-commits
mailing list