summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMohammed Abdul Azeem <azeemmysore@gmail.com>2016-03-07 01:35:57 +0530
committerMichael Meeks <michael.meeks@collabora.com>2016-03-19 14:18:56 +0000
commitbf17a8dfbb9f966c90b5d6eb0a7b8e7838392d27 (patch)
treedb3fc01c601f7f9088ca9b0cf225cfe4f6634b97 /sc
parent90946203acbabcfa68fd0ba692e7cc9f67af7173 (diff)
tdf#82641 Currency drop-down list
Currency drop-down list has been added. It retains the position of selected entry. Clicking on button toggles between the previously selected currency and number formats. Change-Id: I0dea8fc2773497bfaababa418f119d0a5e76cb03 Reviewed-on: https://gerrit.libreoffice.org/22958 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/sdi/scalc.sdi3
-rw-r--r--sc/source/ui/app/scdll.cxx3
-rw-r--r--sc/source/ui/view/formatsh.cxx67
3 files changed, 58 insertions, 15 deletions
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 99a53135ddc5..14169f0757a5 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -3735,7 +3735,7 @@ SfxStringItem NumberFormat SID_NUMBER_FORMAT
SfxVoidItem NumberFormatCurrency SID_NUMBER_CURRENCY
-()
+(SfxUInt32Item NumberFormatCurrency SID_NUMBER_CURRENCY)
[
AutoUpdate = FALSE,
FastCall = FALSE,
@@ -3744,6 +3744,7 @@ SfxVoidItem NumberFormatCurrency SID_NUMBER_CURRENCY
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
+ SlotType = SfxUInt32Item
AccelConfig = TRUE,
MenuConfig = TRUE,
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index e83cc1895114..d35328a901b2 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -146,7 +146,8 @@ void ScDLL::Init()
ScPageBreakShell ::RegisterInterface(pMod);
// Own Controller
- ScZoomSliderControl ::RegisterControl(SID_PREVIEW_SCALINGFACTOR, pMod);
+ ScZoomSliderControl ::RegisterControl(SID_PREVIEW_SCALINGFACTOR, pMod);
+ SvxCurrencyToolBoxControl ::RegisterControl(SID_NUMBER_CURRENCY, pMod);
// SvxToolboxController
SvxTbxCtlDraw ::RegisterControl(SID_INSERT_DRAW, pMod);
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 240cc741a713..0850aad67670 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -988,11 +988,11 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
{
- ScModule* pScMod = SC_MOD();
- ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
- const SfxItemSet* pReqArgs = rReq.GetArgs();
- sal_uInt16 nSlot = rReq.GetSlot();
- SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
@@ -1062,11 +1062,43 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
rReq.Done();
break;
case SID_NUMBER_CURRENCY:
- if ((nType & css::util::NumberFormat::CURRENCY))
- pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
+ if(pReqArgs)
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->HasItem( SID_NUMBER_CURRENCY, &pItem ) )
+ {
+ sal_uInt32 nNewFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
+ ScDocument* pDoc = pViewData->GetDocument();
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ const SfxItemSet& rOldSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+
+ LanguageType eOldLang = static_cast<const SvxLanguageItem&>(
+ rOldSet.Get( ATTR_LANGUAGE_FORMAT ) ).GetLanguage();
+ sal_uInt32 nOldFormat = static_cast<const SfxUInt32Item&>(
+ rOldSet.Get( ATTR_VALUE_FORMAT ) ).GetValue();
+
+ if ( nOldFormat != nNewFormat )
+ {
+ const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
+ ScPatternAttr aNewAttrs( pDoc->GetPool() );
+ SfxItemSet& rSet = aNewAttrs.GetItemSet();
+ LanguageType eNewLang = pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
+ if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
+ rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
+ rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
+ pTabViewShell->ApplySelectionPattern( aNewAttrs );
+ }
+ else
+ pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
+ }
+ }
else
- pTabViewShell->SetNumberFormat( css::util::NumberFormat::CURRENCY );
- aSet.Put( SfxBoolItem(nSlot, !(nType & css::util::NumberFormat::CURRENCY)) );
+ {
+ if ( ( nType & css::util::NumberFormat::CURRENCY ) )
+ pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( css::util::NumberFormat::CURRENCY );
+ }
rBindings.Invalidate( nSlot );
rReq.Done();
break;
@@ -1975,7 +2007,6 @@ void ScFormatShell::GetAttrState( SfxItemSet& rSet )
case SID_BACKGROUND_COLOR:
{
rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) );
-
if(SfxItemState::DONTCARE == rAttrSet.GetItemState(ATTR_BACKGROUND))
{
rSet.InvalidateItem(SID_BACKGROUND_COLOR);
@@ -2544,15 +2575,25 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
}
break;
+ case SID_NUMBER_CURRENCY:
+ {
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ if( SfxItemState::DONTCARE != rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) )
+ {
+ sal_uInt32 nNumberFormat = static_cast<const SfxUInt32Item&>(
+ rAttrSet.Get( ATTR_VALUE_FORMAT ) ).GetValue();
+ rSet.Put( SfxUInt32Item( nWhich, nNumberFormat ) );
+ }
+ else
+ rSet.InvalidateItem( nWhich );
+ }
+ break;
case SID_NUMBER_SCIENTIFIC:
rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::SCIENTIFIC)) );
break;
case SID_NUMBER_DATE:
rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::DATE)) );
break;
- case SID_NUMBER_CURRENCY:
- rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::CURRENCY)) );
- break;
case SID_NUMBER_PERCENT:
rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::PERCENT)) );
break;