summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-10-10 23:08:08 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-11 12:14:27 -0400
commitb3e35aa551fa8abc0215a0ef416fc9acbbc3c0d9 (patch)
tree0dfeb6d94fec97f810fc90b61e689960068ff1c7 /sc
parent7333881bb7b04f7e4e2a28638024ae82a9c14e81 (diff)
Fix VLOOKUP calculation when the matching value is literal string.
ScRawToken needed to store a shared string value rather than the normal unicode string array. This fixes a previously failed unit test. Change-Id: I87164c018ace0761c40d1493f44fe25909a4499c
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/compiler.hxx6
-rw-r--r--sc/source/core/tool/compiler.cxx14
-rw-r--r--sc/source/core/tool/token.cxx24
3 files changed, 25 insertions, 19 deletions
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 0ecb2a5eeb39..28e4efebf013 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -138,6 +138,10 @@ public:
bool bGlobal;
sal_uInt16 nIndex;
} name;
+ struct {
+ rtl_uString* mpData;
+ rtl_uString* mpDataIgnoreCase;
+ } sharedstring;
ScMatrix* pMat;
sal_uInt16 nError;
sal_Unicode cStr[ MAXSTRLEN+1 ]; // string (up to 255 characters + 0)
@@ -161,7 +165,7 @@ public:
// Use these methods only on tokens that are not part of a token array,
// since the reference count is cleared!
void SetOpCode( OpCode eCode );
- void SetString( const sal_Unicode* pStr );
+ void SetString( rtl_uString* pData, rtl_uString* pDataIgoreCase );
void SetSingleReference( const ScSingleRefData& rRef );
void SetDoubleReference( const ScComplexRefData& rRef );
void SetDouble( double fVal );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 128cf183f644..2ba6ffc21ceb 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -17,11 +17,14 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "compiler.hxx"
+
#include <sfx2/app.hxx>
#include <sfx2/objsh.hxx>
#include <basic/sbmeth.hxx>
#include <basic/sbstar.hxx>
#include <svl/zforlist.hxx>
+#include "svl/sharedstringpool.hxx"
#include <sal/macros.h>
#include <tools/rcid.h>
#include <tools/solar.h>
@@ -41,7 +44,6 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
-#include "compiler.hxx"
#include "rangenam.hxx"
#include "dbdata.hxx"
#include "document.hxx"
@@ -2566,7 +2568,9 @@ bool ScCompiler::IsString()
{
cSymbol[nLen] = '\0';
ScRawToken aToken;
- aToken.SetString( cSymbol+1 );
+ const sal_Unicode* pStr = cSymbol+1;
+ svl::SharedString aSS = pDoc->GetSharedStringPool().intern(OUString(pStr));
+ aToken.SetString(aSS.getData(), aSS.getDataIgnoreCase());
pRawToken = aToken.Clone();
return true;
}
@@ -3464,7 +3468,8 @@ bool ScCompiler::NextNewToken( bool bInArray )
* information if not ODFF (in that case it was already handled).
* */
ScRawToken aToken;
- aToken.SetString( aStr.getStr() );
+ svl::SharedString aSS = pDoc->GetSharedStringPool().intern(aStr);
+ aToken.SetString(aSS.getData(), aSS.getDataIgnoreCase());
aToken.NewOpCode( ocBad );
pRawToken = aToken.Clone();
}
@@ -3607,7 +3612,8 @@ bool ScCompiler::NextNewToken( bool bInArray )
// the interpreter.
aUpper = ScGlobal::pCharClass->lowercase( aUpper );
ScRawToken aToken;
- aToken.SetString( aUpper.getStr() );
+ svl::SharedString aSS = pDoc->GetSharedStringPool().intern(aUpper);
+ aToken.SetString(aSS.getData(), aSS.getDataIgnoreCase());
aToken.NewOpCode( ocBad );
pRawToken = aToken.Clone();
if ( bAutoCorrect )
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index c5a7f8e619ce..ab9e3a906280 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -174,21 +174,14 @@ void ScRawToken::SetOpCode( OpCode e )
nRefCnt = 0;
}
-void ScRawToken::SetString( const sal_Unicode* pStr )
+void ScRawToken::SetString( rtl_uString* pData, rtl_uString* pDataIgoreCase )
{
eOp = ocPush;
eType = svString;
- if ( pStr )
- {
- xub_StrLen nLen = GetStrLen( pStr ) + 1;
- if( nLen > MAXSTRLEN )
- nLen = MAXSTRLEN;
- memcpy( cStr, pStr, GetStrLenBytes( nLen ) );
- cStr[ nLen-1 ] = 0;
- }
- else
- cStr[0] = 0;
nRefCnt = 0;
+
+ sharedstring.mpData = pData;
+ sharedstring.mpDataIgnoreCase = pDataIgoreCase;
}
void ScRawToken::SetSingleReference( const ScSingleRefData& rRef )
@@ -340,7 +333,7 @@ ScRawToken* ScRawToken::Clone() const
case svByte: n += sizeof(ScRawToken::sbyte); break;
case svDouble: n += sizeof(double); break;
case svError: n += sizeof(nError); break;
- case svString: n = sal::static_int_cast<sal_uInt16>( n + GetStrLenBytes( cStr ) + GetStrLenBytes( 1 ) ); break;
+ case svString: n += sizeof(sharedstring); break;
case svSingleRef:
case svDoubleRef: n += sizeof(aRef); break;
case svMatrix: n += sizeof(ScMatrix*); break;
@@ -381,10 +374,13 @@ FormulaToken* ScRawToken::CreateToken() const
IF_NOT_OPCODE_ERROR( ocPush, FormulaDoubleToken);
return new FormulaDoubleToken( nValue );
case svString :
+ {
+ svl::SharedString aSS(sharedstring.mpData, sharedstring.mpDataIgnoreCase);
if (eOp == ocPush)
- return new FormulaStringToken( OUString( cStr ) );
+ return new FormulaStringToken(aSS);
else
- return new FormulaStringOpToken( eOp, OUString( cStr ) );
+ return new FormulaStringOpToken(eOp, aSS);
+ }
case svSingleRef :
if (eOp == ocPush)
return new ScSingleRefToken( aRef.Ref1 );