xref: /aoo41x/main/sc/source/ui/dbgui/dpgroupdlg.cxx (revision 58ae0c86)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifdef SC_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SC_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "dpgroupdlg.hxx"
33cdf0e10cSrcweir #ifndef SC_DPGROUPDLG_HRC
34cdf0e10cSrcweir #include "dpgroupdlg.hrc"
35cdf0e10cSrcweir #endif
36*58ae0c86SAriel Constenla-Haile 
37cdf0e10cSrcweir #include "scresid.hxx"
38cdf0e10cSrcweir #ifndef SC_SC_HRC
39cdf0e10cSrcweir #include "sc.hrc"
40cdf0e10cSrcweir #endif
41*58ae0c86SAriel Constenla-Haile 
42*58ae0c86SAriel Constenla-Haile #include "globstr.hrc"
43*58ae0c86SAriel Constenla-Haile 
44cdf0e10cSrcweir #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir // ============================================================================
47cdf0e10cSrcweir 
48cdf0e10cSrcweir namespace {
49cdf0e10cSrcweir 
50cdf0e10cSrcweir /** Date part flags in order of the list box entries. */
51cdf0e10cSrcweir static const sal_Int32 spnDateParts[] =
52cdf0e10cSrcweir {
53cdf0e10cSrcweir     com::sun::star::sheet::DataPilotFieldGroupBy::SECONDS,
54cdf0e10cSrcweir     com::sun::star::sheet::DataPilotFieldGroupBy::MINUTES,
55cdf0e10cSrcweir     com::sun::star::sheet::DataPilotFieldGroupBy::HOURS,
56cdf0e10cSrcweir     com::sun::star::sheet::DataPilotFieldGroupBy::DAYS,
57cdf0e10cSrcweir     com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS,
58cdf0e10cSrcweir     com::sun::star::sheet::DataPilotFieldGroupBy::QUARTERS,
59cdf0e10cSrcweir     com::sun::star::sheet::DataPilotFieldGroupBy::YEARS
60cdf0e10cSrcweir };
61cdf0e10cSrcweir 
62*58ae0c86SAriel Constenla-Haile static const sal_uInt16 nDatePartResIds[] =
63*58ae0c86SAriel Constenla-Haile {
64*58ae0c86SAriel Constenla-Haile     STR_DPFIELD_GROUP_BY_SECONDS,
65*58ae0c86SAriel Constenla-Haile     STR_DPFIELD_GROUP_BY_MINUTES,
66*58ae0c86SAriel Constenla-Haile     STR_DPFIELD_GROUP_BY_HOURS,
67*58ae0c86SAriel Constenla-Haile     STR_DPFIELD_GROUP_BY_DAYS,
68*58ae0c86SAriel Constenla-Haile     STR_DPFIELD_GROUP_BY_MONTHS,
69*58ae0c86SAriel Constenla-Haile     STR_DPFIELD_GROUP_BY_QUARTERS,
70*58ae0c86SAriel Constenla-Haile     STR_DPFIELD_GROUP_BY_YEARS
71*58ae0c86SAriel Constenla-Haile };
72*58ae0c86SAriel Constenla-Haile 
73cdf0e10cSrcweir } // namespace
74cdf0e10cSrcweir 
75cdf0e10cSrcweir // ============================================================================
76cdf0e10cSrcweir 
ScDPGroupEditHelper(RadioButton & rRbAuto,RadioButton & rRbMan,Edit & rEdValue)77cdf0e10cSrcweir ScDPGroupEditHelper::ScDPGroupEditHelper( RadioButton& rRbAuto, RadioButton& rRbMan, Edit& rEdValue ) :
78cdf0e10cSrcweir     mrRbAuto( rRbAuto ),
79cdf0e10cSrcweir     mrRbMan( rRbMan ),
80cdf0e10cSrcweir     mrEdValue( rEdValue )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir     mrRbAuto.SetClickHdl( LINK( this, ScDPGroupEditHelper, ClickHdl ) );
83cdf0e10cSrcweir     mrRbMan.SetClickHdl( LINK( this, ScDPGroupEditHelper, ClickHdl ) );
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
IsAuto() const86cdf0e10cSrcweir bool ScDPGroupEditHelper::IsAuto() const
87cdf0e10cSrcweir {
88cdf0e10cSrcweir     return mrRbAuto.IsChecked();
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
GetValue() const91cdf0e10cSrcweir double ScDPGroupEditHelper::GetValue() const
92cdf0e10cSrcweir {
93cdf0e10cSrcweir     double fValue;
94cdf0e10cSrcweir     if( !ImplGetValue( fValue ) )
95cdf0e10cSrcweir         fValue = 0.0;
96cdf0e10cSrcweir     return fValue;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
SetValue(bool bAuto,double fValue)99cdf0e10cSrcweir void ScDPGroupEditHelper::SetValue( bool bAuto, double fValue )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     if( bAuto )
102cdf0e10cSrcweir     {
103cdf0e10cSrcweir         mrRbAuto.Check();
104cdf0e10cSrcweir         ClickHdl( &mrRbAuto );
105cdf0e10cSrcweir     }
106cdf0e10cSrcweir     else
107cdf0e10cSrcweir     {
108cdf0e10cSrcweir         mrRbMan.Check();
109cdf0e10cSrcweir         ClickHdl( &mrRbMan );
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir     ImplSetValue( fValue );
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
IMPL_LINK(ScDPGroupEditHelper,ClickHdl,RadioButton *,pButton)114cdf0e10cSrcweir IMPL_LINK( ScDPGroupEditHelper, ClickHdl, RadioButton*, pButton )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir     if( pButton == &mrRbAuto )
117cdf0e10cSrcweir     {
118cdf0e10cSrcweir         // disable edit field on clicking "automatic" radio button
119cdf0e10cSrcweir         mrEdValue.Disable();
120cdf0e10cSrcweir     }
121cdf0e10cSrcweir     else if( pButton == &mrRbMan )
122cdf0e10cSrcweir     {
123cdf0e10cSrcweir         // enable and set focus to edit field on clicking "manual" radio button
124cdf0e10cSrcweir         mrEdValue.Enable();
125cdf0e10cSrcweir         mrEdValue.GrabFocus();
126cdf0e10cSrcweir     }
127cdf0e10cSrcweir     return 0;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir // ----------------------------------------------------------------------------
131cdf0e10cSrcweir 
ScDPNumGroupEditHelper(RadioButton & rRbAuto,RadioButton & rRbMan,ScDoubleField & rEdValue)132cdf0e10cSrcweir ScDPNumGroupEditHelper::ScDPNumGroupEditHelper(
133cdf0e10cSrcweir         RadioButton& rRbAuto, RadioButton& rRbMan, ScDoubleField& rEdValue ) :
134cdf0e10cSrcweir     ScDPGroupEditHelper( rRbAuto, rRbMan, rEdValue ),
135cdf0e10cSrcweir     mrEdValue( rEdValue )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
ImplGetValue(double & rfValue) const139cdf0e10cSrcweir bool ScDPNumGroupEditHelper::ImplGetValue( double& rfValue ) const
140cdf0e10cSrcweir {
141cdf0e10cSrcweir     return mrEdValue.GetValue( rfValue );
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
ImplSetValue(double fValue)144cdf0e10cSrcweir void ScDPNumGroupEditHelper::ImplSetValue( double fValue )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir     mrEdValue.SetValue( fValue );
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir // ----------------------------------------------------------------------------
150cdf0e10cSrcweir 
ScDPDateGroupEditHelper(RadioButton & rRbAuto,RadioButton & rRbMan,DateField & rEdValue,const Date & rNullDate)151cdf0e10cSrcweir ScDPDateGroupEditHelper::ScDPDateGroupEditHelper(
152cdf0e10cSrcweir         RadioButton& rRbAuto, RadioButton& rRbMan, DateField& rEdValue, const Date& rNullDate ) :
153cdf0e10cSrcweir     ScDPGroupEditHelper( rRbAuto, rRbMan, rEdValue ),
154cdf0e10cSrcweir     mrEdValue( rEdValue ),
155cdf0e10cSrcweir     maNullDate( rNullDate )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
ImplGetValue(double & rfValue) const159cdf0e10cSrcweir bool ScDPDateGroupEditHelper::ImplGetValue( double& rfValue ) const
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     rfValue = mrEdValue.GetDate() - maNullDate;
162cdf0e10cSrcweir     return true;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
ImplSetValue(double fValue)165cdf0e10cSrcweir void ScDPDateGroupEditHelper::ImplSetValue( double fValue )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir     Date aDate( maNullDate );
168cdf0e10cSrcweir     aDate += static_cast< sal_Int32 >( fValue );
169cdf0e10cSrcweir     mrEdValue.SetDate( aDate );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir // ============================================================================
173cdf0e10cSrcweir // ============================================================================
174cdf0e10cSrcweir 
ScDPNumGroupDlg(Window * pParent,const ScDPNumGroupInfo & rInfo)175cdf0e10cSrcweir ScDPNumGroupDlg::ScDPNumGroupDlg( Window* pParent, const ScDPNumGroupInfo& rInfo ) :
176cdf0e10cSrcweir     ModalDialog     ( pParent, ScResId( RID_SCDLG_DPNUMGROUP ) ),
177cdf0e10cSrcweir     maFlStart       ( this, ScResId( FL_START ) ),
178cdf0e10cSrcweir     maRbAutoStart   ( this, ScResId( RB_AUTOSTART ) ),
179cdf0e10cSrcweir     maRbManStart    ( this, ScResId( RB_MANSTART ) ),
180cdf0e10cSrcweir     maEdStart       ( this, ScResId( ED_START ) ),
181cdf0e10cSrcweir     maFlEnd         ( this, ScResId( FL_END ) ),
182cdf0e10cSrcweir     maRbAutoEnd     ( this, ScResId( RB_AUTOEND ) ),
183cdf0e10cSrcweir     maRbManEnd      ( this, ScResId( RB_MANEND ) ),
184cdf0e10cSrcweir     maEdEnd         ( this, ScResId( ED_END ) ),
185cdf0e10cSrcweir     maFlBy          ( this, ScResId( FL_BY ) ),
186cdf0e10cSrcweir     maEdBy          ( this, ScResId( ED_BY ) ),
187cdf0e10cSrcweir     maBtnOk         ( this, ScResId( BTN_OK ) ),
188cdf0e10cSrcweir     maBtnCancel     ( this, ScResId( BTN_CANCEL ) ),
189cdf0e10cSrcweir     maBtnHelp       ( this, ScResId( BTN_HELP ) ),
190cdf0e10cSrcweir     maStartHelper   ( maRbAutoStart, maRbManStart, maEdStart ),
191cdf0e10cSrcweir     maEndHelper     ( maRbAutoEnd, maRbManEnd, maEdEnd )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir     FreeResource();
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     maStartHelper.SetValue( rInfo.AutoStart, rInfo.Start );
196cdf0e10cSrcweir     maEndHelper.SetValue( rInfo.AutoEnd, rInfo.End );
197cdf0e10cSrcweir     maEdBy.SetValue( (rInfo.Step <= 0.0) ? 1.0 : rInfo.Step );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir     /*  Set the initial focus, currently it is somewhere after calling all the radio
200cdf0e10cSrcweir         button click handlers. Now the first enabled editable control is focused. */
201cdf0e10cSrcweir     if( maEdStart.IsEnabled() )
202cdf0e10cSrcweir         maEdStart.GrabFocus();
203cdf0e10cSrcweir     else if( maEdEnd.IsEnabled() )
204cdf0e10cSrcweir         maEdEnd.GrabFocus();
205cdf0e10cSrcweir     else
206cdf0e10cSrcweir         maEdBy.GrabFocus();
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
GetGroupInfo() const209cdf0e10cSrcweir ScDPNumGroupInfo ScDPNumGroupDlg::GetGroupInfo() const
210cdf0e10cSrcweir {
211cdf0e10cSrcweir     ScDPNumGroupInfo aInfo;
212cdf0e10cSrcweir     aInfo.Enable = sal_True;
213cdf0e10cSrcweir     aInfo.DateValues = sal_False;
214cdf0e10cSrcweir     aInfo.AutoStart = maStartHelper.IsAuto();
215cdf0e10cSrcweir     aInfo.AutoEnd = maEndHelper.IsAuto();
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     // get values and silently auto-correct them, if they are not valid
218cdf0e10cSrcweir     // TODO: error messages in OK event?
219cdf0e10cSrcweir     aInfo.Start = maStartHelper.GetValue();
220cdf0e10cSrcweir     aInfo.End = maEndHelper.GetValue();
221cdf0e10cSrcweir     if( !maEdBy.GetValue( aInfo.Step ) || (aInfo.Step <= 0.0) )
222cdf0e10cSrcweir         aInfo.Step = 1.0;
223cdf0e10cSrcweir     if( aInfo.End <= aInfo.Start )
224cdf0e10cSrcweir         aInfo.End = aInfo.Start + aInfo.Step;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     return aInfo;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
229cdf0e10cSrcweir // ============================================================================
230cdf0e10cSrcweir 
ScDPDateGroupDlg(Window * pParent,const ScDPNumGroupInfo & rInfo,sal_Int32 nDatePart,const Date & rNullDate)231cdf0e10cSrcweir ScDPDateGroupDlg::ScDPDateGroupDlg( Window* pParent,
232cdf0e10cSrcweir         const ScDPNumGroupInfo& rInfo, sal_Int32 nDatePart, const Date& rNullDate ) :
233cdf0e10cSrcweir     ModalDialog     ( pParent, ScResId( RID_SCDLG_DPDATEGROUP ) ),
234cdf0e10cSrcweir     maFlStart       ( this, ScResId( FL_START ) ),
235cdf0e10cSrcweir     maRbAutoStart   ( this, ScResId( RB_AUTOSTART ) ),
236cdf0e10cSrcweir     maRbManStart    ( this, ScResId( RB_MANSTART ) ),
237cdf0e10cSrcweir     maEdStart       ( this, ScResId( ED_START ) ),
238cdf0e10cSrcweir     maFlEnd         ( this, ScResId( FL_END ) ),
239cdf0e10cSrcweir     maRbAutoEnd     ( this, ScResId( RB_AUTOEND ) ),
240cdf0e10cSrcweir     maRbManEnd      ( this, ScResId( RB_MANEND ) ),
241cdf0e10cSrcweir     maEdEnd         ( this, ScResId( ED_END ) ),
242cdf0e10cSrcweir     maFlBy          ( this, ScResId( FL_BY ) ),
243cdf0e10cSrcweir     maRbNumDays     ( this, ScResId( RB_NUMDAYS ) ),
244cdf0e10cSrcweir     maRbUnits       ( this, ScResId( RB_UNITS ) ),
245cdf0e10cSrcweir     maEdNumDays     ( this, ScResId( ED_NUMDAYS ) ),
246cdf0e10cSrcweir     maLbUnits       ( this, ScResId( LB_UNITS ) ),
247cdf0e10cSrcweir     maBtnOk         ( this, ScResId( BTN_OK ) ),
248cdf0e10cSrcweir     maBtnCancel     ( this, ScResId( BTN_CANCEL ) ),
249cdf0e10cSrcweir     maBtnHelp       ( this, ScResId( BTN_HELP ) ),
250cdf0e10cSrcweir     maStartHelper   ( maRbAutoStart, maRbManStart, maEdStart, rNullDate ),
251cdf0e10cSrcweir     maEndHelper     ( maRbAutoEnd, maRbManEnd, maEdEnd, rNullDate )
252cdf0e10cSrcweir {
253*58ae0c86SAriel Constenla-Haile     FreeResource();
254*58ae0c86SAriel Constenla-Haile 
255cdf0e10cSrcweir     maLbUnits.SetHelpId( HID_SC_DPDATEGROUP_LB );
256cdf0e10cSrcweir 
257*58ae0c86SAriel Constenla-Haile     static const size_t nCount = sizeof( nDatePartResIds ) / sizeof( nDatePartResIds[0] );
258*58ae0c86SAriel Constenla-Haile     for( size_t nIdx = 0 ; nIdx < nCount; ++nIdx )
259*58ae0c86SAriel Constenla-Haile         maLbUnits.InsertEntry( ScGlobal::GetRscString( nDatePartResIds[nIdx] ) );
260cdf0e10cSrcweir 
261cdf0e10cSrcweir     maEdStart.SetShowDateCentury( sal_True );
262cdf0e10cSrcweir     maEdEnd.SetShowDateCentury( sal_True );
263cdf0e10cSrcweir 
264cdf0e10cSrcweir     maStartHelper.SetValue( rInfo.AutoStart, rInfo.Start );
265cdf0e10cSrcweir     maEndHelper.SetValue( rInfo.AutoEnd, rInfo.End );
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     if( nDatePart == 0 )
268cdf0e10cSrcweir         nDatePart = com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS;
269*58ae0c86SAriel Constenla-Haile     for( size_t nIdx = 0; nIdx < nCount; ++nIdx )
270cdf0e10cSrcweir         maLbUnits.CheckEntryPos( static_cast< sal_uInt16 >( nIdx ), (nDatePart & spnDateParts[ nIdx ]) != 0 );
271cdf0e10cSrcweir 
272cdf0e10cSrcweir     if( rInfo.DateValues )
273cdf0e10cSrcweir     {
274cdf0e10cSrcweir         maRbNumDays.Check();
275cdf0e10cSrcweir         ClickHdl( &maRbNumDays );
276cdf0e10cSrcweir 
277cdf0e10cSrcweir         double fNumDays = rInfo.Step;
278cdf0e10cSrcweir         if( fNumDays < 1.0 )
279cdf0e10cSrcweir             fNumDays = 1.0;
280cdf0e10cSrcweir         else if( fNumDays > 32767.0 )
281cdf0e10cSrcweir             fNumDays = 32767.0;
282cdf0e10cSrcweir         maEdNumDays.SetValue( static_cast< long >( fNumDays ) );
283cdf0e10cSrcweir     }
284cdf0e10cSrcweir     else
285cdf0e10cSrcweir     {
286cdf0e10cSrcweir         maRbUnits.Check();
287cdf0e10cSrcweir         ClickHdl( &maRbUnits );
288cdf0e10cSrcweir     }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     /*  Set the initial focus, currently it is somewhere after calling all the radio
291cdf0e10cSrcweir         button click handlers. Now the first enabled editable control is focused. */
292cdf0e10cSrcweir     if( maEdStart.IsEnabled() )
293cdf0e10cSrcweir         maEdStart.GrabFocus();
294cdf0e10cSrcweir     else if( maEdEnd.IsEnabled() )
295cdf0e10cSrcweir         maEdEnd.GrabFocus();
296cdf0e10cSrcweir     else if( maEdNumDays.IsEnabled() )
297cdf0e10cSrcweir         maEdNumDays.GrabFocus();
298cdf0e10cSrcweir     else if( maLbUnits.IsEnabled() )
299cdf0e10cSrcweir         maLbUnits.GrabFocus();
300cdf0e10cSrcweir 
301cdf0e10cSrcweir     maRbNumDays.SetClickHdl( LINK( this, ScDPDateGroupDlg, ClickHdl ) );
302cdf0e10cSrcweir     maRbUnits.SetClickHdl( LINK( this, ScDPDateGroupDlg, ClickHdl ) );
303cdf0e10cSrcweir     maLbUnits.SetCheckButtonHdl( LINK( this, ScDPDateGroupDlg, CheckHdl ) );
304cdf0e10cSrcweir }
305cdf0e10cSrcweir 
GetGroupInfo() const306cdf0e10cSrcweir ScDPNumGroupInfo ScDPDateGroupDlg::GetGroupInfo() const
307cdf0e10cSrcweir {
308cdf0e10cSrcweir     ScDPNumGroupInfo aInfo;
309cdf0e10cSrcweir     aInfo.Enable = sal_True;
310cdf0e10cSrcweir     aInfo.DateValues = maRbNumDays.IsChecked();
311cdf0e10cSrcweir     aInfo.AutoStart = maStartHelper.IsAuto();
312cdf0e10cSrcweir     aInfo.AutoEnd = maEndHelper.IsAuto();
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     // get values and silently auto-correct them, if they are not valid
315cdf0e10cSrcweir     // TODO: error messages in OK event?
316cdf0e10cSrcweir     aInfo.Start = maStartHelper.GetValue();
317cdf0e10cSrcweir     aInfo.End = maEndHelper.GetValue();
318cdf0e10cSrcweir     sal_Int64 nNumDays = maEdNumDays.GetValue();
319cdf0e10cSrcweir     aInfo.Step = static_cast<double>( aInfo.DateValues ? nNumDays : 0L );
320cdf0e10cSrcweir     if( aInfo.End <= aInfo.Start )
321cdf0e10cSrcweir         aInfo.End = aInfo.Start + nNumDays;
322cdf0e10cSrcweir 
323cdf0e10cSrcweir     return aInfo;
324cdf0e10cSrcweir }
325cdf0e10cSrcweir 
GetDatePart() const326cdf0e10cSrcweir sal_Int32 ScDPDateGroupDlg::GetDatePart() const
327cdf0e10cSrcweir {
328cdf0e10cSrcweir     // return DAYS for special "number of days" mode
329cdf0e10cSrcweir     if( maRbNumDays.IsChecked() )
330cdf0e10cSrcweir         return com::sun::star::sheet::DataPilotFieldGroupBy::DAYS;
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     // return listbox contents for "units" mode
333cdf0e10cSrcweir     sal_Int32 nDatePart = 0;
334cdf0e10cSrcweir     for( sal_uLong nIdx = 0, nCount = maLbUnits.GetEntryCount(); nIdx < nCount; ++nIdx )
335cdf0e10cSrcweir         if( maLbUnits.IsChecked( static_cast< sal_uInt16 >( nIdx ) ) )
336cdf0e10cSrcweir             nDatePart |= spnDateParts[ nIdx ];
337cdf0e10cSrcweir     return nDatePart;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir 
IMPL_LINK(ScDPDateGroupDlg,ClickHdl,RadioButton *,pButton)340cdf0e10cSrcweir IMPL_LINK( ScDPDateGroupDlg, ClickHdl, RadioButton*, pButton )
341cdf0e10cSrcweir {
342cdf0e10cSrcweir     if( pButton == &maRbNumDays )
343cdf0e10cSrcweir     {
344cdf0e10cSrcweir         maLbUnits.Disable();
345cdf0e10cSrcweir         // enable and set focus to edit field on clicking "num of days" radio button
346cdf0e10cSrcweir         maEdNumDays.Enable();
347cdf0e10cSrcweir         maEdNumDays.GrabFocus();
348cdf0e10cSrcweir         maBtnOk.Enable();
349cdf0e10cSrcweir     }
350cdf0e10cSrcweir     else if( pButton == &maRbUnits )
351cdf0e10cSrcweir     {
352cdf0e10cSrcweir         maEdNumDays.Disable();
353cdf0e10cSrcweir         // enable and set focus to listbox on clicking "units" radio button
354cdf0e10cSrcweir         maLbUnits.Enable();
355cdf0e10cSrcweir         maLbUnits.GrabFocus();
356cdf0e10cSrcweir         // disable OK button if no date part selected
357cdf0e10cSrcweir         CheckHdl( &maLbUnits );
358cdf0e10cSrcweir     }
359cdf0e10cSrcweir     return 0;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir 
IMPL_LINK(ScDPDateGroupDlg,CheckHdl,SvxCheckListBox *,pListBox)362cdf0e10cSrcweir IMPL_LINK( ScDPDateGroupDlg, CheckHdl, SvxCheckListBox*, pListBox )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir     // enable/disable OK button on modifying check list box
365cdf0e10cSrcweir     if( pListBox == &maLbUnits )
366cdf0e10cSrcweir         maBtnOk.Enable( maLbUnits.GetCheckedEntryCount() > 0 );
367cdf0e10cSrcweir     return 0;
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir // ============================================================================
371cdf0e10cSrcweir 
372