[Libreoffice-commits] core.git: officecfg/registry sc/inc sc/sdi sc/source svx/source

Dennis Francis dennisfrancis.in at gmail.com
Fri Mar 11 21:45:50 UTC 2016


 officecfg/registry/schema/org/openoffice/Office/Calc.xcs |    6 
 sc/inc/appoptio.hxx                                      |    6 
 sc/sdi/scalc.sdi                                         |    2 
 sc/source/core/tool/appoptio.cxx                         |   47 +++++-
 sc/source/ui/app/scmod.cxx                               |    6 
 sc/source/ui/view/tabvwsha.cxx                           |  115 ++++++++-------
 svx/source/stbctrls/pszctrl.cxx                          |   43 +++--
 7 files changed, 144 insertions(+), 81 deletions(-)

New commits:
commit 7bc97db5b972f27693161beb9182f8a5850f5551
Author: Dennis Francis <dennisfrancis.in at gmail.com>
Date:   Sat Oct 17 10:45:53 2015 +0530

    tdf#42629 : Allow multiple status bar functions at a time
    
    Change-Id: Ide9ced5ff4cedebd41a85814f74549648a896f16
    Reviewed-on: https://gerrit.libreoffice.org/22060
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index e2006aa..69b3f5c 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -395,6 +395,12 @@
         <info>
           <desc>Contains other layout settings.</desc>
         </info>
+        <prop oor:name="StatusbarMultiFunction" oor:type="xs:int" oor:nillable="false">
+          <info>
+            <desc>Selects a set of functions that are calculated for the selected cells, and which show the results in the status bar.</desc>
+            <label>Statusbar Functions</label>
+          </info>
+        </prop>
         <prop oor:name="StatusbarFunction" oor:type="xs:int" oor:nillable="false">
           <!-- OldPath: Calc/Layout -->
           <!-- OldLocation: Soffice.cfg -->
diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx
index 8c01420..a3fc724 100644
--- a/sc/inc/appoptio.hxx
+++ b/sc/inc/appoptio.hxx
@@ -49,8 +49,8 @@ public:
     sal_uInt16*     GetLRUFuncList() const          { return pLRUList;      }
     void        SetLRUFuncList( const sal_uInt16* pList,
                                 const sal_uInt16  nCount );
-    void        SetStatusFunc( sal_uInt16 nNew )    { nStatusFunc = nNew;   }
-    sal_uInt16      GetStatusFunc() const           { return nStatusFunc;   }
+    void        SetStatusFunc( sal_uInt32 nNew )    { nStatusFunc = nNew;   }
+    sal_uInt32      GetStatusFunc() const           { return nStatusFunc;   }
     void        SetAutoComplete( bool bNew )    { bAutoComplete = bNew; }
     bool        GetAutoComplete() const         { return bAutoComplete; }
     void        SetDetectiveAuto( bool bNew )   { bDetectiveAuto = bNew; }
@@ -87,7 +87,7 @@ private:
     SvxZoomType     eZoomType;
     sal_uInt16      nZoom;
     bool            bSynchronizeZoom;
-    sal_uInt16      nStatusFunc;
+    sal_uInt32      nStatusFunc;
     bool            bAutoComplete;
     bool            bDetectiveAuto;
     sal_uInt32  nTrackContentColor;
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 853bc79..60a4bac 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -5205,7 +5205,7 @@ SfxVoidItem StandardTextAttributes SID_TEXT_STANDARD
 ]
 
 
