formula/source/ui/dlg/FormulaHelper.cxx        |    1 +
 formula/source/ui/dlg/formula.cxx              |   13 +++++++++++--
 formula/source/ui/dlg/funcpage.cxx             |   14 ++++++++++----
 include/formula/IFunctionDescription.hxx       |    1 +
 include/formula/formdata.hxx                   |    8 ++++----
 reportdesign/source/ui/inc/FunctionHelper.hxx  |    1 +
 reportdesign/source/ui/misc/FunctionHelper.cxx |    5 +++++
 sc/inc/funcdesc.hxx                            |    8 ++++++++
 sc/source/core/data/funcdesc.cxx               |   15 +++++++++++++--
 sc/source/ui/src/scfuncs.src                   |   16 +++++++++++-----
 10 files changed, 65 insertions(+), 17 deletions(-)

New commits:
commit f6f73d2e40712dadf69cd73a34d006988669978c
Author: Eike Rathke <er...@redhat.com>
Date:   Fri Jan 8 23:12:32 2016 +0100

    Function Wizard: exclude functions with hidden flag from lists
    
    Change-Id: Ia209bb44cef5969e5c9cd360aa5725708d6bdec5

diff --git a/formula/source/ui/dlg/funcpage.cxx 
b/formula/source/ui/dlg/funcpage.cxx
index 7b83298f..d629ca3 100644
--- a/formula/source/ui/dlg/funcpage.cxx
+++ b/formula/source/ui/dlg/funcpage.cxx
@@ -108,8 +108,9 @@ void FuncPage::impl_addFunctions(const IFunctionCategory* 
_pCategory)
     for(sal_uInt32 i = 0 ; i < nCount; ++i)
     {
         TFunctionDesc pDesc(_pCategory->getFunction(i));
-        m_pLbFunction->SetEntryData(
-            m_pLbFunction->InsertEntry(pDesc->getFunctionName() 
),const_cast<IFunctionDescription *>(pDesc) );
+        if (!pDesc->isHidden())
+            m_pLbFunction->SetEntryData(
+                    m_pLbFunction->InsertEntry(pDesc->getFunctionName() 
),const_cast<IFunctionDescription *>(pDesc) );
     }
 }
 
commit 8aee44c94fd2abdb7f1566ad237da4bfdfc011fa
Author: Eike Rathke <er...@redhat.com>
Date:   Fri Jan 8 22:08:40 2016 +0100

    Function Wizard: don't overwrite an unlisted function
    
    * in a spreadsheet cell enter =LOG(foobar(SIN(1)))
    * invoke Function Wizard on that cell (Ctrl+F2)
      LOG(foobar(SIN(1))) is marked in Formula edit field
    * activate Functions page
      LOG(foobar(SIN(1))) is marked in Formula edit field
      Function LOG is selected
    * click Next button
      foobar(SIN(1)) is marked in Formula edit field
      Function ABS is selected
    * click Next button
      foobar(SIN(1)) is overwritten with ABS( )
    * only Cancel solves the problem
    
    foobar() could be any user defined or macro function that have no
    function description in the Formula Wizard.
    
    Change-Id: I1cb69a9e38c0b8f251d783bd0f67b4b24ade50d0

diff --git a/formula/source/ui/dlg/formula.cxx 
b/formula/source/ui/dlg/formula.cxx
index 0d0a646..1cf839d 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -1041,7 +1041,16 @@ IMPL_LINK_TYPED( FormulaDlg_Impl, BtnHdl, Button*, pBtn, 
void )
     }
     else if ( pBtn == m_pBtnForward )
     {
-        const IFunctionDescription* pDesc =pFuncPage->GetFuncDesc( 
pFuncPage->GetFunction() );
+        const IFunctionDescription* pDesc;
+        sal_Int32 nSelFunc = pFuncPage->GetFunction();
+        if (nSelFunc != LISTBOX_ENTRY_NOTFOUND)
+            pDesc = pFuncPage->GetFuncDesc( nSelFunc );
+        else
+        {
+            // Do not overwrite the selected formula expression, just edit the
+            // unlisted function.
+            pFuncDesc = pDesc = nullptr;
+        }
 
         if(pDesc==pFuncDesc || !pFuncPage->IsVisible())
             EditNextFunc( true );
@@ -1963,7 +1972,7 @@ void FormEditData::Reset()
     nMode = 0;
     nFStart = 0;
     nCatSel = 1;        //! oder 0 (zuletzt benutzte)
-    nFuncSel = 0;
+    nFuncSel = LISTBOX_ENTRY_NOTFOUND;
     nOffset = 0;
     nEdFocus = 0;
     bMatrix = false;
diff --git a/formula/source/ui/dlg/funcpage.cxx 
b/formula/source/ui/dlg/funcpage.cxx
index 42a2b35..7b83298f 100644
--- a/formula/source/ui/dlg/funcpage.cxx
+++ b/formula/source/ui/dlg/funcpage.cxx
@@ -155,7 +155,9 @@ void FuncPage::UpdateFunctionList()
 
 
     m_pLbFunction->SetUpdateMode( true );
-    m_pLbFunction->SelectEntryPos(0);
+    // Ensure no function is selected so the Next button doesn't overwrite a
+    // function that is not in the list with an arbitrary selected one.
+    m_pLbFunction->SetNoSelection();
 
     if(IsVisible()) SelHdl(*m_pLbFunction);
 }
