[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - 2 commits - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Oct 22 20:08:27 PDT 2013
sc/inc/documentimport.hxx | 3 +
sc/inc/paramisc.hxx | 22 ++++---
sc/source/core/data/documen4.cxx | 6 +-
sc/source/core/data/documentimport.cxx | 91 +++++++++++++++++++++++++++++++++
sc/source/core/data/global2.cxx | 14 ++---
sc/source/filter/excel/impop.cxx | 18 ++----
sc/source/ui/docshell/docfunc.cxx | 2
sc/source/ui/inc/undoblk.hxx | 5 +
sc/source/ui/miscdlgs/tabopdlg.cxx | 16 ++---
sc/source/ui/undo/undoblk3.cxx | 8 +-
sc/source/ui/unoobj/cellsuno.cxx | 11 ++-
11 files changed, 144 insertions(+), 52 deletions(-)
New commits:
commit ee55306844abeda86a228ff6fdb36a940289eeeb
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 22 23:08:43 2013 -0400
Use ScDocumentImport to insert data table cells.
This ensures that all cells get populated through ScDocumentImport, which
keeps track of current cell positions in each column.
Change-Id: I2ed10c91778e0b81959c8a436c4b2def5967e70f
diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx
index 0620301..4864c00 100644
--- a/sc/inc/documentimport.hxx
+++ b/sc/inc/documentimport.hxx
@@ -23,6 +23,7 @@ class ScColumn;
class ScAddress;
class ScTokenArray;
class ScFormulaCell;
+struct ScTabOpParam;
struct ScDocumentImportImpl;
/**
@@ -70,6 +71,8 @@ public:
void setMatrixCells(
const ScRange& rRange, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGrammar);
+ void setTableOpCells(const ScRange& rRange, const ScTabOpParam& rParam);
+
void finalize();
private:
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 03f5842..461589f 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -16,6 +16,8 @@
#include "globalnames.hxx"
#include "mtvelements.hxx"
#include "tokenarray.hxx"
+#include "compiler.hxx"
+#include "paramisc.hxx"
#include "svl/sharedstringpool.hxx"
@@ -301,6 +303,95 @@ void ScDocumentImport::setMatrixCells(
}
}
+void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam& rParam)
+{
+ SCTAB nTab = rRange.aStart.Tab();
+ SCCOL nCol1 = rRange.aStart.Col();
+ SCROW nRow1 = rRange.aStart.Row();
+ SCCOL nCol2 = rRange.aEnd.Col();
+ SCROW nRow2 = rRange.aEnd.Row();
+
+ ScTable* pTab = mpImpl->mrDoc.FetchTable(nTab);
+ if (!pTab)
+ return;
+
+ ScDocument* pDoc = &mpImpl->mrDoc;
+ ScRefAddress aRef;
+ OUStringBuffer aFormulaBuf('=');
+ aFormulaBuf.append(ScCompiler::GetNativeSymbol(ocTableOp));
+ aFormulaBuf.append(ScCompiler::GetNativeSymbol(ocOpen));
+
+ OUString aSep = ScCompiler::GetNativeSymbol(ocSep);
+ if (rParam.meMode == ScTabOpParam::Column) // column only
+ {
+ aRef.Set(rParam.aRefFormulaCell.GetAddress(), true, false, false);
+ aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
+ aFormulaBuf.append(aSep);
+ aFormulaBuf.append(rParam.aRefColCell.GetRefString(pDoc, nTab));
+ aFormulaBuf.append(aSep);
+ aRef.Set(nCol1, nRow1, nTab, false, true, true);
+ aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
+ nCol1++;
+ nCol2 = std::min( nCol2, (SCCOL)(rParam.aRefFormulaEnd.Col() -
+ rParam.aRefFormulaCell.Col() + nCol1 + 1));
+ }
+ else if (rParam.meMode == ScTabOpParam::Row) // row only
+ {
+ aRef.Set(rParam.aRefFormulaCell.GetAddress(), false, true, false);
+ aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
+ aFormulaBuf.append(aSep);
+ aFormulaBuf.append(rParam.aRefRowCell.GetRefString(pDoc, nTab));
+ aFormulaBuf.append(aSep);
+ aRef.Set(nCol1, nRow1, nTab, true, false, true);
+ aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
+ ++nRow1;
+ nRow2 = std::min(
+ nRow2, rParam.aRefFormulaEnd.Row() - rParam.aRefFormulaCell.Row() + nRow1 + 1);
+ }
+ else // both
+ {
+ aFormulaBuf.append(rParam.aRefFormulaCell.GetRefString(pDoc, nTab));
+ aFormulaBuf.append(aSep);
+ aFormulaBuf.append(rParam.aRefColCell.GetRefString(pDoc, nTab));
+ aFormulaBuf.append(aSep);
+ aRef.Set(nCol1, nRow1 + 1, nTab, false, true, true);
+ aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
+ aFormulaBuf.append(aSep);
+ aFormulaBuf.append(rParam.aRefRowCell.GetRefString(pDoc, nTab));
+ aFormulaBuf.append(aSep);
+ aRef.Set(nCol1 + 1, nRow1, nTab, true, false, true);
+ aFormulaBuf.append(aRef.GetRefString(pDoc, nTab));
+ ++nCol1;
+ ++nRow1;
+ }
+
+ aFormulaBuf.append(ScCompiler::GetNativeSymbol(ocClose));
+
+ ScFormulaCell aRefCell(
+ pDoc, ScAddress(nCol1, nRow1, nTab), aFormulaBuf.makeStringAndClear(),
+ formula::FormulaGrammar::GRAM_NATIVE, MM_NONE);
+
+ for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
+ {
+ sc::ColumnBlockPosition* pBlockPos =
+ mpImpl->maBlockPosSet.getBlockPosition(nTab, nCol);
+
+ if (!pBlockPos)
+ // Something went horribly wrong.
+ return;
+
+ sc::CellStoreType& rColCells = pTab->aCol[nCol].maCells;
+
+ for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
+ {
+ ScAddress aPos(nCol, nRow, nTab);
+ ScFormulaCell* pCell = new ScFormulaCell(aRefCell, *pDoc, aPos);
+ pBlockPos->miCellPos =
+ rColCells.set(pBlockPos->miCellPos, nRow, pCell);
+ }
+ }
+}
+
namespace {
class CellTextAttrInitializer
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index ceb758b..b86ea72 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -1152,11 +1152,9 @@ void ImportExcel::TableOp( void )
break;
}
- ScMarkData aMarkData;
- aMarkData.SelectOneTable( nTab );
- pD->InsertTableOp( aTabOpParam, static_cast<SCCOL>(nCol),
- static_cast<SCROW>(nRow), static_cast<SCCOL>(nLastCol),
- static_cast<SCROW>(nLastRow), aMarkData );
+ ScDocumentImport& rDoc = GetDocImport();
+ ScRange aTabOpRange(nCol, nRow, nTab, nLastCol, nLastRow, nTab);
+ rDoc.setTableOpCells(aTabOpRange, aTabOpParam);
}
}
else
commit e31f3dc75e5807ca777a44f7081b94de8330ce6f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Oct 22 22:16:20 2013 -0400
Use enum for table op mode.
Change-Id: I51e110fb0a2b72689f529d7094389cc3e20dfbe0
diff --git a/sc/inc/paramisc.hxx b/sc/inc/paramisc.hxx
index 425bb19..b5545a9 100644
--- a/sc/inc/paramisc.hxx
+++ b/sc/inc/paramisc.hxx
@@ -40,25 +40,27 @@ struct ScSolveParam
sal_Bool operator== ( const ScSolveParam& r ) const;
};
-struct ScTabOpParam
+/**
+ * Parameter for data table aka multiple operations.
+ */
+struct SC_DLLPUBLIC ScTabOpParam
{
+ enum Mode { Column = 0, Row = 1, Both = 2 };
+
ScRefAddress aRefFormulaCell;
ScRefAddress aRefFormulaEnd;
ScRefAddress aRefRowCell;
ScRefAddress aRefColCell;
- sal_uInt8 nMode;
+ Mode meMode;
- ScTabOpParam() {};
+ ScTabOpParam();
ScTabOpParam( const ScTabOpParam& r );
- ScTabOpParam( const ScRefAddress& rFormulaCell,
- const ScRefAddress& rFormulaEnd,
- const ScRefAddress& rRowCell,
- const ScRefAddress& rColCell,
- sal_uInt8 nMd);
- ~ScTabOpParam() {};
+ ScTabOpParam(
+ const ScRefAddress& rFormulaCell, const ScRefAddress& rFormulaEnd,
+ const ScRefAddress& rRowCell, const ScRefAddress& rColCell, Mode eMode );
ScTabOpParam& operator= ( const ScTabOpParam& r );
- sal_Bool operator== ( const ScTabOpParam& r ) const;
+ bool operator== ( const ScTabOpParam& r ) const;
};
#endif // SC_PARAMISC_HXX
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 590737c..65005bd 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -378,7 +378,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera
aForString.append(ScCompiler::GetNativeSymbol( ocOpen));
const OUString& sSep = ScCompiler::GetNativeSymbol( ocSep);
- if (rParam.nMode == 0) // nur Spalte
+ if (rParam.meMode == ScTabOpParam::Column) // column only
{
aRef.Set( rParam.aRefFormulaCell.GetAddress(), true, false, false );
aForString.append(aRef.GetRefString(this, nTab1));
@@ -391,7 +391,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera
nCol2 = std::min( nCol2, (SCCOL)(rParam.aRefFormulaEnd.Col() -
rParam.aRefFormulaCell.Col() + nCol1 + 1));
}
- else if (rParam.nMode == 1) // nur zeilenweise
+ else if (rParam.meMode == ScTabOpParam::Row) // row only
{
aRef.Set( rParam.aRefFormulaCell.GetAddress(), false, true, false );
aForString.append(aRef.GetRefString(this, nTab1));
@@ -404,7 +404,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera
nRow2 = std::min( nRow2, (SCROW)(rParam.aRefFormulaEnd.Row() -
rParam.aRefFormulaCell.Row() + nRow1 + 1));
}
- else // beides
+ else // both
{
aForString.append(rParam.aRefFormulaCell.GetRefString(this, nTab1));
aForString.append(sSep);
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 54b7c87..ae5bdf9 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -294,12 +294,14 @@ sal_Bool ScSolveParam::operator==( const ScSolveParam& r ) const
//------------------------------------------------------------------------
// struct ScTabOpParam
+ScTabOpParam::ScTabOpParam() : meMode(Column) {}
+
ScTabOpParam::ScTabOpParam( const ScTabOpParam& r )
: aRefFormulaCell ( r.aRefFormulaCell ),
aRefFormulaEnd ( r.aRefFormulaEnd ),
aRefRowCell ( r.aRefRowCell ),
aRefColCell ( r.aRefColCell ),
- nMode ( r.nMode )
+ meMode(r.meMode)
{
}
@@ -309,12 +311,12 @@ ScTabOpParam::ScTabOpParam( const ScRefAddress& rFormulaCell,
const ScRefAddress& rFormulaEnd,
const ScRefAddress& rRowCell,
const ScRefAddress& rColCell,
- sal_uInt8 nMd)
+ Mode eMode )
: aRefFormulaCell ( rFormulaCell ),
aRefFormulaEnd ( rFormulaEnd ),
aRefRowCell ( rRowCell ),
aRefColCell ( rColCell ),
- nMode ( nMd )
+ meMode(eMode)
{
}
@@ -326,19 +328,19 @@ ScTabOpParam& ScTabOpParam::operator=( const ScTabOpParam& r )
aRefFormulaEnd = r.aRefFormulaEnd;
aRefRowCell = r.aRefRowCell;
aRefColCell = r.aRefColCell;
- nMode = r.nMode;
+ meMode = r.meMode;
return *this;
}
//------------------------------------------------------------------------
-sal_Bool ScTabOpParam::operator==( const ScTabOpParam& r ) const
+bool ScTabOpParam::operator==( const ScTabOpParam& r ) const
{
return ( (aRefFormulaCell == r.aRefFormulaCell)
&& (aRefFormulaEnd == r.aRefFormulaEnd)
&& (aRefRowCell == r.aRefRowCell)
&& (aRefColCell == r.aRefColCell)
- && (nMode == r.nMode) );
+ && (meMode == r.meMode) );
}
OUString ScGlobal::GetAbsDocName( const OUString& rFileName,
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index e8caace..ceb758b 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -1104,13 +1104,13 @@ void ImportExcel::TableOp( void )
if( nFirstCol && nFirstRow )
{
ScTabOpParam aTabOpParam;
- aTabOpParam.nMode = (nGrbit & EXC_TABLEOP_BOTH) ? 2 : ((nGrbit & EXC_TABLEOP_ROW) ? 1 : 0 );
+ aTabOpParam.meMode = (nGrbit & EXC_TABLEOP_BOTH) ? ScTabOpParam::Both : ((nGrbit & EXC_TABLEOP_ROW) ? ScTabOpParam::Row : ScTabOpParam::Column);
sal_uInt16 nCol = nFirstCol - 1;
sal_uInt16 nRow = nFirstRow - 1;
SCTAB nTab = GetCurrScTab();
- switch( aTabOpParam.nMode )
+ switch (aTabOpParam.meMode)
{
- case 0: // COL
+ case ScTabOpParam::Column:
aTabOpParam.aRefFormulaCell.Set(
static_cast<SCCOL>(nFirstCol),
static_cast<SCROW>(nFirstRow - 1), nTab, false,
@@ -1124,7 +1124,7 @@ void ImportExcel::TableOp( void )
false );
nRow++;
break;
- case 1: // ROW
+ case ScTabOpParam::Row:
aTabOpParam.aRefFormulaCell.Set(
static_cast<SCCOL>(nFirstCol - 1),
static_cast<SCROW>(nFirstRow), nTab, false, false,
@@ -1138,7 +1138,7 @@ void ImportExcel::TableOp( void )
false );
nCol++;
break;
- case 2: // TWO-INPUT
+ case ScTabOpParam::Both: // TWO-INPUT
aTabOpParam.aRefFormulaCell.Set(
static_cast<SCCOL>(nFirstCol - 1),
static_cast<SCROW>(nFirstRow - 1), nTab, false,
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 5f1c8cb..60a45f7 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4165,7 +4165,7 @@ sal_Bool ScDocFunc::TabOp( const ScRange& rRange, const ScMarkData* pTabMark,
rParam.aRefFormulaEnd,
rParam.aRefRowCell,
rParam.aRefColCell,
- rParam.nMode) );
+ rParam.meMode) );
}
pDoc->InsertTableOp(rParam, nStartCol, nStartRow, nEndCol, nEndRow, aMark);
rDocShell.PostPaintGridAll();
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
index 129e35a..1b10216 100644
--- a/sc/source/ui/inc/undoblk.hxx
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -24,6 +24,7 @@
#include "viewutil.hxx"
#include "spellparam.hxx"
#include "cellmergeoption.hxx"
+#include "paramisc.hxx"
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
@@ -527,7 +528,7 @@ public:
const ScRefAddress& rFormulaEnd,
const ScRefAddress& rRowCell,
const ScRefAddress& rColCell,
- sal_uInt8 nMode );
+ ScTabOpParam::Mode eMode );
virtual ~ScUndoTabOp();
virtual void Undo();
@@ -544,7 +545,7 @@ private:
ScRefAddress theFormulaEnd;
ScRefAddress theRowCell;
ScRefAddress theColCell;
- sal_uInt8 nMode;
+ ScTabOpParam::Mode meMode;
};
diff --git a/sc/source/ui/miscdlgs/tabopdlg.cxx b/sc/source/ui/miscdlgs/tabopdlg.cxx
index 3a01e3d..abff708 100644
--- a/sc/source/ui/miscdlgs/tabopdlg.cxx
+++ b/sc/source/ui/miscdlgs/tabopdlg.cxx
@@ -243,7 +243,7 @@ IMPL_LINK( ScTabOpDlg, BtnHdl, PushButton*, pBtn )
{
if ( pBtn == &aBtnOk )
{
- sal_uInt8 nMode = 3;
+ ScTabOpParam::Mode eMode = ScTabOpParam::Column;
sal_uInt16 nError = 0;
// Zu ueberpruefen:
@@ -274,7 +274,7 @@ IMPL_LINK( ScTabOpDlg, BtnHdl, PushButton*, pBtn )
theFormulaCell.Col() != theFormulaEnd.Col())
nError = TABOPERR_NOCOLFORMULA;
else
- nMode = 1;
+ eMode = ScTabOpParam::Row;
}
}
if (!aEdColCell.GetText().isEmpty())
@@ -284,16 +284,16 @@ IMPL_LINK( ScTabOpDlg, BtnHdl, PushButton*, pBtn )
nError = TABOPERR_WRONGCOL;
else
{
- if (nMode == 1) // beides
+ if (eMode == ScTabOpParam::Row) // beides
{
- nMode = 2;
+ eMode = ScTabOpParam::Both;
ConvertSingleRef( pDoc, aEdFormulaRange.GetText(), nCurTab,
theFormulaCell, eConv );
}
else if (theFormulaCell.Row() != theFormulaEnd.Row())
nError = TABOPERR_NOROWFORMULA;
else
- nMode = 0;
+ eMode = ScTabOpParam::Column;
}
}
}
@@ -302,11 +302,7 @@ IMPL_LINK( ScTabOpDlg, BtnHdl, PushButton*, pBtn )
RaiseError( (ScTabOpErr) nError );
else
{
- ScTabOpParam aOutParam( theFormulaCell,
- theFormulaEnd,
- theRowCell,
- theColCell,
- nMode );
+ ScTabOpParam aOutParam(theFormulaCell, theFormulaEnd, theRowCell, theColCell, eMode);
ScTabOpItem aOutItem( SID_TABOP, &aOutParam );
SetDispatcherLock( false );
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 53fb213..26029fd 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -1086,7 +1086,7 @@ ScUndoTabOp::ScUndoTabOp( ScDocShell* pNewDocShell,
const ScRefAddress& rFormulaEnd,
const ScRefAddress& rRowCell,
const ScRefAddress& rColCell,
- sal_uInt8 nMd )
+ ScTabOpParam::Mode eMode )
: ScSimpleUndo( pNewDocShell ),
aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ),
pUndoDoc ( pNewUndoDoc ),
@@ -1094,7 +1094,7 @@ ScUndoTabOp::ScUndoTabOp( ScDocShell* pNewDocShell,
theFormulaEnd ( rFormulaEnd ),
theRowCell ( rRowCell ),
theColCell ( rColCell ),
- nMode ( nMd )
+ meMode(eMode)
{
}
@@ -1135,9 +1135,7 @@ void ScUndoTabOp::Redo()
ScUndoUtil::MarkSimpleBlock( pDocShell, aRange );
- ScTabOpParam aParam( theFormulaCell, theFormulaEnd,
- theRowCell, theColCell,
- nMode );
+ ScTabOpParam aParam(theFormulaCell, theFormulaEnd, theRowCell, theColCell, meMode);
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
if (pViewShell)
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index e16f8ae..6c302d5 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -5342,7 +5342,7 @@ void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress&
ScDocShell* pDocSh = GetDocShell();
if (pDocSh)
{
- sal_Bool bError = false;
+ bool bError = false;
ScTabOpParam aParam;
aParam.aRefFormulaCell = ScRefAddress( (SCCOL)aFormulaRange.StartColumn,
(SCROW)aFormulaRange.StartRow, aFormulaRange.Sheet,
@@ -5356,19 +5356,20 @@ void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress&
aParam.aRefColCell = ScRefAddress( (SCCOL)aColumnCell.Column,
(SCROW)aColumnCell.Row, aColumnCell.Sheet,
false, false, false );
+
switch (nMode)
{
case sheet::TableOperationMode_COLUMN:
- aParam.nMode = 0;
+ aParam.meMode = ScTabOpParam::Column;
break;
case sheet::TableOperationMode_ROW:
- aParam.nMode = 1;
+ aParam.meMode = ScTabOpParam::Row;
break;
case sheet::TableOperationMode_BOTH:
- aParam.nMode = 2;
+ aParam.meMode = ScTabOpParam::Both;
break;
default:
- bError = sal_True;
+ bError = true;
}
if (!bError)
More information about the Libreoffice-commits
mailing list