-SfxUInt16Item StatusBarFunc SID_PSZ_FUNCTION
+SfxUInt32Item StatusBarFunc SID_PSZ_FUNCTION
 
 [
     AutoUpdate = FALSE,
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 3bdf429..cbc3c19 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -62,7 +62,7 @@ void ScAppOptions::SetDefaults()
     nZoom           = 100;
     eZoomType       = SvxZoomType::PERCENT;
     bSynchronizeZoom = true;
-    nStatusFunc     = SUBTOTAL_FUNC_SUM;
+    nStatusFunc     = ( 1 << SUBTOTAL_FUNC_SUM );
     bAutoComplete   = true;
     bDetectiveAuto  = true;
 
@@ -215,7 +215,8 @@ static void lcl_GetSortList( Any& rDest )
 #define SCLAYOUTOPT_ZOOMVAL         2
 #define SCLAYOUTOPT_ZOOMTYPE        3
 #define SCLAYOUTOPT_SYNCZOOM        4
-#define SCLAYOUTOPT_COUNT           5
+#define SCLAYOUTOPT_STATUSBARMULTI  5
+#define SCLAYOUTOPT_COUNT           6
 
 #define CFGPATH_INPUT       "Office.Calc/Input"
 
@@ -254,6 +255,16 @@ static void lcl_GetSortList( Any& rDest )
 #define SCCOMPATOPT_KEY_BINDING     0
 #define SCCOMPATOPT_COUNT           1
 
+static sal_uInt32 lcl_ConvertStatusBarFuncSetToSingle( sal_uInt32 nFuncSet )
+{
+    if ( !nFuncSet )
+        return 0;
+    for ( sal_uInt32 nFunc = 1; nFunc < 32; ++nFunc )
+        if ( nFuncSet & ( 1 << nFunc ) )
+            return nFunc;
+    return 0;
+}
+
 Sequence<OUString> ScAppCfg::GetLayoutPropertyNames()
 {
     static const char* aPropNames[] =
@@ -262,7 +273,8 @@ Sequence<OUString> ScAppCfg::GetLayoutPropertyNames()
         "Other/StatusbarFunction",      // SCLAYOUTOPT_STATUSBAR
         "Zoom/Value",                   // SCLAYOUTOPT_ZOOMVAL
         "Zoom/Type",                    // SCLAYOUTOPT_ZOOMTYPE
-        "Zoom/Synchronize"              // SCLAYOUTOPT_SYNCZOOM
+        "Zoom/Synchronize",             // SCLAYOUTOPT_SYNCZOOM
+        "Other/StatusbarMultiFunction"  // SCLAYOUTOPT_STATUSBARMULTI
     };
     Sequence<OUString> aNames(SCLAYOUTOPT_COUNT);
     OUString* pNames = aNames.getArray();
@@ -389,6 +401,8 @@ ScAppCfg::ScAppCfg() :
     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
     if(aValues.getLength() == aNames.getLength())
     {
+        bool bStatusBarFuncSingleFound = false;
+        bool bStatusBarFuncMultiFound = false;
         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
         {
             OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
@@ -400,7 +414,10 @@ ScAppCfg::ScAppCfg() :
                         if (pValues[nProp] >>= nIntVal) SetAppMetric( (FieldUnit) nIntVal );
                         break;
                     case SCLAYOUTOPT_STATUSBAR:
-                        if (pValues[nProp] >>= nIntVal) SetStatusFunc( (sal_uInt16) nIntVal );
+                        bStatusBarFuncSingleFound = true;
+                        break;
+                    case SCLAYOUTOPT_STATUSBARMULTI:
+                        bStatusBarFuncMultiFound = true;
                         break;
                     case SCLAYOUTOPT_ZOOMVAL:
                         if (pValues[nProp] >>= nIntVal) SetZoom( (sal_uInt16) nIntVal );
@@ -414,6 +431,23 @@ ScAppCfg::ScAppCfg() :
                 }
             }
         }
+
+        sal_uInt32 nUIntVal = 0;
+        if ( bStatusBarFuncMultiFound )
+        {
+            if ( pValues[SCLAYOUTOPT_STATUSBARMULTI] >>= nUIntVal )
+                SetStatusFunc( nUIntVal );
+        }
+        else if ( bStatusBarFuncSingleFound )
+        {
+            if ( pValues[SCLAYOUTOPT_STATUSBAR] >>= nUIntVal )
+            {
+                if ( nUIntVal )
+                    SetStatusFunc( 1 << nUIntVal );
+                else
+                    SetStatusFunc( 0 );
+            }
+        }
     }
     aLayoutItem.SetCommitLink( LINK( this, ScAppCfg, LayoutCommitHdl ) );
 
@@ -589,7 +623,7 @@ ScAppCfg::ScAppCfg() :
                 pValues[nProp] <<= (sal_Int32) GetAppMetric();
                 break;
             case SCLAYOUTOPT_STATUSBAR:
-                pValues[nProp] <<= (sal_Int32) GetStatusFunc();
+                pValues[nProp] <<= lcl_ConvertStatusBarFuncSetToSingle( GetStatusFunc() );
                 break;
             case SCLAYOUTOPT_ZOOMVAL:
                 pValues[nProp] <<= (sal_Int32) GetZoom();