@@ -198,7 +200,10 @@ sal_Int32 FuncPage::GetFuncPos(const IFunctionDescription* 
_pDesc)
 
 void FuncPage::SetFunction(sal_Int32 nFunc)
 {
-    m_pLbFunction->SelectEntryPos(nFunc);
+    if (nFunc == LISTBOX_ENTRY_NOTFOUND)
+        m_pLbFunction->SetNoSelection();
+    else
+        m_pLbFunction->SelectEntryPos(nFunc);
 }
 
 void FuncPage::SetFocus()
diff --git a/include/formula/formdata.hxx b/include/formula/formdata.hxx
index 30c0ce5..ecd3dd1 100644
--- a/include/formula/formdata.hxx
+++ b/include/formula/formdata.hxx
@@ -37,8 +37,8 @@ public:
 
     inline sal_uInt16       GetMode() const     { return nMode; }
     inline sal_Int32        GetFStart() const   { return nFStart; }
-    inline sal_uInt16       GetCatSel() const   { return nCatSel; }
-    inline sal_uInt16       GetFuncSel() const  { return nFuncSel; }
+    inline sal_Int32        GetCatSel() const   { return nCatSel; }
+    inline sal_Int32        GetFuncSel() const  { return nFuncSel; }
     inline sal_uInt16       GetOffset() const   { return nOffset; }
     inline sal_uInt16       GetEdFocus() const  { return nEdFocus; }
     inline const OUString&  GetUndoStr() const  { return aUndoStr; }
@@ -63,8 +63,8 @@ protected:
 private:
     sal_uInt16          nMode;              // enum ScFormulaDlgMode
     sal_Int32           nFStart;
-    sal_uInt16          nCatSel;
-    sal_uInt16          nFuncSel;
+    sal_Int32           nCatSel;
+    sal_Int32           nFuncSel;
     sal_uInt16          nOffset;
     sal_uInt16          nEdFocus;
     OUString            aUndoStr;
commit 077cc9fbaa29d1440f930c3ae4be86db73ee30a8
Author: Eike Rathke <er...@redhat.com>
Date:   Fri Jan 8 19:04:50 2016 +0100

    prepare for hidden flag in function description for Function Wizard
    
    Change-Id: Ic018ea5b962a66b6543e57d9cc1d44711e51de6e

diff --git a/formula/source/ui/dlg/FormulaHelper.cxx 
b/formula/source/ui/dlg/FormulaHelper.cxx
index b2ff0c4..a1f98e5 100644
--- a/formula/source/ui/dlg/FormulaHelper.cxx
+++ b/formula/source/ui/dlg/FormulaHelper.cxx
@@ -44,6 +44,7 @@ namespace formula
             virtual void initArgumentInfo()  const override {}
             virtual OUString getSignature() const override { return 
OUString(); }
             virtual OString getHelpId() const override { return ""; }
+            virtual bool isHidden() const override { return false; }
             virtual sal_uInt32 getParameterCount() const override { return 0; }
             virtual sal_uInt32 getVarArgsStart() const override { return 0; }
             virtual OUString getParameterName(sal_uInt32 ) const override { 
return OUString(); }
diff --git a/include/formula/IFunctionDescription.hxx 
b/include/formula/IFunctionDescription.hxx
index bed71cd..7fb02c5 100644
--- a/include/formula/IFunctionDescription.hxx
+++ b/include/formula/IFunctionDescription.hxx
@@ -88,6 +88,7 @@ namespace formula
         virtual void initArgumentInfo() const = 0;
         virtual OUString getSignature() const = 0;
         virtual OString getHelpId() const = 0;
+        virtual bool isHidden() const = 0;
 
         // parameter
         virtual sal_uInt32 getParameterCount() const = 0;
diff --git a/reportdesign/source/ui/inc/FunctionHelper.hxx 
b/reportdesign/source/ui/inc/FunctionHelper.hxx
index 2302d75..df18ed3 100644
--- a/reportdesign/source/ui/inc/FunctionHelper.hxx
+++ b/reportdesign/source/ui/inc/FunctionHelper.hxx
@@ -71,6 +71,7 @@ public:
     virtual void initArgumentInfo()  const override;
     virtual OUString getSignature() const override ;
     virtual OString getHelpId() const override ;
