1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
#undef SC_DLLIMPLEMENTATION
#include "scitems.hxx"
#include "uiitems.hxx"
#include "global.hxx"
#include "userlist.hxx"
#include "viewdata.hxx"
#include "document.hxx"
#include "scresid.hxx"
#include "sc.hrc" // -> Slot IDs
#include "subtdlg.hxx"
#include "subtdlg.hrc"
#include "tpsubt.hxx"
// STATIC DATA -----------------------------------------------------------
static sal_uInt16 pSubTotalsRanges[] =
{
SID_SUBTOTALS,
SID_SUBTOTALS,
0
};
//========================================================================
// Zwischenergebnisgruppen-Tabpage:
ScTpSubTotalGroup::ScTpSubTotalGroup( Window* pParent, sal_uInt16 nResId,
const SfxItemSet& rArgSet )
: SfxTabPage ( pParent,
ScResId( nResId ),
rArgSet ),
//
aFtGroup ( this, ScResId( FT_GROUP ) ),
aLbGroup ( this, ScResId( LB_GROUP ) ),
aFtColumns ( this, ScResId( FT_COLUMNS ) ),
aLbColumns ( this, ScResId( WND_COLUMNS ) ),
aFtFunctions ( this, ScResId( FT_FUNCTIONS ) ),
aLbFunctions ( this, ScResId( LB_FUNCTIONS ) ),
aStrNone ( ScResId( SCSTR_NONE ) ),
aStrColumn ( ScResId( SCSTR_COLUMN ) ),
//
pViewData ( NULL ),
pDoc ( NULL ),
nWhichSubTotals ( rArgSet.GetPool()->GetWhich( SID_SUBTOTALS ) ),
rSubTotalData ( ((const ScSubTotalItem&)
rArgSet.Get( nWhichSubTotals )).
GetSubTotalData() ),
nFieldCount ( 0 )
{
// Font is correctly initialized by SvTreeListBox ctor
aLbColumns.SetSelectionMode( SINGLE_SELECTION );
aLbColumns.SetDragDropMode( SV_DRAGDROP_NONE );
aLbColumns.SetSpaceBetweenEntries( 0 );
aLbColumns.Show();
Init ();
FreeResource();
}
// -----------------------------------------------------------------------
__EXPORT ScTpSubTotalGroup::~ScTpSubTotalGroup()
{
sal_uInt16 nCount = (sal_uInt16)aLbColumns.GetEntryCount();
if ( nCount > 0 )
{
sal_uInt16* pData = NULL;
for ( sal_uInt16 i=0; i<nCount; i++ )
{
pData = (sal_uInt16*)(aLbColumns.GetEntryData( i ));
DBG_ASSERT( pData, "EntryData not found" );
delete pData;
}
}
}
// -----------------------------------------------------------------------
void ScTpSubTotalGroup::Init()
{
const ScSubTotalItem& rSubTotalItem = (const ScSubTotalItem&)
GetItemSet().Get( nWhichSubTotals );
pViewData = rSubTotalItem.GetViewData();
pDoc = ( pViewData ) ? pViewData->GetDocument() : NULL;
DBG_ASSERT( pViewData && pDoc, "ViewData or Document not found :-(" );
aLbGroup.SetSelectHdl ( LINK( this, ScTpSubTotalGroup, SelectHdl ) );
aLbColumns.SetSelectHdl ( LINK( this, ScTpSubTotalGroup, SelectHdl ) );
aLbColumns.SetCheckButtonHdl ( LINK( this, ScTpSubTotalGroup, CheckHdl ) );
aLbFunctions.SetSelectHdl ( LINK( this, ScTpSubTotalGroup, SelectHdl ) );
nFieldArr[0] = 0;
FillListBoxes();
}
//------------------------------------------------------------------------
sal_uInt16* __EXPORT ScTpSubTotalGroup::GetRanges()
{
return pSubTotalsRanges;
}
// -----------------------------------------------------------------------
sal_Bool ScTpSubTotalGroup::DoReset( sal_uInt16 nGroupNo,
const SfxItemSet& rArgSet )
{
sal_uInt16 nGroupIdx = 0;
DBG_ASSERT( (nGroupNo<=3) && (nGroupNo>0), "Invalid group" );
if ( (nGroupNo > 3) || (nGroupNo == 0) )
return sal_False;
else
nGroupIdx = nGroupNo-1;
//----------------------------------------------------------
// #79058# first we have to clear the listboxes...
for ( sal_uInt16 nLbEntry = 0; nLbEntry < aLbColumns.GetEntryCount(); ++nLbEntry )
{
aLbColumns.CheckEntryPos( nLbEntry, sal_False );
*((sal_uInt16*)aLbColumns.GetEntryData( nLbEntry )) = 0;
}
aLbFunctions.SelectEntryPos( 0 );
ScSubTotalParam theSubTotalData( ((const ScSubTotalItem&)
rArgSet.Get( nWhichSubTotals )).
GetSubTotalData() );
if ( theSubTotalData.bGroupActive[nGroupIdx] )
{
SCCOL nField = theSubTotalData.nField[nGroupIdx];
SCCOL nSubTotals = theSubTotalData.nSubTotals[nGroupIdx];
SCCOL* pSubTotals = theSubTotalData.pSubTotals[nGroupIdx];
ScSubTotalFunc* pFunctions = theSubTotalData.pFunctions[nGroupIdx];
aLbGroup.SelectEntryPos( GetFieldSelPos( nField )+1 );
for ( sal_uInt16 i=0; i<nSubTotals; i++ )
{
sal_uInt16 nCheckPos = GetFieldSelPos( pSubTotals[i] );
sal_uInt16* pFunction = (sal_uInt16*)aLbColumns.GetEntryData( nCheckPos );
aLbColumns.CheckEntryPos( nCheckPos );
*pFunction = FuncToLbPos( pFunctions[i] );
}
aLbColumns.SelectEntryPos( 0 );
}
else
{
aLbGroup.SelectEntryPos( (nGroupNo == 1) ? 1 : 0 );
aLbColumns.SelectEntryPos( 0 );
aLbFunctions.SelectEntryPos( 0 );
}
return sal_True;
}
// -----------------------------------------------------------------------
sal_Bool ScTpSubTotalGroup::DoFillItemSet( sal_uInt16 nGroupNo,
SfxItemSet& rArgSet )
{
sal_uInt16 nGroupIdx = 0;
DBG_ASSERT( (nGroupNo<=3) && (nGroupNo>0), "Invalid group" );
DBG_ASSERT( (aLbGroup.GetEntryCount() > 0)
&& (aLbColumns.GetEntryCount() > 0)
&& (aLbFunctions.GetEntryCount() > 0),
"Non-initialized Lists" );
if ( (nGroupNo > 3) || (nGroupNo == 0)
|| (aLbGroup.GetEntryCount() == 0)
|| (aLbColumns.GetEntryCount() == 0)
|| (aLbFunctions.GetEntryCount() == 0)
)
return sal_False;
else
nGroupIdx = nGroupNo-1;
//----------------------------------------------------------
ScSubTotalParam theSubTotalData; // auslesen, wenn schon teilweise gefuellt
SfxTabDialog* pDlg = GetTabDialog();
if ( pDlg )
{
const SfxItemSet* pExample = pDlg->GetExampleSet();
const SfxPoolItem* pItem;
if ( pExample && pExample->GetItemState( nWhichSubTotals, sal_True, &pItem ) == SFX_ITEM_SET )
theSubTotalData = ((const ScSubTotalItem*)pItem)->GetSubTotalData();
}
ScSubTotalFunc* pFunctions = NULL;
SCCOL* pSubTotals = NULL;
sal_uInt16 nGroup = aLbGroup.GetSelectEntryPos();
sal_uInt16 nEntryCount = (sal_uInt16)aLbColumns.GetEntryCount();
sal_uInt16 nCheckCount = aLbColumns.GetCheckedEntryCount();
theSubTotalData.nCol1 = rSubTotalData.nCol1;
theSubTotalData.nRow1 = rSubTotalData.nRow1;
theSubTotalData.nCol2 = rSubTotalData.nCol2;
theSubTotalData.nRow2 = rSubTotalData.nRow2;
theSubTotalData.bGroupActive[nGroupIdx] = (nGroup != 0);
theSubTotalData.nField[nGroupIdx] = (nGroup != 0)
? nFieldArr[nGroup-1]
: static_cast<SCCOL>(0);
if ( nEntryCount>0 && nCheckCount>0 && nGroup!=0 )
{
sal_uInt16 nFunction = 0;
pSubTotals = new SCCOL [nCheckCount];
pFunctions = new ScSubTotalFunc [nCheckCount];
for ( sal_uInt16 i=0, nCheck=0; i<nEntryCount; i++ )
{
if ( aLbColumns.IsChecked( i ) )
{
DBG_ASSERT( nCheck <= nCheckCount,
"Range error :-(" );
nFunction = *((sal_uInt16*)aLbColumns.GetEntryData( i ));
pSubTotals[nCheck] = nFieldArr[i];
pFunctions[nCheck] = LbPosToFunc( nFunction );
nCheck++;
}
}
theSubTotalData.SetSubTotals( nGroupNo, // Gruppen-Nr.
pSubTotals,
pFunctions,
nCheckCount ); // Anzahl der Array-Elemente
}
rArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, &theSubTotalData ) );
if ( pSubTotals ) delete [] pSubTotals;
if ( pFunctions ) delete [] pFunctions;
return sal_True;
}
// -----------------------------------------------------------------------
void ScTpSubTotalGroup::FillListBoxes()
{
DBG_ASSERT( pViewData && pDoc, "ViewData or Document not found :-/" );
if ( pViewData && pDoc )
{
SCCOL nFirstCol = rSubTotalData.nCol1;
SCROW nFirstRow = rSubTotalData.nRow1;
SCTAB nTab = pViewData->GetTabNo();
SCCOL nMaxCol = rSubTotalData.nCol2;
SCCOL col;
sal_uInt16 i=0;
String aFieldName;
aLbGroup.Clear();
aLbColumns.Clear();
aLbGroup.InsertEntry( aStrNone, 0 );
i=0;
for ( col=nFirstCol; col<=nMaxCol && i<SC_MAXFIELDS; col++ )
{
pDoc->GetString( col, nFirstRow, nTab, aFieldName );
if ( aFieldName.Len() == 0 )
{
aFieldName = aStrColumn;
aFieldName += ' ';
aFieldName += ::ScColToAlpha( col ); // from global.hxx
}
nFieldArr[i] = col;
aLbGroup.InsertEntry( aFieldName, i+1 );
aLbColumns.InsertEntry( aFieldName, i );
aLbColumns.SetEntryData( i, new sal_uInt16(0) );
i++;
}
// Nachtraegliche "Konstanteninitialisierung":
(sal_uInt16&)nFieldCount = i;
}
}
// -----------------------------------------------------------------------
sal_uInt16 ScTpSubTotalGroup::GetFieldSelPos( SCCOL nField )
{
sal_uInt16 nFieldPos = 0;
sal_Bool bFound = sal_False;
for ( sal_uInt16 n=0; n<nFieldCount && !bFound; n++ )
{
if ( nFieldArr[n] == nField )
{
nFieldPos = n;
bFound = sal_True;
}
}
return nFieldPos;
}
// -----------------------------------------------------------------------
ScSubTotalFunc ScTpSubTotalGroup::LbPosToFunc( sal_uInt16 nPos )
{
switch ( nPos )
{
// case 0: return SUBTOTAL_FUNC_NONE;
case 2: return SUBTOTAL_FUNC_AVE;
case 6: return SUBTOTAL_FUNC_CNT;
case 1: return SUBTOTAL_FUNC_CNT2;
case 3: return SUBTOTAL_FUNC_MAX;
case 4: return SUBTOTAL_FUNC_MIN;
case 5: return SUBTOTAL_FUNC_PROD;
case 7: return SUBTOTAL_FUNC_STD;
case 8: return SUBTOTAL_FUNC_STDP;
case 0: return SUBTOTAL_FUNC_SUM;
case 9: return SUBTOTAL_FUNC_VAR;
case 10: return SUBTOTAL_FUNC_VARP;
default:
DBG_ERROR( "ScTpSubTotalGroup::LbPosToFunc" );
return SUBTOTAL_FUNC_NONE;
}
}
// -----------------------------------------------------------------------
sal_uInt16 ScTpSubTotalGroup::FuncToLbPos( ScSubTotalFunc eFunc )
{
switch ( eFunc )
{
// case SUBTOTAL_FUNC_NONE: return 0;
case SUBTOTAL_FUNC_AVE: return 2;
case SUBTOTAL_FUNC_CNT: return 6;
case SUBTOTAL_FUNC_CNT2: return 1;
case SUBTOTAL_FUNC_MAX: return 3;
case SUBTOTAL_FUNC_MIN: return 4;
case SUBTOTAL_FUNC_PROD: return 5;
case SUBTOTAL_FUNC_STD: return 7;
case SUBTOTAL_FUNC_STDP: return 8;
case SUBTOTAL_FUNC_SUM: return 0;
case SUBTOTAL_FUNC_VAR: return 9;
case SUBTOTAL_FUNC_VARP: return 10;
default:
DBG_ERROR( "ScTpSubTotalGroup::FuncToLbPos" );
return 0;
}
}
// -----------------------------------------------------------------------
// Handler:
//---------
IMPL_LINK( ScTpSubTotalGroup, SelectHdl, ListBox *, pLb )
{
if ( (aLbColumns.GetEntryCount() > 0)
&& (aLbColumns.GetSelectionCount() > 0) )
{
sal_uInt16 nFunction = aLbFunctions.GetSelectEntryPos();
sal_uInt16 nColumn = aLbColumns.GetSelectEntryPos();
sal_uInt16* pFunction = (sal_uInt16*)aLbColumns.GetEntryData( nColumn );
DBG_ASSERT( pFunction, "EntryData nicht gefunden!" );
if ( !pFunction )
return 0;
if ( ((SvxCheckListBox*)pLb) == &aLbColumns )
{
aLbFunctions.SelectEntryPos( *pFunction );
}
else if ( pLb == &aLbFunctions )
{
*pFunction = nFunction;
// aLbColumns.CheckEntryPos( nColumn, (nFunction != 0) );//XXX
aLbColumns.CheckEntryPos( nColumn, sal_True );
}
}
return 0;
}
// -----------------------------------------------------------------------
IMPL_LINK( ScTpSubTotalGroup, CheckHdl, ListBox *, pLb )
{
if ( ((SvxCheckListBox*)pLb) == &aLbColumns )
{
SvLBoxEntry* pEntry = aLbColumns.GetHdlEntry();
if ( pEntry )
{
aLbColumns.SelectEntryPos( (sal_uInt16)aLbColumns.GetModel()->GetAbsPos( pEntry ) );
SelectHdl( pLb );
}
}
return 0;
}
//========================================================================
// Abgeleitete Gruppen-TabPages:
SfxTabPage* __EXPORT ScTpSubTotalGroup1::Create( Window* pParent,
const SfxItemSet& rArgSet )
{ return ( new ScTpSubTotalGroup1( pParent, rArgSet ) ); }
// -----------------------------------------------------------------------
SfxTabPage* __EXPORT ScTpSubTotalGroup2::Create( Window* pParent,
const SfxItemSet& rArgSet )
{ return ( new ScTpSubTotalGroup2( pParent, rArgSet ) ); }
// -----------------------------------------------------------------------
SfxTabPage* __EXPORT ScTpSubTotalGroup3::Create( Window* pParent,
const SfxItemSet& rArgSet )
{ return ( new ScTpSubTotalGroup3( pParent, rArgSet ) ); }
// -----------------------------------------------------------------------
ScTpSubTotalGroup1::ScTpSubTotalGroup1( Window* pParent, const SfxItemSet& rArgSet ) :
ScTpSubTotalGroup( pParent, RID_SCPAGE_SUBT_GROUP1, rArgSet )
{}
ScTpSubTotalGroup2::ScTpSubTotalGroup2( Window* pParent, const SfxItemSet& rArgSet ) :
ScTpSubTotalGroup( pParent, RID_SCPAGE_SUBT_GROUP2, rArgSet )
{}
ScTpSubTotalGroup3::ScTpSubTotalGroup3( Window* pParent, const SfxItemSet& rArgSet ) :
ScTpSubTotalGroup( pParent, RID_SCPAGE_SUBT_GROUP3, rArgSet )
{}
// -----------------------------------------------------------------------
#define RESET(i) (ScTpSubTotalGroup::DoReset( (i), rArgSet ))
void __EXPORT ScTpSubTotalGroup1::Reset( const SfxItemSet& rArgSet ) { RESET(1); }
void __EXPORT ScTpSubTotalGroup2::Reset( const SfxItemSet& rArgSet ) { RESET(2); }
void __EXPORT ScTpSubTotalGroup3::Reset( const SfxItemSet& rArgSet ) { RESET(3); }
#undef RESET
// -----------------------------------------------------------------------
#define FILLSET(i) (ScTpSubTotalGroup::DoFillItemSet( (i), rArgSet ))
sal_Bool __EXPORT ScTpSubTotalGroup1::FillItemSet( SfxItemSet& rArgSet ) { return FILLSET(1); }
sal_Bool __EXPORT ScTpSubTotalGroup2::FillItemSet( SfxItemSet& rArgSet ) { return FILLSET(2); }
sal_Bool __EXPORT ScTpSubTotalGroup3::FillItemSet( SfxItemSet& rArgSet ) { return FILLSET(3); }
#undef FILL
//========================================================================
// Optionen-Tabpage:
ScTpSubTotalOptions::ScTpSubTotalOptions( Window* pParent,
const SfxItemSet& rArgSet )
: SfxTabPage ( pParent,
ScResId( RID_SCPAGE_SUBT_OPTIONS ),
rArgSet ),
//
aFlGroup ( this, ScResId( FL_GROUP ) ),
aBtnPagebreak ( this, ScResId( BTN_PAGEBREAK ) ),
aBtnCase ( this, ScResId( BTN_CASE ) ),
aBtnSort ( this, ScResId( BTN_SORT ) ),
aFlSort ( this, ScResId( FL_SORT ) ),
aBtnAscending ( this, ScResId( BTN_ASCENDING ) ),
aBtnDescending ( this, ScResId( BTN_DESCENDING ) ),
aBtnFormats ( this, ScResId( BTN_FORMATS ) ),
aBtnUserDef ( this, ScResId( BTN_USERDEF ) ),
aLbUserDef ( this, ScResId( LB_USERDEF ) ),
//
pViewData ( NULL ),
pDoc ( NULL ),
nWhichSubTotals ( rArgSet.GetPool()->GetWhich( SID_SUBTOTALS ) ),
rSubTotalData ( ((const ScSubTotalItem&)
rArgSet.Get( nWhichSubTotals )).
GetSubTotalData() )
{
Init();
FreeResource();
}
// -----------------------------------------------------------------------
__EXPORT ScTpSubTotalOptions::~ScTpSubTotalOptions()
{
}
// -----------------------------------------------------------------------
void ScTpSubTotalOptions::Init()
{
const ScSubTotalItem& rSubTotalItem = (const ScSubTotalItem&)
GetItemSet().Get( nWhichSubTotals );
pViewData = rSubTotalItem.GetViewData();
pDoc = ( pViewData ) ? pViewData->GetDocument() : NULL;
DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
aBtnSort.SetClickHdl ( LINK( this, ScTpSubTotalOptions, CheckHdl ) );
aBtnUserDef.SetClickHdl ( LINK( this, ScTpSubTotalOptions, CheckHdl ) );
FillUserSortListBox();
}
// -----------------------------------------------------------------------
SfxTabPage* __EXPORT ScTpSubTotalOptions::Create( Window* pParent,
const SfxItemSet& rArgSet )
{
return ( new ScTpSubTotalOptions( pParent, rArgSet ) );
}
// -----------------------------------------------------------------------
void __EXPORT ScTpSubTotalOptions::Reset( const SfxItemSet& /* rArgSet */ )
{
aBtnPagebreak.Check ( rSubTotalData.bPagebreak );
aBtnCase.Check ( rSubTotalData.bCaseSens );
aBtnFormats.Check ( rSubTotalData.bIncludePattern );
aBtnSort.Check ( rSubTotalData.bDoSort );
aBtnAscending.Check ( rSubTotalData.bAscending );
aBtnDescending.Check( !rSubTotalData.bAscending );
if ( rSubTotalData.bUserDef )
{
aBtnUserDef.Check( sal_True );
aLbUserDef.Enable();
aLbUserDef.SelectEntryPos( rSubTotalData.nUserIndex );
}
else
{
aBtnUserDef.Check( sal_False );
aLbUserDef.Disable();
aLbUserDef.SelectEntryPos( 0 );
}
CheckHdl( &aBtnSort );
}
// -----------------------------------------------------------------------
sal_Bool __EXPORT ScTpSubTotalOptions::FillItemSet( SfxItemSet& rArgSet )
{
ScSubTotalParam theSubTotalData; // auslesen, wenn schon teilweise gefuellt
SfxTabDialog* pDlg = GetTabDialog();
if ( pDlg )
{
const SfxItemSet* pExample = pDlg->GetExampleSet();
const SfxPoolItem* pItem;
if ( pExample && pExample->GetItemState( nWhichSubTotals, sal_True, &pItem ) == SFX_ITEM_SET )
theSubTotalData = ((const ScSubTotalItem*)pItem)->GetSubTotalData();
}
theSubTotalData.bPagebreak = aBtnPagebreak.IsChecked();
theSubTotalData.bReplace = sal_True;
theSubTotalData.bCaseSens = aBtnCase.IsChecked();
theSubTotalData.bIncludePattern = aBtnFormats.IsChecked();
theSubTotalData.bDoSort = aBtnSort.IsChecked();
theSubTotalData.bAscending = aBtnAscending.IsChecked();
theSubTotalData.bUserDef = aBtnUserDef.IsChecked();
theSubTotalData.nUserIndex = (aBtnUserDef.IsChecked())
? aLbUserDef.GetSelectEntryPos()
: 0;
rArgSet.Put( ScSubTotalItem( nWhichSubTotals, &theSubTotalData ) );
return sal_True;
}
// -----------------------------------------------------------------------
void ScTpSubTotalOptions::FillUserSortListBox()
{
ScUserList* pUserLists = ScGlobal::GetUserList();
aLbUserDef.Clear();
if ( pUserLists )
{
sal_uInt16 nCount = pUserLists->GetCount();
if ( nCount > 0 )
for ( sal_uInt16 i=0; i<nCount; i++ )
aLbUserDef.InsertEntry( (*pUserLists)[i]->GetString() );
}
}
// -----------------------------------------------------------------------
// Handler:
IMPL_LINK( ScTpSubTotalOptions, CheckHdl, CheckBox *, pBox )
{
if ( pBox == &aBtnSort )
{
if ( aBtnSort.IsChecked() )
{
aFlSort .Enable();
aBtnFormats .Enable();
aBtnUserDef .Enable();
aBtnAscending .Enable();
aBtnDescending .Enable();
if ( aBtnUserDef.IsChecked() )
aLbUserDef.Enable();
}
else
{
aFlSort .Disable();
aBtnFormats .Disable();
aBtnUserDef .Disable();
aBtnAscending .Disable();
aBtnDescending .Disable();
aLbUserDef .Disable();
}
}
else if ( pBox == &aBtnUserDef )
{
if ( aBtnUserDef.IsChecked() )
{
aLbUserDef.Enable();
aLbUserDef.GrabFocus();
}
else
aLbUserDef.Disable();
}
return 0;
}
__EXPORT ScTpSubTotalGroup1::~ScTpSubTotalGroup1()
{
}
__EXPORT ScTpSubTotalGroup2::~ScTpSubTotalGroup2()
{
}
__EXPORT ScTpSubTotalGroup3::~ScTpSubTotalGroup3()
{
}
|