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
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: autofmt.cxx,v $
* $Revision: 1.19.122.1 $
*
* 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"
//------------------------------------------------------------------
#include "scitems.hxx"
#include <svx/algitem.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/brshitem.hxx>
#include <editeng/cntritem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/crsditem.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/postitem.hxx>
#include <editeng/shdditem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/wghtitem.hxx>
#include <sfx2/topfrm.hxx>
#include <vcl/svapp.hxx>
#include <svl/zforlist.hxx>
#include <vcl/msgbox.hxx>
#include <comphelper/processfactory.hxx>
#include "sc.hrc"
#include "scmod.hxx"
#include "attrib.hxx"
#include "zforauto.hxx"
#include "scitems.hxx"
#include "global.hxx"
#include "globstr.hrc"
#include "autoform.hxx"
//CHINA001 #include "strindlg.hxx"
#include "miscdlgs.hrc"
#include "autofmt.hxx"
#include "scresid.hxx"
#include "document.hxx"
#include "docsh.hxx"
#include "tabvwsh.hxx"
#define FRAME_OFFSET 4
BOOL bIsOlk = FALSE;
//CHINA001 //========================================================================
//CHINA001 // AutoFormat-Dialog:
//CHINA001
//CHINA001 ScAutoFormatDlg::ScAutoFormatDlg( Window* pParent,
//CHINA001 ScAutoFormat* pAutoFormat,
//CHINA001 const ScAutoFormatData* pSelFormatData,
//CHINA001 ScDocument* pDoc ) :
//CHINA001
//CHINA001 ModalDialog ( pParent, ScResId( RID_SCDLG_AUTOFORMAT ) ),
//CHINA001 //
//CHINA001 aLbFormat ( this, ScResId( LB_FORMAT ) ),
//CHINA001 aFlFormat ( this, ScResId( FL_FORMAT ) ),
//CHINA001 pWndPreview ( new ScAutoFmtPreview( this, ScResId( WND_PREVIEW ), pDoc ) ),
//CHINA001 aBtnNumFormat ( this, ScResId( BTN_NUMFORMAT ) ),
//CHINA001 aBtnBorder ( this, ScResId( BTN_BORDER ) ),
//CHINA001 aBtnFont ( this, ScResId( BTN_FONT ) ),
//CHINA001 aBtnPattern ( this, ScResId( BTN_PATTERN ) ),
//CHINA001 aBtnAlignment ( this, ScResId( BTN_ALIGNMENT ) ),
//CHINA001 aBtnAdjust ( this, ScResId( BTN_ADJUST ) ),
//CHINA001 aFlFormatting ( this, ScResId( FL_FORMATTING ) ),
//CHINA001 aBtnOk ( this, ScResId( BTN_OK ) ),
//CHINA001 aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
//CHINA001 aBtnHelp ( this, ScResId( BTN_HELP ) ),
//CHINA001 aBtnAdd ( this, ScResId( BTN_ADD ) ),
//CHINA001 aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
//CHINA001 aBtnMore ( this, ScResId( BTN_MORE ) ),
//CHINA001 aBtnRename ( this, ScResId( BTN_RENAME ) ),
//CHINA001 aStrTitle ( ScResId( STR_ADD_TITLE ) ),
//CHINA001 aStrLabel ( ScResId( STR_ADD_LABEL ) ),
//CHINA001 aStrRename ( ScResId( STR_RENAME_TITLE ) ),
//CHINA001 aStrClose ( ScResId( STR_BTN_CLOSE ) ),
//CHINA001 aStrDelTitle ( ScResId( STR_DEL_TITLE ) ),
//CHINA001 aStrDelMsg ( ScResId( STR_DEL_MSG ) ) ,
//CHINA001 //
//CHINA001 nIndex ( 0 ),
//CHINA001 bFmtInserted ( FALSE ),
//CHINA001 bCoreDataChanged( FALSE ),
//CHINA001 pFormat ( pAutoFormat ),
//CHINA001 pSelFmtData ( pSelFormatData )
//CHINA001 {
//CHINA001 Init();
//CHINA001 pWndPreview->NotifyChange( (*pFormat)[0] );
//CHINA001 FreeResource();
//CHINA001 }
//CHINA001
//CHINA001 //------------------------------------------------------------------------
//CHINA001
//CHINA001 ScAutoFormatDlg::~ScAutoFormatDlg()
//CHINA001 {
//CHINA001 delete pWndPreview;
//CHINA001 }
//CHINA001
//CHINA001 //------------------------------------------------------------------------
//CHINA001
//CHINA001 void ScAutoFormatDlg::Init()
//CHINA001 {
//CHINA001 USHORT nCount;
//CHINA001 String aEntry;
//CHINA001
//CHINA001 aLbFormat .SetSelectHdl( LINK( this, ScAutoFormatDlg, SelFmtHdl ) );
//CHINA001 aBtnNumFormat.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
//CHINA001 aBtnBorder .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
//CHINA001 aBtnFont .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
//CHINA001 aBtnPattern .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
//CHINA001 aBtnAlignment.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
//CHINA001 aBtnAdjust .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
//CHINA001 aBtnAdd .SetClickHdl ( LINK( this, ScAutoFormatDlg, AddHdl ) );
//CHINA001 aBtnRemove .SetClickHdl ( LINK( this, ScAutoFormatDlg, RemoveHdl ) );
//CHINA001 aBtnOk .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
//CHINA001 aBtnCancel .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
//CHINA001 aBtnRename .SetClickHdl ( LINK( this, ScAutoFormatDlg, RenameHdl ) );
//CHINA001 aLbFormat .SetDoubleClickHdl( LINK( this, ScAutoFormatDlg, DblClkHdl ) );
//CHINA001
//CHINA001 aBtnMore.AddWindow( &aBtnRename );
//CHINA001 aBtnMore.AddWindow( &aBtnNumFormat );
//CHINA001 aBtnMore.AddWindow( &aBtnBorder );
//CHINA001 aBtnMore.AddWindow( &aBtnFont );
//CHINA001 aBtnMore.AddWindow( &aBtnPattern );
//CHINA001 aBtnMore.AddWindow( &aBtnAlignment );
//CHINA001 aBtnMore.AddWindow( &aBtnAdjust );
//CHINA001 aBtnMore.AddWindow( &aFlFormatting );
//CHINA001
//CHINA001 nCount = pFormat->GetCount();
//CHINA001
//CHINA001 for ( USHORT i = 0; i < nCount; i++ )
//CHINA001 {
//CHINA001 ((*pFormat)[i])->GetName( aEntry );
//CHINA001 aLbFormat.InsertEntry( aEntry );
//CHINA001 }
//CHINA001
//CHINA001 if ( nCount == 1 )
//CHINA001 aBtnRemove.Disable();
//CHINA001
//CHINA001 aLbFormat.SelectEntryPos( 0 );
//CHINA001 aBtnRename.Disable();
//CHINA001 aBtnRemove.Disable();
//CHINA001
//CHINA001 nIndex = 0;
//CHINA001 UpdateChecks();
//CHINA001
//CHINA001 if ( !pSelFmtData )
//CHINA001 {
//CHINA001 aBtnAdd.Disable();
//CHINA001 aBtnRemove.Disable();
//CHINA001 bFmtInserted = TRUE;
//CHINA001 }
//CHINA001 }
//CHINA001
//CHINA001 //------------------------------------------------------------------------
//CHINA001
//CHINA001 void ScAutoFormatDlg::UpdateChecks()
//CHINA001 {
//CHINA001 ScAutoFormatData* pData = (*pFormat)[nIndex];
//CHINA001
//CHINA001 aBtnNumFormat.Check( pData->GetIncludeValueFormat() );
//CHINA001 aBtnBorder .Check( pData->GetIncludeFrame() );
//CHINA001 aBtnFont .Check( pData->GetIncludeFont() );
//CHINA001 aBtnPattern .Check( pData->GetIncludeBackground() );
//CHINA001 aBtnAlignment.Check( pData->GetIncludeJustify() );
//CHINA001 aBtnAdjust .Check( pData->GetIncludeWidthHeight() );
//CHINA001 }
//CHINA001
//CHINA001 //------------------------------------------------------------------------
//CHINA001 // Handler:
//CHINA001 //---------
//CHINA001
//CHINA001 IMPL_LINK( ScAutoFormatDlg, CloseHdl, PushButton *, pBtn )
//CHINA001 {
//CHINA001 if ( pBtn == &aBtnOk || pBtn == &aBtnCancel )
//CHINA001 {
//CHINA001 if ( bCoreDataChanged )
//CHINA001 ScGlobal::GetAutoFormat()->Save();
//CHINA001
//CHINA001 EndDialog( (pBtn == &aBtnOk) ? RET_OK : RET_CANCEL );
//CHINA001 }
//CHINA001 return 0;
//CHINA001 }
//CHINA001
//CHINA001 //------------------------------------------------------------------------
//CHINA001
//CHINA001 IMPL_LINK_INLINE_START( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG )
//CHINA001 {
//CHINA001 if ( bCoreDataChanged )
//CHINA001 ScGlobal::GetAutoFormat()->Save();
//CHINA001
//CHINA001 EndDialog( RET_OK );
//CHINA001 return 0;
//CHINA001 }
//CHINA001 IMPL_LINK_INLINE_END( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG )
//CHINA001
//CHINA001 //------------------------------------------------------------------------
//CHINA001
//CHINA001 IMPL_LINK( ScAutoFormatDlg, CheckHdl, Button *, pBtn )
//CHINA001 {
//CHINA001 ScAutoFormatData* pData = (*pFormat)[nIndex];
//CHINA001 BOOL bCheck = ((CheckBox*)pBtn)->IsChecked();
//CHINA001
//CHINA001 if ( pBtn == &aBtnNumFormat )
//CHINA001 pData->SetIncludeValueFormat( bCheck );
//CHINA001 else if ( pBtn == &aBtnBorder )
//CHINA001 pData->SetIncludeFrame( bCheck );
//CHINA001 else if ( pBtn == &aBtnFont )
//CHINA001 pData->SetIncludeFont( bCheck );
//CHINA001 else if ( pBtn == &aBtnPattern )
//CHINA001 pData->SetIncludeBackground( bCheck );
//CHINA001 else if ( pBtn == &aBtnAlignment )
//CHINA001 pData->SetIncludeJustify( bCheck );
//CHINA001 else if ( pBtn == &aBtnAdjust )
//CHINA001 pData->SetIncludeWidthHeight( bCheck );
//CHINA001
//CHINA001 if ( !bCoreDataChanged )
//CHINA001 {
//CHINA001 aBtnCancel.SetText( aStrClose );
//CHINA001 bCoreDataChanged = TRUE;
//CHINA001 }
//CHINA001
//CHINA001 pWndPreview->NotifyChange( pData );
//CHINA001
//CHINA001 return 0;
//CHINA001 }
//CHINA001
//CHINA001 //------------------------------------------------------------------------
//CHINA001
//CHINA001 IMPL_LINK( ScAutoFormatDlg, AddHdl, void *, EMPTYARG )
//CHINA001 {
//CHINA001 if ( !bFmtInserted && pSelFmtData )
//CHINA001 {
//CHINA001 String aStrStandard( ScResId(STR_STANDARD) );
//CHINA001 String aFormatName;
//CHINA001 ScStringInputDlg* pDlg;
//CHINA001 BOOL bOk = FALSE;
//CHINA001
//CHINA001 while ( !bOk )
//CHINA001 {
//CHINA001 pDlg = new ScStringInputDlg( this,
//CHINA001 aStrTitle,
//CHINA001 aStrLabel,
//CHINA001 aFormatName,
//CHINA001 HID_SC_ADD_AUTOFMT );
//CHINA001
//CHINA001 if ( pDlg->Execute() == RET_OK )
//CHINA001 {
//CHINA001 pDlg->GetInputString( aFormatName );
//CHINA001
//CHINA001 if ( (aFormatName.Len() > 0) && (aFormatName != aStrStandard) )
//CHINA001 {
//CHINA001 ScAutoFormatData* pNewData
//CHINA001 = new ScAutoFormatData( *pSelFmtData );
//CHINA001
//CHINA001 pNewData->SetName( aFormatName );
//CHINA001 bFmtInserted = pFormat->Insert( pNewData );
//CHINA001
//CHINA001 if ( bFmtInserted )
//CHINA001 {
//CHINA001 USHORT nAt = pFormat->IndexOf( pNewData );
//CHINA001
//CHINA001 aLbFormat.InsertEntry( aFormatName, nAt );
//CHINA001 aLbFormat.SelectEntry( aFormatName );
//CHINA001 aBtnAdd.Disable();
//CHINA001
//CHINA001 if ( !bCoreDataChanged )
//CHINA001 {
//CHINA001 aBtnCancel.SetText( aStrClose );
//CHINA001 bCoreDataChanged = TRUE;
//CHINA001 }
//CHINA001
//CHINA001 SelFmtHdl( 0 );
//CHINA001 bOk = TRUE;
//CHINA001 }
//CHINA001 else
//CHINA001 delete pNewData;
//CHINA001
//CHINA001 }
//CHINA001
//CHINA001 if ( !bFmtInserted )
//CHINA001 {
//CHINA001 USHORT nRet = ErrorBox( this,
//CHINA001 WinBits( WB_OK_CANCEL | WB_DEF_OK),
//CHINA001 ScGlobal::GetRscString(STR_INVALID_AFNAME)
//CHINA001 ).Execute();
//CHINA001
//CHINA001 bOk = ( nRet == RET_CANCEL );
//CHINA001 }
//CHINA001 }
//CHINA001 else
//CHINA001 bOk = TRUE;
//CHINA001
//CHINA001 delete pDlg;
//CHINA001 }
//CHINA001 }
//CHINA001
//CHINA001 return 0;
//CHINA001 }
//CHINA001
//CHINA001 //------------------------------------------------------------------------
//CHINA001
//CHINA001 IMPL_LINK( ScAutoFormatDlg, RemoveHdl, void *, EMPTYARG )
//CHINA001 {
//CHINA001 if ( (nIndex > 0) && (aLbFormat.GetEntryCount() > 0) )
//CHINA001 {
//CHINA001 String aMsg( aStrDelMsg.GetToken( 0, '#' ) );
//CHINA001
//CHINA001 aMsg += aLbFormat.GetSelectEntry();
//CHINA001 aMsg += aStrDelMsg.GetToken( 1, '#' );
//CHINA001
//CHINA001 if ( RET_YES ==
//CHINA001 QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() )
//CHINA001 {
//CHINA001 aLbFormat.RemoveEntry( nIndex );
//CHINA001 aLbFormat.SelectEntryPos( nIndex-1 );
//CHINA001
//CHINA001 if ( nIndex-1 == 0 )
//CHINA001 aBtnRemove.Disable();
//CHINA001
//CHINA001 if ( !bCoreDataChanged )
//CHINA001 {
//CHINA001 aBtnCancel.SetText( aStrClose );
//CHINA001 bCoreDataChanged = TRUE;
//CHINA001 }
//CHINA001
//CHINA001 pFormat->AtFree( nIndex ); // in der Core loeschen
//CHINA001 nIndex--;
//CHINA001
//CHINA001 SelFmtHdl( 0 );
//CHINA001 }
//CHINA001 }
//CHINA001
//CHINA001 SelFmtHdl( 0 );
//CHINA001
//CHINA001 return 0;
//CHINA001 }
//CHINA001
//CHINA001 IMPL_LINK( ScAutoFormatDlg, RenameHdl, void *, pBtn)
//CHINA001 {
//CHINA001 BOOL bOk = FALSE;
//CHINA001 while( !bOk )
//CHINA001 {
//CHINA001
//CHINA001 String aFormatName=aLbFormat.GetSelectEntry();
//CHINA001 String aEntry;
//CHINA001
//CHINA001 ScStringInputDlg* pDlg = new ScStringInputDlg( this,
//CHINA001 aStrRename,
//CHINA001 aStrLabel,
//CHINA001 aFormatName,
//CHINA001 HID_SC_RENAME_AUTOFMT );
//CHINA001 if( pDlg->Execute() == RET_OK )
//CHINA001 {
//CHINA001 BOOL bFmtRenamed = FALSE;
//CHINA001 pDlg->GetInputString( aFormatName );
//CHINA001 USHORT n;
//CHINA001
//CHINA001 if ( aFormatName.Len() > 0 )
//CHINA001 {
//CHINA001 for( n = 0; n < pFormat->GetCount(); ++n )
//CHINA001 {
//CHINA001 (*pFormat)[n]->GetName(aEntry);
//CHINA001 if ( aEntry== aFormatName)
//CHINA001 break;
//CHINA001 }
//CHINA001 if( n >= pFormat->GetCount() )
//CHINA001 {
//CHINA001 // Format mit dem Namen noch nicht vorhanden, also
//CHINA001 // umbenennen
//CHINA001
//CHINA001 aLbFormat.RemoveEntry(nIndex );
//CHINA001 ScAutoFormatData* p=(*pFormat)[ nIndex ];
//CHINA001 ScAutoFormatData* pNewData
//CHINA001 = new ScAutoFormatData(*p);
//CHINA001
//CHINA001 pFormat->AtFree( nIndex );
//CHINA001
//CHINA001 pNewData->SetName( aFormatName );
//CHINA001
//CHINA001 pFormat->Insert( pNewData);
//CHINA001
//CHINA001 USHORT nCount = pFormat->GetCount();
//CHINA001
//CHINA001 aLbFormat.SetUpdateMode(FALSE);
//CHINA001 aLbFormat.Clear();
//CHINA001 for ( USHORT i = 0; i < nCount; i++ )
//CHINA001 {
//CHINA001 ((*pFormat)[i])->GetName( aEntry );
//CHINA001 aLbFormat.InsertEntry( aEntry );
//CHINA001 }
//CHINA001
//CHINA001 aLbFormat.SetUpdateMode( TRUE);
//CHINA001 aLbFormat.SelectEntry( aFormatName);
//CHINA001
//CHINA001 if ( !bCoreDataChanged )
//CHINA001 {
//CHINA001 aBtnCancel.SetText( aStrClose );
//CHINA001 bCoreDataChanged = TRUE;
//CHINA001 }
//CHINA001
//CHINA001
//CHINA001 SelFmtHdl( 0 );
//CHINA001 bOk = TRUE;
//CHINA001 bFmtRenamed = TRUE;
//CHINA001 }
//CHINA001 }
//CHINA001 if( !bFmtRenamed )
//CHINA001 {
//CHINA001 bOk = RET_CANCEL == ErrorBox( this,
//CHINA001 WinBits( WB_OK_CANCEL | WB_DEF_OK),
//CHINA001 ScGlobal::GetRscString(STR_INVALID_AFNAME)
//CHINA001 ).Execute();
//CHINA001 }
//CHINA001 }
//CHINA001 else
//CHINA001 bOk = TRUE;
//CHINA001 delete pDlg;
//CHINA001 }
//CHINA001
//CHINA001 return 0;
//CHINA001 }
//CHINA001
//CHINA001 //------------------------------------------------------------------------
//CHINA001
//CHINA001 IMPL_LINK( ScAutoFormatDlg, SelFmtHdl, void *, EMPTYARG )
//CHINA001 {
//CHINA001 nIndex = aLbFormat.GetSelectEntryPos();
//CHINA001 UpdateChecks();
//CHINA001
//CHINA001 if ( nIndex == 0 )
//CHINA001 {
//CHINA001 aBtnRename.Disable();
//CHINA001 aBtnRemove.Disable();
//CHINA001 }
//CHINA001 else
//CHINA001 {
//CHINA001 aBtnRename.Enable();
//CHINA001 aBtnRemove.Enable();
//CHINA001 }
//CHINA001
//CHINA001 pWndPreview->NotifyChange( (*pFormat)[nIndex] );
//CHINA001
//CHINA001 return 0;
//CHINA001 }
//CHINA001
//CHINA001 //------------------------------------------------------------------------
//CHINA001
//CHINA001 String ScAutoFormatDlg::GetCurrFormatName()
//CHINA001 {
//CHINA001 String aResult;
//CHINA001
//CHINA001 ((*pFormat)[nIndex])->GetName( aResult );
//CHINA001
//CHINA001 return aResult;
//CHINA001 }
//CHINA001
//========================================================================
// ScAutoFmtPreview
ScAutoFmtPreview::ScAutoFmtPreview( Window* pParent, const ResId& rRes, ScDocument* pDoc ) :
Window ( pParent, rRes ),
pCurData ( NULL ),
aVD ( *this ),
aScriptedText ( aVD ),
xBreakIter ( pDoc->GetBreakIterator() ),
bFitWidth ( FALSE ),
mbRTL ( false ),
aPrvSize ( GetSizePixel().Width() - 6, GetSizePixel().Height() - 30 ),
mnLabelColWidth ( (aPrvSize.Width() - 4) / 4 - 12 ),
mnDataColWidth1 ( (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 3 ),
mnDataColWidth2 ( (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 4 ),
mnRowHeight ( (aPrvSize.Height() - 4) / 5 ),
aStrJan ( ScResId( STR_JAN ) ),
aStrFeb ( ScResId( STR_FEB ) ),
aStrMar ( ScResId( STR_MAR ) ),
aStrNorth ( ScResId( STR_NORTH ) ),
aStrMid ( ScResId( STR_MID ) ),
aStrSouth ( ScResId( STR_SOUTH ) ),
aStrSum ( ScResId( STR_SUM ) ),
pNumFmt ( new SvNumberFormatter( ::comphelper::getProcessServiceFactory(), ScGlobal::eLnge ) )
{
Init();
if( bIsOlk )
((String&)aStrMar).AssignAscii(RTL_CONSTASCII_STRINGPARAM( "Olk" ));
}
//------------------------------------------------------------------------
ScAutoFmtPreview::~ScAutoFmtPreview()
{
delete pNumFmt;
}
//------------------------------------------------------------------------
void lcl_SetFontProperties(
Font& rFont,
const SvxFontItem& rFontItem,
const SvxWeightItem& rWeightItem,
const SvxPostureItem& rPostureItem )
{
rFont.SetFamily ( rFontItem.GetFamily() );
rFont.SetName ( rFontItem.GetFamilyName() );
rFont.SetStyleName ( rFontItem.GetStyleName() );
rFont.SetCharSet ( rFontItem.GetCharSet() );
rFont.SetPitch ( rFontItem.GetPitch() );
rFont.SetWeight ( (FontWeight)rWeightItem.GetValue() );
rFont.SetItalic ( (FontItalic)rPostureItem.GetValue() );
}
void ScAutoFmtPreview::MakeFonts( USHORT nIndex, Font& rFont, Font& rCJKFont, Font& rCTLFont )
{
if ( pCurData )
{
rFont = rCJKFont = rCTLFont = GetFont();
Size aFontSize( rFont.GetSize().Width(), 10 );
const SvxFontItem* pFontItem = (const SvxFontItem*) pCurData->GetItem( nIndex, ATTR_FONT );
const SvxWeightItem* pWeightItem = (const SvxWeightItem*) pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT );
const SvxPostureItem* pPostureItem = (const SvxPostureItem*) pCurData->GetItem( nIndex, ATTR_FONT_POSTURE );
const SvxFontItem* pCJKFontItem = (const SvxFontItem*) pCurData->GetItem( nIndex, ATTR_CJK_FONT );
const SvxWeightItem* pCJKWeightItem = (const SvxWeightItem*) pCurData->GetItem( nIndex, ATTR_CJK_FONT_WEIGHT );
const SvxPostureItem* pCJKPostureItem = (const SvxPostureItem*) pCurData->GetItem( nIndex, ATTR_CJK_FONT_POSTURE );
const SvxFontItem* pCTLFontItem = (const SvxFontItem*) pCurData->GetItem( nIndex, ATTR_CTL_FONT );
const SvxWeightItem* pCTLWeightItem = (const SvxWeightItem*) pCurData->GetItem( nIndex, ATTR_CTL_FONT_WEIGHT );
const SvxPostureItem* pCTLPostureItem = (const SvxPostureItem*) pCurData->GetItem( nIndex, ATTR_CTL_FONT_POSTURE );
const SvxUnderlineItem* pUnderlineItem = (const SvxUnderlineItem*) pCurData->GetItem( nIndex, ATTR_FONT_UNDERLINE );
const SvxOverlineItem* pOverlineItem = (const SvxOverlineItem*) pCurData->GetItem( nIndex, ATTR_FONT_OVERLINE );
const SvxCrossedOutItem* pCrossedOutItem = (const SvxCrossedOutItem*)pCurData->GetItem( nIndex, ATTR_FONT_CROSSEDOUT );
const SvxContourItem* pContourItem = (const SvxContourItem*) pCurData->GetItem( nIndex, ATTR_FONT_CONTOUR );
const SvxShadowedItem* pShadowedItem = (const SvxShadowedItem*) pCurData->GetItem( nIndex, ATTR_FONT_SHADOWED );
const SvxColorItem* pColorItem = (const SvxColorItem*) pCurData->GetItem( nIndex, ATTR_FONT_COLOR );
lcl_SetFontProperties( rFont, *pFontItem, *pWeightItem, *pPostureItem );
lcl_SetFontProperties( rCJKFont, *pCJKFontItem, *pCJKWeightItem, *pCJKPostureItem );
lcl_SetFontProperties( rCTLFont, *pCTLFontItem, *pCTLWeightItem, *pCTLPostureItem );
Color aColor( pColorItem->GetValue() );
if( aColor.GetColor() == COL_TRANSPARENT )
aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
#define SETONALLFONTS( MethodName, Value ) \
rFont.MethodName( Value ); rCJKFont.MethodName( Value ); rCTLFont.MethodName( Value );
SETONALLFONTS( SetUnderline, (FontUnderline)pUnderlineItem->GetValue() )
SETONALLFONTS( SetOverline, (FontUnderline)pOverlineItem->GetValue() )
SETONALLFONTS( SetStrikeout, (FontStrikeout)pCrossedOutItem->GetValue() )
SETONALLFONTS( SetOutline, pContourItem->GetValue() )
SETONALLFONTS( SetShadow, pShadowedItem->GetValue() )
SETONALLFONTS( SetColor, aColor )
SETONALLFONTS( SetSize, aFontSize )
SETONALLFONTS( SetTransparent, TRUE )
#undef SETONALLFONTS
}
}
//------------------------------------------------------------------------
USHORT ScAutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
{
static const USHORT pnFmtMap[] =
{
0, 1, 2, 1, 3,
4, 5, 6, 5, 7,
8, 9, 10, 9, 11,
4, 5, 6, 5, 7,
12, 13, 14, 13, 15
};
return pnFmtMap[ maArray.GetCellIndex( nCol, nRow, mbRTL ) ];
}
const SvxBoxItem& ScAutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const
{
DBG_ASSERT( pCurData, "ScAutoFmtPreview::GetBoxItem - no format data found" );
return *static_cast< const SvxBoxItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BORDER ) );
}
const SvxLineItem& ScAutoFmtPreview::GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const
{
DBG_ASSERT( pCurData, "ScAutoFmtPreview::GetDiagItem - no format data found" );
return *static_cast< const SvxLineItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), bTLBR ? ATTR_BORDER_TLBR : ATTR_BORDER_BLTR ) );
}
//------------------------------------------------------------------------
void ScAutoFmtPreview::DrawString( size_t nCol, size_t nRow )
{
if ( pCurData )
{
//------------------------
// Ausgabe des Zelltextes:
//------------------------
String cellString;
BOOL bNumFormat = pCurData->GetIncludeValueFormat();
ULONG nNum;
double nVal;
Color* pDummy = NULL;
USHORT nIndex = static_cast< USHORT >( maArray.GetCellIndex( nCol, nRow, mbRTL ) );
switch( nIndex )
{
case 1: cellString = aStrJan; break;
case 2: cellString = aStrFeb; break;
case 3: cellString = aStrMar; break;
case 5: cellString = aStrNorth; break;
case 10: cellString = aStrMid; break;
case 15: cellString = aStrSouth; break;
case 4:
case 20: cellString = aStrSum; break;
case 6:
case 8:
case 16:
case 18: nVal = nIndex;
nNum = 5;
goto mknum;
case 17:
case 7: nVal = nIndex;
nNum = 6;
goto mknum;
case 11:
case 12:
case 13: nVal = nIndex;
nNum = 12 == nIndex ? 10 : 9;
goto mknum;
case 9: nVal = 21; nNum = 7; goto mknum;
case 14: nVal = 36; nNum = 11; goto mknum;
case 19: nVal = 51; nNum = 7; goto mknum;
case 21: nVal = 33; nNum = 13; goto mknum;
case 22: nVal = 36; nNum = 14; goto mknum;
case 23: nVal = 39; nNum = 13; goto mknum;
case 24: nVal = 108; nNum = 15;
mknum:
if( bNumFormat )
{
ScNumFormatAbbrev& rNumFormat = (ScNumFormatAbbrev&)pCurData->GetNumFormat( (USHORT) nNum );
nNum = rNumFormat.GetFormatIndex( *pNumFmt );
}
else
nNum = 0;
pNumFmt->GetOutputString( nVal, nNum, cellString, &pDummy );
break;
}
if ( cellString.Len() > 0 )
{
Size aStrSize;
USHORT nFmtIndex = GetFormatIndex( nCol, nRow );
Rectangle cellRect = maArray.GetCellRect( nCol, nRow );
Point aPos = cellRect.TopLeft();
USHORT nRightX = 0;
BOOL bJustify = pCurData->GetIncludeJustify();
SvxHorJustifyItem aHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY );
SvxCellHorJustify eJustification;
//-------------
// Ausrichtung:
//-------------
eJustification = mbRTL ? SVX_HOR_JUSTIFY_RIGHT : bJustify ?
(SvxCellHorJustify)(((const SvxHorJustifyItem*)pCurData->GetItem( nFmtIndex, ATTR_HOR_JUSTIFY ))->GetValue()) :
SVX_HOR_JUSTIFY_STANDARD;
if ( pCurData->GetIncludeFont() )
{
Font aFont, aCJKFont, aCTLFont;
Size theMaxStrSize;
MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont );
theMaxStrSize = cellRect.GetSize();
theMaxStrSize.Width() -= FRAME_OFFSET;
theMaxStrSize.Height() -= FRAME_OFFSET;
aScriptedText.SetFonts( &aFont, &aCJKFont, &aCTLFont );
aScriptedText.SetText( cellString, xBreakIter );
aStrSize = aScriptedText.GetTextSize();
if ( theMaxStrSize.Height() < aStrSize.Height() )
{
// wenn der String in diesem Font nicht
// in die Zelle passt, wird wieder der
// Standard-Font genommen:
aScriptedText.SetDefaultFont();
aStrSize = aScriptedText.GetTextSize();
}
while ( ( theMaxStrSize.Width() <= aStrSize.Width() )
&& ( cellString.Len() > 1 ) )
{
if( eJustification == SVX_HOR_JUSTIFY_RIGHT )
cellString.Erase( 0, 1 );
else
cellString.Erase( cellString.Len() - 1 );
aScriptedText.SetText( cellString, xBreakIter );
aStrSize = aScriptedText.GetTextSize();
}
}
else
{
aScriptedText.SetDefaultFont();
aScriptedText.SetText( cellString, xBreakIter );
aStrSize = aScriptedText.GetTextSize();
}
nRightX = (USHORT)( cellRect.GetWidth()
- aStrSize.Width()
- FRAME_OFFSET );
//-----------------------------
// vertikal (immer zentrieren):
//-----------------------------
aPos.Y() += (mnRowHeight - (USHORT)aStrSize.Height()) / 2;
//-----------
// horizontal
//-----------
if ( eJustification != SVX_HOR_JUSTIFY_STANDARD )
{
USHORT nHorPos = (USHORT)
((cellRect.GetWidth()-aStrSize.Width())/2);
switch ( eJustification )
{
case SVX_HOR_JUSTIFY_LEFT:
aPos.X() += FRAME_OFFSET;
break;
case SVX_HOR_JUSTIFY_RIGHT:
aPos.X() += nRightX;
break;
case SVX_HOR_JUSTIFY_BLOCK:
case SVX_HOR_JUSTIFY_REPEAT:
case SVX_HOR_JUSTIFY_CENTER:
aPos.X() += nHorPos;
break;
case SVX_HOR_JUSTIFY_STANDARD:
default:
// Standard wird hier nicht behandelt
break;
}
}
else
{
//---------------------
// Standardausrichtung:
//---------------------
if ( (nCol == 0) || (nRow == 0) )
{
// Text-Label links oder Summe linksbuendig
aPos.X() += FRAME_OFFSET;
}
else
{
// Zahlen/Datum rechtsbuendig
aPos.X() += nRightX;
}
}
//-------------------------------
aScriptedText.DrawText( aPos );
//-------------------------------
}
}
}
#undef FRAME_OFFSET
//------------------------------------------------------------------------
void ScAutoFmtPreview::DrawStrings()
{
for( size_t nRow = 0; nRow < 5; ++nRow )
for( size_t nCol = 0; nCol < 5; ++nCol )
DrawString( nCol, nRow );
}
//------------------------------------------------------------------------
void ScAutoFmtPreview::DrawBackground()
{
if( pCurData )
{
for( size_t nRow = 0; nRow < 5; ++nRow )
{
for( size_t nCol = 0; nCol < 5; ++nCol )
{
const SvxBrushItem* pItem = static_cast< const SvxBrushItem* >(
pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BACKGROUND ) );
aVD.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
aVD.SetLineColor();
aVD.SetFillColor( pItem->GetColor() );
aVD.DrawRect( maArray.GetCellRect( nCol, nRow ) );
aVD.Pop();
}
}
}
}
//------------------------------------------------------------------------
void ScAutoFmtPreview::PaintCells()
{
if ( pCurData )
{
// 1) background
if ( pCurData->GetIncludeBackground() )
DrawBackground();
// 2) values
DrawStrings();
// 3) border
if ( pCurData->GetIncludeFrame() )
maArray.DrawArray( aVD );
}
}
//------------------------------------------------------------------------
void ScAutoFmtPreview::Init()
{
SetBorderStyle( WINDOW_BORDER_MONO );
maArray.Initialize( 5, 5 );
maArray.SetUseDiagDoubleClipping( false );
CalcCellArray( FALSE );
CalcLineMap();
TypeId aType(TYPE(ScDocShell));
ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
SfxViewShell* p = pFrame->GetViewShell();
ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell* >( p );
ScViewData* pViewData = pViewSh->GetViewData();
SCTAB nCurrentTab = pViewData->GetTabNo();
ScDocument* pDoc = pViewData->GetDocument();
mbRTL = pDoc->IsLayoutRTL( nCurrentTab );
}
//------------------------------------------------------------------------
void ScAutoFmtPreview::CalcCellArray( BOOL bFitWidthP )
{
maArray.SetXOffset( 2 );
maArray.SetAllColWidths( bFitWidthP ? mnDataColWidth2 : mnDataColWidth1 );
maArray.SetColWidth( 0, mnLabelColWidth );
maArray.SetColWidth( 4, mnLabelColWidth );
maArray.SetYOffset( 2 );
maArray.SetAllRowHeights( mnRowHeight );
aPrvSize.Width() = maArray.GetWidth() + 4;
aPrvSize.Height() = maArray.GetHeight() + 4;
}
//------------------------------------------------------------------------
inline void lclSetStyleFromBorder( svx::frame::Style& rStyle, const SvxBorderLine* pBorder )
{
rStyle.Set( pBorder, 1.0 / TWIPS_PER_POINT, 5 );
}
void ScAutoFmtPreview::CalcLineMap()
{
if ( pCurData )
{
for( size_t nRow = 0; nRow < 5; ++nRow )
{
for( size_t nCol = 0; nCol < 5; ++nCol )
{
svx::frame::Style aStyle;
const SvxBoxItem& rItem = GetBoxItem( nCol, nRow );
lclSetStyleFromBorder( aStyle, rItem.GetLeft() );
maArray.SetCellStyleLeft( nCol, nRow, aStyle );
lclSetStyleFromBorder( aStyle, rItem.GetRight() );
maArray.SetCellStyleRight( nCol, nRow, aStyle );
lclSetStyleFromBorder( aStyle, rItem.GetTop() );
maArray.SetCellStyleTop( nCol, nRow, aStyle );
lclSetStyleFromBorder( aStyle, rItem.GetBottom() );
maArray.SetCellStyleBottom( nCol, nRow, aStyle );
lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, true ).GetLine() );
maArray.SetCellStyleTLBR( nCol, nRow, aStyle );
lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, false ).GetLine() );
maArray.SetCellStyleBLTR( nCol, nRow, aStyle );
}
}
}
}
//------------------------------------------------------------------------
void ScAutoFmtPreview::NotifyChange( ScAutoFormatData* pNewData )
{
if ( pNewData != pCurData )
{
pCurData = pNewData;
bFitWidth = pNewData->GetIncludeWidthHeight();
CalcCellArray( bFitWidth );
CalcLineMap();
}
else if ( bFitWidth != pNewData->GetIncludeWidthHeight() )
{
bFitWidth = !bFitWidth;
CalcCellArray( bFitWidth );
}
DoPaint( Rectangle( Point(0,0), GetSizePixel() ) );
}
//------------------------------------------------------------------------
void ScAutoFmtPreview::DoPaint( const Rectangle& /* rRect */ )
{
sal_uInt32 nOldDrawMode = aVD.GetDrawMode();
// #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
if( GetSettings().GetStyleSettings().GetHighContrastMode() )
aVD.SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
Size aWndSize( GetSizePixel() );
Font aFont( aVD.GetFont() );
Color aBackCol( GetSettings().GetStyleSettings().GetWindowColor() );
Point aTmpPoint;
Rectangle aRect( aTmpPoint, aWndSize );
aFont.SetTransparent( TRUE );
aVD.SetFont( aFont );
aVD.SetLineColor();
aVD.SetFillColor( aBackCol );
aVD.SetOutputSize( aWndSize );
aVD.DrawRect( aRect );
PaintCells();
SetLineColor();
SetFillColor( aBackCol );
DrawRect( aRect );
Point aPos( (aWndSize.Width() - aPrvSize.Width()) / 2, (aWndSize.Height() - aPrvSize.Height()) / 2 );
if (Application::GetSettings().GetLayoutRTL())
aPos.X() = -aPos.X();
DrawOutDev( aPos, aWndSize, Point(), aWndSize, aVD );
aVD.SetDrawMode( nOldDrawMode );
}
//------------------------------------------------------------------------
void ScAutoFmtPreview::Paint( const Rectangle& rRect )
{
DoPaint( rRect );
}
|