+    virtual bool isHidden() const override;
     virtual sal_uInt32 getParameterCount() const override ;
     virtual sal_uInt32 getVarArgsStart() const override;
     virtual OUString getParameterName(sal_uInt32 _nPos) const override ;
diff --git a/reportdesign/source/ui/misc/FunctionHelper.cxx 
b/reportdesign/source/ui/misc/FunctionHelper.cxx
index a92fc49..00c3ae9 100644
--- a/reportdesign/source/ui/misc/FunctionHelper.cxx
+++ b/reportdesign/source/ui/misc/FunctionHelper.cxx
@@ -193,6 +193,11 @@ OString FunctionDescription::getHelpId() const
     return OString();
 }
 
+bool FunctionDescription::isHidden() const
+{
+    return false;
+}
+
 sal_uInt32 FunctionDescription::getParameterCount() const
 {
     return m_aParameter.getLength();
diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx
index 1c2bccd..b078644 100644
--- a/sc/inc/funcdesc.hxx
+++ b/sc/inc/funcdesc.hxx
@@ -102,6 +102,13 @@ public:
     */
     virtual OString getHelpId() const override ;
 
+    /** Returns whether function is hidden and not offered in the Function
+        Wizard unless used in an expression.
+
+        @return flag whether function is hidden
+     */
+    virtual bool isHidden() const override;
+
     /**
       Returns number of arguments
 
@@ -216,6 +223,7 @@ public:
     OString          sHelpId;                /**< HelpId of function */
     bool                  bIncomplete         :1; /**< Incomplete argument 
info (set for add-in info from configuration) */
     bool                  bHasSuppressedArgs  :1; /**< Whether there is any 
suppressed parameter. */
+    bool                  mbHidden            :1; /**< Whether function is 
hidden */
 };
 
 /**
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index 729590b..10c070b 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -69,7 +69,8 @@ ScFuncDesc::ScFuncDesc() :
         nArgCount       (0),
         nVarArgsStart   (0),
         bIncomplete     (false),
-        bHasSuppressedArgs(false)
+        bHasSuppressedArgs(false),
+        mbHidden        (false)
 {}
 
 ScFuncDesc::~ScFuncDesc()
@@ -105,6 +106,7 @@ void ScFuncDesc::Clear()
     sHelpId.clear();
     bIncomplete = false;
     bHasSuppressedArgs = false;
+    mbHidden = false;
 }
 
 OUString ScFuncDesc::GetParamList() const
@@ -354,6 +356,11 @@ OString ScFuncDesc::getHelpId() const
     return sHelpId;
 }
 
+bool ScFuncDesc::isHidden() const
+{
+    return mbHidden;
+}
+
 sal_uInt32 ScFuncDesc::getParameterCount() const
 {
     return nArgCount;
@@ -799,7 +806,11 @@ sal_Unicode ScFunctionMgr::getSingleToken(const 
formula::IFunctionManager::EToke
 ScFuncRes::ScFuncRes( ResId &aRes, ScFuncDesc* pDesc, bool & rbSuppressed )
  : Resource(aRes)
 {
-    rbSuppressed = (bool)GetNum();
+    sal_uInt16 nFunctionFlags = GetNum();
+    // Bit 1: entirely suppressed
+    // Bit 2: hidden unless used
+    rbSuppressed = ((nFunctionFlags & 1) != 0);
+    pDesc->mbHidden = ((nFunctionFlags & 2) != 0);
     pDesc->nCategory = GetNum();
     pDesc->sHelpId = ReadByteStringRes();
     pDesc->nArgCount = GetNum();
diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src
index 122815f..632cd43 100644
--- a/sc/source/ui/src/scfuncs.src
+++ b/sc/source/ui/src/scfuncs.src
@@ -31,11 +31,17 @@
  *
  *      ExtraData block with:
  *
- *          Boolean flag whether function is suppressed. Usually 0. This may be
- *          used to add UI string resources before UI freeze if implementation
- *          isn't ready yet without displaying them in the function wizard,
- *          most recent used list and other UI elements. Also not available via
- *          API then.
+ *          16-bit value:
+ *
+ *          Bit 1: boolean flag whether function is suppressed. Usually 0. This
+ *          may be used to add UI string resources before UI freeze if
+ *          implementation isn't ready yet without displaying them in the
+ *          function wizard, most recent used list and other UI elements. Also
+ *          not available via API then.
+ *
+ *          Bit 2: boolean flag whether function is hidden in the Function
+ *          Wizard unless used in an expression.
+ *
  *
  *          Function group (text, math, ...), one of ID_FUNCTION_GRP_...
  *
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to