diff options
author | Dennis Francis <dennisfrancis.in@gmail.com> | 2015-10-17 10:45:53 +0530 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-03-11 21:45:26 +0000 |
commit | 7bc97db5b972f27693161beb9182f8a5850f5551 (patch) | |
tree | a8d8fce3ef4eddd7de753ae8db2518f2f41e01ef /sc/source/ui | |
parent | 97c872d015350810fb0180ffdb10de7f039363a4 (diff) |
tdf#42629 : Allow multiple status bar functions at a time
Change-Id: Ide9ced5ff4cedebd41a85814f74549648a896f16
Reviewed-on: https://gerrit.libreoffice.org/22060
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/app/scmod.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsha.cxx | 115 |
2 files changed, 66 insertions, 55 deletions
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index f9afa31e9ddf..c385bbe7c9df 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 513c735af81d..dd55e5224924 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 |