--- sc/source/ui/app/inputhdl.cxx 2008-04-13 08:22:38.000000000 +0530 +++ sc/source/ui/app/inputhdl.cxx 2008-05-14 15:54:09.000000000 +0530 @@ -1792,13 +1792,56 @@ void ScInputHandler::DataChanged( BOOL b void ScInputHandler::UpdateFormulaMode() { SfxApplication* pSfxApp = SFX_APP(); + bool bRefMode=false; - if ( pEngine->GetParagraphCount() == 1 && - ( pEngine->GetText((USHORT)0).GetChar(0) == '=' || + if( pEngine->GetText((USHORT)0).GetChar(0) == '=' || pEngine->GetText((USHORT)0).GetChar(0) == '+' || - pEngine->GetText((USHORT)0).GetChar(0) == '-' ) && + pEngine->GetText((USHORT)0).GetChar(0) == '-' ) + { + String aString = GetEditString(); + EditView* pActiveView = pTopView ? pTopView : pTableView; + if (pActiveView) + { + ESelection aSel = pActiveView->GetSelection(); + if(aSel.nStartPos != aSel.nEndPos) + { + aString = String(aString, 0, aSel.nStartPos); + } + } + + if(aString.Len() == 1) + { + bRefMode=true; + } + else + { + if ( !GetSelIsRef() && aString.Len() > 2 && + ( aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) ) + { + String aStr('='); + aStr += aString; + aString = aStr; + } + if(pActiveViewSh) + { + ScViewData* pViewData = pActiveViewSh->GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + ScAddress aPos( pViewData->GetCurPos() ); + ScCompiler aComp( pDoc, aPos ); + aComp.SetCloseBrackets( false ); + ScTokenArray* pArr = aComp.CompileString( aString ); + if ( pArr->MayReferenceFollow() ) + { + bRefMode = true; + } + } + } + } + + if ( pEngine->GetParagraphCount() == 1 && + ( bRefMode == true ) && !bProtected ) - { + { if (!bFormulaMode) { bFormulaMode = TRUE; --- sc/source/ui/view/tabvwsha.cxx 2007-10-02 20:52:06.000000000 +0530 +++ sc/source/ui/view/tabvwsha.cxx 2008-05-06 15:50:32.000000000 +0530 @@ -469,35 +469,9 @@ void ScTabViewShell::ExecuteCellFormatDl //------------------------------------------------------------------ void ScTabViewShell::ExecuteInputDirect() { - bool bRefInputMode = false; ScModule* pScMod = SC_MOD(); - if ( pScMod->IsFormulaMode() ) - { - ScInputHandler* pHdl = pScMod->GetInputHdl(); - String aString = pHdl->GetEditString(); - - if ( !pHdl->GetSelIsRef() && aString.Len() > 1 && - ( aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) ) - { - ScViewData* pViewData = GetViewData(); - ScDocument* pDoc = pViewData->GetDocument(); - ScAddress aPos( pViewData->GetCurPos() ); - ScCompiler aComp( pDoc, aPos ); - aComp.SetCloseBrackets( false ); - ScTokenArray* pArr = aComp.CompileString( aString ); - if ( pArr->MayReferenceFollow() ) - { - bRefInputMode = true; - } - } - else - { - bRefInputMode = true; - } - } - - if ( !bRefInputMode ) + if ( !pScMod->IsFormulaMode() ) { pScMod->InputEnterHandler(); }