diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-20 19:41:42 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-22 21:49:19 -0400 |
commit | 9d0869e2f0a2c8e6a07c16c34686ef0029c63587 (patch) | |
tree | 08d4123a7292553d6e325e89af3d361094157150 /sc | |
parent | 18d821241c33686a419aec6d6dbaa165bf5e95b7 (diff) |
Reduce indentation levels by early bail-out.
Change-Id: Ief345d48750250150836097af2072fb030aa4505
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 103 |
1 files changed, 51 insertions, 52 deletions
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 184c859bfa82..dde15a6a7514 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -6342,66 +6342,65 @@ void ScCellObj::InputEnglishString( const ::rtl::OUString& rText ) // but all parsing is in English. ScDocShell* pDocSh = GetDocShell(); - if ( pDocSh ) + if (!pDocSh) + return; + + String aString(rText); + ScDocument* pDoc = pDocSh->GetDocument(); + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + sal_uInt32 nOldFormat = pDoc->GetNumberFormat( aCellPos ); + if (pFormatter->GetType(nOldFormat) == NUMBERFORMAT_TEXT) { - String aString(rText); - ScDocument* pDoc = pDocSh->GetDocument(); - SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); - sal_uInt32 nOldFormat = pDoc->GetNumberFormat( aCellPos ); - if ( pFormatter->GetType( nOldFormat ) == NUMBERFORMAT_TEXT ) - { - SetString_Impl(aString, false, false); // text cell - } - else - { - ScDocFunc &rFunc = pDocSh->GetDocFunc(); + SetString_Impl(aString, false, false); // text cell + return; + } + + ScDocFunc &rFunc = pDocSh->GetDocFunc(); - ScInputStringType aRes = - ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US); + ScInputStringType aRes = + ScStringUtil::parseInputString(*pFormatter, aString, LANGUAGE_ENGLISH_US); - if (aRes.meType != ScInputStringType::Unknown) + if (aRes.meType != ScInputStringType::Unknown) + { + 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, aRes.mnFormatType); + if (nNewFormat != nOldFormat) { - 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, 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, true, true ); - } - } + ScPatternAttr aPattern( pDoc->GetPool() ); + aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); + // ATTR_LANGUAGE_FORMAT remains unchanged + rFunc.ApplyAttributes( *GetMarkData(), aPattern, true, true ); } - switch (aRes.meType) + } + } + 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)) { - 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<EditTextObject> 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 + ScFieldEditEngine& rEngine = pDoc->GetEditEngine(); + rEngine.SetText(aRes.maText); + boost::scoped_ptr<EditTextObject> 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 } } |