14e8031e0SArmin Le Grand /**************************************************************
24e8031e0SArmin Le Grand  *
34e8031e0SArmin Le Grand  * Licensed to the Apache Software Foundation (ASF) under one
44e8031e0SArmin Le Grand  * or more contributor license agreements.  See the NOTICE file
54e8031e0SArmin Le Grand  * distributed with this work for additional information
64e8031e0SArmin Le Grand  * regarding copyright ownership.  The ASF licenses this file
74e8031e0SArmin Le Grand  * to you under the Apache License, Version 2.0 (the
84e8031e0SArmin Le Grand  * "License"); you may not use this file except in compliance
94e8031e0SArmin Le Grand  * with the License.  You may obtain a copy of the License at
104e8031e0SArmin Le Grand  *
114e8031e0SArmin Le Grand  *   http://www.apache.org/licenses/LICENSE-2.0
124e8031e0SArmin Le Grand  *
134e8031e0SArmin Le Grand  * Unless required by applicable law or agreed to in writing,
144e8031e0SArmin Le Grand  * software distributed under the License is distributed on an
154e8031e0SArmin Le Grand  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
164e8031e0SArmin Le Grand  * KIND, either express or implied.  See the License for the
174e8031e0SArmin Le Grand  * specific language governing permissions and limitations
184e8031e0SArmin Le Grand  * under the License.
194e8031e0SArmin Le Grand  *
204e8031e0SArmin Le Grand  *************************************************************/
214e8031e0SArmin Le Grand 
224e8031e0SArmin Le Grand #include "precompiled_sc.hxx"
234e8031e0SArmin Le Grand 
24d29c2fc2SAndre Fischer #include <sfx2/sidebar/ResourceDefinitions.hrc>
254e8031e0SArmin Le Grand #include <sfx2/sidebar/Theme.hxx>
26*6a606da0SAndre Fischer #include <sfx2/sidebar/Layouter.hxx>
274e8031e0SArmin Le Grand #include <sfx2/sidebar/ControlFactory.hxx>
284e8031e0SArmin Le Grand #include <NumberFormatPropertyPanel.hxx>
294e8031e0SArmin Le Grand #include <NumberFormatPropertyPanel.hrc>
304e8031e0SArmin Le Grand #include "sc.hrc"
314e8031e0SArmin Le Grand #include "scresid.hxx"
324e8031e0SArmin Le Grand #include <sfx2/bindings.hxx>
334e8031e0SArmin Le Grand #include <sfx2/dispatch.hxx>
345f4a9ac1SAndre Fischer #include <sfx2/imagemgr.hxx>
354e8031e0SArmin Le Grand #include <vcl/fixed.hxx>
364e8031e0SArmin Le Grand #include <vcl/lstbox.hxx>
374e8031e0SArmin Le Grand #include <vcl/field.hxx>
384e8031e0SArmin Le Grand #include <vcl/toolbox.hxx>
394e8031e0SArmin Le Grand #include <svl/intitem.hxx>
404e8031e0SArmin Le Grand #include <svl/stritem.hxx>
414e8031e0SArmin Le Grand 
424e8031e0SArmin Le Grand using namespace css;
434e8031e0SArmin Le Grand using namespace cssu;
44*6a606da0SAndre Fischer using ::sfx2::sidebar::Layouter;
455f4a9ac1SAndre Fischer using ::sfx2::sidebar::Theme;
464e8031e0SArmin Le Grand 
474e8031e0SArmin Le Grand #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
484e8031e0SArmin Le Grand 
494e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
504e8031e0SArmin Le Grand // namespace open
514e8031e0SArmin Le Grand 
524e8031e0SArmin Le Grand namespace sc { namespace sidebar {
534e8031e0SArmin Le Grand 
544e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
554e8031e0SArmin Le Grand 
NumberFormatPropertyPanel(Window * pParent,const cssu::Reference<css::frame::XFrame> & rxFrame,SfxBindings * pBindings)564e8031e0SArmin Le Grand NumberFormatPropertyPanel::NumberFormatPropertyPanel(
574e8031e0SArmin Le Grand     Window* pParent,
584e8031e0SArmin Le Grand     const cssu::Reference<css::frame::XFrame>& rxFrame,
594e8031e0SArmin Le Grand     SfxBindings* pBindings)
604e8031e0SArmin Le Grand :   Control(
614e8031e0SArmin Le Grand         pParent,
624e8031e0SArmin Le Grand         ScResId(RID_PROPERTYPANEL_SC_NUMBERFORMAT)),
634e8031e0SArmin Le Grand     mpFtCategory(new FixedText(this, ScResId(FT_CATEGORY))),
644e8031e0SArmin Le Grand     mpLbCategory(new ListBox(this, ScResId(LB_CATEGORY))),
654e8031e0SArmin Le Grand     mpTBCategoryBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
664e8031e0SArmin Le Grand     mpTBCategory(sfx2::sidebar::ControlFactory::CreateToolBox(mpTBCategoryBackground.get(), ScResId(TBX_CATEGORY))),
674e8031e0SArmin Le Grand     mpFtDecimals(new FixedText(this, ScResId(FT_DECIMALS))),
684e8031e0SArmin Le Grand     mpEdDecimals(new NumericField(this, ScResId(ED_DECIMALS))),
694e8031e0SArmin Le Grand     mpFtLeadZeroes(new FixedText(this, ScResId(FT_LEADZEROES))),
704e8031e0SArmin Le Grand     mpEdLeadZeroes(new NumericField(this, ScResId(ED_LEADZEROES))),
714e8031e0SArmin Le Grand     mpBtnNegRed(new CheckBox(this, ScResId(BTN_NEGRED))),
724e8031e0SArmin Le Grand     mpBtnThousand(new CheckBox(this, ScResId(BTN_THOUSAND))),
734e8031e0SArmin Le Grand     maNumFormatControl(SID_NUMBER_TYPE_FORMAT, *pBindings, *this),
744e8031e0SArmin Le Grand 
754e8031e0SArmin Le Grand     // Caution! SID_NUMBER_FORMAT is reworked in symphony code, may be needed (!) If
764e8031e0SArmin Le Grand     // yes, grep for it in SC and symphony (!)
774e8031e0SArmin Le Grand     maFormatControl(SID_NUMBER_FORMAT, *pBindings, *this),
784e8031e0SArmin Le Grand 
794e8031e0SArmin Le Grand     mnCategorySelected(0),
804e8031e0SArmin Le Grand     mxFrame(rxFrame),
814e8031e0SArmin Le Grand     maContext(),
824e8031e0SArmin Le Grand     mpBindings(pBindings)
834e8031e0SArmin Le Grand {
844e8031e0SArmin Le Grand     Initialize();
854e8031e0SArmin Le Grand     FreeResource();
86*6a606da0SAndre Fischer 
87*6a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtCategory);
88*6a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtDecimals);
89*6a606da0SAndre Fischer     Layouter::PrepareForLayouting(*mpFtLeadZeroes);
904e8031e0SArmin Le Grand }
914e8031e0SArmin Le Grand 
924e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
934e8031e0SArmin Le Grand 
~NumberFormatPropertyPanel()944e8031e0SArmin Le Grand NumberFormatPropertyPanel::~NumberFormatPropertyPanel()
954e8031e0SArmin Le Grand {
964e8031e0SArmin Le Grand     // Destroy the toolboxes, then their background windows.
974e8031e0SArmin Le Grand     mpTBCategory.reset();
984e8031e0SArmin Le Grand     mpTBCategoryBackground.reset();
994e8031e0SArmin Le Grand }
1004e8031e0SArmin Le Grand 
1014e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
1024e8031e0SArmin Le Grand 
Initialize()1034e8031e0SArmin Le Grand void NumberFormatPropertyPanel::Initialize()
1044e8031e0SArmin Le Grand {
1054e8031e0SArmin Le Grand 	Link aLink = LINK(this, NumberFormatPropertyPanel, NumFormatSelectHdl);
1064e8031e0SArmin Le Grand 	mpLbCategory->SetSelectHdl ( aLink );
1074e8031e0SArmin Le Grand 	mpLbCategory->SelectEntryPos(0);
1084e8031e0SArmin Le Grand 	mpLbCategory->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Category")));		//wj acc
109df46ddf6SArmin Le Grand     mpLbCategory->SetDropDownLineCount(mpLbCategory->GetEntryCount());
1104e8031e0SArmin Le Grand 
1115f4a9ac1SAndre Fischer     // Note that we use icons from UNO commands that are not in every case the commands
1125f4a9ac1SAndre Fischer     // that are really dispatched.  They just look right.
1135f4a9ac1SAndre Fischer 	mpTBCategory->SetItemImage(
1145f4a9ac1SAndre Fischer         ID_NUMBER,
1155f4a9ac1SAndre Fischer         GetImage(mxFrame, A2S(".uno:NumericField"), sal_False, Theme::IsHighContrastMode()));
1165f4a9ac1SAndre Fischer 	mpTBCategory->SetItemImage(
1175f4a9ac1SAndre Fischer         ID_PERCENT,
1185f4a9ac1SAndre Fischer         GetImage(mxFrame, A2S(".uno:NumberFormatPercent"), sal_False, Theme::IsHighContrastMode()));
1195f4a9ac1SAndre Fischer 	mpTBCategory->SetItemImage(
1205f4a9ac1SAndre Fischer         ID_CURRENCY,
1215f4a9ac1SAndre Fischer         GetImage(mxFrame, A2S(".uno:NumberFormatCurrency"), sal_False, Theme::IsHighContrastMode()));
1225f4a9ac1SAndre Fischer 	mpTBCategory->SetItemImage(
1235f4a9ac1SAndre Fischer         ID_DATE,
1245f4a9ac1SAndre Fischer         GetImage(mxFrame, A2S(".uno:NumberFormatDate"), sal_False, Theme::IsHighContrastMode()));
1255f4a9ac1SAndre Fischer 	mpTBCategory->SetItemImage(
1265f4a9ac1SAndre Fischer         ID_TEXT,
1275f4a9ac1SAndre Fischer         GetImage(mxFrame, A2S(".uno:InsertFixedText"), sal_False, Theme::IsHighContrastMode()));
1285f4a9ac1SAndre Fischer 
1294e8031e0SArmin Le Grand 	Size aTbxSize( mpTBCategory->CalcWindowSizePixel() );
1304e8031e0SArmin Le Grand 	mpTBCategory->SetOutputSizePixel( aTbxSize );
1314e8031e0SArmin Le Grand 	mpTBCategory->SetBackground(Wallpaper());
1324e8031e0SArmin Le Grand 	mpTBCategory->SetPaintTransparent(true);
1334e8031e0SArmin Le Grand 	aLink = LINK(this, NumberFormatPropertyPanel, NumFormatHdl);
1344e8031e0SArmin Le Grand 	mpTBCategory->SetSelectHdl ( aLink );
1354e8031e0SArmin Le Grand 
1364e8031e0SArmin Le Grand 	aLink = LINK(this, NumberFormatPropertyPanel, NumFormatValueHdl);
1374e8031e0SArmin Le Grand 
1384e8031e0SArmin Le Grand 	mpEdDecimals->SetModifyHdl( aLink );
1394e8031e0SArmin Le Grand 	mpEdLeadZeroes->SetModifyHdl( aLink );
1404e8031e0SArmin Le Grand 	mpEdDecimals->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Decimal Places")));		//wj acc
1414e8031e0SArmin Le Grand 	mpEdLeadZeroes->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Leading Zeroes")));		//wj acc
1424e8031e0SArmin Le Grand 	mpBtnNegRed->SetClickHdl( aLink );
1434e8031e0SArmin Le Grand 	mpBtnThousand->SetClickHdl( aLink );
1444e8031e0SArmin Le Grand 
1454e8031e0SArmin Le Grand     mpLbCategory->SetAccessibleRelationLabeledBy(mpFtCategory.get());
1464e8031e0SArmin Le Grand 	mpTBCategory->SetAccessibleRelationLabeledBy(mpTBCategory.get());
1474e8031e0SArmin Le Grand 	mpEdDecimals->SetAccessibleRelationLabeledBy(mpFtDecimals.get());
1484e8031e0SArmin Le Grand 	mpEdLeadZeroes->SetAccessibleRelationLabeledBy(mpFtLeadZeroes.get());
1494e8031e0SArmin Le Grand }
1504e8031e0SArmin Le Grand 
1514e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
1524e8031e0SArmin Le Grand 
IMPL_LINK(NumberFormatPropertyPanel,NumFormatHdl,ToolBox *,pBox)1534e8031e0SArmin Le Grand IMPL_LINK( NumberFormatPropertyPanel, NumFormatHdl, ToolBox*, pBox )
1544e8031e0SArmin Le Grand {
1554e8031e0SArmin Le Grand 	sal_uInt16 nVal = pBox->GetCurItemId();
1564e8031e0SArmin Le Grand 	sal_uInt16 nId = 0;
1574e8031e0SArmin Le Grand 	switch(nVal)
1584e8031e0SArmin Le Grand 	{
1594e8031e0SArmin Le Grand 	case ID_NUMBER:
1604e8031e0SArmin Le Grand 		nId = 1;
1614e8031e0SArmin Le Grand 		break;
1624e8031e0SArmin Le Grand 	case ID_PERCENT:
1634e8031e0SArmin Le Grand 		nId = 2;
1644e8031e0SArmin Le Grand 		break;
1654e8031e0SArmin Le Grand 	case ID_CURRENCY:
1664e8031e0SArmin Le Grand 		nId = 3;
1674e8031e0SArmin Le Grand 		break;
1684e8031e0SArmin Le Grand 	case ID_DATE:
1694e8031e0SArmin Le Grand 		nId = 4;
1704e8031e0SArmin Le Grand 		break;
1714e8031e0SArmin Le Grand 	case ID_TEXT:
1724e8031e0SArmin Le Grand 		nId = 9;
1734e8031e0SArmin Le Grand 		break;
1744e8031e0SArmin Le Grand 	default:
1754e8031e0SArmin Le Grand 		;
1764e8031e0SArmin Le Grand 	}
1774e8031e0SArmin Le Grand 	if( nId != mnCategorySelected )
1784e8031e0SArmin Le Grand 	{
1794e8031e0SArmin Le Grand 		SfxUInt16Item aItem( SID_NUMBER_TYPE_FORMAT,  nId );
1804e8031e0SArmin Le Grand 		GetBindings()->GetDispatcher()->Execute(SID_NUMBER_TYPE_FORMAT, SFX_CALLMODE_RECORD, &aItem, 0L);
1814e8031e0SArmin Le Grand 	}
1824e8031e0SArmin Le Grand 	return 0L;
1834e8031e0SArmin Le Grand }
1844e8031e0SArmin Le Grand 
1854e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
1864e8031e0SArmin Le Grand 
IMPL_LINK(NumberFormatPropertyPanel,NumFormatSelectHdl,ListBox *,pBox)1874e8031e0SArmin Le Grand IMPL_LINK( NumberFormatPropertyPanel, NumFormatSelectHdl, ListBox*, pBox )
1884e8031e0SArmin Le Grand {
1894e8031e0SArmin Le Grand 	sal_uInt16 nVal = pBox->GetSelectEntryPos();
1904e8031e0SArmin Le Grand 	if( nVal != mnCategorySelected )
1914e8031e0SArmin Le Grand 	{
1924e8031e0SArmin Le Grand 		SfxUInt16Item aItem( SID_NUMBER_TYPE_FORMAT,  nVal );
1934e8031e0SArmin Le Grand 		GetBindings()->GetDispatcher()->Execute(SID_NUMBER_TYPE_FORMAT, SFX_CALLMODE_RECORD, &aItem, 0L);
1944e8031e0SArmin Le Grand 		mnCategorySelected = nVal;
1954e8031e0SArmin Le Grand 	}
1964e8031e0SArmin Le Grand 	return 0L;
1974e8031e0SArmin Le Grand }
1984e8031e0SArmin Le Grand 
1994e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2004e8031e0SArmin Le Grand 
IMPL_LINK(NumberFormatPropertyPanel,NumFormatValueHdl,void *,EMPTYARG)2014e8031e0SArmin Le Grand IMPL_LINK( NumberFormatPropertyPanel, NumFormatValueHdl, void*, EMPTYARG )
2024e8031e0SArmin Le Grand {
2034e8031e0SArmin Le Grand 	String		  aFormat;
2044e8031e0SArmin Le Grand 	String		  sBreak = String::CreateFromAscii(",");
2054e8031e0SArmin Le Grand 	bool		  bThousand 	=    mpBtnThousand->IsEnabled()
2064e8031e0SArmin Le Grand 		&& mpBtnThousand->IsChecked();
2074e8031e0SArmin Le Grand 	bool		  bNegRed		=    mpBtnNegRed->IsEnabled()
2084e8031e0SArmin Le Grand 		&& mpBtnNegRed->IsChecked();
2094e8031e0SArmin Le Grand 	sal_uInt16		  nPrecision	= (mpEdDecimals->IsEnabled())
2104e8031e0SArmin Le Grand 		? (sal_uInt16)mpEdDecimals->GetValue()
2114e8031e0SArmin Le Grand 		: (sal_uInt16)0;
2124e8031e0SArmin Le Grand 	sal_uInt16		  nLeadZeroes	= (mpEdLeadZeroes->IsEnabled())
2134e8031e0SArmin Le Grand 		? (sal_uInt16)mpEdLeadZeroes->GetValue()
2144e8031e0SArmin Le Grand 		: (sal_uInt16)0;
2154e8031e0SArmin Le Grand 
2164e8031e0SArmin Le Grand 	String sThousand = String::CreateFromInt32(bThousand);
2174e8031e0SArmin Le Grand 	String sNegRed = String::CreateFromInt32(bNegRed);
2184e8031e0SArmin Le Grand 	String sPrecision = String::CreateFromInt32(nPrecision);
2194e8031e0SArmin Le Grand 	String sLeadZeroes = String::CreateFromInt32(nLeadZeroes);
2204e8031e0SArmin Le Grand 
2214e8031e0SArmin Le Grand 	aFormat += sThousand;
2224e8031e0SArmin Le Grand 	aFormat += sBreak;
2234e8031e0SArmin Le Grand 	aFormat += sNegRed;
2244e8031e0SArmin Le Grand 	aFormat += sBreak;
2254e8031e0SArmin Le Grand 	aFormat += sPrecision;
2264e8031e0SArmin Le Grand 	aFormat += sBreak;
2274e8031e0SArmin Le Grand 	aFormat += sLeadZeroes;
2284e8031e0SArmin Le Grand 	aFormat += sBreak;
2294e8031e0SArmin Le Grand 
2304e8031e0SArmin Le Grand 	SfxStringItem aItem( SID_NUMBER_FORMAT,  aFormat );
2314e8031e0SArmin Le Grand 	GetBindings()->GetDispatcher()->Execute(SID_NUMBER_FORMAT, SFX_CALLMODE_RECORD, &aItem, 0L);
2324e8031e0SArmin Le Grand 	return 0L;
2334e8031e0SArmin Le Grand }
2344e8031e0SArmin Le Grand 
2354e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2364e8031e0SArmin Le Grand 
Create(Window * pParent,const cssu::Reference<css::frame::XFrame> & rxFrame,SfxBindings * pBindings)2374e8031e0SArmin Le Grand NumberFormatPropertyPanel* NumberFormatPropertyPanel::Create (
2384e8031e0SArmin Le Grand     Window* pParent,
2394e8031e0SArmin Le Grand     const cssu::Reference<css::frame::XFrame>& rxFrame,
2404e8031e0SArmin Le Grand     SfxBindings* pBindings)
2414e8031e0SArmin Le Grand {
2424e8031e0SArmin Le Grand     if (pParent == NULL)
2434e8031e0SArmin Le Grand         throw lang::IllegalArgumentException(A2S("no parent Window given to NumberFormatPropertyPanel::Create"), NULL, 0);
2444e8031e0SArmin Le Grand     if ( ! rxFrame.is())
2454e8031e0SArmin Le Grand         throw lang::IllegalArgumentException(A2S("no XFrame given to NumberFormatPropertyPanel::Create"), NULL, 1);
2464e8031e0SArmin Le Grand     if (pBindings == NULL)
2474e8031e0SArmin Le Grand         throw lang::IllegalArgumentException(A2S("no SfxBindings given to NumberFormatPropertyPanel::Create"), NULL, 2);
2484e8031e0SArmin Le Grand 
2494e8031e0SArmin Le Grand     return new NumberFormatPropertyPanel(
2504e8031e0SArmin Le Grand         pParent,
2514e8031e0SArmin Le Grand         rxFrame,
2524e8031e0SArmin Le Grand         pBindings);
2534e8031e0SArmin Le Grand }
2544e8031e0SArmin Le Grand 
2554e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2564e8031e0SArmin Le Grand 
DataChanged(const DataChangedEvent & rEvent)2574e8031e0SArmin Le Grand void NumberFormatPropertyPanel::DataChanged(
2584e8031e0SArmin Le Grand     const DataChangedEvent& rEvent)
2594e8031e0SArmin Le Grand {
2604e8031e0SArmin Le Grand     (void)rEvent;
2614e8031e0SArmin Le Grand }
2624e8031e0SArmin Le Grand 
2634e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2644e8031e0SArmin Le Grand 
HandleContextChange(const::sfx2::sidebar::EnumContext aContext)2654e8031e0SArmin Le Grand void NumberFormatPropertyPanel::HandleContextChange(
2664e8031e0SArmin Le Grand     const ::sfx2::sidebar::EnumContext aContext)
2674e8031e0SArmin Le Grand {
2684e8031e0SArmin Le Grand     if(maContext == aContext)
2694e8031e0SArmin Le Grand     {
2704e8031e0SArmin Le Grand         // Nothing to do.
2714e8031e0SArmin Le Grand         return;
2724e8031e0SArmin Le Grand     }
2734e8031e0SArmin Le Grand 
2744e8031e0SArmin Le Grand     maContext = aContext;
2754e8031e0SArmin Le Grand 
2764e8031e0SArmin Le Grand 
2774e8031e0SArmin Le Grand 
2784e8031e0SArmin Le Grand     // todo
2794e8031e0SArmin Le Grand }
2804e8031e0SArmin Le Grand 
2814e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
2824e8031e0SArmin Le Grand 
NotifyItemUpdate(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState,const bool bIsEnabled)2834e8031e0SArmin Le Grand void NumberFormatPropertyPanel::NotifyItemUpdate(
2844e8031e0SArmin Le Grand     sal_uInt16 nSID,
2854e8031e0SArmin Le Grand     SfxItemState eState,
28645da7d5eSAndre Fischer     const SfxPoolItem* pState,
28745da7d5eSAndre Fischer     const bool bIsEnabled)
2884e8031e0SArmin Le Grand {
28945da7d5eSAndre Fischer     (void)bIsEnabled;
29045da7d5eSAndre Fischer 
2914e8031e0SArmin Le Grand 	switch(nSID)
2924e8031e0SArmin Le Grand 	{
2934e8031e0SArmin Le Grand 	case SID_NUMBER_TYPE_FORMAT:
2944e8031e0SArmin Le Grand 		{
2954e8031e0SArmin Le Grand 			if( eState >= SFX_ITEM_AVAILABLE)
2964e8031e0SArmin Le Grand 			{
2974e8031e0SArmin Le Grand 				const SfxInt16Item* pItem = (const SfxInt16Item*)pState;
2984e8031e0SArmin Le Grand 				sal_uInt16 nVal = pItem->GetValue();
2994e8031e0SArmin Le Grand 				mnCategorySelected = nVal;
3004e8031e0SArmin Le Grand 				mpLbCategory->SelectEntryPos(nVal);
3014e8031e0SArmin Le Grand 				if( nVal < 4 )
3024e8031e0SArmin Le Grand 				{
3034e8031e0SArmin Le Grand 					mpBtnThousand->Enable();
3044e8031e0SArmin Le Grand 					mpBtnNegRed->Enable();
3054e8031e0SArmin Le Grand 					mpEdDecimals->Enable();
3064e8031e0SArmin Le Grand 					mpEdLeadZeroes->Enable();
3074e8031e0SArmin Le Grand 				}
3084e8031e0SArmin Le Grand 				else
3094e8031e0SArmin Le Grand 				{
3104e8031e0SArmin Le Grand 					mpBtnThousand->Disable();
3114e8031e0SArmin Le Grand 					mpBtnNegRed->Disable();
3124e8031e0SArmin Le Grand 					mpEdDecimals->Disable();
3134e8031e0SArmin Le Grand 					mpEdLeadZeroes->Disable();
3144e8031e0SArmin Le Grand 				}
3154e8031e0SArmin Le Grand 			}
3164e8031e0SArmin Le Grand 			else
3174e8031e0SArmin Le Grand 			{
3184e8031e0SArmin Le Grand 				mpLbCategory->SetNoSelection();
3194e8031e0SArmin Le Grand 				mnCategorySelected = 0;
3204e8031e0SArmin Le Grand 				mpBtnThousand->Disable();
3214e8031e0SArmin Le Grand 				mpBtnNegRed->Disable();
3224e8031e0SArmin Le Grand 				mpEdDecimals->Disable();
3234e8031e0SArmin Le Grand 				mpEdLeadZeroes->Disable();
3244e8031e0SArmin Le Grand 			}
3254e8031e0SArmin Le Grand 		}
3264e8031e0SArmin Le Grand 		break;
3274e8031e0SArmin Le Grand 	case SID_NUMBER_FORMAT:
3284e8031e0SArmin Le Grand 		{
3294e8031e0SArmin Le Grand 			bool		  bThousand 	=    0;
3304e8031e0SArmin Le Grand 			bool		  bNegRed		=    0;
3314e8031e0SArmin Le Grand 			sal_uInt16		  nPrecision	=	 0;
3324e8031e0SArmin Le Grand 			sal_uInt16		  nLeadZeroes	=    0;
3334e8031e0SArmin Le Grand 			if( eState >= SFX_ITEM_AVAILABLE)
3344e8031e0SArmin Le Grand 			{
3354e8031e0SArmin Le Grand 				const SfxStringItem* pItem = (const SfxStringItem*)pState;
3364e8031e0SArmin Le Grand 				String aCode = pItem->GetValue();
3374e8031e0SArmin Le Grand 			/*	if(aCode.Equals(String::CreateFromAscii("General")))
3384e8031e0SArmin Le Grand 				{
3394e8031e0SArmin Le Grand 					mnCategorySelected = 0;
3404e8031e0SArmin Le Grand 					mpLbCategory->SelectEntryPos(0);
3414e8031e0SArmin Le Grand 					mpBtnThousand->Check(0);
3424e8031e0SArmin Le Grand 					mpBtnNegRed->Check(0);
3434e8031e0SArmin Le Grand 					mpEdDecimals->SetValue(0);
3444e8031e0SArmin Le Grand 					mpEdLeadZeroes->SetValue(1);
3454e8031e0SArmin Le Grand 					break;
3464e8031e0SArmin Le Grand 				}
3474e8031e0SArmin Le Grand 				else if( mpLbCategory->GetSelectEntryPos() == 0 )
3484e8031e0SArmin Le Grand 				{
3494e8031e0SArmin Le Grand 					mnCategorySelected = 1;
3504e8031e0SArmin Le Grand 					mpLbCategory->SelectEntryPos(1);
3514e8031e0SArmin Le Grand 				}*/
3524e8031e0SArmin Le Grand 				sal_uInt16 aLen = aCode.Len();
3534e8031e0SArmin Le Grand 				String* sFormat = new String[4];
3544e8031e0SArmin Le Grand 				String  sTmpStr = String::CreateFromAscii("");
3554e8031e0SArmin Le Grand 				sal_uInt16 nCount = 0;
3564e8031e0SArmin Le Grand 				sal_uInt16 nStrCount = 0;
3574e8031e0SArmin Le Grand 				while( nCount < aLen )
3584e8031e0SArmin Le Grand 				{
3594e8031e0SArmin Le Grand 					sal_Unicode cChar = aCode.GetChar(nCount);
3604e8031e0SArmin Le Grand 					if(cChar == sal_Unicode(','))
3614e8031e0SArmin Le Grand 					{
3624e8031e0SArmin Le Grand 						sFormat[nStrCount] = sTmpStr;
3634e8031e0SArmin Le Grand 						sTmpStr = String::CreateFromAscii("");
3644e8031e0SArmin Le Grand 						nStrCount++;
3654e8031e0SArmin Le Grand 					}
3664e8031e0SArmin Le Grand 					else
3674e8031e0SArmin Le Grand 					{
3684e8031e0SArmin Le Grand 						sTmpStr += cChar;
3694e8031e0SArmin Le Grand 					}
3704e8031e0SArmin Le Grand 					nCount++;
3714e8031e0SArmin Le Grand 				}
3724e8031e0SArmin Le Grand 				bThousand 	=    sFormat[0].ToInt32();
3734e8031e0SArmin Le Grand 				bNegRed		=    sFormat[1].ToInt32();
3744e8031e0SArmin Le Grand 				nPrecision	=	 (sal_uInt16)sFormat[2].ToInt32();
3754e8031e0SArmin Le Grand 				nLeadZeroes	=    (sal_uInt16)sFormat[3].ToInt32();
3764e8031e0SArmin Le Grand 				delete[] sFormat;
3774e8031e0SArmin Le Grand 			}
3784e8031e0SArmin Le Grand 			else
3794e8031e0SArmin Le Grand 			{
3804e8031e0SArmin Le Grand 				bThousand 	=    0;
3814e8031e0SArmin Le Grand 				bNegRed		=    0;
3824e8031e0SArmin Le Grand 				nPrecision	=	 0;
3834e8031e0SArmin Le Grand 				nLeadZeroes	=    1;
3844e8031e0SArmin Le Grand 			}
3854e8031e0SArmin Le Grand 			mpBtnThousand->Check(bThousand);
3864e8031e0SArmin Le Grand 			mpBtnNegRed->Check(bNegRed);
3874e8031e0SArmin Le Grand 			mpEdDecimals->SetValue(nPrecision);
3884e8031e0SArmin Le Grand 			mpEdLeadZeroes->SetValue(nLeadZeroes);
3894e8031e0SArmin Le Grand 		}
3904e8031e0SArmin Le Grand 	default:
3914e8031e0SArmin Le Grand 		;
3924e8031e0SArmin Le Grand 	}
3934e8031e0SArmin Le Grand }
3944e8031e0SArmin Le Grand 
3954e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
3964e8031e0SArmin Le Grand 
GetBindings()3974e8031e0SArmin Le Grand SfxBindings* NumberFormatPropertyPanel::GetBindings()
3984e8031e0SArmin Le Grand {
3994e8031e0SArmin Le Grand     return mpBindings;
4004e8031e0SArmin Le Grand }
4014e8031e0SArmin Le Grand 
402*6a606da0SAndre Fischer 
403*6a606da0SAndre Fischer 
404*6a606da0SAndre Fischer 
Resize(void)405*6a606da0SAndre Fischer void NumberFormatPropertyPanel::Resize (void)
406*6a606da0SAndre Fischer {
407*6a606da0SAndre Fischer     const sal_Int32 nRight (GetSizePixel().Width() - Layouter::MapWidth(*this, TB_BORDER));
408*6a606da0SAndre Fischer     Layouter::SetRight(*mpFtCategory, nRight);
409*6a606da0SAndre Fischer     Layouter::SetRight(*mpFtLeadZeroes, nRight);
410*6a606da0SAndre Fischer     Layouter::SetRight(*mpBtnNegRed, nRight);
411*6a606da0SAndre Fischer     Layouter::SetRight(*mpBtnThousand, nRight);
412*6a606da0SAndre Fischer }
4134e8031e0SArmin Le Grand 
4144e8031e0SArmin Le Grand }} // end of namespace ::sc::sidebar
4154e8031e0SArmin Le Grand 
4164e8031e0SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
4174e8031e0SArmin Le Grand // eof
418