From 18d821241c33686a419aec6d6dbaa165bf5e95b7 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 20 Mar 2013 19:40:29 -0400 Subject: Another removal of PutCell(). Change-Id: I1519ed62f623770f690385cb725e5d1e9a636e48 --- sc/source/ui/unoobj/cellsuno.cxx | 50 +++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'sc/source/ui/unoobj') diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 0e3994ce132e..184c859bfa82 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -27,6 +27,7 @@ #include #include #include +#include "editeng/editobj.hxx" #include #include #include @@ -6354,29 +6355,52 @@ void ScCellObj::InputEnglishString( const ::rtl::OUString& rText ) else { ScDocFunc &rFunc = pDocSh->GetDocFunc(); - short nFormatType = 0; - ScBaseCell* pNewCell = rFunc.InterpretEnglishString( aCellPos, aString, - EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1, &nFormatType ); - if (pNewCell) + + ScInputStringType aRes = + ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US); + + if (aRes.meType != ScInputStringType::Unknown) { - if ( ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 && nFormatType != 0 ) + if ((nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && aRes.mnFormatType) { // apply a format for the recognized type and the old format's language - sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat( *pFormatter, nOldFormat, nFormatType ); - if ( nNewFormat != nOldFormat ) + sal_uInt32 nNewFormat = ScGlobal::GetStandardFormat(*pFormatter, nOldFormat, aRes.mnFormatType); + if (nNewFormat != nOldFormat) { ScPatternAttr aPattern( pDoc->GetPool() ); aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); // ATTR_LANGUAGE_FORMAT remains unchanged - rFunc.ApplyAttributes( *GetMarkData(), aPattern, sal_True, sal_True ); + rFunc.ApplyAttributes( *GetMarkData(), aPattern, true, true ); } } - // put the cell into the document - // (after applying the format, so possible formula recalculation already uses the new format) - (void)rFunc.PutCell( aCellPos, pNewCell, sal_True ); } - else - SetString_Impl(aString, false, false); // no cell from InterpretEnglishString, probably empty string + switch (aRes.meType) + { + case ScInputStringType::Formula: + rFunc.SetFormulaCell( + aCellPos, + new ScFormulaCell(pDoc, aCellPos, aRes.maText, formula::FormulaGrammar::GRAM_PODF_A1), + false); + break; + case ScInputStringType::Number: + rFunc.SetValueCell(aCellPos, aRes.mfValue, false); + break; + case ScInputStringType::Text: + { + if (ScStringUtil::isMultiline(aRes.maText)) + { + ScFieldEditEngine& rEngine = pDoc->GetEditEngine(); + rEngine.SetText(aRes.maText); + boost::scoped_ptr pEditText(rEngine.CreateTextObject()); + rFunc.SetEditCell(aCellPos, *pEditText, false); + } + else + rFunc.SetStringCell(aCellPos, aRes.maText, false); + } + break; + default: + SetString_Impl(aString, false, false); // probably empty string + } } } } -- cgit