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 | |
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')
-rw-r--r-- | sc/source/core/tool/appoptio.cxx | 47 | ||||
-rw-r--r-- | sc/source/ui/app/scmod.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsha.cxx | 115 |
3 files changed, 108 insertions, 60 deletions
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx index 3bdf429dfa67..cbc3c19a3e8c 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 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 |