[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - 2 commits - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Thu Oct 31 21:25:42 CET 2013
sc/inc/tokenuno.hxx | 2 -
sc/source/filter/inc/workbookhelper.hxx | 7 +++
sc/source/filter/inc/worksheethelper.hxx | 20 +++-------
sc/source/filter/oox/defnamesbuffer.cxx | 2 -
sc/source/filter/oox/numberformatsbuffer.cxx | 2 -
sc/source/filter/oox/workbookhelper.cxx | 50 +++++++++++++++++++--------
sc/source/filter/oox/worksheethelper.cxx | 27 +++++++-------
sc/source/ui/unoobj/tokenuno.cxx | 2 -
8 files changed, 67 insertions(+), 45 deletions(-)
New commits:
commit c2780da92bcb99e8cf95dec404da4837e4cd9f3d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Oct 31 16:25:32 2013 -0400
Populate raw cell values using ScDocumentImport.
Also fix incorrect const methods. Methods that populate the document
model should not be marked const even if the compiler allows it.
Change-Id: Ic5d1670ce93c166d0f44ace04494fccab6eac275
diff --git a/sc/inc/tokenuno.hxx b/sc/inc/tokenuno.hxx
index a323b62..4287405 100644
--- a/sc/inc/tokenuno.hxx
+++ b/sc/inc/tokenuno.hxx
@@ -43,7 +43,7 @@ public:
ScTokenArray& rTokenArray,
const com::sun::star::uno::Sequence< com::sun::star::sheet::FormulaToken >& rSequence );
static SC_DLLPUBLIC bool ConvertToTokenSequence(
- ScDocument& rDoc,
+ const ScDocument& rDoc,
com::sun::star::uno::Sequence< com::sun::star::sheet::FormulaToken >& rSequence,
const ScTokenArray& rTokenArray );
};
diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx
index 4db98ce..a905612 100644
--- a/sc/source/filter/inc/workbookhelper.hxx
+++ b/sc/source/filter/inc/workbookhelper.hxx
@@ -149,7 +149,11 @@ public:
void useInternalChartDataTable( bool bInternal );
// document model ---------------------------------------------------------
- ScDocument& getScDocument() const;
+ ScDocument& getScDocument();
+ const ScDocument& getScDocument() const;
+
+ ScDocumentImport& getDocImport();
+
ScEditEngineDefaulter& getEditEngine() const;
/** Returns a reference to the source/target spreadsheet document model. */
::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
diff --git a/sc/source/filter/inc/worksheethelper.hxx b/sc/source/filter/inc/worksheethelper.hxx
index 270cafe..8cda876 100644
--- a/sc/source/filter/inc/worksheethelper.hxx
+++ b/sc/source/filter/inc/worksheethelper.hxx
@@ -281,23 +281,17 @@ public:
void setManualRowHeight( sal_Int32 nRow );
/** Inserts a value cell directly into the Calc sheet. */
- void putValue(
- const ::com::sun::star::table::CellAddress& rAddress,
- double fValue ) const;
+ void putValue( const com::sun::star::table::CellAddress& rAddress, double fValue );
/** Inserts a string cell directly into the Calc sheet. */
- void putString(
- const ::com::sun::star::table::CellAddress& rAddress,
- const OUString& rText ) const;
+ void putString( const com::sun::star::table::CellAddress& rAddress, const OUString& rText );
/** Inserts a rich-string cell directly into the Calc sheet. */
- void putRichString(
- const ::com::sun::star::table::CellAddress& rAddress,
- const RichString& rString,
- const Font* pFirstPortionFont ) const;
+ void putRichString(
+ const com::sun::star::table::CellAddress& rAddress,
+ const RichString& rString, const Font* pFirstPortionFont );
/** Inserts a formula cell directly into the Calc sheet. */
- void putFormulaTokens(
- const ::com::sun::star::table::CellAddress& rAddress,
- const ApiTokenSequence& rTokens ) const;
+ void putFormulaTokens(
+ const com::sun::star::table::CellAddress& rAddress, const ApiTokenSequence& rTokens );
/** Initial conversion before importing the worksheet. */
void initializeWorksheetImport();
diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx
index 3c3dd09..94203a8 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -458,7 +458,7 @@ bool DefinedName::getAbsoluteRange( CellRangeAddress& orRange ) const
{
ScTokenArray* pTokenArray = mpScRangeData->GetCode();
Sequence< FormulaToken > aFTokenSeq;
- ScTokenConversion::ConvertToTokenSequence( this->getScDocument(), aFTokenSeq, *pTokenArray );
+ ScTokenConversion::ConvertToTokenSequence(getScDocument(), aFTokenSeq, *pTokenArray);
return getFormulaParser().extractCellRange( orRange, aFTokenSeq, false );
}
diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx
index d6992f5..2b6f271 100644
--- a/sc/source/filter/oox/numberformatsbuffer.cxx
+++ b/sc/source/filter/oox/numberformatsbuffer.cxx
@@ -1936,7 +1936,7 @@ sal_Int32 NumberFormat::finalizeImport( const Reference< XNumberFormats >& rxNum
void NumberFormat::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
{
- ScDocument& rDoc = getScDocument();
+ const ScDocument& rDoc = getScDocument();
static sal_uLong nDflt = rDoc.GetFormatTable()->GetStandardFormat( ScGlobal::eLnge );
sal_uLong nScNumFmt = nDflt;
if ( maApiData.mnIndex )
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index f7fc225..496be44 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -662,7 +662,7 @@ void WorkbookGlobals::finalize()
//stop preventing establishment of listeners as is done in
//ScDocShell::AfterXMLLoading() for ods
getScDocument().SetInsertingFromOtherDoc(false);
- getScDocument().RebuildFormulaGroups();
+ getDocImport().finalize();
if (mxCLKernelThread.is())
mxCLKernelThread->join();
@@ -755,11 +755,21 @@ void WorkbookHelper::finalizeWorkbookImport()
// document model -------------------------------------------------------------
-ScDocument& WorkbookHelper::getScDocument() const
+ScDocument& WorkbookHelper::getScDocument()
{
return mrBookGlob.getScDocument();
}
+const ScDocument& WorkbookHelper::getScDocument() const
+{
+ return mrBookGlob.getScDocument();
+}
+
+ScDocumentImport& WorkbookHelper::getDocImport()
+{
+ return mrBookGlob.getDocImport();
+}
+
ScEditEngineDefaulter& WorkbookHelper::getEditEngine() const
{
return mrBookGlob.getEditEngine();
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index ee8201f..fe02efa 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -69,6 +69,7 @@
#include "editutil.hxx"
#include "tokenarray.hxx"
#include "tablebuffer.hxx"
+#include "documentimport.hxx"
#include <svl/stritem.hxx>
#include <editeng/editobj.hxx>
@@ -355,11 +356,11 @@ private:
typedef ::std::list< ValidationModel > ValidationModelList;
/** Inserts all imported hyperlinks into their cell ranges. */
- void finalizeHyperlinkRanges() const;
+ void finalizeHyperlinkRanges();
/** Generates the final URL for the passed hyperlink. */
OUString getHyperlinkUrl( const HyperlinkModel& rHyperlink ) const;
/** Inserts a hyperlinks into the specified cell. */
- void insertHyperlink( const CellAddress& rAddress, const OUString& rUrl ) const;
+ void insertHyperlink( const CellAddress& rAddress, const OUString& rUrl );
/** Inserts all imported data validations into their cell ranges. */
void finalizeValidationRanges() const;
@@ -977,7 +978,7 @@ void WorksheetGlobals::finalizeDrawingImport()
// private --------------------------------------------------------------------
-void WorksheetGlobals::finalizeHyperlinkRanges() const
+void WorksheetGlobals::finalizeHyperlinkRanges()
{
for( HyperlinkModelList::const_iterator aIt = maHyperlinks.begin(), aEnd = maHyperlinks.end(); aIt != aEnd; ++aIt )
{
@@ -1018,7 +1019,7 @@ OUString WorksheetGlobals::getHyperlinkUrl( const HyperlinkModel& rHyperlink ) c
return aUrl;
}
-void WorksheetGlobals::insertHyperlink( const CellAddress& rAddress, const OUString& rUrl ) const
+void WorksheetGlobals::insertHyperlink( const CellAddress& rAddress, const OUString& rUrl )
{
Reference< XCell > xCell = getCell( rAddress );
if( xCell.is() ) switch( xCell->getType() )
@@ -1544,11 +1545,11 @@ void WorksheetHelper::setRowModel( const RowModel& rModel )
mrSheetGlob.setRowModel( rModel );
}
-void WorksheetHelper::putValue( const CellAddress& rAddress, double fValue ) const
+void WorksheetHelper::putValue( const CellAddress& rAddress, double fValue )
{
ScAddress aAddress;
ScUnoConversion::FillScAddress( aAddress, rAddress );
- getScDocument().SetValue( aAddress.Col(), aAddress.Row(), aAddress.Tab(), fValue );
+ getDocImport().setNumericCell(aAddress, fValue);
}
void WorksheetHelper::setCellFormulaValue( const ::com::sun::star::table::CellAddress& rAddress,
@@ -1557,34 +1558,32 @@ void WorksheetHelper::setCellFormulaValue( const ::com::sun::star::table::CellAd
getFormulaBuffer().setCellFormulaValue( rAddress, fValue );
}
-void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rText ) const
+void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rText )
{
ScAddress aAddress;
ScUnoConversion::FillScAddress( aAddress, rAddress );
- ScDocument& rDoc = getScDocument();
if ( !rText.isEmpty() )
- rDoc.SetTextCell(aAddress, rText);
+ getDocImport().setStringCell(aAddress, rText);
}
-void WorksheetHelper::putRichString( const CellAddress& rAddress, const RichString& rString, const Font* pFirstPortionFont ) const
+void WorksheetHelper::putRichString( const CellAddress& rAddress, const RichString& rString, const Font* pFirstPortionFont )
{
- ScDocument& rDoc = getScDocument();
ScEditEngineDefaulter& rEE = getEditEngine();
// The cell will own the text object instance returned from convert().
ScAddress aAddress;
ScUnoConversion::FillScAddress( aAddress, rAddress );
- rDoc.SetEditText(aAddress, rString.convert(rEE, pFirstPortionFont));
+ getDocImport().setEditCell(aAddress, rString.convert(rEE, pFirstPortionFont));
}
-void WorksheetHelper::putFormulaTokens( const CellAddress& rAddress, const ApiTokenSequence& rTokens ) const
+void WorksheetHelper::putFormulaTokens( const CellAddress& rAddress, const ApiTokenSequence& rTokens )
{
ScDocument& rDoc = getScDocument();
ScTokenArray aTokenArray;
ScAddress aCellPos;
ScUnoConversion::FillScAddress( aCellPos, rAddress );
ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens );
- rDoc.SetFormula(aCellPos, aTokenArray);
+ getDocImport().setFormulaCell(aCellPos, aTokenArray);
}
void WorksheetHelper::initializeWorksheetImport()
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx
index 1694981..ff1b417 100644
--- a/sc/source/ui/unoobj/tokenuno.cxx
+++ b/sc/source/ui/unoobj/tokenuno.cxx
@@ -372,7 +372,7 @@ bool ScTokenConversion::ConvertToTokenArray( ScDocument& rDoc,
return !rTokenArray.Fill(rSequence,rDoc.GetExternalRefManager());
}
-bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc,
+bool ScTokenConversion::ConvertToTokenSequence( const ScDocument& rDoc,
uno::Sequence<sheet::FormulaToken>& rSequence, const ScTokenArray& rTokenArray )
{
bool bError = false;
commit 6a1cdd5f2f57b22cde3fd8f1ae3cf3f62585ff37
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Oct 31 14:30:18 2013 -0400
Set up ScDocumentImport accessor and initialize it.
Also, those createFoo() methods shouldn't be const since it does
modify the state of the document model.
Change-Id: I6a9267c54710f359506ca39c1e213f82595ebfe3
diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx
index 9ea2353..4db98ce 100644
--- a/sc/source/filter/inc/workbookhelper.hxx
+++ b/sc/source/filter/inc/workbookhelper.hxx
@@ -56,6 +56,7 @@ namespace oox { namespace core {
} }
class ScDocument;
+class ScDocumentImport;
class ScEditEngineDefaulter;
namespace oox {
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 9ae6fea..f7fc225 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -72,6 +72,7 @@
#include "datauno.hxx"
#include "globalnames.hxx"
#include "clkernelthread.hxx"
+#include "documentimport.hxx"
#include "rtl/ref.hxx"
#include "formulabuffer.hxx"
@@ -80,6 +81,7 @@
#include "editeng/editstat.hxx"
#include <boost/noncopyable.hpp>
+#include <boost/scoped_ptr.hpp>
namespace oox {
namespace xls {
@@ -147,7 +149,10 @@ public:
return *mxEditEngine.get();
}
- ScDocument& getScDocument() const { return *mpDoc; }
+ ScDocument& getScDocument() { return *mpDoc; }
+ const ScDocument& getScDocument() const { return *mpDoc; }
+
+ ScDocumentImport& getDocImport();
/** Returns a reference to the source/target spreadsheet document model. */
inline Reference< XSpreadsheetDocument > getDocument() const { return mxDoc; }
@@ -156,15 +161,15 @@ public:
/** Returns the specified cell or page style from the Calc document. */
Reference< XStyle > getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
/** Creates and returns a defined name on-the-fly in the Calc document. */
- ScRangeData* createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const;
+ ScRangeData* createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags );
/** Creates and returns a defined name on the-fly in the correct Calc sheet. */
- ScRangeData* createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const;
+ ScRangeData* createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab );
/** Creates and returns a database range on-the-fly in the Calc document. */
- Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr ) const;
+ Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr );
/** Creates and returns an unnamed database range on-the-fly in the Calc document. */
- Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const;
+ Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr );
/** Creates and returns a com.sun.star.style.Style object for cells or pages. */
- Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle ) const;
+ Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle );
/** Helper to switch chart data table - specifically for xlsx imports */
void useInternalChartDataTable( bool bInternal );
@@ -306,6 +311,7 @@ private:
rtl_TextEncoding meTextEnc; /// BIFF byte string text encoding.
bool mbHasCodePage; /// True = CODEPAGE record exists in imported stream.
ScDocument* mpDoc;
+ boost::scoped_ptr<ScDocumentImport> mxDocImport;
};
// ----------------------------------------------------------------------------
@@ -329,6 +335,10 @@ WorkbookGlobals::~WorkbookGlobals()
mrExcelFilter.unregisterWorkbookGlobals();
}
+ScDocumentImport& WorkbookGlobals::getDocImport()
+{
+ return *mxDocImport;
+}
Reference< XNameContainer > WorkbookGlobals::getStyleFamily( bool bPageStyles ) const
{
@@ -396,7 +406,8 @@ OUString findUnusedName( const ScRangeName* pRangeName, const OUString& rSuggest
}
-ScRangeData* WorkbookGlobals::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
+ScRangeData* WorkbookGlobals::createNamedRangeObject(
+ OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags )
{
// create the name and insert it into the Calc document
ScRangeData* pScRangeData = NULL;
@@ -412,7 +423,8 @@ ScRangeData* WorkbookGlobals::createNamedRangeObject( OUString& orName, const Se
return pScRangeData;
}
-ScRangeData* WorkbookGlobals::createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken >& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
+ScRangeData* WorkbookGlobals::createLocalNamedRangeObject(
+ OUString& orName, const Sequence< FormulaToken >& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab )
{
// create the name and insert it into the Calc document
ScRangeData* pScRangeData = NULL;
@@ -428,7 +440,7 @@ ScRangeData* WorkbookGlobals::createLocalNamedRangeObject( OUString& orName, con
return pScRangeData;
}
-Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr ) const
+Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr )
{
// validate cell range
CellRangeAddress aDestRange = rRangeAddr;
@@ -453,7 +465,7 @@ Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString
return xDatabaseRange;
}
-Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const
+Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr )
{
// validate cell range
CellRangeAddress aDestRange = rRangeAddr;
@@ -482,7 +494,7 @@ Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( c
return xDatabaseRange;
}
-Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle ) const
+Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle )
{
Reference< XStyle > xStyle;
try
@@ -547,6 +559,8 @@ void WorkbookGlobals::initialize( bool bWorkbookFile )
if (!mpDoc)
throw RuntimeException("Workbookhelper::getScDocument(): Failed to access ScDocument from model", Reference<XInterface>());
+ mxDocImport.reset(new ScDocumentImport(*mpDoc));
+
mxFormulaBuffer.reset( new FormulaBuffer( *this ) );
mxWorkbookSettings.reset( new WorkbookSettings( *this ) );
mxViewSettings.reset( new ViewSettings( *this ) );
More information about the Libreoffice-commits
mailing list