[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - 2 commits - sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Fri Nov 15 09:49:29 PST 2013
sc/source/core/tool/compiler.cxx | 74 ++++-------------------------
sc/source/core/tool/tokenstringcontext.cxx | 6 ++
2 files changed, 17 insertions(+), 63 deletions(-)
New commits:
commit 9ba5a227b0e71f73356d2783720d2cdeff37ba01
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Nov 15 12:49:53 2013 -0500
Pre-quote sheet names to avoid doing it every single time.
Change-Id: Ib103ca22bf59c334945c0462588610899a0acfaa
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 395bf11..a9d17d6 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -734,10 +734,7 @@ struct ConventionOOO_A1 : public Convention_A1
if (static_cast<size_t>(nTab) >= rCxt.maTabNames.size())
aString = ScGlobal::GetRscString(STR_NO_REF_TABLE);
else
- {
aString = rCxt.maTabNames[nTab];
- ScCompiler::CheckTabQuotes( aString, FormulaGrammar::CONV_OOO );
- }
aString += ".";
return aString;
}
@@ -1040,10 +1037,6 @@ struct ConventionXL
return;
}
rTabName = rCxt.maTabNames[aAbs.Tab()];
-
- // XL uses the same sheet name quoting conventions in both modes
- // it is safe to use A1 here
- ScCompiler::CheckTabQuotes( rTabName, FormulaGrammar::CONV_XL_A1 );
}
static void MakeTabStr( OUStringBuffer& rBuf,
diff --git a/sc/source/core/tool/tokenstringcontext.cxx b/sc/source/core/tool/tokenstringcontext.cxx
index b26d338..075bd96 100644
--- a/sc/source/core/tool/tokenstringcontext.cxx
+++ b/sc/source/core/tool/tokenstringcontext.cxx
@@ -27,6 +27,12 @@ TokenStringContext::TokenStringContext( const ScDocument* pDoc, formula::Formula
if (pDoc)
{
maTabNames = pDoc->GetAllTableNames();
+ {
+ std::vector<OUString>::iterator it = maTabNames.begin(), itEnd = maTabNames.end();
+ for (; it != itEnd; ++it)
+ ScCompiler::CheckTabQuotes(*it, formula::FormulaGrammar::extractRefConvention(eGram));
+ }
+
const ScRangeName* pNames = pDoc->GetRangeName();
if (pNames)
{
commit e69986d7a4c4e793a2cabdbbd50cbf3149c332f1
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Nov 15 12:33:41 2013 -0500
We don't need this any more.
This was used when external references used hidden sheets as a cheesy
workaround.
Change-Id: I7e4bf3a2235a0c2e80d0aa71a81f22a10b8d0fd5
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index b5fdedc..395bf11 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -728,7 +728,7 @@ struct ConventionOOO_A1 : public Convention_A1
ConventionOOO_A1() : Convention_A1 (FormulaGrammar::CONV_OOO) { }
ConventionOOO_A1( FormulaGrammar::AddressConvention eConv ) : Convention_A1 (eConv) { }
- static OUString MakeTabStr( const sc::TokenStringContext& rCxt, SCTAB nTab, OUString& aDoc )
+ static OUString MakeTabStr( const sc::TokenStringContext& rCxt, SCTAB nTab )
{
OUString aString;
if (static_cast<size_t>(nTab) >= rCxt.maTabNames.size())
@@ -736,17 +736,6 @@ struct ConventionOOO_A1 : public Convention_A1
else
{
aString = rCxt.maTabNames[nTab];
- // "'Doc'#Tab"
- sal_Int32 nPos = ScCompiler::GetDocTabPos( aString );
- if ( nPos != -1 )
- {
- aDoc = aString.copy( 0, nPos + 1 );
- aString = aString.copy( nPos + 1 );
- aDoc = INetURLObject::decode( aDoc, INET_HEX_ESCAPE,
- INetURLObject::DECODE_UNAMBIGUOUS );
- }
- else
- aDoc = "";
ScCompiler::CheckTabQuotes( aString, FormulaGrammar::CONV_OOO );
}
aString += ".";
@@ -769,9 +758,7 @@ struct ConventionOOO_A1 : public Convention_A1
}
else
{
- OUString aDoc;
- OUString aRefStr(MakeTabStr(rCxt, rAbsRef.Tab(), aDoc));
- rBuffer.append(aDoc);
+ OUString aRefStr(MakeTabStr(rCxt, rAbsRef.Tab()));
if (!rRef.IsTabRel())
rBuffer.append('$');
rBuffer.append(aRefStr);
@@ -1042,40 +1029,24 @@ const ScCompiler::Convention * const ScCompiler::pConvOOO_A1_ODF = &ConvOOO_A1_O
struct ConventionXL
{
- static bool GetDocAndTab(
+ static void GetTab(
const ScAddress& rPos, const sc::TokenStringContext& rCxt,
- const ScSingleRefData& rRef, OUString& rDocName, OUString& rTabName )
+ const ScSingleRefData& rRef, OUString& rTabName )
{
- bool bHasDoc = false;
-
- rDocName = "";
ScAddress aAbs = rRef.toAbs(rPos);
if (rRef.IsTabDeleted() || static_cast<size_t>(aAbs.Tab()) >= rCxt.maTabNames.size())
{
rTabName = ScGlobal::GetRscString( STR_NO_REF_TABLE );
- return false;
+ return;
}
rTabName = rCxt.maTabNames[aAbs.Tab()];
- // Cheesy hack to unparse the OOO style "'Doc'#Tab"
- sal_Int32 nPos = ScCompiler::GetDocTabPos( rTabName);
- if (nPos != -1)
- {
- rDocName = rTabName.copy( 0, nPos );
- // TODO : More research into how XL escapes the doc path
- rDocName = INetURLObject::decode( rDocName, INET_HEX_ESCAPE,
- INetURLObject::DECODE_UNAMBIGUOUS );
- rTabName = rTabName.copy( nPos + 1 );
- bHasDoc = true;
- }
-
// XL uses the same sheet name quoting conventions in both modes
// it is safe to use A1 here
ScCompiler::CheckTabQuotes( rTabName, FormulaGrammar::CONV_XL_A1 );
- return bHasDoc;
}
- static void MakeDocStr( OUStringBuffer& rBuf,
+ static void MakeTabStr( OUStringBuffer& rBuf,
const ScAddress& rPos,
const sc::TokenStringContext& rCxt,
const ScComplexRefData& rRef,
@@ -1083,29 +1054,13 @@ struct ConventionXL
{
if( rRef.Ref1.IsFlag3D() )
{
- OUString aStartTabName, aStartDocName, aEndTabName, aEndDocName;
- bool bStartHasDoc = false, bEndHasDoc = false;
+ OUString aStartTabName, aEndTabName;
- bStartHasDoc = GetDocAndTab(
- rPos, rCxt, rRef.Ref1, aStartDocName, aStartTabName);
+ GetTab(rPos, rCxt, rRef.Ref1, aStartTabName);
if( !bSingleRef && rRef.Ref2.IsFlag3D() )
{
- bEndHasDoc = GetDocAndTab(
- rPos, rCxt, rRef.Ref2, aEndDocName, aEndTabName);
- }
- else
- bEndHasDoc = bStartHasDoc;
-
- if( bStartHasDoc )
- {
- // A ref across multipled workbooks ?
- if( !bEndHasDoc )
- return;
-
- rBuf.append( '[' );
- rBuf.append( aStartDocName );
- rBuf.append( ']' );
+ GetTab(rPos, rCxt, rRef.Ref2, aEndTabName);
}
rBuf.append( aStartTabName );
@@ -1274,7 +1229,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
// Foo!A1:#REF! versus #REF! at this point
ScAddress aAbs1 = aRef.Ref1.toAbs(rPos), aAbs2;
- MakeDocStr(rBuf, rPos, rCxt, aRef, bSingleRef);
+ MakeTabStr(rBuf, rPos, rCxt, aRef, bSingleRef);
if (!ValidAddress(aAbs1))
{
@@ -1461,7 +1416,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
ScRange aAbsRef = rRef.toAbs(rPos);
ScComplexRefData aRef( rRef );
- MakeDocStr(rBuf, rPos, rCxt, aRef, bSingleRef);
+ MakeTabStr(rBuf, rPos, rCxt, aRef, bSingleRef);
// Play fast and loose with invalid refs. There is not much point in producing
// Foo!A1:#REF! versus #REF! at this point
More information about the Libreoffice-commits
mailing list