@@ -600,6 +634,9 @@ ScAppCfg::ScAppCfg() :
             case SCLAYOUTOPT_SYNCZOOM:
                 ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetSynchronizeZoom() );
                 break;
+            case SCLAYOUTOPT_STATUSBARMULTI:
+                pValues[nProp] <<= GetStatusFunc();
+                break;
         }
     }
     aLayoutItem.PutProperties(aNames, aValues);
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index f9afa31..c385bbe 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -468,8 +468,8 @@ void ScModule::Execute( SfxRequest& rReq )
             if (pReqArgs)
             {
                 auto const & p = pReqArgs->Get(SID_PSZ_FUNCTION);
-                OSL_ENSURE(dynamic_cast<const SfxUInt16Item*>(&p) !=  nullptr,"wrong Parameter");
-                const SfxUInt16Item& rItem = static_cast<const SfxUInt16Item&>(p);
+                OSL_ENSURE(dynamic_cast<const SfxUInt32Item*>(&p) !=  nullptr,"wrong Parameter");
+                const SfxUInt32Item& rItem = static_cast<const SfxUInt32Item&>(p);
 
                 ScAppOptions aNewOpts( GetAppOptions() );
                 aNewOpts.SetStatusFunc( rItem.GetValue() );
@@ -585,7 +585,7 @@ void ScModule::GetState( SfxItemSet& rSet )
                 rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetDetectiveAuto() ) );
                 break;
             case SID_PSZ_FUNCTION:
-                rSet.Put( SfxUInt16Item( nWhich, GetAppOptions().GetStatusFunc() ) );
+                rSet.Put( SfxUInt32Item( nWhich, GetAppOptions().GetStatusFunc() ) );
                 break;
             case SID_ATTR_METRIC:
                 rSet.Put( SfxUInt16Item( nWhich, sal::static_int_cast<sal_uInt16>(GetAppOptions().GetAppMetric()) ) );
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 513c735..dd55e52 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -66,75 +66,86 @@ bool ScTabViewShell::GetFunction( OUString& rFuncStr, sal_uInt16 nErrCode )
 {
     OUString aStr;
 
-    ScSubTotalFunc eFunc = (ScSubTotalFunc) SC_MOD()->GetAppOptions().GetStatusFunc();
+    sal_uInt32 nFuncs = SC_MOD()->GetAppOptions().GetStatusFunc();
     ScViewData& rViewData   = GetViewData();
     ScMarkData& rMark       = rViewData.GetMarkData();
     bool bIgnoreError = (rMark.IsMarked() || rMark.IsMultiMarked());
+    bool bFirst = true;
+    for ( sal_uInt16 nFunc = 0; nFunc < 32; nFunc++ )
+    {
+        if ( !(nFuncs & (1 << nFunc)) )
+            continue;
+        ScSubTotalFunc eFunc = (ScSubTotalFunc)nFunc;
 
-    if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2))
-        nErrCode = 0;
+        if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2))
+            nErrCode = 0;
 
-    if (nErrCode)
-    {
-        rFuncStr = ScGlobal::GetLongErrorString(nErrCode);
-        return true;
-    }
+        if (nErrCode)
+        {
+            rFuncStr = ScGlobal::GetLongErrorString(nErrCode);
+            return true;
+        }
 
