diff options
author | Kurt Zenker <kz@openoffice.org> | 2007-10-02 14:22:22 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2007-10-02 14:22:22 +0000 |
commit | 89a4b89ea6dce139afdae2dd022432be3031f3be (patch) | |
tree | 8409f6ff4673363428e5e54b8926ba153fae61d1 /sc/source/ui/view/viewfunc.cxx | |
parent | adf4e0989c800eb1860df4770d1d092f299bfbac (diff) |
INTEGRATION: CWS calcformula (1.37.116); FILE MERGED
2007/08/20 15:05:43 tbe 1.37.116.1: #i20496# Enhanced formula input
Diffstat (limited to 'sc/source/ui/view/viewfunc.cxx')
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index e083842bd9ed..cd603910e539 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -4,9 +4,9 @@ * * $RCSfile: viewfunc.cxx,v $ * - * $Revision: 1.37 $ + * $Revision: 1.38 $ * - * last change: $Author: kz $ $Date: 2007-05-10 17:04:32 $ + * last change: $Author: kz $ $Date: 2007-10-02 15:22:22 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -421,9 +421,46 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS DBG_ASSERT( nUndoPos==nSelCount, "nUndoPos!=nSelCount" ); } + bool bFormula = false; + + // a single '=' character is handled as string (needed for special filters) + if ( rString.Len() > 1 ) + { + if ( rString.GetChar(0) == '=' ) + { + // handle as formula + bFormula = true; + } + else if ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' ) + { + // if there is more than one leading '+' or '-' character, remove the additional ones + String aString( rString ); + xub_StrLen nIndex = 1; + xub_StrLen nLen = aString.Len(); + while ( nIndex < nLen && ( aString.GetChar( nIndex ) == '+' || aString.GetChar( nIndex ) == '-' ) ) + { + ++nIndex; + } + aString.Erase( 1, nIndex - 1 ); + + // if the remaining part without the leading '+' or '-' character + // is non-empty and not a number, handle as formula + if ( aString.Len() > 1 ) + { + sal_uInt32 nFormat = 0; + pDoc->GetNumberFormat( nCol, nRow, nTab, nFormat ); + SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); + double fNumber = 0; + if ( !pFormatter->IsNumberFormat( aString, nFormat, fNumber ) ) + { + bFormula = true; + } + } + } + } + BOOL bNumFmtChanged = FALSE; - // einzelnes '=' ist String (wird fuer Spezialfilter so gebraucht) - if ( rString.GetChar(0) == '=' && rString.Len() > 1 ) + if ( bFormula ) { // Formel, compile mit AutoCorrection for (i=0; i<nTabCount; i++) if (rMark.GetTableSelect(i)) @@ -540,7 +577,8 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rS aPos.SetTab( i ); ULONG nIndex = (ULONG) ((SfxUInt32Item*) pDoc->GetAttr( nCol, nRow, i, ATTR_VALUE_FORMAT ))->GetValue(); - if ( pFormatter->GetType(nIndex) == NUMBERFORMAT_TEXT ) + if ( pFormatter->GetType( nIndex ) == NUMBERFORMAT_TEXT || + ( ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' ) && nError && rString.Equals( aFormula ) ) ) { ScStringCell* pCell = new ScStringCell( aFormula ); pDoc->PutCell( aPos, pCell ); |