1cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5cde9e8dcSAndrew Rist  * distributed with this work for additional information
6cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cde9e8dcSAndrew Rist  *
11cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cde9e8dcSAndrew Rist  *
13cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18cde9e8dcSAndrew Rist  * under the License.
19cde9e8dcSAndrew Rist  *
20cde9e8dcSAndrew Rist  *************************************************************/
21cde9e8dcSAndrew Rist 
22cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "tp_RangeChooser.hxx"
28cdf0e10cSrcweir #include "tp_RangeChooser.hrc"
29cdf0e10cSrcweir #include "Strings.hrc"
30cdf0e10cSrcweir #include "ResId.hxx"
31cdf0e10cSrcweir #include "macros.hxx"
32cdf0e10cSrcweir #include "NoWarningThisInCTOR.hxx"
33cdf0e10cSrcweir #include "DataSourceHelper.hxx"
34cdf0e10cSrcweir #include "DiagramHelper.hxx"
35cdf0e10cSrcweir #include "ChartTypeTemplateProvider.hxx"
36cdf0e10cSrcweir #include "DialogModel.hxx"
37cdf0e10cSrcweir #include "RangeSelectionHelper.hxx"
38cdf0e10cSrcweir #include <com/sun/star/awt/XTopWindow.hpp>
39cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp>
40cdf0e10cSrcweir #include <com/sun/star/embed/XComponentSupplier.hpp>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace
43cdf0e10cSrcweir {
lcl_ShowChooserButton(::chart::RangeSelectionButton & rChooserButton,Edit & rEditField,sal_Bool bShow)44cdf0e10cSrcweir void lcl_ShowChooserButton(
45cdf0e10cSrcweir     ::chart::RangeSelectionButton & rChooserButton,
46cdf0e10cSrcweir     Edit & rEditField,
47cdf0e10cSrcweir     sal_Bool bShow )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir     if( rChooserButton.IsVisible() != bShow )
50cdf0e10cSrcweir     {
51cdf0e10cSrcweir         rChooserButton.Show( bShow );
52cdf0e10cSrcweir         sal_Int32 nWidhtDiff = 10 + 2;
53cdf0e10cSrcweir         if( bShow )
54cdf0e10cSrcweir             nWidhtDiff = -nWidhtDiff;
55cdf0e10cSrcweir         Size aSize = rChooserButton.PixelToLogic( rEditField.GetSizePixel(), MAP_APPFONT );
56cdf0e10cSrcweir         aSize.setWidth( aSize.getWidth() + nWidhtDiff );
57cdf0e10cSrcweir         rEditField.SetSizePixel( rChooserButton.LogicToPixel( aSize, MAP_APPFONT ));
58cdf0e10cSrcweir     }
59cdf0e10cSrcweir }
lcl_enableRangeChoosing(bool bEnable,Dialog * pDialog)60cdf0e10cSrcweir void lcl_enableRangeChoosing( bool bEnable, Dialog * pDialog )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     if( pDialog )
63cdf0e10cSrcweir     {
64cdf0e10cSrcweir         pDialog->Show( bEnable ? sal_False : sal_True );
65cdf0e10cSrcweir         pDialog->SetModalInputMode( bEnable ? sal_False : sal_True );
66cdf0e10cSrcweir     }
67cdf0e10cSrcweir }
lcl_shiftControlY(Control & rControl,long nYOffset)68cdf0e10cSrcweir void lcl_shiftControlY( Control & rControl, long nYOffset )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir     Point aPos( rControl.GetPosPixel());
71cdf0e10cSrcweir     aPos.setY( aPos.getY() + nYOffset );
72cdf0e10cSrcweir     rControl.SetPosPixel( aPos );
73cdf0e10cSrcweir }
74cdf0e10cSrcweir } // anonymous namespace
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //.............................................................................
77cdf0e10cSrcweir namespace chart
78cdf0e10cSrcweir {
79cdf0e10cSrcweir //.............................................................................
80cdf0e10cSrcweir using namespace ::com::sun::star;
81cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
84cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 
RangeChooserTabPage(Window * pParent,DialogModel & rDialogModel,ChartTypeTemplateProvider * pTemplateProvider,Dialog * pParentDialog,bool bHideDescription)87cdf0e10cSrcweir RangeChooserTabPage::RangeChooserTabPage( Window* pParent
88cdf0e10cSrcweir         , DialogModel & rDialogModel
89cdf0e10cSrcweir         , ChartTypeTemplateProvider* pTemplateProvider
90cdf0e10cSrcweir         , Dialog * pParentDialog
91cdf0e10cSrcweir         , bool bHideDescription /* = false */ )
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         : OWizardPage( pParent, SchResId(TP_RANGECHOOSER) )
94cdf0e10cSrcweir 
95cdf0e10cSrcweir         , m_aFT_Caption( this, SchResId( FT_CAPTION_FOR_WIZARD ) )
96cdf0e10cSrcweir         , m_aFT_Range( this, SchResId( FT_RANGE ) )
97cdf0e10cSrcweir         , m_aED_Range( this, SchResId( ED_RANGE ) )
98cdf0e10cSrcweir         , m_aIB_Range( this, SchResId( IB_RANGE ) )
99cdf0e10cSrcweir         , m_aRB_Rows( this, SchResId( RB_DATAROWS ) )
100cdf0e10cSrcweir         , m_aRB_Columns( this, SchResId( RB_DATACOLS ) )
101cdf0e10cSrcweir         , m_aCB_FirstRowAsLabel( this, SchResId( CB_FIRST_ROW_ASLABELS ) )
102cdf0e10cSrcweir         , m_aCB_FirstColumnAsLabel( this, SchResId( CB_FIRST_COLUMN_ASLABELS ) )
103cdf0e10cSrcweir         , m_nChangingControlCalls(0)
104cdf0e10cSrcweir         , m_bIsDirty(false)
105cdf0e10cSrcweir         , m_xDataProvider( 0 )
106cdf0e10cSrcweir         , m_aLastValidRangeString()
107cdf0e10cSrcweir         , m_xCurrentChartTypeTemplate(0)
108cdf0e10cSrcweir         , m_pTemplateProvider(pTemplateProvider)
109cdf0e10cSrcweir         , m_rDialogModel( rDialogModel )
110cdf0e10cSrcweir         , m_pParentDialog( pParentDialog )
111cdf0e10cSrcweir         , m_pTabPageNotifiable( dynamic_cast< TabPageNotifiable * >( pParentDialog ))
112cdf0e10cSrcweir {
113cdf0e10cSrcweir     FreeResource();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     if( bHideDescription )
116cdf0e10cSrcweir     {
117cdf0e10cSrcweir         // note: the offset should be a negative value for shifting upwards, the
118cdf0e10cSrcweir         // 4 is for the offset difference between a wizard page and a tab-page
119cdf0e10cSrcweir         long nYOffset = - ( m_aFT_Range.GetPosPixel().getY() - m_aFT_Caption.GetPosPixel().getY() + 4 );
120cdf0e10cSrcweir         m_aFT_Caption.Hide();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         // shift all controls by the offset space saved by hiding the caption
123cdf0e10cSrcweir         lcl_shiftControlY( m_aFT_Range, nYOffset );
124cdf0e10cSrcweir         lcl_shiftControlY( m_aED_Range, nYOffset );
125cdf0e10cSrcweir         lcl_shiftControlY( m_aIB_Range, nYOffset );
126cdf0e10cSrcweir         lcl_shiftControlY( m_aRB_Rows, nYOffset );
127cdf0e10cSrcweir         lcl_shiftControlY( m_aRB_Columns, nYOffset );
128cdf0e10cSrcweir         lcl_shiftControlY( m_aCB_FirstRowAsLabel, nYOffset );
129cdf0e10cSrcweir         lcl_shiftControlY( m_aCB_FirstColumnAsLabel, nYOffset );
130cdf0e10cSrcweir     }
131cdf0e10cSrcweir     else
132cdf0e10cSrcweir     {
133cdf0e10cSrcweir         // make font of caption bold
134cdf0e10cSrcweir         Font aFont( m_aFT_Caption.GetControlFont() );
135cdf0e10cSrcweir         aFont.SetWeight( WEIGHT_BOLD );
136cdf0e10cSrcweir         m_aFT_Caption.SetControlFont( aFont );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         // no mnemonic
139cdf0e10cSrcweir         m_aFT_Caption.SetStyle( m_aFT_Caption.GetStyle() | WB_NOLABEL );
140cdf0e10cSrcweir     }
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     this->SetText( String(SchResId(STR_PAGE_DATA_RANGE)) );
143cdf0e10cSrcweir     m_aIB_Range.SetQuickHelpText( String(SchResId(STR_TIP_SELECT_RANGE)) );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     // set defaults as long as DetectArguments does not work
146cdf0e10cSrcweir     m_aRB_Columns.Check();
147cdf0e10cSrcweir     m_aCB_FirstColumnAsLabel.Check();
148cdf0e10cSrcweir     m_aCB_FirstRowAsLabel.Check();
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     // BM: Note, that the range selection is not available, if there is no view.
151cdf0e10cSrcweir     // This happens for charts having their own embedded spreadsheet.  If you
152cdf0e10cSrcweir     // force to get the range selection here, this would mean when entering this
153cdf0e10cSrcweir     // page the calc view would be created in this case.  So, I enable the
154cdf0e10cSrcweir     // button here, and in the worst case nothing happens when it is pressed.
155cdf0e10cSrcweir     // Not nice, but I see no better solution for the moment.
156cdf0e10cSrcweir     m_aIB_Range.SetClickHdl( LINK( this, RangeChooserTabPage, ChooseRangeHdl ));
157cdf0e10cSrcweir     m_aED_Range.SetKeyInputHdl( LINK( this, RangeChooserTabPage, ChooseRangeHdl ));
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     // #i75179# enable setting the background to a different color
160cdf0e10cSrcweir     m_aED_Range.SetStyle( m_aED_Range.GetStyle() | WB_FORCECTRLBACKGROUND );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     m_aED_Range.SetUpdateDataHdl( LINK( this, RangeChooserTabPage, ControlChangedHdl ));
163cdf0e10cSrcweir     m_aED_Range.SetModifyHdl( LINK( this, RangeChooserTabPage, ControlEditedHdl ));
164cdf0e10cSrcweir     m_aRB_Rows.SetToggleHdl( LINK( this, RangeChooserTabPage, ControlChangedHdl ) );
165cdf0e10cSrcweir     m_aCB_FirstRowAsLabel.SetToggleHdl( LINK( this, RangeChooserTabPage, ControlChangedHdl ) );
166cdf0e10cSrcweir     m_aCB_FirstColumnAsLabel.SetToggleHdl( LINK( this, RangeChooserTabPage, ControlChangedHdl ) );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
~RangeChooserTabPage()169cdf0e10cSrcweir RangeChooserTabPage::~RangeChooserTabPage()
170cdf0e10cSrcweir {
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
ActivatePage()173cdf0e10cSrcweir void RangeChooserTabPage::ActivatePage()
174cdf0e10cSrcweir {
175cdf0e10cSrcweir     OWizardPage::ActivatePage();
176cdf0e10cSrcweir     initControlsFromModel();
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
initControlsFromModel()179cdf0e10cSrcweir void RangeChooserTabPage::initControlsFromModel()
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     m_nChangingControlCalls++;
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     if(m_pTemplateProvider)
184cdf0e10cSrcweir     {
185cdf0e10cSrcweir         m_xCurrentChartTypeTemplate = m_pTemplateProvider->getCurrentTemplate();
186cdf0e10cSrcweir     }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     bool bUseColumns = ! m_aRB_Rows.IsChecked();
189cdf0e10cSrcweir     bool bFirstCellAsLabel = bUseColumns ? m_aCB_FirstRowAsLabel.IsChecked() : m_aCB_FirstColumnAsLabel.IsChecked();
190cdf0e10cSrcweir     bool bHasCategories = bUseColumns ? m_aCB_FirstColumnAsLabel.IsChecked() : m_aCB_FirstRowAsLabel.IsChecked();
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     bool bIsValid = m_rDialogModel.allArgumentsForRectRangeDetected();
193cdf0e10cSrcweir     if( bIsValid )
194cdf0e10cSrcweir         m_rDialogModel.detectArguments(
195cdf0e10cSrcweir             m_aLastValidRangeString, bUseColumns, bFirstCellAsLabel, bHasCategories );
196cdf0e10cSrcweir     else
197cdf0e10cSrcweir         m_aLastValidRangeString = String::EmptyString();
198cdf0e10cSrcweir 
199cdf0e10cSrcweir     m_aED_Range.SetText( m_aLastValidRangeString );
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     m_aRB_Rows.Check( !bUseColumns );
202cdf0e10cSrcweir     m_aRB_Columns.Check(  bUseColumns );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     m_aCB_FirstRowAsLabel.Check( m_aRB_Rows.IsChecked()?bHasCategories:bFirstCellAsLabel  );
205cdf0e10cSrcweir     m_aCB_FirstColumnAsLabel.Check( m_aRB_Columns.IsChecked()?bHasCategories:bFirstCellAsLabel  );
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     isValid();
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     m_nChangingControlCalls--;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
DeactivatePage()212cdf0e10cSrcweir void RangeChooserTabPage::DeactivatePage()
213cdf0e10cSrcweir {
214cdf0e10cSrcweir     commitPage();
215cdf0e10cSrcweir     svt::OWizardPage::DeactivatePage();
216cdf0e10cSrcweir }
217cdf0e10cSrcweir 
commitPage()218cdf0e10cSrcweir void RangeChooserTabPage::commitPage()
219cdf0e10cSrcweir {
220cdf0e10cSrcweir     commitPage(::svt::WizardTypes::eFinish);
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
commitPage(::svt::WizardTypes::CommitPageReason)223cdf0e10cSrcweir sal_Bool RangeChooserTabPage::commitPage( ::svt::WizardTypes::CommitPageReason /*eReason*/ )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir     //ranges may have been edited in the meanwhile (dirty is true in that case here)
226cdf0e10cSrcweir     if( isValid() )
227cdf0e10cSrcweir     {
228cdf0e10cSrcweir         changeDialogModelAccordingToControls();
229cdf0e10cSrcweir         return sal_True;//return false if this page should not be left
230cdf0e10cSrcweir     }
231cdf0e10cSrcweir     else
232cdf0e10cSrcweir         return sal_False;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
changeDialogModelAccordingToControls()235cdf0e10cSrcweir void RangeChooserTabPage::changeDialogModelAccordingToControls()
236cdf0e10cSrcweir {
237cdf0e10cSrcweir     if(m_nChangingControlCalls>0)
238cdf0e10cSrcweir         return;
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     if( !m_xCurrentChartTypeTemplate.is() )
241cdf0e10cSrcweir     {
242cdf0e10cSrcweir         if(m_pTemplateProvider)
243cdf0e10cSrcweir             m_xCurrentChartTypeTemplate.set( m_pTemplateProvider->getCurrentTemplate());
244cdf0e10cSrcweir         if( !m_xCurrentChartTypeTemplate.is())
245cdf0e10cSrcweir         {
246cdf0e10cSrcweir             OSL_ENSURE( false, "Need a template to change data source" );
247cdf0e10cSrcweir             return;
248cdf0e10cSrcweir         }
249cdf0e10cSrcweir     }
250cdf0e10cSrcweir 
251cdf0e10cSrcweir     if( m_bIsDirty )
252cdf0e10cSrcweir     {
253cdf0e10cSrcweir         sal_Bool bFirstCellAsLabel = ( m_aCB_FirstColumnAsLabel.IsChecked() && !m_aRB_Columns.IsChecked() )
254cdf0e10cSrcweir             || ( m_aCB_FirstRowAsLabel.IsChecked()    && !m_aRB_Rows.IsChecked() );
255cdf0e10cSrcweir         sal_Bool bHasCategories = ( m_aCB_FirstColumnAsLabel.IsChecked() && m_aRB_Columns.IsChecked() )
256cdf0e10cSrcweir             || ( m_aCB_FirstRowAsLabel.IsChecked()    && m_aRB_Rows.IsChecked() );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir         Sequence< beans::PropertyValue > aArguments(
259cdf0e10cSrcweir             DataSourceHelper::createArguments(
260cdf0e10cSrcweir                 m_aRB_Columns.IsChecked(), bFirstCellAsLabel, bHasCategories ) );
261cdf0e10cSrcweir 
262cdf0e10cSrcweir         // only if range is valid
263cdf0e10cSrcweir         if( m_aLastValidRangeString.equals( m_aED_Range.GetText()))
264cdf0e10cSrcweir         {
265cdf0e10cSrcweir             m_rDialogModel.setTemplate( m_xCurrentChartTypeTemplate );
266cdf0e10cSrcweir             aArguments.realloc( aArguments.getLength() + 1 );
267cdf0e10cSrcweir             aArguments[aArguments.getLength() - 1] =
268cdf0e10cSrcweir                 beans::PropertyValue( C2U("CellRangeRepresentation"), -1,
269cdf0e10cSrcweir                                       uno::makeAny( m_aLastValidRangeString ),
270cdf0e10cSrcweir                                       beans::PropertyState_DIRECT_VALUE );
271cdf0e10cSrcweir             m_rDialogModel.setData( aArguments );
272cdf0e10cSrcweir             m_bIsDirty = false;
273cdf0e10cSrcweir         }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir         //@todo warn user that the selected range is not valid
276cdf0e10cSrcweir         //@todo better: disable OK-Button if range is invalid
277cdf0e10cSrcweir     }
278cdf0e10cSrcweir }
279cdf0e10cSrcweir 
isValid()280cdf0e10cSrcweir bool RangeChooserTabPage::isValid()
281cdf0e10cSrcweir {
282cdf0e10cSrcweir     ::rtl::OUString aRange( m_aED_Range.GetText());
283cdf0e10cSrcweir     sal_Bool bFirstCellAsLabel = ( m_aCB_FirstColumnAsLabel.IsChecked() && !m_aRB_Columns.IsChecked() )
284cdf0e10cSrcweir         || ( m_aCB_FirstRowAsLabel.IsChecked()    && !m_aRB_Rows.IsChecked() );
285cdf0e10cSrcweir     sal_Bool bHasCategories = ( m_aCB_FirstColumnAsLabel.IsChecked() && m_aRB_Columns.IsChecked() )
286cdf0e10cSrcweir         || ( m_aCB_FirstRowAsLabel.IsChecked()    && m_aRB_Rows.IsChecked() );
287*9ec58d04SHerbert Dürr     bool bIsValid = aRange.isEmpty() ||
288cdf0e10cSrcweir         m_rDialogModel.getRangeSelectionHelper()->verifyArguments(
289cdf0e10cSrcweir             DataSourceHelper::createArguments(
290cdf0e10cSrcweir                 aRange, Sequence< sal_Int32 >(), m_aRB_Columns.IsChecked(), bFirstCellAsLabel, bHasCategories ));
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     if( bIsValid )
293cdf0e10cSrcweir     {
294cdf0e10cSrcweir         m_aED_Range.SetControlForeground();
295cdf0e10cSrcweir         m_aED_Range.SetControlBackground();
296cdf0e10cSrcweir         if( m_pTabPageNotifiable )
297cdf0e10cSrcweir             m_pTabPageNotifiable->setValidPage( this );
298cdf0e10cSrcweir         m_aLastValidRangeString = aRange;
299cdf0e10cSrcweir     }
300cdf0e10cSrcweir     else
301cdf0e10cSrcweir     {
302cdf0e10cSrcweir         m_aED_Range.SetControlBackground( RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR );
303cdf0e10cSrcweir         m_aED_Range.SetControlForeground( RANGE_SELECTION_INVALID_RANGE_FOREGROUND_COLOR );
304cdf0e10cSrcweir         if( m_pTabPageNotifiable )
305cdf0e10cSrcweir             m_pTabPageNotifiable->setInvalidPage( this );
306cdf0e10cSrcweir     }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir     // enable/disable controls
309cdf0e10cSrcweir     // #i79531# if the range is valid but an action of one of these buttons
310cdf0e10cSrcweir     // would render it invalid, the button should be disabled
311cdf0e10cSrcweir     if( bIsValid )
312cdf0e10cSrcweir     {
313cdf0e10cSrcweir         bool bDataInColumns = m_aRB_Columns.IsChecked();
314cdf0e10cSrcweir         bool bIsSwappedRangeValid = m_rDialogModel.getRangeSelectionHelper()->verifyArguments(
315cdf0e10cSrcweir             DataSourceHelper::createArguments(
316cdf0e10cSrcweir                 aRange, Sequence< sal_Int32 >(), ! bDataInColumns, bHasCategories, bFirstCellAsLabel ));
317cdf0e10cSrcweir         m_aRB_Rows.Enable( bIsSwappedRangeValid );
318cdf0e10cSrcweir         m_aRB_Columns.Enable( bIsSwappedRangeValid );
319cdf0e10cSrcweir 
320cdf0e10cSrcweir         m_aCB_FirstRowAsLabel.Enable(
321cdf0e10cSrcweir             m_rDialogModel.getRangeSelectionHelper()->verifyArguments(
322cdf0e10cSrcweir                 DataSourceHelper::createArguments(
323cdf0e10cSrcweir                     aRange, Sequence< sal_Int32 >(), m_aRB_Columns.IsChecked(),
324cdf0e10cSrcweir                     bDataInColumns ? ! bFirstCellAsLabel : bFirstCellAsLabel,
325cdf0e10cSrcweir                     bDataInColumns ? bHasCategories : ! bHasCategories )));
326cdf0e10cSrcweir         m_aCB_FirstColumnAsLabel.Enable(
327cdf0e10cSrcweir             m_rDialogModel.getRangeSelectionHelper()->verifyArguments(
328cdf0e10cSrcweir                 DataSourceHelper::createArguments(
329cdf0e10cSrcweir                     aRange, Sequence< sal_Int32 >(), m_aRB_Columns.IsChecked(),
330cdf0e10cSrcweir                     bDataInColumns ? bFirstCellAsLabel : ! bFirstCellAsLabel,
331cdf0e10cSrcweir                     bDataInColumns ? ! bHasCategories : bHasCategories )));
332cdf0e10cSrcweir     }
333cdf0e10cSrcweir     else
334cdf0e10cSrcweir     {
335cdf0e10cSrcweir         m_aRB_Rows.Enable( bIsValid );
336cdf0e10cSrcweir         m_aRB_Columns.Enable( bIsValid );
337cdf0e10cSrcweir         m_aCB_FirstRowAsLabel.Enable( bIsValid );
338cdf0e10cSrcweir         m_aCB_FirstColumnAsLabel.Enable( bIsValid );
339cdf0e10cSrcweir }
340cdf0e10cSrcweir     sal_Bool bShowIB = m_rDialogModel.getRangeSelectionHelper()->hasRangeSelection();
341cdf0e10cSrcweir     lcl_ShowChooserButton( m_aIB_Range, m_aED_Range, bShowIB );
342cdf0e10cSrcweir 
343cdf0e10cSrcweir     return bIsValid;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir 
IMPL_LINK(RangeChooserTabPage,ControlEditedHdl,void *,EMPTYARG)346cdf0e10cSrcweir IMPL_LINK( RangeChooserTabPage, ControlEditedHdl, void*, EMPTYARG )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir     setDirty();
349cdf0e10cSrcweir     isValid();
350cdf0e10cSrcweir     return 0;
351cdf0e10cSrcweir }
352cdf0e10cSrcweir 
IMPL_LINK(RangeChooserTabPage,ControlChangedHdl,void *,EMPTYARG)353cdf0e10cSrcweir IMPL_LINK( RangeChooserTabPage, ControlChangedHdl, void*, EMPTYARG )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir     setDirty();
356cdf0e10cSrcweir     if( isValid())
357cdf0e10cSrcweir         changeDialogModelAccordingToControls();
358cdf0e10cSrcweir     return 0;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
IMPL_LINK(RangeChooserTabPage,ChooseRangeHdl,void *,EMPTYARG)361cdf0e10cSrcweir IMPL_LINK( RangeChooserTabPage, ChooseRangeHdl, void *, EMPTYARG )
362cdf0e10cSrcweir {
363cdf0e10cSrcweir     rtl::OUString aRange = m_aED_Range.GetText();
364cdf0e10cSrcweir     // using assignment for broken gcc 3.3
365cdf0e10cSrcweir     rtl::OUString aTitle = String( SchResId( STR_PAGE_DATA_RANGE ) );
366cdf0e10cSrcweir 
367cdf0e10cSrcweir     lcl_enableRangeChoosing( true, m_pParentDialog );
368cdf0e10cSrcweir     m_rDialogModel.getRangeSelectionHelper()->chooseRange( aRange, aTitle, *this );
369cdf0e10cSrcweir 
370cdf0e10cSrcweir     return 0;
371cdf0e10cSrcweir }
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 
listeningFinished(const::rtl::OUString & rNewRange)374cdf0e10cSrcweir void RangeChooserTabPage::listeningFinished( const ::rtl::OUString & rNewRange )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir     //user has selected a new range
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     rtl::OUString aRange( rNewRange );
379cdf0e10cSrcweir 
380cdf0e10cSrcweir     m_rDialogModel.startControllerLockTimer();
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     // stop listening
383cdf0e10cSrcweir     m_rDialogModel.getRangeSelectionHelper()->stopRangeListening();
384cdf0e10cSrcweir 
385cdf0e10cSrcweir     //update dialog state
386cdf0e10cSrcweir     ToTop();
387cdf0e10cSrcweir     GrabFocus();
388cdf0e10cSrcweir     m_aED_Range.SetText( String( aRange ) );
389cdf0e10cSrcweir     m_aED_Range.GrabFocus();
390cdf0e10cSrcweir 
391cdf0e10cSrcweir     setDirty();
392cdf0e10cSrcweir     if( isValid())
393cdf0e10cSrcweir         changeDialogModelAccordingToControls();
394cdf0e10cSrcweir 
395cdf0e10cSrcweir     lcl_enableRangeChoosing( false, m_pParentDialog );
396cdf0e10cSrcweir }
disposingRangeSelection()397cdf0e10cSrcweir void RangeChooserTabPage::disposingRangeSelection()
398cdf0e10cSrcweir {
399cdf0e10cSrcweir     m_rDialogModel.getRangeSelectionHelper()->stopRangeListening( false );
400cdf0e10cSrcweir }
401cdf0e10cSrcweir 
setDirty()402cdf0e10cSrcweir void RangeChooserTabPage::setDirty()
403cdf0e10cSrcweir {
404cdf0e10cSrcweir     if( m_nChangingControlCalls == 0 )
405cdf0e10cSrcweir         m_bIsDirty = true;
406cdf0e10cSrcweir }
407cdf0e10cSrcweir 
408cdf0e10cSrcweir //.............................................................................
409cdf0e10cSrcweir } //namespace chart
410cdf0e10cSrcweir //.............................................................................
411