1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_chart2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "res_DataLabel.hxx" 32*cdf0e10cSrcweir #include "res_DataLabel_IDs.hrc" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include "Strings.hrc" 35*cdf0e10cSrcweir #include "ResId.hxx" 36*cdf0e10cSrcweir #include "chartview/ChartSfxItemIds.hxx" 37*cdf0e10cSrcweir #include "NoWarningThisInCTOR.hxx" 38*cdf0e10cSrcweir #include "dlg_NumberFormat.hxx" 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir // header for class SvxNumberInfoItem 41*cdf0e10cSrcweir #include <svx/numinf.hxx> 42*cdf0e10cSrcweir #include <svl/eitem.hxx> 43*cdf0e10cSrcweir // for SfxUInt32Item 44*cdf0e10cSrcweir #include <svl/intitem.hxx> 45*cdf0e10cSrcweir // header for class SfxStringItem 46*cdf0e10cSrcweir #include <svl/stritem.hxx> 47*cdf0e10cSrcweir //SfxIntegerListItem 48*cdf0e10cSrcweir #include <svl/ilstitem.hxx> 49*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 50*cdf0e10cSrcweir #include <editeng/frmdiritem.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir // header for define RET_OK 53*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 54*cdf0e10cSrcweir #include <svx/svxids.hrc> 55*cdf0e10cSrcweir // header for SvNumberFormatter 56*cdf0e10cSrcweir #include <svl/zforlist.hxx> 57*cdf0e10cSrcweir #include <svtools/controldims.hrc> 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir //............................................................................. 61*cdf0e10cSrcweir namespace chart 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir //............................................................................. 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir namespace 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir bool lcl_ReadNumberFormatFromItemSet( const SfxItemSet& rSet, sal_uInt16 nValueWhich, sal_uInt16 nSourceFormatWhich, sal_uLong& rnFormatKeyOut, bool& rbSourceFormatOut, bool& rbSourceFormatMixedStateOut ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir bool bSet = false; 71*cdf0e10cSrcweir const SfxPoolItem *pItem1 = NULL; 72*cdf0e10cSrcweir if( rSet.GetItemState( nValueWhich, sal_True, &pItem1 ) == SFX_ITEM_SET ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir const SfxUInt32Item * pNumItem = dynamic_cast< const SfxUInt32Item * >( pItem1 ); 75*cdf0e10cSrcweir if( pNumItem ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir rnFormatKeyOut = pNumItem->GetValue(); 78*cdf0e10cSrcweir bSet = true; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir rbSourceFormatMixedStateOut=true; 83*cdf0e10cSrcweir const SfxPoolItem *pItem2 = NULL; 84*cdf0e10cSrcweir if( rSet.GetItemState( nSourceFormatWhich, sal_True, &pItem2 ) == SFX_ITEM_SET ) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir const SfxBoolItem * pBoolItem = dynamic_cast< const SfxBoolItem * >( pItem2 ); 87*cdf0e10cSrcweir if( pBoolItem ) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir rbSourceFormatOut = pBoolItem->GetValue(); 90*cdf0e10cSrcweir rbSourceFormatMixedStateOut=false; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir return bSet; 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir void lcl_setBoolItemToCheckBox( const SfxItemSet& rInAttrs, sal_uInt16 nWhichId, CheckBox& rCheckbox ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir rCheckbox.EnableTriState( sal_False ); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL; 101*cdf0e10cSrcweir if( rInAttrs.GetItemState(nWhichId, sal_True, &pPoolItem) == SFX_ITEM_SET ) 102*cdf0e10cSrcweir rCheckbox.Check( ((const SfxBoolItem*)pPoolItem)->GetValue() ); 103*cdf0e10cSrcweir else 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir rCheckbox.EnableTriState( sal_True ); 106*cdf0e10cSrcweir rCheckbox.SetState( STATE_DONTKNOW ); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir }//end anonymous namespace 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir DataLabelResources::DataLabelResources( Window* pWindow, const SfxItemSet& rInAttrs ) 113*cdf0e10cSrcweir : m_aCBNumber(pWindow, SchResId(CB_VALUE_AS_NUMBER)), 114*cdf0e10cSrcweir m_aPB_NumberFormatForValue(pWindow, SchResId(PB_NUMBERFORMAT)), 115*cdf0e10cSrcweir m_aCBPercent(pWindow, SchResId(CB_VALUE_AS_PERCENTAGE)), 116*cdf0e10cSrcweir m_aPB_NumberFormatForPercent(pWindow, SchResId(PB_PERCENT_NUMBERFORMAT)), 117*cdf0e10cSrcweir m_aCBCategory(pWindow, SchResId(CB_CATEGORY)), 118*cdf0e10cSrcweir m_aCBSymbol(pWindow, SchResId(CB_SYMBOL)), 119*cdf0e10cSrcweir m_aSeparatorResources(pWindow), 120*cdf0e10cSrcweir m_aFT_LabelPlacement(pWindow, SchResId(FT_LABEL_PLACEMENT)), 121*cdf0e10cSrcweir m_aLB_LabelPlacement(pWindow, SchResId(LB_LABEL_PLACEMENT)), 122*cdf0e10cSrcweir m_aFL_Rotate(pWindow, SchResId(FL_LABEL_ROTATE)), 123*cdf0e10cSrcweir m_aDC_Dial(pWindow, SchResId(CT_LABEL_DIAL)), 124*cdf0e10cSrcweir m_aFT_Degrees(pWindow, SchResId(FT_LABEL_DEGREES)), 125*cdf0e10cSrcweir m_aNF_Degrees(pWindow, SchResId(NF_LABEL_DEGREES)), 126*cdf0e10cSrcweir m_aFT_TextDirection(pWindow, SchResId(FT_LABEL_TEXTDIR)), 127*cdf0e10cSrcweir m_aLB_TextDirection(pWindow, SchResId(LB_LABEL_TEXTDIR), &m_aFT_TextDirection), 128*cdf0e10cSrcweir m_pNumberFormatter(0), 129*cdf0e10cSrcweir m_bNumberFormatMixedState(true), 130*cdf0e10cSrcweir m_bPercentFormatMixedState(true), 131*cdf0e10cSrcweir m_nNumberFormatForValue(0), 132*cdf0e10cSrcweir m_nNumberFormatForPercent(11), 133*cdf0e10cSrcweir m_bSourceFormatMixedState(true), 134*cdf0e10cSrcweir m_bPercentSourceMixedState(true), 135*cdf0e10cSrcweir m_bSourceFormatForValue(true), 136*cdf0e10cSrcweir m_bSourceFormatForPercent(true), 137*cdf0e10cSrcweir m_pWindow(pWindow), 138*cdf0e10cSrcweir m_pPool(rInAttrs.GetPool()) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir //fill label placement list 141*cdf0e10cSrcweir std::map< sal_Int32, XubString > aPlacementToStringMap; 142*cdf0e10cSrcweir for( sal_Int32 nEnum=0; nEnum<m_aLB_LabelPlacement.GetEntryCount(); ++nEnum ) 143*cdf0e10cSrcweir aPlacementToStringMap[nEnum]=m_aLB_LabelPlacement.GetEntry(static_cast<sal_uInt16>(nEnum)); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir ::com::sun::star::uno::Sequence < sal_Int32 > aAvailabelPlacementList; 146*cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL; 147*cdf0e10cSrcweir if( rInAttrs.GetItemState(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS, sal_True, &pPoolItem) == SFX_ITEM_SET ) 148*cdf0e10cSrcweir aAvailabelPlacementList =((const SfxIntegerListItem*)pPoolItem)->GetConstSequence(); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir m_aLB_LabelPlacement.Clear(); 151*cdf0e10cSrcweir for( sal_Int32 nN=0; nN<aAvailabelPlacementList.getLength(); ++nN ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir sal_uInt16 nListBoxPos = static_cast<sal_uInt16>( nN ); 154*cdf0e10cSrcweir sal_Int32 nPlacement = aAvailabelPlacementList[nN]; 155*cdf0e10cSrcweir m_aPlacementToListBoxMap[nPlacement]=nListBoxPos; 156*cdf0e10cSrcweir m_aListBoxToPlacementMap[nListBoxPos]=nPlacement; 157*cdf0e10cSrcweir m_aLB_LabelPlacement.InsertEntry( aPlacementToStringMap[nPlacement] ); 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir m_aLB_LabelPlacement.SetDropDownLineCount(m_aLB_LabelPlacement.GetEntryCount()); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir //replace&resize push buttons and resize checkboxes 162*cdf0e10cSrcweir Size aControlDistance( pWindow->LogicToPixel( Size(RSC_SP_CTRL_DESC_X,RSC_SP_CTRL_GROUP_Y), MapMode(MAP_APPFONT) ) ); 163*cdf0e10cSrcweir long nPBWidth = ::std::max( m_aPB_NumberFormatForPercent.CalcMinimumSize().getWidth(), m_aPB_NumberFormatForValue.CalcMinimumSize().getWidth() ) 164*cdf0e10cSrcweir + 20; //the min with is to small to fit, hm... so add alittle 165*cdf0e10cSrcweir long nCBXWidth = ::std::max( m_aCBNumber.CalcMinimumSize().getWidth(), m_aCBPercent.CalcMinimumSize().getWidth() ); 166*cdf0e10cSrcweir long nNewPBXPos = m_aCBNumber.GetPosPixel().X() + nCBXWidth + aControlDistance.Width(); 167*cdf0e10cSrcweir long nPageWidth = pWindow->LogicToPixel( Size(260,185), MapMode(MAP_APPFONT) ).getWidth(); 168*cdf0e10cSrcweir if( nNewPBXPos + nPBWidth > nPageWidth ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir if( nPBWidth > nPageWidth/2 ) 171*cdf0e10cSrcweir nPBWidth = nPageWidth/2; 172*cdf0e10cSrcweir nNewPBXPos = nPageWidth-nPBWidth; 173*cdf0e10cSrcweir nCBXWidth = nPageWidth-m_aCBNumber.GetPosPixel().X()-nPBWidth-aControlDistance.Width(); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir m_aPB_NumberFormatForValue.SetPosPixel( Point( nNewPBXPos, m_aPB_NumberFormatForValue.GetPosPixel().Y() ) ); 176*cdf0e10cSrcweir m_aPB_NumberFormatForPercent.SetPosPixel( Point( nNewPBXPos, m_aPB_NumberFormatForPercent.GetPosPixel().Y() ) ); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir Size aPBSize( m_aPB_NumberFormatForPercent.GetSizePixel() ); 179*cdf0e10cSrcweir aPBSize.setWidth( nPBWidth ); 180*cdf0e10cSrcweir m_aPB_NumberFormatForValue.SetSizePixel( aPBSize ); 181*cdf0e10cSrcweir m_aPB_NumberFormatForPercent.SetSizePixel( aPBSize ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir Size aCBSize( m_aCBNumber.GetSizePixel() ); 184*cdf0e10cSrcweir aCBSize.setWidth(nCBXWidth); 185*cdf0e10cSrcweir m_aCBNumber.SetSizePixel( aCBSize ); 186*cdf0e10cSrcweir m_aCBPercent.SetSizePixel( aCBSize ); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir //place and align separator and label placement listboxes 189*cdf0e10cSrcweir Size aSize( m_aFT_LabelPlacement.GetSizePixel() ); 190*cdf0e10cSrcweir aSize.setWidth( m_aFT_LabelPlacement.CalcMinimumSize().getWidth() ); 191*cdf0e10cSrcweir m_aFT_LabelPlacement.SetSizePixel(aSize); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir long nWantedMinLeftBorder = m_aFT_LabelPlacement.GetPosPixel().X() + aSize.getWidth () + aControlDistance.Width(); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir m_aSeparatorResources.PositionBelowControl(m_aCBSymbol); 196*cdf0e10cSrcweir m_aSeparatorResources.AlignListBoxWidthAndXPos( nWantedMinLeftBorder, -1, m_aLB_LabelPlacement.CalcMinimumSize().getWidth() ); 197*cdf0e10cSrcweir m_aSeparatorResources.Show(true); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir aSize = m_aLB_LabelPlacement.GetSizePixel(); 200*cdf0e10cSrcweir aSize.setWidth( m_aSeparatorResources.GetCurrentListBoxSize().getWidth() ); 201*cdf0e10cSrcweir m_aLB_LabelPlacement.SetSizePixel(aSize); 202*cdf0e10cSrcweir m_aLB_LabelPlacement.SetPosPixel( Point( m_aSeparatorResources.GetCurrentListBoxPosition().X(), m_aLB_LabelPlacement.GetPosPixel().Y() ) ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir //some click handler 205*cdf0e10cSrcweir m_aPB_NumberFormatForValue.SetClickHdl( LINK( this, DataLabelResources, NumberFormatDialogHdl ) ); 206*cdf0e10cSrcweir m_aPB_NumberFormatForPercent.SetClickHdl( LINK( this, DataLabelResources, NumberFormatDialogHdl ) ); 207*cdf0e10cSrcweir m_aCBNumber.SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); 208*cdf0e10cSrcweir m_aCBPercent.SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); 209*cdf0e10cSrcweir m_aCBCategory.SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); 210*cdf0e10cSrcweir m_aCBSymbol.SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir m_bNumberFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, m_nNumberFormatForValue, m_bSourceFormatForValue, m_bSourceFormatMixedState ); 213*cdf0e10cSrcweir m_bPercentFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, m_nNumberFormatForPercent, m_bSourceFormatForPercent , m_bPercentSourceMixedState); 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir if( rInAttrs.GetItemState(SCHATTR_DATADESCR_NO_PERCENTVALUE, sal_True, &pPoolItem) == SFX_ITEM_SET ) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir bool bForbidPercentValue = (static_cast< const SfxBoolItem & >( rInAttrs.Get( SCHATTR_DATADESCR_NO_PERCENTVALUE )).GetValue() ); 218*cdf0e10cSrcweir if( bForbidPercentValue ) 219*cdf0e10cSrcweir m_aCBPercent.Enable(false); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir m_aDC_Dial.SetLinkedField( &m_aNF_Degrees ); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir DataLabelResources::~DataLabelResources() 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir void DataLabelResources::SetNumberFormatter( SvNumberFormatter* pFormatter ) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir m_pNumberFormatter = pFormatter; 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir IMPL_LINK( DataLabelResources, NumberFormatDialogHdl, PushButton *, pButton ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir if( !m_pPool || !m_pNumberFormatter ) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir DBG_ERROR("Missing item pool or number formatter"); 239*cdf0e10cSrcweir return 1; 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir if( pButton == &m_aPB_NumberFormatForValue && !m_aCBNumber.IsChecked()) 243*cdf0e10cSrcweir m_aCBNumber.Check(); 244*cdf0e10cSrcweir else if( pButton == &m_aPB_NumberFormatForPercent && !m_aCBPercent.IsChecked()) 245*cdf0e10cSrcweir m_aCBPercent.Check(); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir SfxItemSet aNumberSet = NumberFormatDialog::CreateEmptyItemSetForNumberFormatDialog( *m_pPool ); 248*cdf0e10cSrcweir aNumberSet.Put (SvxNumberInfoItem( m_pNumberFormatter, (const sal_uInt16)SID_ATTR_NUMBERFORMAT_INFO)); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir bool bPercent = ( pButton == &m_aPB_NumberFormatForPercent ); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir sal_uLong& rnFormatKey = bPercent ? m_nNumberFormatForPercent : m_nNumberFormatForValue; 253*cdf0e10cSrcweir bool& rUseSourceFormat = bPercent ? m_bSourceFormatForPercent : m_bSourceFormatForValue; 254*cdf0e10cSrcweir bool& rbMixedState = bPercent ? m_bPercentFormatMixedState : m_bNumberFormatMixedState; 255*cdf0e10cSrcweir bool& rbSourceMixedState = bPercent ? m_bPercentSourceMixedState : m_bSourceFormatMixedState; 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir if(!rbMixedState) 258*cdf0e10cSrcweir aNumberSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, rnFormatKey )); 259*cdf0e10cSrcweir aNumberSet.Put( SfxBoolItem( SID_ATTR_NUMBERFORMAT_SOURCE, rUseSourceFormat )); 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir NumberFormatDialog aDlg(m_pWindow, aNumberSet); 262*cdf0e10cSrcweir if( bPercent ) 263*cdf0e10cSrcweir aDlg.SetText( String( SchResId( STR_DLG_NUMBERFORMAT_FOR_PERCENTAGE_VALUE ) ) ); 264*cdf0e10cSrcweir if( RET_OK == aDlg.Execute() ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir const SfxItemSet* pResult = aDlg.GetOutputItemSet(); 267*cdf0e10cSrcweir if( pResult ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir bool bOldSource = rUseSourceFormat; 270*cdf0e10cSrcweir sal_uLong nOldFormat = rnFormatKey; 271*cdf0e10cSrcweir bool bOldMixedState = rbMixedState || rbSourceMixedState; 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir rbMixedState = !lcl_ReadNumberFormatFromItemSet( *pResult, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, rnFormatKey, rUseSourceFormat, rbSourceMixedState ); 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir //todo this maybe can be removed when the numberformatter dialog does handle mixed state for source format correctly 276*cdf0e10cSrcweir if( bOldMixedState && bOldSource == rUseSourceFormat && nOldFormat == rnFormatKey ) 277*cdf0e10cSrcweir rbMixedState = rbSourceMixedState = true; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir return 0; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir IMPL_LINK( DataLabelResources, CheckHdl, CheckBox*, pBox ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir if( pBox ) 286*cdf0e10cSrcweir pBox->EnableTriState( sal_False ); 287*cdf0e10cSrcweir EnableControls(); 288*cdf0e10cSrcweir return 0; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir void DataLabelResources::EnableControls() 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir m_aCBSymbol.Enable( m_aCBNumber.IsChecked() || (m_aCBPercent.IsChecked() && m_aCBPercent.IsEnabled()) || m_aCBCategory.IsChecked() ); 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir //enable separator 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir long nNumberOfCheckedLabelParts = 0; 298*cdf0e10cSrcweir if( m_aCBNumber.IsChecked() ) 299*cdf0e10cSrcweir ++nNumberOfCheckedLabelParts; 300*cdf0e10cSrcweir if( m_aCBPercent.IsChecked() && m_aCBPercent.IsEnabled() ) 301*cdf0e10cSrcweir ++nNumberOfCheckedLabelParts; 302*cdf0e10cSrcweir if( m_aCBCategory.IsChecked() ) 303*cdf0e10cSrcweir ++nNumberOfCheckedLabelParts; 304*cdf0e10cSrcweir m_aSeparatorResources.Enable( nNumberOfCheckedLabelParts > 1 ); 305*cdf0e10cSrcweir bool bEnableTextDir = nNumberOfCheckedLabelParts > 0; 306*cdf0e10cSrcweir m_aFT_TextDirection.Enable( bEnableTextDir ); 307*cdf0e10cSrcweir m_aLB_TextDirection.Enable( bEnableTextDir ); 308*cdf0e10cSrcweir bool bEnablePlacement = nNumberOfCheckedLabelParts > 0 && m_aLB_LabelPlacement.GetEntryCount()>1; 309*cdf0e10cSrcweir m_aFT_LabelPlacement.Enable( bEnablePlacement ); 310*cdf0e10cSrcweir m_aLB_LabelPlacement.Enable( bEnablePlacement ); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir m_aPB_NumberFormatForValue.Enable( m_pNumberFormatter && m_aCBNumber.IsChecked() ); 314*cdf0e10cSrcweir m_aPB_NumberFormatForPercent.Enable( m_pNumberFormatter && m_aCBPercent.IsChecked() && m_aCBPercent.IsEnabled() ); 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir bool bEnableRotation = ( m_aCBNumber.IsChecked() || m_aCBPercent.IsChecked() || m_aCBCategory.IsChecked() ); 317*cdf0e10cSrcweir m_aFL_Rotate.Enable( bEnableRotation ); 318*cdf0e10cSrcweir m_aDC_Dial.Enable( bEnableRotation ); 319*cdf0e10cSrcweir m_aFT_Degrees.Enable( bEnableRotation ); 320*cdf0e10cSrcweir m_aNF_Degrees.Enable( bEnableRotation ); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir sal_Bool DataLabelResources::FillItemSet( SfxItemSet& rOutAttrs ) const 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir if( m_aCBNumber.IsChecked() ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir if( !m_bNumberFormatMixedState ) 328*cdf0e10cSrcweir rOutAttrs.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, m_nNumberFormatForValue )); 329*cdf0e10cSrcweir if( !m_bSourceFormatMixedState ) 330*cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( SID_ATTR_NUMBERFORMAT_SOURCE, m_bSourceFormatForValue )); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir if( m_aCBPercent.IsChecked() ) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir if( !m_bPercentFormatMixedState ) 335*cdf0e10cSrcweir rOutAttrs.Put( SfxUInt32Item( SCHATTR_PERCENT_NUMBERFORMAT_VALUE, m_nNumberFormatForPercent )); 336*cdf0e10cSrcweir if( !m_bPercentSourceMixedState ) 337*cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, m_bSourceFormatForPercent )); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir if( m_aCBNumber.GetState()!= STATE_DONTKNOW ) 341*cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_NUMBER, m_aCBNumber.IsChecked() ) ); 342*cdf0e10cSrcweir if( m_aCBPercent.GetState()!= STATE_DONTKNOW ) 343*cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_PERCENTAGE, m_aCBPercent.IsChecked() ) ); 344*cdf0e10cSrcweir if( m_aCBCategory.GetState()!= STATE_DONTKNOW ) 345*cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_CATEGORY, m_aCBCategory.IsChecked() ) ); 346*cdf0e10cSrcweir if( m_aCBSymbol.GetState()!= STATE_DONTKNOW ) 347*cdf0e10cSrcweir rOutAttrs.Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_SYMBOL, m_aCBSymbol.IsChecked()) ); 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir rOutAttrs.Put( SfxStringItem( SCHATTR_DATADESCR_SEPARATOR, m_aSeparatorResources.GetValue() ) ); 350*cdf0e10cSrcweir ::std::map< sal_uInt16, sal_Int32 >::const_iterator aIt( m_aListBoxToPlacementMap.find(m_aLB_LabelPlacement.GetSelectEntryPos()) ); 351*cdf0e10cSrcweir if(aIt!=m_aListBoxToPlacementMap.end()) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir sal_Int32 nValue = aIt->second; 354*cdf0e10cSrcweir rOutAttrs.Put( SfxInt32Item( SCHATTR_DATADESCR_PLACEMENT, nValue ) ); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir if( m_aLB_TextDirection.GetSelectEntryCount() > 0 ) 358*cdf0e10cSrcweir rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_aLB_TextDirection.GetSelectEntryValue() ) ); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir if( m_aDC_Dial.IsVisible() ) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir sal_Int32 nDegrees = m_aDC_Dial.GetRotation(); 363*cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) ); 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir return sal_True; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir void DataLabelResources::Reset(const SfxItemSet& rInAttrs) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir // default state 372*cdf0e10cSrcweir m_aCBSymbol.Enable( sal_False ); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_NUMBER, m_aCBNumber ); 375*cdf0e10cSrcweir lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_PERCENTAGE, m_aCBPercent ); 376*cdf0e10cSrcweir lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_CATEGORY, m_aCBCategory ); 377*cdf0e10cSrcweir lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_SYMBOL, m_aCBSymbol ); 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir m_bNumberFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, m_nNumberFormatForValue, m_bSourceFormatForValue, m_bSourceFormatMixedState ); 380*cdf0e10cSrcweir m_bPercentFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, m_nNumberFormatForPercent, m_bSourceFormatForPercent , m_bPercentSourceMixedState); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL; 383*cdf0e10cSrcweir if( rInAttrs.GetItemState(SCHATTR_DATADESCR_SEPARATOR, sal_True, &pPoolItem) == SFX_ITEM_SET ) 384*cdf0e10cSrcweir m_aSeparatorResources.SetValue( ((const SfxStringItem*)pPoolItem)->GetValue() ); 385*cdf0e10cSrcweir else 386*cdf0e10cSrcweir m_aSeparatorResources.SetDefault(); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir if( rInAttrs.GetItemState(SCHATTR_DATADESCR_PLACEMENT, sal_True, &pPoolItem) == SFX_ITEM_SET ) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir sal_Int32 nPlacement = ((const SfxInt32Item*)pPoolItem)->GetValue(); 391*cdf0e10cSrcweir ::std::map< sal_Int32, sal_uInt16 >::const_iterator aIt( m_aPlacementToListBoxMap.find(nPlacement) ); 392*cdf0e10cSrcweir if(aIt!=m_aPlacementToListBoxMap.end()) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir sal_uInt16 nPos = aIt->second; 395*cdf0e10cSrcweir m_aLB_LabelPlacement.SelectEntryPos( nPos ); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir else 398*cdf0e10cSrcweir m_aLB_LabelPlacement.SetNoSelection(); 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir else 401*cdf0e10cSrcweir m_aLB_LabelPlacement.SetNoSelection(); 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, sal_True, &pPoolItem ) == SFX_ITEM_SET ) 404*cdf0e10cSrcweir m_aLB_TextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir if( rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, sal_True, &pPoolItem ) == SFX_ITEM_SET ) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir sal_Int32 nDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); 409*cdf0e10cSrcweir m_aDC_Dial.SetRotation( nDegrees ); 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir else 412*cdf0e10cSrcweir m_aDC_Dial.SetRotation( 0 ); 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir EnableControls(); 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir //............................................................................. 418*cdf0e10cSrcweir } //namespace chart 419*cdf0e10cSrcweir //............................................................................. 420