-    sal_uInt16 nGlobStrId = 0;
-    switch (eFunc)
-    {
-        case SUBTOTAL_FUNC_AVE:  nGlobStrId = STR_FUN_TEXT_AVG; break;
-        case SUBTOTAL_FUNC_CNT:  nGlobStrId = STR_FUN_TEXT_COUNT; break;
-        case SUBTOTAL_FUNC_CNT2: nGlobStrId = STR_FUN_TEXT_COUNT2; break;
-        case SUBTOTAL_FUNC_MAX:  nGlobStrId = STR_FUN_TEXT_MAX; break;
-        case SUBTOTAL_FUNC_MIN:  nGlobStrId = STR_FUN_TEXT_MIN; break;
-        case SUBTOTAL_FUNC_SUM:  nGlobStrId = STR_FUN_TEXT_SUM; break;
-        case SUBTOTAL_FUNC_SELECTION_COUNT: nGlobStrId = STR_FUN_TEXT_SELECTION_COUNT; break;
-
-        default:
+        sal_uInt16 nGlobStrId = 0;
+        switch (eFunc)
         {
-            // added to avoid warnings
+            case SUBTOTAL_FUNC_AVE:  nGlobStrId = STR_FUN_TEXT_AVG; break;
+            case SUBTOTAL_FUNC_CNT:  nGlobStrId = STR_FUN_TEXT_COUNT; break;
+            case SUBTOTAL_FUNC_CNT2: nGlobStrId = STR_FUN_TEXT_COUNT2; break;
+            case SUBTOTAL_FUNC_MAX:  nGlobStrId = STR_FUN_TEXT_MAX; break;
+            case SUBTOTAL_FUNC_MIN:  nGlobStrId = STR_FUN_TEXT_MIN; break;
+            case SUBTOTAL_FUNC_SUM:  nGlobStrId = STR_FUN_TEXT_SUM; break;
+            case SUBTOTAL_FUNC_SELECTION_COUNT: nGlobStrId = STR_FUN_TEXT_SELECTION_COUNT; break;
+
+            default:
+            {
+                // added to avoid warnings
+            }
         }
-    }
-    if (nGlobStrId)
-    {
-        ScDocument* pDoc        = rViewData.GetDocument();
-        SCCOL       nPosX       = rViewData.GetCurX();
-        SCROW       nPosY       = rViewData.GetCurY();
-        SCTAB       nTab        = rViewData.GetTabNo();
+        if (nGlobStrId)
+        {
+            ScDocument* pDoc        = rViewData.GetDocument();
+            SCCOL       nPosX       = rViewData.GetCurX();
+            SCROW       nPosY       = rViewData.GetCurY();
+            SCTAB       nTab        = rViewData.GetTabNo();
 
-        aStr = ScGlobal::GetRscString(nGlobStrId);
-        aStr += "=";
+            aStr = ScGlobal::GetRscString(nGlobStrId);
+            aStr += "=";
 
-        ScAddress aCursor( nPosX, nPosY, nTab );
-        double nVal;
-        if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) )
-        {
-            if ( nVal == 0.0 )
-                aStr += "0";
-            else
+            ScAddress aCursor( nPosX, nPosY, nTab );
+            double nVal;
+            if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) )
             {
-                // Number in the standard format, the other on the cursor position
-                SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
-                sal_uInt32 nNumFmt = 0;
-                if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 && eFunc != SUBTOTAL_FUNC_SELECTION_COUNT)
+                if ( nVal == 0.0 )
+                    aStr += "0";
+                else
                 {
-                    // number format from attributes or formula
-                    pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
-                }
+                    // Number in the standard format, the other on the cursor position
+                    SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+                    sal_uInt32 nNumFmt = 0;
+                    if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 && eFunc != SUBTOTAL_FUNC_SELECTION_COUNT)
+                    {
+                        // number format from attributes or formula
+                        pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
+                    }
 
-                OUString aValStr;
-                Color* pDummy;
-                pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy );
-                aStr += aValStr;
+                    OUString aValStr;
+                    Color* pDummy;
+                    pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy );
+                    aStr += aValStr;
+                }
+            }
+            if ( bFirst )
+            {
+                rFuncStr += aStr;
+                bFirst = false;
             }
+            else
+                rFuncStr += (";" + aStr);
         }
-
-        rFuncStr = aStr;
-        return true;
     }
 
-    return false;
+    return !rFuncStr.isEmpty();
 }
 
 //  Functions that are disabled, depending on the selection
diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx
index 861efa12..e05c21a 100644
--- a/svx/source/stbctrls/pszctrl.cxx
+++ b/svx/source/stbctrls/pszctrl.cxx
@@ -92,29 +92,39 @@ SFX_IMPL_STATUSBAR_CONTROL(SvxPosSizeStatusBarControl, SvxSizeItem);
 class FunctionPopup_Impl : public PopupMenu
 {
 public:
-    explicit FunctionPopup_Impl( sal_uInt16 nCheck );
+    explicit FunctionPopup_Impl( sal_uInt32 nCheckEncoded );
 
-    sal_uInt16          GetSelected() const { return nSelected; }
+    sal_uInt32          GetSelected() const { return nSelected; }
 
 private:
-    sal_uInt16          nSelected;
+    sal_uInt32          nSelected;
 
     virtual void    Select() override;
 };
 
 
