summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-05-03 03:42:56 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-06-02 03:24:55 +0200
commit737fbae8e3e62b587e2651be3668d0a39192af18 (patch)
tree064127c45bacc800030c3b67398390a9fa81a591
parent326fc28c4180bad32858bbc4ae4883043d4d0750 (diff)
String->OUString and bail out early
Change-Id: I3fe720269be83840f3d76304042e92541ee14dbf
-rw-r--r--sc/source/ui/app/inputhdl.cxx100
1 files changed, 49 insertions, 51 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 3a4f2b9d2a67..04a09ed4c2b5 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1299,77 +1299,75 @@ void ScInputHandler::PasteFunctionData()
// Selektion berechnen und als Tip-Hilfe anzeigen
//
-static String lcl_Calculate( const String& rFormula, ScDocument* pDoc, const ScAddress &rPos )
+static String lcl_Calculate( const OUString& rFormula, ScDocument* pDoc, const ScAddress &rPos )
{
//! mit ScFormulaDlg::CalcValue zusammenfassen und ans Dokument verschieben !!!!
//! (Anfuehrungszeichen bei Strings werden nur hier eingefuegt)
- String aValue;
+ if(rFormula.isEmpty())
+ return String();
- if (rFormula.Len())
+ boost::scoped_ptr<ScFormulaCell> pCell(new ScFormulaCell( pDoc, rPos, rFormula ));
+
+ // HACK! um bei ColRowNames kein #REF! zu bekommen,
+ // wenn ein Name eigentlich als Bereich in die Gesamt-Formel
+ // eingefuegt wird, bei der Einzeldarstellung aber als
+ // single-Zellbezug interpretiert wird
+ bool bColRowName = pCell->HasColRowName();
+ if ( bColRowName )
{
- boost::scoped_ptr<ScFormulaCell> pCell(new ScFormulaCell( pDoc, rPos, rFormula ));
+ // ColRowName im RPN-Code?
+ if ( pCell->GetCode()->GetCodeLen() <= 1 )
+ { // ==1: einzelner ist als Parameter immer Bereich
+ // ==0: es waere vielleicht einer, wenn..
+ OUStringBuffer aBraced;
+ aBraced.append('(');
+ aBraced.append(rFormula);
+ aBraced.append(')');
+ pCell.reset(new ScFormulaCell( pDoc, rPos, aBraced.makeStringAndClear() ));
+ }
+ else
+ bColRowName = false;
+ }
- // HACK! um bei ColRowNames kein #REF! zu bekommen,
- // wenn ein Name eigentlich als Bereich in die Gesamt-Formel
- // eingefuegt wird, bei der Einzeldarstellung aber als
- // single-Zellbezug interpretiert wird
- bool bColRowName = pCell->HasColRowName();
- if ( bColRowName )
+ sal_uInt16 nErrCode = pCell->GetErrCode();
+ if ( nErrCode == 0 )
+ {
+ SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable());
+ Color* pColor;
+ if ( pCell->IsValue() )
{
- // ColRowName im RPN-Code?
- if ( pCell->GetCode()->GetCodeLen() <= 1 )
- { // ==1: einzelner ist als Parameter immer Bereich
- // ==0: es waere vielleicht einer, wenn..
- OUStringBuffer aBraced;
- aBraced.append('(');
- aBraced.append(rFormula);
- aBraced.append(')');
- pCell.reset(new ScFormulaCell( pDoc, rPos, aBraced.makeStringAndClear() ));
- }
- else
- bColRowName = false;
+ double n = pCell->GetValue();
+ sal_uLong nFormat = aFormatter.GetStandardFormat( n, 0,
+ pCell->GetFormatType(), ScGlobal::eLnge );
+ aFormatter.GetInputLineString( n, nFormat, aValue );
+ //! display OutputString but insert InputLineString
}
-
- sal_uInt16 nErrCode = pCell->GetErrCode();
- if ( nErrCode == 0 )
+ else
{
- SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable());
- Color* pColor;
- if ( pCell->IsValue() )
+ String aStr = pCell->GetString();
+ sal_uLong nFormat = aFormatter.GetStandardFormat(
+ pCell->GetFormatType(), ScGlobal::eLnge);
{
- double n = pCell->GetValue();
- sal_uLong nFormat = aFormatter.GetStandardFormat( n, 0,
- pCell->GetFormatType(), ScGlobal::eLnge );
- aFormatter.GetInputLineString( n, nFormat, aValue );
- //! display OutputString but insert InputLineString
- }
- else
- {
- String aStr = pCell->GetString();
- sal_uLong nFormat = aFormatter.GetStandardFormat(
- pCell->GetFormatType(), ScGlobal::eLnge);
- {
OUString sTempIn(aStr);
OUString sTempOut(aValue);
aFormatter.GetOutputString( sTempIn, nFormat,
- sTempOut, &pColor );
+ sTempOut, &pColor );
aStr = sTempIn;
aValue = sTempOut;
- }
-
- aValue.Insert('"',0); // in Anfuehrungszeichen
- aValue+='"';
- //! Anfuehrungszeichen im String escapen ????
}
- ScRange aTestRange;
- if ( bColRowName || (aTestRange.Parse(rFormula) & SCA_VALID) )
- aValue.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ..." )); // Bereich
+ aValue.Insert('"',0); // in Anfuehrungszeichen
+ aValue+='"';
+ //! Anfuehrungszeichen im String escapen ????
}
- else
- aValue = ScGlobal::GetErrorString(nErrCode);
+
+ ScRange aTestRange;
+ if ( bColRowName || (aTestRange.Parse(rFormula) & SCA_VALID) )
+ aValue.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ..." )); // Bereich
}
+ else
+ aValue = ScGlobal::GetErrorString(nErrCode);
return aValue;
}