[Libreoffice-commits] .: Branch 'feature/matrix-new-backend' - sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue Jul 17 23:06:23 PDT 2012
sc/source/core/tool/scmatrix.cxx | 37 ++++++++++++++++++++++++++++++-------
1 file changed, 30 insertions(+), 7 deletions(-)
New commits:
commit e504b7113eb0c56cfe58815143a7e46f01bbcf74
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Jul 18 01:54:01 2012 -0400
Reorganized code to remove redundant calls to get_type().
This makes GetString() a teeny bit faster.
Change-Id: Id49df508d45584d529caa4061e77f4ddc4431c67
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 039b289..d6cec83 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -668,16 +668,25 @@ rtl::OUString ScMatrixImpl::GetString(SCSIZE nC, SCSIZE nR) const
{
if (ValidColRowOrReplicated( nC, nR ))
{
+ double fErr = 0.0;
switch (maMat.get_type(nR, nC))
{
case mdds::mtm::element_string:
return maMat.get<rtl::OUString>(nR, nC);
case mdds::mtm::element_empty:
return EMPTY_OUSTRING;
+ case mdds::mtm::element_numeric:
+ OSL_FAIL("ScMatrixImpl::GetString: access error, no string");
+ fErr = maMat.get<double>(nR, nC);
+ break;
+ case mdds::mtm::element_boolean:
+ OSL_FAIL("ScMatrixImpl::GetString: access error, no string");
+ fErr = maMat.get<bool>(nR, nC);
+ break;
default:
- SetErrorAtInterpreter( GetError(nC, nR));
OSL_FAIL("ScMatrixImpl::GetString: access error, no string");
}
+ SetErrorAtInterpreter(GetDoubleErrorValue(fErr));
}
else
{
@@ -701,10 +710,18 @@ rtl::OUString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC,
return ::rtl::OUString();
}
- if (IsString( nC, nR))
+ double fVal = 0.0;
+ switch (maMat.get_type(nR, nC))
{
- if (IsEmptyPath( nC, nR))
- { // result of empty FALSE jump path
+ case mdds::mtm::element_string:
+ return maMat.get<rtl::OUString>(nR, nC);
+ case mdds::mtm::element_empty:
+ {
+ if (!maMatFlag.get<double>(nR, nC))
+ // not an empty path.
+ break;
+
+ // result of empty FALSE jump path
sal_uLong nKey = rFormatter.GetStandardFormat( NUMBERFORMAT_LOGICAL,
ScGlobal::eLnge);
::rtl::OUString aStr;
@@ -712,17 +729,23 @@ rtl::OUString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC,
rFormatter.GetOutputString( 0.0, nKey, aStr, &pColor);
return aStr;
}
- return GetString( nC, nR);
+ case mdds::mtm::element_numeric:
+ fVal = maMat.get<double>(nR, nC);
+ break;
+ case mdds::mtm::element_boolean:
+ fVal = maMat.get<bool>(nR, nC);
+ break;
+ default:
+ ;
}
- sal_uInt16 nError = GetError( nC, nR);
+ sal_uInt16 nError = GetDoubleErrorValue(fVal);
if (nError)
{
SetErrorAtInterpreter( nError);
return ScGlobal::GetErrorString( nError);
}
- double fVal= GetDouble( nC, nR);
sal_uLong nKey = rFormatter.GetStandardFormat( NUMBERFORMAT_NUMBER,
ScGlobal::eLnge);
::rtl::OUString aStr;
More information about the Libreoffice-commits
mailing list