[Libreoffice-commits] core.git: 2 commits - sc/source

Eike Rathke erack at redhat.com
Mon May 12 14:27:30 PDT 2014


 sc/source/ui/app/inputhdl.cxx |   31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

New commits:
commit ad8a7bf570576186f37d5c30bb41bb119ded1626
Author: Eike Rathke <erack at redhat.com>
Date:   Mon May 12 23:22:22 2014 +0200

    include parentheses replacement in functions' formula data, fdo#75264
    
    ... to actually make hitting Enter on a function tip work so the
    parentheses are added and the cursor is placed in between and the
    correct description is displayed.
    
    Change-Id: I2cbe8f9e2b745a8331aeb8744b64d0baa1f0513e

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index da4f5a2..f35ab6a 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -98,6 +98,11 @@ namespace {
 // and the quotation mark (so string constants can be skipped)
 const sal_Char pMinDelimiters[] = " !\"";
 
+// Formula data replacement character for a pair of parentheses at end of
+// function name, to force sorting parentheses before all other characters.
+// Collation may treat parentheses differently.
+const sal_Unicode cParenthesesReplacement = 0x0001;
+
 sal_Unicode lcl_getSheetSeparator(ScDocument* pDoc)
 {
     ScCompiler aComp(pDoc, ScAddress());
@@ -720,6 +725,7 @@ void ScInputHandler::GetFormulaData()
         else
             pFormulaDataPara = new ScTypedCaseStrSet;
 
+        const OUString aParenthesesReplacement( cParenthesesReplacement);
         const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
         sal_uLong nListCount = pFuncList->GetCount();
         for(sal_uLong i=0;i<nListCount;i++)
@@ -727,7 +733,6 @@ void ScInputHandler::GetFormulaData()
             const ScFuncDesc* pDesc = pFuncList->GetFunction( i );
             if ( pDesc->pFuncName )
             {
-                pFormulaData->insert(ScTypedStrData(*pDesc->pFuncName, 0.0, ScTypedStrData::Standard));
                 const sal_Unicode* pName = pDesc->pFuncName->getStr();
                 const sal_Int32 nLen = pDesc->pFuncName->getLength();
                 // fdo#75264 fill maFormulaChar with all characters used in formula names
@@ -736,6 +741,8 @@ void ScInputHandler::GetFormulaData()
                     sal_Unicode c = pName[ j ];
                     maFormulaChar.insert( c );
                 }
+                OUString aFuncName = *pDesc->pFuncName + aParenthesesReplacement;
+                pFormulaData->insert(ScTypedStrData(aFuncName, 0.0, ScTypedStrData::Standard));
                 pDesc->initArgumentInfo();
                 OUString aEntry = pDesc->getSignature();
                 pFormulaDataPara->insert(ScTypedStrData(aEntry, 0.0, ScTypedStrData::Standard));
@@ -830,9 +837,10 @@ void ScInputHandler::ShowTipCursor()
                             nArgPos = aHelper.GetArgStart( aSelText, nNextFStart, 0 );
                             nArgs = static_cast<sal_uInt16>(ppFDesc->getParameterCount());
 
+                            OUString aFuncName = ppFDesc->getFunctionName() + "(";
                             OUString aNew;
                             ScTypedCaseStrSet::const_iterator it =
-                                findText(*pFormulaDataPara, pFormulaDataPara->end(), ppFDesc->getFunctionName(), aNew, false);
+                                findText(*pFormulaDataPara, pFormulaDataPara->end(), aFuncName, aNew, false);
                             if (it != pFormulaDataPara->end())
                             {
                                 bool bFlag = false;
@@ -1084,7 +1092,8 @@ void ScInputHandler::UseFormulaData()
                 miAutoPosFormula = findText(*pFormulaData, miAutoPosFormula, aText, aNew, false);
                 if (miAutoPosFormula != pFormulaData->end())
                 {
-                    aNew += "()";
+                    if (aNew[aNew.getLength()-1] == cParenthesesReplacement)
+                        aNew = aNew.copy( 0, aNew.getLength()-1) + "()";
                     ShowTip( aNew );
                     aAutoSearch = aText;
                 }
@@ -1227,6 +1236,8 @@ void ScInputHandler::NextFormulaEntry( bool bBack )
         if (itNew != pFormulaData->end())
         {
             miAutoPosFormula = itNew;
+            if (aNew[aNew.getLength()-1] == cParenthesesReplacement)
+                aNew = aNew.copy( 0, aNew.getLength()-1) + "()";
             ShowTip(aNew); // Display a quick help
         }
     }
@@ -1288,7 +1299,9 @@ void ScInputHandler::PasteFunctionData()
     if (pFormulaData && miAutoPosFormula != pFormulaData->end())
     {
         const ScTypedStrData& rData = *miAutoPosFormula;
-        const OUString& aInsert = rData.GetString();
+        OUString aInsert = rData.GetString();
+        if (aInsert[aInsert.getLength()-1] == cParenthesesReplacement)
+            aInsert = aInsert.copy( 0, aInsert.getLength()-1) + "()";
         bool bParInserted = false;
 
         DataChanging(); // Cannot be new
commit ead754112a1ecaa456d8b5d7231ed178bbcb3a0b
Author: Eike Rathke <erack at redhat.com>
Date:   Mon May 12 19:04:48 2014 +0200

    nitpick: avoid triple redirection inside loop, fdo#75264 related
    
    Also, it's fdo#12345 instead of fdo12345 (just to provide better
    "grep'ability").
    
    Change-Id: Id1c1f849addcb96f71408ba38e2dde8e316271be

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 22a0e05..da4f5a2 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -728,10 +728,12 @@ void ScInputHandler::GetFormulaData()
             if ( pDesc->pFuncName )
             {
                 pFormulaData->insert(ScTypedStrData(*pDesc->pFuncName, 0.0, ScTypedStrData::Standard));
-                // fdo75264 fill maFormulaChar with all characters used in formula names
-                for ( sal_Int32 j = 0; j < pDesc->pFuncName->getLength(); j++ )
+                const sal_Unicode* pName = pDesc->pFuncName->getStr();
+                const sal_Int32 nLen = pDesc->pFuncName->getLength();
+                // fdo#75264 fill maFormulaChar with all characters used in formula names
+                for ( sal_Int32 j = 0; j < nLen; j++ )
                 {
-                    sal_Unicode c = pDesc->pFuncName->getStr()[ j ];
+                    sal_Unicode c = pName[ j ];
                     maFormulaChar.insert( c );
                 }
                 pDesc->initArgumentInfo();
@@ -1018,7 +1020,7 @@ bool ScInputHandler::GetFuncName( OUString& aStart, OUString& aResult )
     aStart = ScGlobal::pCharClass->uppercase( aStart );
     sal_Int32 nPos = aStart.getLength() - 1;
     sal_Unicode c = aStart[ nPos ];
-    // fdo75264 use maFormulaChar to check if characters are used in function names
+    // fdo#75264 use maFormulaChar to check if characters are used in function names
     ::std::set< sal_Unicode >::const_iterator p = maFormulaChar.find( c );
     if ( p == maFormulaChar.end() )
         return false; // last character is not part of any function name, quit


More information about the Libreoffice-commits mailing list