-FunctionPopup_Impl::FunctionPopup_Impl( sal_uInt16 nCheck ) :
+FunctionPopup_Impl::FunctionPopup_Impl( sal_uInt32 nCheckEncoded ) :
     PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ),
-    nSelected( 0 )
+    nSelected( nCheckEncoded )
 {
-    if (nCheck)
-        CheckItem( nCheck );
+    for ( sal_uInt16 nCheck = 1; nCheck < 32; ++nCheck )
+        if ( nCheckEncoded & (1 << nCheck) )
+            CheckItem( nCheck );
 }
 
 
 void FunctionPopup_Impl::Select()
 {
-    nSelected = GetCurItemId();
+    sal_uInt16 nCurItemId = GetCurItemId();
+    if ( nCurItemId == PSZ_FUNC_NONE )
+        nSelected = ( 1 << PSZ_FUNC_NONE );
+    else
+    {
+        nSelected &= (~( 1 << PSZ_FUNC_NONE )); // Clear the "None" bit
+        nSelected ^= ( 1 << nCurItemId ); // Toggle the bit corresponding to nCurItemId
+        if ( !nSelected )
+            nSelected = ( 1 << PSZ_FUNC_NONE );
+    }
 }
 
 struct SvxPosSizeStatusBarControl_Impl
@@ -137,7 +147,7 @@ struct SvxPosSizeStatusBarControl_Impl
     bool      bSize;      // set size ?
     bool      bTable;     // set table index ?
     bool      bHasMenu;   // set StarCalc popup menu ?
-    sal_uInt16  nFunction;  // the selected StarCalc function
+    sal_uInt32  nFunctionSet;  // the selected StarCalc functions encoded in 32 bits
     Image     aPosImage;  // Image to show the position
     Image     aSizeImage; // Image to show the size
 };
@@ -163,7 +173,7 @@ SvxPosSizeStatusBarControl::SvxPosSizeStatusBarControl( sal_uInt16 _nSlotId,
     pImp->bSize = false;
     pImp->bTable = false;
     pImp->bHasMenu = false;
-    pImp->nFunction = 0;
+    pImp->nFunctionSet = 0;
     pImp->aPosImage = Image( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) );
     pImp->aSizeImage = Image( ResId( RID_SVXBMP_SIZE, DIALOG_MGR() ) );
 
@@ -232,8 +242,8 @@ void SvxPosSizeStatusBarControl::StateChanged( sal_uInt16 nSID, SfxItemState eSt
         if ( eState == SfxItemState::DEFAULT )
         {
             pImp->bHasMenu = true;
-            if ( pState && dynamic_cast< const SfxUInt16Item* >(pState) !=  nullptr )
-                pImp->nFunction = static_cast<const SfxUInt16Item*>(pState)->GetValue();
+            if ( pState && dynamic_cast< const SfxUInt32Item* >(pState) !=  nullptr )
+                pImp->nFunctionSet = static_cast<const SfxUInt32Item*>(pState)->GetValue();
         }
         else
             pImp->bHasMenu = false;
@@ -305,20 +315,20 @@ void SvxPosSizeStatusBarControl::Command( const CommandEvent& rCEvt )
 {
     if ( rCEvt.GetCommand() == CommandEventId::ContextMenu && pImp->bHasMenu )
     {
-        sal_uInt16 nSelect = pImp->nFunction;
+        sal_uInt32 nSelect = pImp->nFunctionSet;
         if (!nSelect)
-            nSelect = PSZ_FUNC_NONE;
+            nSelect = ( 1 << PSZ_FUNC_NONE );
         FunctionPopup_Impl aMenu( nSelect );
         if ( aMenu.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel() ) )
         {
             nSelect = aMenu.GetSelected();
             if (nSelect)
             {
-                if (nSelect == PSZ_FUNC_NONE)
+                if (nSelect == (1 << PSZ_FUNC_NONE))
                     nSelect = 0;
 
                 css::uno::Any a;
-                SfxUInt16Item aItem( SID_PSZ_FUNCTION, nSelect );
+                SfxUInt32Item aItem( SID_PSZ_FUNCTION, nSelect );
 
                 css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 );
                 aArgs[0].Name  = "StatusBarFunc";
@@ -408,5 +418,4 @@ void SvxPosSizeStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
     pDev->SetFillColor( aOldFillColor );
 }
 
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list