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 "tp_DataSource.hxx" 32*cdf0e10cSrcweir #include "tp_DataSource.hrc" 33*cdf0e10cSrcweir #include "Strings.hrc" 34*cdf0e10cSrcweir #include "ResId.hxx" 35*cdf0e10cSrcweir #include "chartview/ChartSfxItemIds.hxx" 36*cdf0e10cSrcweir #include "macros.hxx" 37*cdf0e10cSrcweir #include "ChartTypeTemplateProvider.hxx" 38*cdf0e10cSrcweir #include "RangeSelectionHelper.hxx" 39*cdf0e10cSrcweir #include "DataSeriesHelper.hxx" 40*cdf0e10cSrcweir #include "tp_DataSourceControls.hxx" 41*cdf0e10cSrcweir #include "ControllerLockGuard.hxx" 42*cdf0e10cSrcweir #include "DataSourceHelper.hxx" 43*cdf0e10cSrcweir #include <com/sun/star/sheet/XRangeSelection.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/table/XCellRange.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/chart2/XChartType.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/chart2/XChartTypeTemplate.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/util/XModifiable.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataSink.hpp> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir // for RET_OK 51*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 52*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #include <functional> 55*cdf0e10cSrcweir #include <algorithm> 56*cdf0e10cSrcweir #include <map> 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir using namespace ::com::sun::star; 59*cdf0e10cSrcweir using namespace ::com::sun::star::chart2; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 62*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 63*cdf0e10cSrcweir using ::rtl::OUString; 64*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir namespace 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir const OUString lcl_aLabelRole( RTL_CONSTASCII_USTRINGPARAM( "label" )); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir String lcl_GetRoleLBEntry( 74*cdf0e10cSrcweir const OUString & rRole, const OUString & rRange ) 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir String aEntry( rRole ); 77*cdf0e10cSrcweir aEntry += '\t'; 78*cdf0e10cSrcweir aEntry += String( 79*cdf0e10cSrcweir ::chart::DialogModel::ConvertRoleFromInternalToUI( rRole )); 80*cdf0e10cSrcweir aEntry += '\t'; 81*cdf0e10cSrcweir aEntry += String( rRange ); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir return aEntry; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir void lcl_UpdateCurrentRange( 87*cdf0e10cSrcweir SvTabListBox & rOutListBox, 88*cdf0e10cSrcweir const OUString & rRole, const OUString & rRange ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir SvLBoxEntry * pEntry = rOutListBox.FirstSelected(); 91*cdf0e10cSrcweir if( pEntry ) 92*cdf0e10cSrcweir rOutListBox.SetEntryText( lcl_GetRoleLBEntry( rRole, rRange ), pEntry ); 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir bool lcl_UpdateCurrentSeriesName( 96*cdf0e10cSrcweir SvTreeListBox & rOutListBox ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir bool bResult = false; 99*cdf0e10cSrcweir ::chart::SeriesEntry * pEntry = dynamic_cast< ::chart::SeriesEntry * >( rOutListBox.FirstSelected()); 100*cdf0e10cSrcweir if( pEntry && 101*cdf0e10cSrcweir pEntry->m_xDataSeries.is() && 102*cdf0e10cSrcweir pEntry->m_xChartType.is()) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir String aLabel( ::chart::DataSeriesHelper::getDataSeriesLabel( 105*cdf0e10cSrcweir pEntry->m_xDataSeries, 106*cdf0e10cSrcweir pEntry->m_xChartType->getRoleOfSequenceForSeriesLabel())); 107*cdf0e10cSrcweir if( aLabel.Len()) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir rOutListBox.SetEntryText( pEntry, aLabel ); 110*cdf0e10cSrcweir bResult = true; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir return bResult; 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir OUString lcl_GetSelectedRole( const SvTabListBox & rRoleListBox, bool bUITranslated = false ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir OUString aResult; 119*cdf0e10cSrcweir SvLBoxEntry * pEntry = rRoleListBox.FirstSelected(); 120*cdf0e10cSrcweir if( pEntry ) 121*cdf0e10cSrcweir aResult = OUString( rRoleListBox.GetEntryText( pEntry, 122*cdf0e10cSrcweir bUITranslated ? 1 : 0 )); 123*cdf0e10cSrcweir return aResult; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir OUString lcl_GetSelectedRolesRange( const SvTabListBox & rRoleListBox ) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir OUString aResult; 129*cdf0e10cSrcweir SvLBoxEntry * pEntry = rRoleListBox.FirstSelected(); 130*cdf0e10cSrcweir if( pEntry ) 131*cdf0e10cSrcweir aResult = OUString( rRoleListBox.GetEntryText( pEntry, 2 )); 132*cdf0e10cSrcweir return aResult; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir OUString lcl_GetSequenceNameForLabel( ::chart::SeriesEntry * pEntry ) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir OUString aResult( RTL_CONSTASCII_USTRINGPARAM("values-y")); 138*cdf0e10cSrcweir if( pEntry && 139*cdf0e10cSrcweir pEntry->m_xChartType.is()) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir aResult = pEntry->m_xChartType->getRoleOfSequenceForSeriesLabel(); 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir return aResult; 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir static long lcl_pRoleListBoxTabs[] = 147*cdf0e10cSrcweir { 3, // Number of Tabs 148*cdf0e10cSrcweir 0, 0, 75 149*cdf0e10cSrcweir }; 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir void lcl_ShowChooserButton( 152*cdf0e10cSrcweir ::chart::RangeSelectionButton & rChooserButton, 153*cdf0e10cSrcweir Edit & rEditField, 154*cdf0e10cSrcweir sal_Bool bShow ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir if( rChooserButton.IsVisible() != bShow ) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir rChooserButton.Show( bShow ); 159*cdf0e10cSrcweir sal_Int32 nWidhtDiff = 12 + 4; 160*cdf0e10cSrcweir if( bShow ) 161*cdf0e10cSrcweir nWidhtDiff = -nWidhtDiff; 162*cdf0e10cSrcweir Size aSize = rChooserButton.PixelToLogic( rEditField.GetSizePixel(), MAP_APPFONT ); 163*cdf0e10cSrcweir aSize.setWidth( aSize.getWidth() + nWidhtDiff ); 164*cdf0e10cSrcweir rEditField.SetSizePixel( rChooserButton.LogicToPixel( aSize, MAP_APPFONT )); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir void lcl_enableRangeChoosing( bool bEnable, Dialog * pDialog ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir if( pDialog ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir pDialog->Show( bEnable ? sal_False : sal_True ); 173*cdf0e10cSrcweir pDialog->SetModalInputMode( bEnable ? sal_False : sal_True ); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir void lcl_addLSequenceToDataSource( 178*cdf0e10cSrcweir const Reference< chart2::data::XLabeledDataSequence > & xLSequence, 179*cdf0e10cSrcweir const Reference< chart2::data::XDataSource > & xSource ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir Reference< data::XDataSink > xSink( xSource, uno::UNO_QUERY ); 182*cdf0e10cSrcweir if( xSink.is()) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xSource->getDataSequences()); 185*cdf0e10cSrcweir aData.realloc( aData.getLength() + 1 ); 186*cdf0e10cSrcweir aData[ aData.getLength() - 1 ] = xLSequence; 187*cdf0e10cSrcweir xSink->setData( aData ); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel( 192*cdf0e10cSrcweir const Reference< chart2::data::XDataSource > & xDataSource ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir Reference< chart2::data::XLabeledDataSequence > xResult; 195*cdf0e10cSrcweir Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences()); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir for( sal_Int32 i=0; i<aSequences.getLength(); ++i ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir // no values are set but a label exists 200*cdf0e10cSrcweir if( ! aSequences[i]->getValues().is() && 201*cdf0e10cSrcweir aSequences[i]->getLabel().is()) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir xResult.set( aSequences[i] ); 204*cdf0e10cSrcweir break; 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir return xResult; 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir void lcl_shiftControlY( Control & rControl, long nYOffset ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir Point aPos( rControl.GetPosPixel()); 214*cdf0e10cSrcweir aPos.setY( aPos.getY() + nYOffset ); 215*cdf0e10cSrcweir rControl.SetPosPixel( aPos ); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir void lcl_increaseHeightOfControl( Control & rControl, long nYOffset ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir Size aSize( rControl.GetSizePixel()); 221*cdf0e10cSrcweir aSize.setHeight( aSize.getHeight () + nYOffset ); 222*cdf0e10cSrcweir rControl.SetSizePixel( aSize ); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir } // anonymous namespace 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir namespace chart 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir DataSourceTabPage::DataSourceTabPage( 233*cdf0e10cSrcweir Window * pParent, 234*cdf0e10cSrcweir DialogModel & rDialogModel, 235*cdf0e10cSrcweir ChartTypeTemplateProvider* pTemplateProvider, 236*cdf0e10cSrcweir Dialog * pParentDialog, 237*cdf0e10cSrcweir bool bHideDescription /* = false */ ) : 238*cdf0e10cSrcweir ::svt::OWizardPage( pParent, SchResId( TP_DATA_SOURCE )), 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir m_aFT_CAPTION ( this, SchResId( FT_CAPTION_FOR_WIZARD )), 241*cdf0e10cSrcweir m_aFT_SERIES ( this, SchResId( FT_SERIES )), 242*cdf0e10cSrcweir m_apLB_SERIES( new SeriesListBox( this, SchResId( LB_SERIES ))), 243*cdf0e10cSrcweir m_aBTN_ADD ( this, SchResId( BTN_ADD )), 244*cdf0e10cSrcweir m_aBTN_REMOVE ( this, SchResId( BTN_REMOVE )), 245*cdf0e10cSrcweir m_aBTN_UP ( this, SchResId( BTN_UP )), 246*cdf0e10cSrcweir m_aBTN_DOWN ( this, SchResId( BTN_DOWN )), 247*cdf0e10cSrcweir m_aFT_ROLE ( this, SchResId( FT_ROLE )), 248*cdf0e10cSrcweir m_aLB_ROLE ( this, SchResId( LB_ROLE )), 249*cdf0e10cSrcweir m_aFT_RANGE ( this, SchResId( FT_RANGE )), 250*cdf0e10cSrcweir m_aEDT_RANGE ( this, SchResId( EDT_RANGE )), 251*cdf0e10cSrcweir m_aIMB_RANGE_MAIN ( this, SchResId( IMB_RANGE_MAIN )), 252*cdf0e10cSrcweir m_aFT_CATEGORIES ( this, SchResId( FT_CATEGORIES )), 253*cdf0e10cSrcweir m_aFT_DATALABELS ( this, SchResId( FT_DATALABELS )), 254*cdf0e10cSrcweir m_aEDT_CATEGORIES ( this, SchResId( EDT_CATEGORIES )), 255*cdf0e10cSrcweir m_aIMB_RANGE_CAT ( this, SchResId( IMB_RANGE_CAT )), 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir m_pTemplateProvider( pTemplateProvider ), 258*cdf0e10cSrcweir m_rDialogModel( rDialogModel ), 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir m_pCurrentRangeChoosingField( 0 ), 261*cdf0e10cSrcweir m_bIsDirty( false ), 262*cdf0e10cSrcweir m_pParentDialog( pParentDialog ), 263*cdf0e10cSrcweir m_pTabPageNotifiable( dynamic_cast< TabPageNotifiable * >( pParentDialog )) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir FreeResource(); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir if( bHideDescription ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir // note: the offset should be a negative value for shifting upwards, the 270*cdf0e10cSrcweir // 4 is for the offset difference between a wizard page and a tab-page 271*cdf0e10cSrcweir long nYOffset = - ( m_aFT_SERIES.GetPosPixel().getY() - m_aFT_CAPTION.GetPosPixel().getY() + 4 ); 272*cdf0e10cSrcweir long nUpShift = - 2; 273*cdf0e10cSrcweir long nYResize = - (nYOffset - nUpShift); 274*cdf0e10cSrcweir m_aFT_CAPTION.Hide(); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir // shift list boxes and enlarge them by the space saved by hiding the caption 277*cdf0e10cSrcweir lcl_shiftControlY( m_aFT_SERIES, nYOffset ); 278*cdf0e10cSrcweir lcl_shiftControlY( *(m_apLB_SERIES.get()), nYOffset ); 279*cdf0e10cSrcweir lcl_increaseHeightOfControl( *(m_apLB_SERIES.get()), nYResize ); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir lcl_shiftControlY( m_aFT_ROLE, nYOffset ); 282*cdf0e10cSrcweir lcl_shiftControlY( m_aLB_ROLE, nYOffset ); 283*cdf0e10cSrcweir lcl_increaseHeightOfControl( m_aLB_ROLE, nYResize ); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir lcl_shiftControlY( m_aBTN_ADD, nUpShift ); 286*cdf0e10cSrcweir lcl_shiftControlY( m_aBTN_REMOVE, nUpShift ); 287*cdf0e10cSrcweir lcl_shiftControlY( m_aBTN_UP, nUpShift ); 288*cdf0e10cSrcweir lcl_shiftControlY( m_aBTN_DOWN, nUpShift ); 289*cdf0e10cSrcweir lcl_shiftControlY( m_aFT_RANGE, nUpShift ); 290*cdf0e10cSrcweir lcl_shiftControlY( m_aEDT_RANGE, nUpShift ); 291*cdf0e10cSrcweir lcl_shiftControlY( m_aIMB_RANGE_MAIN, nUpShift ); 292*cdf0e10cSrcweir lcl_shiftControlY( m_aFT_CATEGORIES, nUpShift ); 293*cdf0e10cSrcweir lcl_shiftControlY( m_aFT_DATALABELS, nUpShift ); 294*cdf0e10cSrcweir lcl_shiftControlY( m_aEDT_CATEGORIES, nUpShift ); 295*cdf0e10cSrcweir lcl_shiftControlY( m_aIMB_RANGE_CAT, nUpShift ); 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir else 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir // make font of caption bold 300*cdf0e10cSrcweir Font aFont( m_aFT_CAPTION.GetControlFont() ); 301*cdf0e10cSrcweir aFont.SetWeight( WEIGHT_BOLD ); 302*cdf0e10cSrcweir m_aFT_CAPTION.SetControlFont( aFont ); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir // no mnemonic 305*cdf0e10cSrcweir m_aFT_CAPTION.SetStyle( m_aFT_CAPTION.GetStyle() | WB_NOLABEL ); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir m_aFixedTextRange = OUString( m_aFT_RANGE.GetText() ); 309*cdf0e10cSrcweir this->SetText( String( SchResId( STR_OBJECT_DATASERIES_PLURAL ) ) ); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir // set handlers 312*cdf0e10cSrcweir m_apLB_SERIES->SetSelectHdl( LINK( this, DataSourceTabPage, SeriesSelectionChangedHdl )); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir m_aLB_ROLE.SetStyle( m_aLB_ROLE.GetStyle() | WB_HSCROLL | WB_CLIPCHILDREN ); 315*cdf0e10cSrcweir m_aLB_ROLE.SetSelectionMode( SINGLE_SELECTION ); 316*cdf0e10cSrcweir m_aLB_ROLE.SetSelectHdl( LINK( this, DataSourceTabPage, RoleSelectionChangedHdl )); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir m_aEDT_RANGE.SetKeyInputHdl( LINK( this, DataSourceTabPage, MainRangeButtonClickedHdl )); 319*cdf0e10cSrcweir m_aEDT_CATEGORIES.SetKeyInputHdl( LINK( this, DataSourceTabPage, CategoriesRangeButtonClickedHdl )); 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir m_aIMB_RANGE_MAIN.SetClickHdl( LINK( this, DataSourceTabPage, MainRangeButtonClickedHdl )); 322*cdf0e10cSrcweir m_aIMB_RANGE_CAT.SetClickHdl( LINK( this, DataSourceTabPage, CategoriesRangeButtonClickedHdl )); 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir m_aBTN_ADD.SetClickHdl( LINK( this, DataSourceTabPage, AddButtonClickedHdl )); 325*cdf0e10cSrcweir m_aBTN_REMOVE.SetClickHdl( LINK( this, DataSourceTabPage, RemoveButtonClickedHdl )); 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir m_aBTN_UP.SetClickHdl( LINK( this, DataSourceTabPage, UpButtonClickedHdl )); 328*cdf0e10cSrcweir m_aBTN_DOWN.SetClickHdl( LINK( this, DataSourceTabPage, DownButtonClickedHdl )); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir m_aEDT_RANGE.SetModifyHdl( LINK( this, DataSourceTabPage, RangeModifiedHdl )); 331*cdf0e10cSrcweir m_aEDT_CATEGORIES.SetModifyHdl( LINK( this, DataSourceTabPage, RangeModifiedHdl )); 332*cdf0e10cSrcweir m_aEDT_RANGE.SetUpdateDataHdl( LINK( this, DataSourceTabPage, RangeUpdateDataHdl )); 333*cdf0e10cSrcweir m_aEDT_CATEGORIES.SetUpdateDataHdl( LINK( this, DataSourceTabPage, RangeUpdateDataHdl )); 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir // #i75179# enable setting the background to a different color 336*cdf0e10cSrcweir m_aEDT_RANGE.SetStyle( m_aEDT_RANGE.GetStyle() | WB_FORCECTRLBACKGROUND ); 337*cdf0e10cSrcweir m_aEDT_CATEGORIES.SetStyle( m_aEDT_CATEGORIES.GetStyle() | WB_FORCECTRLBACKGROUND ); 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir // set symbol font for arrows 340*cdf0e10cSrcweir // note: StarSymbol is substituted to OpenSymbol for OOo 341*cdf0e10cSrcweir Font aSymbolFont( m_aBTN_UP.GetFont()); 342*cdf0e10cSrcweir aSymbolFont.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "StarSymbol" ))); 343*cdf0e10cSrcweir m_aBTN_UP.SetControlFont( aSymbolFont ); 344*cdf0e10cSrcweir m_aBTN_DOWN.SetControlFont( aSymbolFont ); 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir // set button text 347*cdf0e10cSrcweir sal_Unicode cBlackUpPointingTriangle( 0x25b2 ); 348*cdf0e10cSrcweir sal_Unicode cBlackDownPointingTriangle( 0x25bc ); 349*cdf0e10cSrcweir m_aBTN_UP.SetText( String( cBlackUpPointingTriangle )); 350*cdf0e10cSrcweir m_aBTN_DOWN.SetText( String( cBlackDownPointingTriangle )); 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir // init controls 353*cdf0e10cSrcweir m_aLB_ROLE.SetTabs( lcl_pRoleListBoxTabs, MAP_APPFONT ); 354*cdf0e10cSrcweir m_aLB_ROLE.Show(); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir updateControlsFromDialogModel(); 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir // select first series 359*cdf0e10cSrcweir if( m_apLB_SERIES->First()) 360*cdf0e10cSrcweir m_apLB_SERIES->Select( m_apLB_SERIES->First()); 361*cdf0e10cSrcweir m_apLB_SERIES->GrabFocus(); 362*cdf0e10cSrcweir m_aBTN_UP.SetAccessibleName(String(SchResId(STR_BUTTON_UP))); 363*cdf0e10cSrcweir m_aBTN_DOWN.SetAccessibleName(String(SchResId(STR_BUTTON_DOWN))); 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir DataSourceTabPage::~DataSourceTabPage() 367*cdf0e10cSrcweir {} 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir void DataSourceTabPage::ActivatePage() 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir OWizardPage::ActivatePage(); 372*cdf0e10cSrcweir updateControlsFromDialogModel(); 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir void DataSourceTabPage::initializePage() 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir void DataSourceTabPage::DeactivatePage() 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir commitPage(); 382*cdf0e10cSrcweir svt::OWizardPage::DeactivatePage(); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir void DataSourceTabPage::commitPage() 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir commitPage(::svt::WizardTypes::eFinish); 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir sal_Bool DataSourceTabPage::commitPage( ::svt::WizardTypes::CommitPageReason /*eReason*/ ) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir //ranges may have been edited in the meanwhile (dirty is true in that case here) 393*cdf0e10cSrcweir if( isValid() ) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir updateModelFromControl( 0 /*update all*/ ); 396*cdf0e10cSrcweir return sal_True;//return false if this page should not be left 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir else 399*cdf0e10cSrcweir return sal_False; 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir bool DataSourceTabPage::isRangeFieldContentValid( Edit & rEdit ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir OUString aRange( rEdit.GetText()); 405*cdf0e10cSrcweir bool bIsValid = ( aRange.getLength() == 0 ) || 406*cdf0e10cSrcweir m_rDialogModel.getRangeSelectionHelper()->verifyCellRange( aRange ); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir if( bIsValid ) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir rEdit.SetControlForeground(); 411*cdf0e10cSrcweir rEdit.SetControlBackground(); 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir else 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir rEdit.SetControlBackground( RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR ); 416*cdf0e10cSrcweir rEdit.SetControlForeground( RANGE_SELECTION_INVALID_RANGE_FOREGROUND_COLOR ); 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir return bIsValid; 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir bool DataSourceTabPage::isValid() 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir bool bRoleRangeValid = true; 425*cdf0e10cSrcweir bool bCategoriesRangeValid = true; 426*cdf0e10cSrcweir bool bHasSelectedEntry = (m_apLB_SERIES->FirstSelected() != 0); 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir if( bHasSelectedEntry ) 429*cdf0e10cSrcweir bRoleRangeValid = isRangeFieldContentValid( m_aEDT_RANGE ); 430*cdf0e10cSrcweir if( m_aEDT_CATEGORIES.IsEnabled() ) 431*cdf0e10cSrcweir bCategoriesRangeValid = isRangeFieldContentValid( m_aEDT_CATEGORIES ); 432*cdf0e10cSrcweir bool bValid = ( bRoleRangeValid && bCategoriesRangeValid ); 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir if( m_pTabPageNotifiable ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir if( bValid ) 437*cdf0e10cSrcweir m_pTabPageNotifiable->setValidPage( this ); 438*cdf0e10cSrcweir else 439*cdf0e10cSrcweir m_pTabPageNotifiable->setInvalidPage( this ); 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir return bValid; 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir void DataSourceTabPage::setDirty() 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir m_bIsDirty = true; 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir void DataSourceTabPage::updateControlsFromDialogModel() 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir // series 453*cdf0e10cSrcweir fillSeriesListBox(); 454*cdf0e10cSrcweir SeriesSelectionChangedHdl( 0 ); 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir // categories 457*cdf0e10cSrcweir m_aEDT_CATEGORIES.SetText( String( m_rDialogModel.getCategoriesRange() )); 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir updateControlState(); 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir void DataSourceTabPage::fillSeriesListBox() 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir m_apLB_SERIES->SetUpdateMode( sal_False ); 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir Reference< XDataSeries > xSelected; 467*cdf0e10cSrcweir SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); 468*cdf0e10cSrcweir if( pEntry ) 469*cdf0e10cSrcweir xSelected.set( pEntry->m_xDataSeries ); 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir bool bHasSelectedEntry = (pEntry != 0); 472*cdf0e10cSrcweir SvLBoxEntry * pSelectedEntry = 0; 473*cdf0e10cSrcweir m_apLB_SERIES->Clear(); 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir ::std::vector< DialogModel::tSeriesWithChartTypeByName > aSeries( 476*cdf0e10cSrcweir m_rDialogModel.getAllDataSeriesWithLabel() ); 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir sal_Int32 nUnnamedSeriesIndex = 1; 479*cdf0e10cSrcweir for( ::std::vector< DialogModel::tSeriesWithChartTypeByName >::const_iterator aIt = aSeries.begin(); 480*cdf0e10cSrcweir aIt != aSeries.end(); ++aIt ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir String aLabel( (*aIt).first ); 483*cdf0e10cSrcweir if( !aLabel.Len()) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir if( nUnnamedSeriesIndex > 1 ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir OUString aResString( String( ::chart::SchResId( STR_DATA_UNNAMED_SERIES_WITH_INDEX ))); 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir // replace index of unnamed series 490*cdf0e10cSrcweir const OUString aReplacementStr( RTL_CONSTASCII_USTRINGPARAM( "%NUMBER" )); 491*cdf0e10cSrcweir sal_Int32 nIndex = aResString.indexOf( aReplacementStr ); 492*cdf0e10cSrcweir if( nIndex != -1 ) 493*cdf0e10cSrcweir aLabel = String( aResString.replaceAt( 494*cdf0e10cSrcweir nIndex, aReplacementStr.getLength(), 495*cdf0e10cSrcweir String::CreateFromInt32( nUnnamedSeriesIndex ))); 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir if( aLabel.Len() == 0 ) 498*cdf0e10cSrcweir aLabel = String( ::chart::SchResId( STR_DATA_UNNAMED_SERIES )); 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir ++nUnnamedSeriesIndex; 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir pEntry = dynamic_cast< SeriesEntry * >( 503*cdf0e10cSrcweir m_apLB_SERIES->InsertEntry( aLabel )); 504*cdf0e10cSrcweir if( pEntry ) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir pEntry->m_xDataSeries.set( (*aIt).second.first ); 507*cdf0e10cSrcweir pEntry->m_xChartType.set( (*aIt).second.second ); 508*cdf0e10cSrcweir if( bHasSelectedEntry && ((*aIt).second.first == xSelected)) 509*cdf0e10cSrcweir pSelectedEntry = pEntry; 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir if( bHasSelectedEntry && pSelectedEntry ) 514*cdf0e10cSrcweir m_apLB_SERIES->Select( pSelectedEntry ); 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir m_apLB_SERIES->SetUpdateMode( sal_True ); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir void DataSourceTabPage::fillRoleListBox() 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir SeriesEntry * pSeriesEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); 522*cdf0e10cSrcweir bool bHasSelectedEntry = (pSeriesEntry != 0); 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir SvLBoxEntry * pRoleEntry = m_aLB_ROLE.FirstSelected(); 525*cdf0e10cSrcweir sal_uLong nRoleIndex = SAL_MAX_UINT32; 526*cdf0e10cSrcweir if( pRoleEntry ) 527*cdf0e10cSrcweir nRoleIndex = m_aLB_ROLE.GetModel()->GetAbsPos( pRoleEntry ); 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir if( bHasSelectedEntry ) 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir DialogModel::tRolesWithRanges aRoles( 532*cdf0e10cSrcweir m_rDialogModel.getRolesWithRanges( 533*cdf0e10cSrcweir pSeriesEntry->m_xDataSeries, 534*cdf0e10cSrcweir lcl_GetSequenceNameForLabel( pSeriesEntry ), 535*cdf0e10cSrcweir pSeriesEntry->m_xChartType )); 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir // fill role list 538*cdf0e10cSrcweir m_aLB_ROLE.SetUpdateMode( sal_False ); 539*cdf0e10cSrcweir m_aLB_ROLE.Clear(); 540*cdf0e10cSrcweir m_aLB_ROLE.RemoveSelection(); 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir for( DialogModel::tRolesWithRanges::const_iterator aIt( aRoles.begin()); 543*cdf0e10cSrcweir aIt != aRoles.end(); ++ aIt ) 544*cdf0e10cSrcweir { 545*cdf0e10cSrcweir m_aLB_ROLE.InsertEntry( lcl_GetRoleLBEntry( aIt->first, aIt->second )); 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir // series may contain no roles, check listbox size before selecting entries 549*cdf0e10cSrcweir if( m_aLB_ROLE.GetEntryCount() > 0 ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir if( nRoleIndex >= m_aLB_ROLE.GetEntryCount()) 552*cdf0e10cSrcweir nRoleIndex = 0; 553*cdf0e10cSrcweir m_aLB_ROLE.Select( m_aLB_ROLE.GetEntry( nRoleIndex )); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir m_aLB_ROLE.SetUpdateMode( sal_True ); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir void DataSourceTabPage::updateControlState() 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir SvLBoxEntry * pSeriesEntry = m_apLB_SERIES->FirstSelected(); 563*cdf0e10cSrcweir bool bHasSelectedSeries = (pSeriesEntry != 0); 564*cdf0e10cSrcweir bool bHasValidRole = false; 565*cdf0e10cSrcweir bool bHasRangeChooser = m_rDialogModel.getRangeSelectionHelper()->hasRangeSelection(); 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir if( bHasSelectedSeries ) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir SvLBoxEntry * pRoleEntry = m_aLB_ROLE.FirstSelected(); 570*cdf0e10cSrcweir bHasValidRole = (pRoleEntry != 0); 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir m_aBTN_ADD.Enable( true ); 574*cdf0e10cSrcweir m_aBTN_REMOVE.Enable( bHasSelectedSeries ); 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir m_aBTN_UP.Enable( bHasSelectedSeries && (pSeriesEntry != m_apLB_SERIES->First())); 577*cdf0e10cSrcweir m_aBTN_DOWN.Enable( bHasSelectedSeries && (pSeriesEntry != m_apLB_SERIES->Last())); 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir bool bHasCategories = m_rDialogModel.isCategoryDiagram(); 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir m_aFT_DATALABELS.Show(!bHasCategories); 582*cdf0e10cSrcweir m_aFT_CATEGORIES.Show( bHasCategories); 583*cdf0e10cSrcweir sal_Bool bShowIB = bHasRangeChooser; 584*cdf0e10cSrcweir lcl_ShowChooserButton( m_aIMB_RANGE_CAT, m_aEDT_CATEGORIES, bShowIB ); 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir m_aFT_SERIES.Enable(); 587*cdf0e10cSrcweir m_apLB_SERIES->Enable(); 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir m_aFT_ROLE.Enable( bHasSelectedSeries ); 590*cdf0e10cSrcweir m_aLB_ROLE.Enable( bHasSelectedSeries ); 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir m_aFT_RANGE.Enable( bHasValidRole ); 593*cdf0e10cSrcweir m_aEDT_RANGE.Enable( bHasValidRole ); 594*cdf0e10cSrcweir lcl_ShowChooserButton( m_aIMB_RANGE_MAIN, m_aEDT_RANGE, bShowIB ); 595*cdf0e10cSrcweir isValid(); 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir IMPL_LINK( DataSourceTabPage, SeriesSelectionChangedHdl, void *, EMPTYARG ) 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir m_rDialogModel.startControllerLockTimer(); 601*cdf0e10cSrcweir if( m_apLB_SERIES->FirstSelected()) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir fillRoleListBox(); 604*cdf0e10cSrcweir RoleSelectionChangedHdl( 0 ); 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir updateControlState(); 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir return 0; 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir IMPL_LINK( DataSourceTabPage, RoleSelectionChangedHdl, void *, EMPTYARG ) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir m_rDialogModel.startControllerLockTimer(); 614*cdf0e10cSrcweir SvLBoxEntry * pEntry = m_aLB_ROLE.FirstSelected(); 615*cdf0e10cSrcweir if( pEntry ) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir OUString aRange( m_aEDT_RANGE.GetText()); 618*cdf0e10cSrcweir OUString aSelectedRoleUI = lcl_GetSelectedRole( m_aLB_ROLE, true ); 619*cdf0e10cSrcweir OUString aSelectedRange = lcl_GetSelectedRolesRange( m_aLB_ROLE ); 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir // replace role in fixed text label 622*cdf0e10cSrcweir const OUString aReplacementStr( RTL_CONSTASCII_USTRINGPARAM( "%VALUETYPE" )); 623*cdf0e10cSrcweir sal_Int32 nIndex = m_aFixedTextRange.indexOf( aReplacementStr ); 624*cdf0e10cSrcweir if( nIndex != -1 ) 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir m_aFT_RANGE.SetText( 627*cdf0e10cSrcweir String( m_aFixedTextRange.replaceAt( 628*cdf0e10cSrcweir nIndex, aReplacementStr.getLength(), aSelectedRoleUI ))); 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir m_aEDT_RANGE.SetText( String( aSelectedRange )); 632*cdf0e10cSrcweir isValid(); 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir return 0; 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir IMPL_LINK( DataSourceTabPage, MainRangeButtonClickedHdl, void *, EMPTYARG ) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir OSL_ASSERT( m_pCurrentRangeChoosingField == 0 ); 641*cdf0e10cSrcweir m_pCurrentRangeChoosingField = & m_aEDT_RANGE; 642*cdf0e10cSrcweir if( m_aEDT_RANGE.GetText().Len() > 0 && 643*cdf0e10cSrcweir ! updateModelFromControl( m_pCurrentRangeChoosingField )) 644*cdf0e10cSrcweir return 0; 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); 647*cdf0e10cSrcweir bool bHasSelectedEntry = (pEntry != 0); 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir OUString aSelectedRolesRange = lcl_GetSelectedRolesRange( m_aLB_ROLE ); 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir if( bHasSelectedEntry && (m_aLB_ROLE.FirstSelected() != 0)) 652*cdf0e10cSrcweir { 653*cdf0e10cSrcweir String aStr( SchResId( STR_DATA_SELECT_RANGE_FOR_SERIES )); 654*cdf0e10cSrcweir OUString aUIStr( aStr ); 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir // replace role 657*cdf0e10cSrcweir OUString aReplacement( RTL_CONSTASCII_USTRINGPARAM( "%VALUETYPE" )); 658*cdf0e10cSrcweir sal_Int32 nIndex = aUIStr.indexOf( aReplacement ); 659*cdf0e10cSrcweir if( nIndex != -1 ) 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir aUIStr = aUIStr.replaceAt( nIndex, aReplacement.getLength(), 662*cdf0e10cSrcweir lcl_GetSelectedRole( m_aLB_ROLE, true )); 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir // replace series name 665*cdf0e10cSrcweir aReplacement = C2U( "%SERIESNAME" ); 666*cdf0e10cSrcweir nIndex = aUIStr.indexOf( aReplacement ); 667*cdf0e10cSrcweir if( nIndex != -1 ) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir aUIStr = aUIStr.replaceAt( nIndex, aReplacement.getLength(), 670*cdf0e10cSrcweir OUString( m_apLB_SERIES->GetEntryText( pEntry ))); 671*cdf0e10cSrcweir } 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir lcl_enableRangeChoosing( true, m_pParentDialog ); 674*cdf0e10cSrcweir m_rDialogModel.getRangeSelectionHelper()->chooseRange( aSelectedRolesRange, aUIStr, *this ); 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir else 677*cdf0e10cSrcweir m_pCurrentRangeChoosingField = 0; 678*cdf0e10cSrcweir 679*cdf0e10cSrcweir return 0; 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir IMPL_LINK( DataSourceTabPage, CategoriesRangeButtonClickedHdl, void *, EMPTYARG ) 683*cdf0e10cSrcweir { 684*cdf0e10cSrcweir OSL_ASSERT( m_pCurrentRangeChoosingField == 0 ); 685*cdf0e10cSrcweir m_pCurrentRangeChoosingField = & m_aEDT_CATEGORIES; 686*cdf0e10cSrcweir if( m_aEDT_CATEGORIES.GetText().Len() > 0 && 687*cdf0e10cSrcweir ! updateModelFromControl( m_pCurrentRangeChoosingField )) 688*cdf0e10cSrcweir return 0; 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir String aStr( SchResId( m_aFT_CATEGORIES.IsVisible() ? STR_DATA_SELECT_RANGE_FOR_CATEGORIES : STR_DATA_SELECT_RANGE_FOR_DATALABELS )); 691*cdf0e10cSrcweir lcl_enableRangeChoosing( true, m_pParentDialog ); 692*cdf0e10cSrcweir m_rDialogModel.getRangeSelectionHelper()->chooseRange( 693*cdf0e10cSrcweir m_rDialogModel.getCategoriesRange(), OUString( aStr ), *this ); 694*cdf0e10cSrcweir return 0; 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir IMPL_LINK( DataSourceTabPage, AddButtonClickedHdl, void *, EMPTYARG ) 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir m_rDialogModel.startControllerLockTimer(); 700*cdf0e10cSrcweir SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); 701*cdf0e10cSrcweir Reference< XDataSeries > xSeriesToInsertAfter; 702*cdf0e10cSrcweir Reference< XChartType > xChartTypeForNewSeries; 703*cdf0e10cSrcweir if( m_pTemplateProvider ) 704*cdf0e10cSrcweir m_rDialogModel.setTemplate( m_pTemplateProvider->getCurrentTemplate()); 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir if( pEntry ) 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir xSeriesToInsertAfter.set( pEntry->m_xDataSeries ); 709*cdf0e10cSrcweir xChartTypeForNewSeries.set( pEntry->m_xChartType ); 710*cdf0e10cSrcweir } 711*cdf0e10cSrcweir else 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir ::std::vector< Reference< XDataSeriesContainer > > aCntVec( 714*cdf0e10cSrcweir m_rDialogModel.getAllDataSeriesContainers()); 715*cdf0e10cSrcweir if( ! aCntVec.empty()) 716*cdf0e10cSrcweir xChartTypeForNewSeries.set( aCntVec.front(), uno::UNO_QUERY ); 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir OSL_ENSURE( xChartTypeForNewSeries.is(), "Cannot insert new series" ); 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir m_rDialogModel.insertSeriesAfter( xSeriesToInsertAfter, xChartTypeForNewSeries ); 721*cdf0e10cSrcweir setDirty(); 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir fillSeriesListBox(); 724*cdf0e10cSrcweir // note the box was cleared and refilled, so pEntry is invalid now 725*cdf0e10cSrcweir SvLBoxEntry * pSelEntry = m_apLB_SERIES->FirstSelected(); 726*cdf0e10cSrcweir if( pSelEntry ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir SvLBoxEntry * pNextEntry = m_apLB_SERIES->Next( pSelEntry ); 729*cdf0e10cSrcweir if( pNextEntry ) 730*cdf0e10cSrcweir m_apLB_SERIES->Select( pNextEntry ); 731*cdf0e10cSrcweir } 732*cdf0e10cSrcweir SeriesSelectionChangedHdl( 0 ); 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir return 0; 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir 737*cdf0e10cSrcweir IMPL_LINK( DataSourceTabPage, RemoveButtonClickedHdl, void *, EMPTYARG ) 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir m_rDialogModel.startControllerLockTimer(); 740*cdf0e10cSrcweir SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); 741*cdf0e10cSrcweir if( pEntry ) 742*cdf0e10cSrcweir { 743*cdf0e10cSrcweir Reference< XDataSeries > xNewSelSeries; 744*cdf0e10cSrcweir SeriesEntry * pNewSelEntry = dynamic_cast< SeriesEntry * >( 745*cdf0e10cSrcweir m_apLB_SERIES->Next( pEntry )); 746*cdf0e10cSrcweir if( pNewSelEntry ) 747*cdf0e10cSrcweir xNewSelSeries.set( pNewSelEntry->m_xDataSeries ); 748*cdf0e10cSrcweir else 749*cdf0e10cSrcweir { 750*cdf0e10cSrcweir pNewSelEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->Prev( pEntry )); 751*cdf0e10cSrcweir if( pNewSelEntry ) 752*cdf0e10cSrcweir xNewSelSeries.set( pNewSelEntry->m_xDataSeries ); 753*cdf0e10cSrcweir } 754*cdf0e10cSrcweir 755*cdf0e10cSrcweir m_rDialogModel.deleteSeries( pEntry->m_xDataSeries, pEntry->m_xChartType ); 756*cdf0e10cSrcweir setDirty(); 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir m_apLB_SERIES->RemoveSelection(); 759*cdf0e10cSrcweir fillSeriesListBox(); 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir // select previous or next series 762*cdf0e10cSrcweir //@improve: see methods GetModel()->GetAbsPos()/GetEntry() for absoulte list positions 763*cdf0e10cSrcweir if( xNewSelSeries.is()) 764*cdf0e10cSrcweir { 765*cdf0e10cSrcweir pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->First()); 766*cdf0e10cSrcweir while( pEntry ) 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir if( pEntry->m_xDataSeries == xNewSelSeries ) 769*cdf0e10cSrcweir { 770*cdf0e10cSrcweir m_apLB_SERIES->Select( pEntry ); 771*cdf0e10cSrcweir break; 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->Next( pEntry )); 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir } 776*cdf0e10cSrcweir SeriesSelectionChangedHdl( 0 ); 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir return 0; 780*cdf0e10cSrcweir } 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir IMPL_LINK( DataSourceTabPage, UpButtonClickedHdl, void *, EMPTYARG ) 783*cdf0e10cSrcweir { 784*cdf0e10cSrcweir m_rDialogModel.startControllerLockTimer(); 785*cdf0e10cSrcweir SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); 786*cdf0e10cSrcweir bool bHasSelectedEntry = (pEntry != 0); 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir if( bHasSelectedEntry ) 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir m_rDialogModel.moveSeries( pEntry->m_xDataSeries, DialogModel::MOVE_UP ); 791*cdf0e10cSrcweir setDirty(); 792*cdf0e10cSrcweir fillSeriesListBox(); 793*cdf0e10cSrcweir SeriesSelectionChangedHdl(0); 794*cdf0e10cSrcweir } 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir return 0; 797*cdf0e10cSrcweir } 798*cdf0e10cSrcweir 799*cdf0e10cSrcweir IMPL_LINK( DataSourceTabPage, DownButtonClickedHdl, void *, EMPTYARG ) 800*cdf0e10cSrcweir { 801*cdf0e10cSrcweir m_rDialogModel.startControllerLockTimer(); 802*cdf0e10cSrcweir SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); 803*cdf0e10cSrcweir bool bHasSelectedEntry = (pEntry != 0); 804*cdf0e10cSrcweir 805*cdf0e10cSrcweir if( bHasSelectedEntry ) 806*cdf0e10cSrcweir { 807*cdf0e10cSrcweir m_rDialogModel.moveSeries( pEntry->m_xDataSeries, DialogModel::MOVE_DOWN ); 808*cdf0e10cSrcweir setDirty(); 809*cdf0e10cSrcweir fillSeriesListBox(); 810*cdf0e10cSrcweir SeriesSelectionChangedHdl(0); 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir return 0; 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir IMPL_LINK( DataSourceTabPage, RangeModifiedHdl, Edit*, pEdit ) 817*cdf0e10cSrcweir { 818*cdf0e10cSrcweir if( isRangeFieldContentValid( *pEdit )) 819*cdf0e10cSrcweir setDirty(); 820*cdf0e10cSrcweir 821*cdf0e10cSrcweir // enable/disable OK button 822*cdf0e10cSrcweir isValid(); 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir return 0; 825*cdf0e10cSrcweir } 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir IMPL_LINK( DataSourceTabPage, RangeUpdateDataHdl, Edit*, pEdit ) 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir // note: isValid sets the color of the edit field 830*cdf0e10cSrcweir if( isRangeFieldContentValid( *pEdit )) 831*cdf0e10cSrcweir { 832*cdf0e10cSrcweir setDirty(); 833*cdf0e10cSrcweir updateModelFromControl( pEdit ); 834*cdf0e10cSrcweir if( pEdit== &m_aEDT_RANGE ) 835*cdf0e10cSrcweir { 836*cdf0e10cSrcweir if( ! lcl_UpdateCurrentSeriesName( *m_apLB_SERIES )) 837*cdf0e10cSrcweir fillSeriesListBox(); 838*cdf0e10cSrcweir } 839*cdf0e10cSrcweir } 840*cdf0e10cSrcweir // enable/disable OK button 841*cdf0e10cSrcweir isValid(); 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir return 0; 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir void DataSourceTabPage::listeningFinished( 847*cdf0e10cSrcweir const ::rtl::OUString & rNewRange ) 848*cdf0e10cSrcweir { 849*cdf0e10cSrcweir // rNewRange becomes invalid after removing the listener 850*cdf0e10cSrcweir OUString aRange( rNewRange ); 851*cdf0e10cSrcweir 852*cdf0e10cSrcweir m_rDialogModel.startControllerLockTimer(); 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir // stop listening 855*cdf0e10cSrcweir m_rDialogModel.getRangeSelectionHelper()->stopRangeListening(); 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir // change edit field 858*cdf0e10cSrcweir ToTop(); 859*cdf0e10cSrcweir GrabFocus(); 860*cdf0e10cSrcweir if( m_pCurrentRangeChoosingField ) 861*cdf0e10cSrcweir { 862*cdf0e10cSrcweir m_pCurrentRangeChoosingField->SetText( String( aRange )); 863*cdf0e10cSrcweir m_pCurrentRangeChoosingField->GrabFocus(); 864*cdf0e10cSrcweir } 865*cdf0e10cSrcweir 866*cdf0e10cSrcweir if( m_pCurrentRangeChoosingField == & m_aEDT_RANGE ) 867*cdf0e10cSrcweir { 868*cdf0e10cSrcweir m_aEDT_RANGE.SetText( String( aRange )); 869*cdf0e10cSrcweir setDirty(); 870*cdf0e10cSrcweir } 871*cdf0e10cSrcweir else if( m_pCurrentRangeChoosingField == & m_aEDT_CATEGORIES ) 872*cdf0e10cSrcweir { 873*cdf0e10cSrcweir m_aEDT_CATEGORIES.SetText( String( aRange )); 874*cdf0e10cSrcweir setDirty(); 875*cdf0e10cSrcweir } 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir updateModelFromControl( m_pCurrentRangeChoosingField ); 878*cdf0e10cSrcweir if( ! lcl_UpdateCurrentSeriesName( *m_apLB_SERIES )) 879*cdf0e10cSrcweir fillSeriesListBox(); 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir m_pCurrentRangeChoosingField = 0; 882*cdf0e10cSrcweir 883*cdf0e10cSrcweir updateControlState(); 884*cdf0e10cSrcweir lcl_enableRangeChoosing( false, m_pParentDialog ); 885*cdf0e10cSrcweir } 886*cdf0e10cSrcweir 887*cdf0e10cSrcweir void DataSourceTabPage::disposingRangeSelection() 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir m_rDialogModel.getRangeSelectionHelper()->stopRangeListening( false ); 890*cdf0e10cSrcweir } 891*cdf0e10cSrcweir 892*cdf0e10cSrcweir bool DataSourceTabPage::updateModelFromControl( Edit * pField ) 893*cdf0e10cSrcweir { 894*cdf0e10cSrcweir if( !m_bIsDirty ) 895*cdf0e10cSrcweir return true; 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir ControllerLockGuard aLockedControllers( m_rDialogModel.getChartModel() ); 898*cdf0e10cSrcweir 899*cdf0e10cSrcweir // @todo: validity check of field content 900*cdf0e10cSrcweir bool bResult = true; 901*cdf0e10cSrcweir bool bAll = (pField == 0); 902*cdf0e10cSrcweir Reference< data::XDataProvider > xDataProvider( m_rDialogModel.getDataProvider()); 903*cdf0e10cSrcweir 904*cdf0e10cSrcweir if( bAll || (pField == & m_aEDT_CATEGORIES) ) 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir Reference< data::XLabeledDataSequence > xLabeledSeq( m_rDialogModel.getCategories() ); 907*cdf0e10cSrcweir if( xDataProvider.is()) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir OUString aRange( m_aEDT_CATEGORIES.GetText()); 910*cdf0e10cSrcweir if( aRange.getLength()) 911*cdf0e10cSrcweir { 912*cdf0e10cSrcweir // create or change categories 913*cdf0e10cSrcweir if( !xLabeledSeq.is()) 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir xLabeledSeq.set( DataSourceHelper::createLabeledDataSequence( Reference< uno::XComponentContext >(0))); 916*cdf0e10cSrcweir m_rDialogModel.setCategories( xLabeledSeq ); 917*cdf0e10cSrcweir } 918*cdf0e10cSrcweir try 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir xLabeledSeq->setValues( xDataProvider->createDataSequenceByRangeRepresentation( aRange )); 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir catch( const uno::Exception & ex ) 923*cdf0e10cSrcweir { 924*cdf0e10cSrcweir // should work as validation should have happened before 925*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir } 928*cdf0e10cSrcweir else if( xLabeledSeq.is()) 929*cdf0e10cSrcweir { 930*cdf0e10cSrcweir // clear existing categories 931*cdf0e10cSrcweir xLabeledSeq.set(0); 932*cdf0e10cSrcweir m_rDialogModel.setCategories( xLabeledSeq ); 933*cdf0e10cSrcweir } 934*cdf0e10cSrcweir } 935*cdf0e10cSrcweir } 936*cdf0e10cSrcweir 937*cdf0e10cSrcweir SeriesEntry * pSeriesEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); 938*cdf0e10cSrcweir bool bHasSelectedEntry = (pSeriesEntry != 0); 939*cdf0e10cSrcweir 940*cdf0e10cSrcweir if( bHasSelectedEntry ) 941*cdf0e10cSrcweir { 942*cdf0e10cSrcweir if( bAll || (pField == & m_aEDT_RANGE) ) 943*cdf0e10cSrcweir { 944*cdf0e10cSrcweir try 945*cdf0e10cSrcweir { 946*cdf0e10cSrcweir OUString aSelectedRole = lcl_GetSelectedRole( m_aLB_ROLE ); 947*cdf0e10cSrcweir OUString aRange( m_aEDT_RANGE.GetText()); 948*cdf0e10cSrcweir OUString aSequenceRole( aSelectedRole ); 949*cdf0e10cSrcweir bool bIsLabel = aSequenceRole.equals( lcl_aLabelRole ); 950*cdf0e10cSrcweir OUString aSequenceNameForLabel( lcl_GetSequenceNameForLabel( pSeriesEntry )); 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir if( bIsLabel ) 953*cdf0e10cSrcweir aSequenceRole = aSequenceNameForLabel; 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir Reference< data::XDataSource > xSource( pSeriesEntry->m_xDataSeries, uno::UNO_QUERY_THROW ); 956*cdf0e10cSrcweir Reference< data::XLabeledDataSequence > xLabeledSeq( 957*cdf0e10cSrcweir DataSeriesHelper::getDataSequenceByRole( xSource, aSequenceRole )); 958*cdf0e10cSrcweir 959*cdf0e10cSrcweir if( xDataProvider.is()) 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir if( bIsLabel ) 962*cdf0e10cSrcweir { 963*cdf0e10cSrcweir if( ! xLabeledSeq.is()) 964*cdf0e10cSrcweir { 965*cdf0e10cSrcweir // check if there is already an "orphan" label sequence 966*cdf0e10cSrcweir xLabeledSeq.set( lcl_findLSequenceWithOnlyLabel( xSource )); 967*cdf0e10cSrcweir if( ! xLabeledSeq.is()) 968*cdf0e10cSrcweir { 969*cdf0e10cSrcweir // no corresponding labeled data sequence for label found 970*cdf0e10cSrcweir xLabeledSeq.set( DataSourceHelper::createLabeledDataSequence( Reference< uno::XComponentContext >(0))); 971*cdf0e10cSrcweir lcl_addLSequenceToDataSource( xLabeledSeq, xSource ); 972*cdf0e10cSrcweir } 973*cdf0e10cSrcweir } 974*cdf0e10cSrcweir if( xLabeledSeq.is()) 975*cdf0e10cSrcweir { 976*cdf0e10cSrcweir if( aRange.getLength()) 977*cdf0e10cSrcweir { 978*cdf0e10cSrcweir Reference< data::XDataSequence > xNewSeq; 979*cdf0e10cSrcweir try 980*cdf0e10cSrcweir { 981*cdf0e10cSrcweir xNewSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( aRange )); 982*cdf0e10cSrcweir } 983*cdf0e10cSrcweir catch( const uno::Exception & ex ) 984*cdf0e10cSrcweir { 985*cdf0e10cSrcweir // should work as validation should have happened before 986*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 987*cdf0e10cSrcweir } 988*cdf0e10cSrcweir if( xNewSeq.is()) 989*cdf0e10cSrcweir { 990*cdf0e10cSrcweir // update range name by the full string provided 991*cdf0e10cSrcweir // by the data provider. E.g. "a1" might become 992*cdf0e10cSrcweir // "$Sheet1.$A$1" 993*cdf0e10cSrcweir aRange = xNewSeq->getSourceRangeRepresentation(); 994*cdf0e10cSrcweir Reference< beans::XPropertySet > xProp( xNewSeq, uno::UNO_QUERY_THROW ); 995*cdf0e10cSrcweir xProp->setPropertyValue( C2U("Role"), uno::makeAny( lcl_aLabelRole )); 996*cdf0e10cSrcweir xLabeledSeq->setLabel( xNewSeq ); 997*cdf0e10cSrcweir } 998*cdf0e10cSrcweir } 999*cdf0e10cSrcweir else 1000*cdf0e10cSrcweir { 1001*cdf0e10cSrcweir xLabeledSeq->setLabel( Reference< data::XDataSequence >()); 1002*cdf0e10cSrcweir } 1003*cdf0e10cSrcweir } 1004*cdf0e10cSrcweir } 1005*cdf0e10cSrcweir else 1006*cdf0e10cSrcweir { 1007*cdf0e10cSrcweir if( aRange.getLength()) 1008*cdf0e10cSrcweir { 1009*cdf0e10cSrcweir Reference< data::XDataSequence > xNewSeq; 1010*cdf0e10cSrcweir try 1011*cdf0e10cSrcweir { 1012*cdf0e10cSrcweir xNewSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( aRange )); 1013*cdf0e10cSrcweir } 1014*cdf0e10cSrcweir catch( const uno::Exception & ex ) 1015*cdf0e10cSrcweir { 1016*cdf0e10cSrcweir // should work as validation should have happened before 1017*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 1018*cdf0e10cSrcweir } 1019*cdf0e10cSrcweir if( xNewSeq.is()) 1020*cdf0e10cSrcweir { 1021*cdf0e10cSrcweir // update range name by the full string provided 1022*cdf0e10cSrcweir // by the data provider. E.g. "a1:e1" might become 1023*cdf0e10cSrcweir // "$Sheet1.$A$1:$E$1" 1024*cdf0e10cSrcweir aRange = xNewSeq->getSourceRangeRepresentation(); 1025*cdf0e10cSrcweir 1026*cdf0e10cSrcweir Reference< beans::XPropertySet > xProp( xNewSeq, uno::UNO_QUERY_THROW ); 1027*cdf0e10cSrcweir xProp->setPropertyValue( C2U("Role"), uno::makeAny( aSelectedRole )); 1028*cdf0e10cSrcweir if( !xLabeledSeq.is()) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir if( aSelectedRole.equals( aSequenceNameForLabel )) 1031*cdf0e10cSrcweir xLabeledSeq.set( lcl_findLSequenceWithOnlyLabel( xSource )); 1032*cdf0e10cSrcweir if( ! xLabeledSeq.is()) 1033*cdf0e10cSrcweir { 1034*cdf0e10cSrcweir xLabeledSeq.set( DataSourceHelper::createLabeledDataSequence( Reference< uno::XComponentContext >(0))); 1035*cdf0e10cSrcweir lcl_addLSequenceToDataSource( xLabeledSeq, xSource ); 1036*cdf0e10cSrcweir } 1037*cdf0e10cSrcweir } 1038*cdf0e10cSrcweir xLabeledSeq->setValues( xNewSeq ); 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir } 1041*cdf0e10cSrcweir else if( xLabeledSeq.is()) 1042*cdf0e10cSrcweir { 1043*cdf0e10cSrcweir // values cannot be deleted. This would also delete the Role (for labels) 1044*cdf0e10cSrcweir // xLabeledSeq->setValues( Reference< data::XDataSequence >()); 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir } 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir lcl_UpdateCurrentRange( m_aLB_ROLE, aSelectedRole, aRange ); 1050*cdf0e10cSrcweir } 1051*cdf0e10cSrcweir catch( uno::Exception & ex ) 1052*cdf0e10cSrcweir { 1053*cdf0e10cSrcweir bResult = false; 1054*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 1055*cdf0e10cSrcweir } 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir } 1058*cdf0e10cSrcweir 1059*cdf0e10cSrcweir // update View 1060*cdf0e10cSrcweir // @todo remove this when automatic view updates from calc, writer and own data sequences are available 1061*cdf0e10cSrcweir if( bResult ) 1062*cdf0e10cSrcweir { 1063*cdf0e10cSrcweir try 1064*cdf0e10cSrcweir { 1065*cdf0e10cSrcweir Reference< util::XModifiable > xModifiable( m_rDialogModel.getChartModel(), uno::UNO_QUERY ); 1066*cdf0e10cSrcweir if( xModifiable.is() ) 1067*cdf0e10cSrcweir xModifiable->setModified( sal_True ); 1068*cdf0e10cSrcweir } 1069*cdf0e10cSrcweir catch( uno::Exception & ex ) 1070*cdf0e10cSrcweir { 1071*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 1072*cdf0e10cSrcweir } 1073*cdf0e10cSrcweir } 1074*cdf0e10cSrcweir 1075*cdf0e10cSrcweir return bResult; 1076*cdf0e10cSrcweir } 1077*cdf0e10cSrcweir 1078*cdf0e10cSrcweir } // namespace chart 1079