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
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
|
/*************************************************************************
*
* $RCSfile: tautofmt.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 17:14:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifdef PRECOMPILED
#include "ui_pch.hxx"
#endif
#pragma hdrstop
#ifndef _EDIT_HXX //autogen
#include <vcl/edit.hxx>
#endif
#ifndef _MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _ZFORLIST_HXX //autogen
#include <svtools/zforlist.hxx>
#endif
#ifndef _SV_SYSTEM_HXX //autogen
#include <vcl/system.hxx>
#endif
#ifndef _UIPARAM_HXX
#include <uiparam.hxx>
#endif
#include "swtypes.hxx"
#include "view.hxx"
#include "wrtsh.hxx"
#include "tblafmt.hxx"
#include "tautofmt.hxx"
#include "shellres.hxx"
#include "tautofmt.hrc"
#define FRAME_OFFSET 4
//========================================================================
class AutoFmtPreview : public Window
{
public:
AutoFmtPreview( Window* pParent, const ResId& rRes );
~AutoFmtPreview();
void NotifyChange( const SwTableAutoFmt& rNewData );
protected:
virtual void Paint( const Rectangle& rRect );
private:
SwTableAutoFmt aCurData;
VirtualDevice aVD;
BOOL bFitWidth;
static BYTE aFmtMap[25]; // Zuordnung: Zelle->Format
Rectangle aCellArray[25]; // Position und Groesse der Zellen
SvxBoxItem* aLinePtrArray[49]; // LinienAttribute
Size aPrvSize;
const USHORT nLabelColWidth;
const USHORT nDataColWidth1;
const USHORT nDataColWidth2;
const USHORT nRowHeight;
const String aStrJan;
const String aStrFeb;
const String aStrMar;
const String aStrNorth;
const String aStrMid;
const String aStrSouth;
const String aStrSum;
SvNumberFormatter* pNumFmt;
//-------------------------------------------
void Init ();
void DoPaint ( const Rectangle& rRect );
void CalcCellArray ( BOOL bFitWidth );
void CalcLineMap ();
void PaintCells ();
void DrawBackground ( BYTE nIndex );
void DrawFrame ( BYTE nIndex );
void DrawString ( BYTE nIndex );
void MakeFont ( BYTE nIndex, Font& rFont );
String MakeNumberString( String cellString, BOOL bAddDec );
void DrawFrameLine ( const SvxBorderLine& rLineD,
Point from,
Point to,
BOOL bHorizontal,
const SvxBorderLine& rLineLT,
const SvxBorderLine& rLineL,
const SvxBorderLine& rLineLB,
const SvxBorderLine& rLineRT,
const SvxBorderLine& rLineR,
const SvxBorderLine& rLineRB );
void CheckPriority ( USHORT nCurLine,
AutoFmtLine eLine,
SvxBorderLine& rLine );
void GetLines ( BYTE nIndex, AutoFmtLine eLine,
SvxBorderLine& rLineD,
SvxBorderLine& rLineLT,
SvxBorderLine& rLineL,
SvxBorderLine& rLineLB,
SvxBorderLine& rLineRT,
SvxBorderLine& rLineR,
SvxBorderLine& rLineRB );
};
//========================================================================
struct SwLineStruct
{
short nLeft; //Breite der linken Linie
short nMiddle;//Breite des Zwischenraums
short nRight; //Breite der rechten Linie
};
void lcl_SwLinkLine( const SwLineStruct& dLine,
const SwLineStruct& ltLine,
const SwLineStruct& lLine,
const SwLineStruct& lbLine,
const SwLineStruct& rtLine,
const SwLineStruct& rLine,
const SwLineStruct& rbLine,
short* dxArr);
//SC-Produkt!
BOOL lcl_HasPriority( const SvxBorderLine* pThis,
const SvxBorderLine* pOther );
//------------------------------------------------------------------------
class SwStringInputDlg : public ModalDialog
{
public:
SwStringInputDlg( Window* pParent,
const String& rTitle,
const String& rEditTitle,
const String& rDefault );
~SwStringInputDlg();
void GetInputString( String& rString ) const;
private:
Edit aEdInput; // Edit erhaelt so den Focus
FixedText aFtEditTitle;
OKButton aBtnOk;
CancelButton aBtnCancel;
};
BYTE AutoFmtPreview::aFmtMap[] = { 0, 1, 2, 1, 3, // Zuordnung:
4, 5, 6, 5, 7, // Zelle->Format
8, 9, 10, 9, 11,
4, 5, 6, 5, 7,
12, 13, 14, 13, 15 };
SwStringInputDlg::SwStringInputDlg( Window* pParent,
const String& rTitle,
const String& rEditTitle,
const String& rDefault ) :
ModalDialog ( pParent, SW_RES( DLG_SWDLG_STRINPUT ) ),
//
aEdInput ( this, SW_RES( ED_INPUT ) ),
aBtnOk ( this, SW_RES( BTN_OK ) ),
aBtnCancel ( this, SW_RES( BTN_CANCEL ) ),
aFtEditTitle ( this, SW_RES( FT_LABEL ) )
{
SetText( rTitle );
aFtEditTitle.SetText( rEditTitle );
aEdInput.SetText( rDefault );
//-------------
FreeResource();
}
//------------------------------------------------------------------------
void SwStringInputDlg::GetInputString( String& rString ) const
{
rString = aEdInput.GetText();
}
__EXPORT SwStringInputDlg::~SwStringInputDlg()
{
}
//========================================================================
// AutoFormat-Dialog:
SwAutoFormatDlg::SwAutoFormatDlg( Window* pParent, SwWrtShell* pWrtShell,
BOOL bSetAutoFormat, const SwTableAutoFmt* pSelFmt )
: SfxModalDialog( pParent, SW_RES( DLG_AUTOFMT_TABLE ) ),
//
aFtFormat ( this, SW_RES( FT_FORMAT ) ),
aLbFormat ( this, SW_RES( LB_FORMAT ) ),
aGbPreview ( this, SW_RES( GB_PREVIEW ) ),
pWndPreview ( new AutoFmtPreview( this, SW_RES( WND_PREVIEW ) ) ),
aBtnNumFormat ( this, SW_RES( BTN_NUMFORMAT ) ),
aBtnBorder ( this, SW_RES( BTN_BORDER ) ),
aBtnFont ( this, SW_RES( BTN_FONT ) ),
aBtnPattern ( this, SW_RES( BTN_PATTERN ) ),
aBtnAlignment ( this, SW_RES( BTN_ALIGNMENT ) ),
aGbFormat ( this, SW_RES( GB_FORMAT ) ),
aBtnOk ( this, SW_RES( BTN_OK ) ),
aBtnCancel ( this, SW_RES( BTN_CANCEL ) ),
aBtnHelp ( this, SW_RES( BTN_HELP ) ),
aBtnAdd ( this, SW_RES( BTN_ADD ) ),
aBtnRemove ( this, SW_RES( BTN_REMOVE ) ),
aBtnMore ( this, SW_RES( BTN_MORE ) ),
aBtnRename ( this, SW_RES( BTN_RENAME ) ),
aStrTitle ( SW_RES( STR_ADD_TITLE ) ),
aStrLabel ( SW_RES( STR_ADD_LABEL ) ),
aStrClose ( SW_RES( STR_BTN_CLOSE ) ),
aStrDelTitle ( SW_RES( STR_DEL_TITLE ) ),
aStrDelMsg ( SW_RES( STR_DEL_MSG ) ),
aStrRenameTitle ( SW_RES( STR_RENAME_TITLE ) ),
aStrInvalidFmt ( SW_RES( STR_INVALID_AFNAME )),
//
nIndex ( 0 ),
nDfltStylePos ( 0 ),
bCoreDataChanged( FALSE ),
bSetAutoFmt ( bSetAutoFormat ),
pShell ( pWrtShell )
{
pTableTbl = new SwTableAutoFmtTbl;
pTableTbl->Load();
Init( pSelFmt );
//------------- >
FreeResource();
}
//------------------------------------------------------------------------
__EXPORT SwAutoFormatDlg::~SwAutoFormatDlg()
{
delete pWndPreview;
if( bCoreDataChanged )
pTableTbl->Save();
delete pTableTbl;
}
//------------------------------------------------------------------------
void SwAutoFormatDlg::Init( const SwTableAutoFmt* pSelFmt )
{
Link aLk( LINK( this, SwAutoFormatDlg, CheckHdl ) );
aBtnBorder.SetClickHdl( aLk );
aBtnFont.SetClickHdl( aLk );
aBtnPattern.SetClickHdl( aLk );
aBtnAlignment.SetClickHdl( aLk );
aBtnNumFormat.SetClickHdl( aLk );
aBtnAdd.SetClickHdl ( LINK( this, SwAutoFormatDlg, AddHdl ) );
aBtnRemove.SetClickHdl ( LINK( this, SwAutoFormatDlg, RemoveHdl ) );
aBtnRename.SetClickHdl ( LINK( this, SwAutoFormatDlg, RenameHdl ) );
aBtnOk.SetClickHdl ( LINK( this, SwAutoFormatDlg, OkHdl ) );
aLbFormat.SetSelectHdl( LINK( this, SwAutoFormatDlg, SelFmtHdl ) );
aBtnMore.AddWindow( &aBtnNumFormat );
aBtnMore.AddWindow( &aBtnBorder );
aBtnMore.AddWindow( &aBtnFont );
aBtnMore.AddWindow( &aBtnPattern );
aBtnMore.AddWindow( &aBtnAlignment );
aBtnMore.AddWindow( &aGbFormat );
aBtnMore.AddWindow( &aBtnRename );
aBtnAdd.Enable( bSetAutoFmt );
nIndex = 0;
if( !bSetAutoFmt )
{
// dann muss die Liste um den Eintrag <Keins> erweitert werden.
aLbFormat.InsertEntry( ViewShell::GetShellRes()->aStrNone );
nDfltStylePos = 1;
nIndex = 255;
}
for( BYTE i = 0, nCount = (BYTE)pTableTbl->Count(); i < nCount; i++ )
{
SwTableAutoFmt* pFmt = (*pTableTbl)[ i ];
aLbFormat.InsertEntry( pFmt->GetName() );
if( pSelFmt && pFmt->GetName() == pSelFmt->GetName() )
nIndex = i;
}
aLbFormat.SelectEntryPos( 255 != nIndex ? (nDfltStylePos + nIndex) : 0 );
SelFmtHdl( 0 );
}
//------------------------------------------------------------------------
void SwAutoFormatDlg::UpdateChecks( const SwTableAutoFmt& rFmt, BOOL bEnable )
{
aBtnNumFormat.Enable( bEnable );
aBtnNumFormat.Check( rFmt.IsValueFormat() );
aBtnBorder.Enable( bEnable );
aBtnBorder.Check( rFmt.IsFrame() );
aBtnFont.Enable( bEnable );
aBtnFont.Check( rFmt.IsFont() );
aBtnPattern.Enable( bEnable );
aBtnPattern.Check( rFmt.IsBackground() );
aBtnAlignment.Enable( bEnable );
aBtnAlignment.Check( rFmt.IsJustify() );
}
void SwAutoFormatDlg::FillAutoFmtOfIndex( SwTableAutoFmt*& rToFill ) const
{
if( 255 != nIndex )
{
if( rToFill )
*rToFill = *(*pTableTbl)[ nIndex ];
else
rToFill = new SwTableAutoFmt( *(*pTableTbl)[ nIndex ] );
}
else if( rToFill )
delete rToFill, rToFill = 0;
}
/*------------------------------------------------------------------------
Handler:
---------*/
IMPL_LINK( SwAutoFormatDlg, CheckHdl, Button *, pBtn )
{
SwTableAutoFmtPtr pData = (*pTableTbl)[nIndex];
BOOL bCheck = ((CheckBox*)pBtn)->IsChecked(), bDataChgd = TRUE;
if( pBtn == &aBtnNumFormat )
pData->SetValueFormat( bCheck );
else if ( pBtn == &aBtnBorder )
pData->SetFrame( bCheck );
else if ( pBtn == &aBtnFont )
pData->SetFont( bCheck );
else if ( pBtn == &aBtnPattern )
pData->SetBackground( bCheck );
else if ( pBtn == &aBtnAlignment )
pData->SetJustify( bCheck );
// else if ( pBtn == &aBtnAdjust )
// pData->SetIncludeWidthHeight( bCheck );
else
bDataChgd = FALSE;
if( bDataChgd )
{
if( !bCoreDataChanged )
{
aBtnCancel.SetText( aStrClose );
bCoreDataChanged = TRUE;
}
pWndPreview->NotifyChange( *pData );
}
return 0;
}
/*------------------------------------------------------------------------*/
IMPL_LINK( SwAutoFormatDlg, AddHdl, void *, EMPTYARG )
{
BOOL bOk = FALSE, bFmtInserted = FALSE;
while( !bOk )
{
SwStringInputDlg* pDlg = new SwStringInputDlg( this,
aStrTitle,
aStrLabel,
aEmptyStr );
if( RET_OK == pDlg->Execute() )
{
String aFormatName;
pDlg->GetInputString( aFormatName );
if( aFormatName.Len() > 0 )
{
for( USHORT n = 0; n < pTableTbl->Count(); ++n )
if( (*pTableTbl)[n]->GetName() == aFormatName )
break;
if( n >= pTableTbl->Count() )
{
// Format mit dem Namen noch nicht vorhanden, also
// aufnehmen
SwTableAutoFmtPtr pNewData = new
SwTableAutoFmt( aFormatName );
pShell->GetTableAutoFmt( *pNewData );
// Sortiert einfuegen!!
for( n = 1; n < pTableTbl->Count(); ++n )
if( (*pTableTbl)[ n ]->GetName() > aFormatName )
break;
pTableTbl->Insert( pNewData, n );
aLbFormat.InsertEntry( aFormatName, nDfltStylePos + n );
aLbFormat.SelectEntryPos( nDfltStylePos + n );
bFmtInserted = TRUE;
aBtnAdd.Enable( FALSE );
if ( !bCoreDataChanged )
{
aBtnCancel.SetText( aStrClose );
bCoreDataChanged = TRUE;
}
SelFmtHdl( 0 );
bOk = TRUE;
}
}
if( !bFmtInserted )
{
bOk = RET_CANCEL == ErrorBox( this,
WinBits( WB_OK_CANCEL | WB_DEF_OK),
aStrInvalidFmt
).Execute();
}
}
else
bOk = TRUE;
delete pDlg;
}
return 0;
}
//------------------------------------------------------------------------
IMPL_LINK( SwAutoFormatDlg, RemoveHdl, void *, EMPTYARG )
{
String aMessage = aStrDelMsg ;
aMessage.AppendAscii("\n\n");
aMessage += aLbFormat.GetSelectEntry() ;
aMessage += '\n';
MessBox* pBox = new MessBox( this, WinBits( WB_OK_CANCEL ),
aStrDelTitle, aMessage);
if ( pBox->Execute() == RET_OK )
{
aLbFormat.RemoveEntry( nDfltStylePos + nIndex );
aLbFormat.SelectEntryPos( nDfltStylePos + nIndex-1 );
pTableTbl->DeleteAndDestroy( nIndex );
nIndex--;
if( !nIndex )
{
aBtnRemove.Enable(FALSE);
aBtnRename.Enable(FALSE);
}
if( !bCoreDataChanged )
{
aBtnCancel.SetText( aStrClose );
bCoreDataChanged = TRUE;
}
}
delete pBox;
SelFmtHdl( 0 );
return 0;
}
IMPL_LINK( SwAutoFormatDlg, RenameHdl, void *, EMPTYARG )
{
BOOL bOk = FALSE;
while( !bOk )
{
SwStringInputDlg* pDlg = new SwStringInputDlg( this,
aStrRenameTitle, aLbFormat.GetSelectEntry(),
aEmptyStr );
if( pDlg->Execute() == RET_OK )
{
BOOL bFmtRenamed = FALSE;
String aFormatName;
pDlg->GetInputString( aFormatName );
if ( aFormatName.Len() > 0 )
{
for( USHORT n = 0; n < pTableTbl->Count(); ++n )
if ((*pTableTbl)[n]->GetName() == aFormatName)
break;
if( n >= pTableTbl->Count() )
{
// Format mit dem Namen noch nicht vorhanden, also
// umbenennen
aLbFormat.RemoveEntry( nDfltStylePos + nIndex );
SwTableAutoFmtPtr p = (*pTableTbl)[ nIndex ];
pTableTbl->Remove( nIndex );
p->SetName( aFormatName );
// Sortiert einfuegen!!
for( n = 1; n < pTableTbl->Count(); ++n )
if( (*pTableTbl)[ n ]->GetName() > aFormatName )
break;
pTableTbl->Insert( p, n );
aLbFormat.InsertEntry( aFormatName, nDfltStylePos + n );
aLbFormat.SelectEntryPos( nDfltStylePos + n );
if ( !bCoreDataChanged )
{
aBtnCancel.SetText( aStrClose );
bCoreDataChanged = TRUE;
}
SelFmtHdl( 0 );
bOk = TRUE;
bFmtRenamed = TRUE;
}
}
if( !bFmtRenamed )
{
bOk = RET_CANCEL == ErrorBox( this,
WinBits( WB_OK_CANCEL | WB_DEF_OK),
aStrInvalidFmt
).Execute();
}
}
else
bOk = TRUE;
delete pDlg;
}
return 0;
}
//------------------------------------------------------------------------
IMPL_LINK( SwAutoFormatDlg, SelFmtHdl, void *, EMPTYARG )
{
BOOL bBtnEnable = FALSE;
BYTE nSelPos = (BYTE) aLbFormat.GetSelectEntryPos(), nOldIdx = nIndex;
if( nSelPos >= nDfltStylePos )
{
nIndex = nSelPos - nDfltStylePos;
pWndPreview->NotifyChange( *(*pTableTbl)[nIndex] );
bBtnEnable = 0 != nIndex;
UpdateChecks( *(*pTableTbl)[nIndex], TRUE );
}
else
{
nIndex = 255;
SwTableAutoFmt aTmp( ViewShell::GetShellRes()->aStrNone );
aTmp.SetFont( FALSE );
aTmp.SetJustify( FALSE );
aTmp.SetFrame( FALSE );
aTmp.SetBackground( FALSE );
aTmp.SetValueFormat( FALSE );
aTmp.SetWidthHeight( FALSE );
if( nOldIdx != nIndex )
pWndPreview->NotifyChange( aTmp );
UpdateChecks( aTmp, FALSE );
}
aBtnRemove.Enable( bBtnEnable );
aBtnRename.Enable( bBtnEnable );
return 0;
}
//------------------------------------------------------------------------
IMPL_LINK_INLINE_START( SwAutoFormatDlg, OkHdl, Button *, EMPTYARG )
{
if( bSetAutoFmt )
pShell->SetTableAutoFmt( *(*pTableTbl)[ nIndex ] );
EndDialog( RET_OK );
return TRUE;
}
IMPL_LINK_INLINE_END( SwAutoFormatDlg, OkHdl, Button *, EMPTYARG )
//========================================================================
// AutoFmtPreview
//------------------------------------------------------------------------
AutoFmtPreview::AutoFmtPreview( Window* pParent, const ResId& rRes ) :
Window ( pParent, rRes ),
aVD ( *this ),
aCurData ( aEmptyStr ),
bFitWidth ( FALSE ),
aStrJan ( SW_RES( STR_JAN ) ),
aStrFeb ( SW_RES( STR_FEB ) ),
aStrMar ( SW_RES( STR_MAR ) ),
aStrNorth ( SW_RES( STR_NORTH ) ),
aStrMid ( SW_RES( STR_MID ) ),
aStrSouth ( SW_RES( STR_SOUTH ) ),
aStrSum ( SW_RES( STR_SUM ) ),
aPrvSize ( GetSizePixel().Width() - 6,
GetSizePixel().Height() - 30 ),
nLabelColWidth ( (USHORT)(((aPrvSize.Width()-4)/4)-12) ),
nDataColWidth1 ( (USHORT)(((aPrvSize.Width()-4)-(nLabelColWidth*2)) / 3) ),
nDataColWidth2 ( (USHORT)(((aPrvSize.Width()-4)-(nLabelColWidth*2)) / 4) ),
nRowHeight ( (USHORT)((aPrvSize.Height()-4) / 5) ),
pNumFmt ( new SvNumberFormatter( LANGUAGE_SYSTEM ) )
{
Init();
}
//------------------------------------------------------------------------
__EXPORT AutoFmtPreview::~AutoFmtPreview()
{
for ( USHORT i=0; i<=35; i++ )
{
delete aLinePtrArray[i];
}
delete pNumFmt;
}
//------------------------------------------------------------------------
void lcl_AssignLine( SvxBorderLine& dest,
const SvxBorderLine* src )
{
if( src )
{
dest.SetColor( src->GetColor() );
dest.SetOutWidth( src->GetOutWidth() );
dest.SetInWidth( src->GetInWidth() );
dest.SetDistance( src->GetDistance() );
}
else
{
dest.SetColor( Color( COL_WHITE ) );
dest.SetOutWidth ( 0 );
dest.SetInWidth ( 0 );
dest.SetDistance ( 0 );
}
}
//------------------------------------------------------------------------
void lcl_GetLineStruct( SwLineStruct& rLine,
const SvxBorderLine& rBoxLine )
{
if ( rBoxLine.GetOutWidth() > 0 )
{
rLine.nLeft = rBoxLine.GetOutWidth();
rLine.nMiddle = rBoxLine.GetDistance();
rLine.nRight = rBoxLine.GetInWidth();
/* Linienstaerke auf dick/duenn abbilden:
*
* (in TWIPS, 1pt = 20 TWIPS = duenn)
* alles was <=0 ist -> (0,0,0)
* alles was <=20 ist -> (1,0,0)/(1,1,1)
* alles andere -> (3,0,0)/(2,1,2)
*/
if ( rLine.nMiddle == 0 ) // einfache Linie?
{
rLine.nRight = 0; // sicher ist sicher
if ( rLine.nLeft <= 20 )
{
rLine.nLeft = 1;
}
else if ( rLine.nLeft > 20 )
{
rLine.nLeft = 3;
}
}
else // doppelte Linie
{
rLine.nMiddle = 1;
if ( rLine.nLeft <= 20 )
{
rLine.nLeft = rLine.nRight = 1;
}
else if ( rLine.nLeft > 20 )
{
rLine.nLeft = rLine.nRight = 2;
}
}
}
else
{
rLine.nLeft = 0;
rLine.nMiddle = 0;
rLine.nRight = 0;
}
}
//------------------------------------------------------------------------
void AutoFmtPreview::CheckPriority( USHORT nCurLine,
AutoFmtLine eLine,
SvxBorderLine& rLine )
{
const SvxBorderLine* pDrawLine;
USHORT nOther = 0;
switch ( eLine )
{
case TOP_LINE:
{
lcl_AssignLine( rLine, aLinePtrArray[nCurLine]->GetTop() );
nOther = nCurLine-7;
pDrawLine = aLinePtrArray[nOther]->GetBottom();
if ( lcl_HasPriority( pDrawLine, &rLine ) )
lcl_AssignLine( rLine, pDrawLine );
}
break;
case BOTTOM_LINE:
{
lcl_AssignLine( rLine, aLinePtrArray[nCurLine]->GetBottom() );
nOther = nCurLine+7;
pDrawLine = aLinePtrArray[nOther]->GetTop();
if ( lcl_HasPriority( pDrawLine, &rLine ) )
lcl_AssignLine( rLine, pDrawLine );
}
break;
case LEFT_LINE:
{
lcl_AssignLine( rLine, aLinePtrArray[nCurLine]->GetLeft() );
nOther = nCurLine-1;
pDrawLine = aLinePtrArray[nOther]->GetRight();
if ( lcl_HasPriority( pDrawLine, &rLine ) )
lcl_AssignLine( rLine, pDrawLine );
}
break;
case RIGHT_LINE:
{
lcl_AssignLine( rLine, aLinePtrArray[nCurLine]->GetRight() );
nOther = nCurLine+1;
pDrawLine = aLinePtrArray[nOther]->GetLeft();
if ( lcl_HasPriority( pDrawLine, &rLine ) )
lcl_AssignLine( rLine, pDrawLine );
}
break;
}
}
//------------------------------------------------------------------------
void AutoFmtPreview::GetLines( BYTE nIndex, AutoFmtLine eLine,
SvxBorderLine& rLineD,
SvxBorderLine& rLineLT,
SvxBorderLine& rLineL,
SvxBorderLine& rLineLB,
SvxBorderLine& rLineRT,
SvxBorderLine& rLineR,
SvxBorderLine& rLineRB )
{
{
SvxBorderLine aNullLine;
lcl_AssignLine( rLineD, &aNullLine);
lcl_AssignLine( rLineLT, &aNullLine);
lcl_AssignLine( rLineL, &aNullLine);
lcl_AssignLine( rLineLB, &aNullLine);
lcl_AssignLine( rLineRT, &aNullLine);
lcl_AssignLine( rLineR, &aNullLine);
lcl_AssignLine( rLineRB, &aNullLine);
}
USHORT nCurLine = nIndex + 8 + ((nIndex/5)*2);
USHORT nOther = 0;
switch ( eLine )
{
case TOP_LINE:
{
// obere Linien werden nur in der
// ersten Zeile gemalt:
if ( (nIndex >= 0) && (nIndex <= 4) )
{
// links
CheckPriority( nCurLine, eLine, rLineD );
nOther = nCurLine-7;
CheckPriority( nOther, LEFT_LINE, rLineLT );
nOther = nCurLine-1;
CheckPriority( nOther, TOP_LINE, rLineL );
CheckPriority( nCurLine, LEFT_LINE, rLineLB );
// rechts
nOther = nCurLine-7;
CheckPriority( nOther, RIGHT_LINE, rLineRT );
nOther = nCurLine+1;
CheckPriority( nOther, TOP_LINE, rLineR );
CheckPriority( nCurLine, RIGHT_LINE, rLineRB );
}
}
break;
case BOTTOM_LINE:
{
// links
CheckPriority( nCurLine, eLine, rLineD );
CheckPriority( nCurLine, LEFT_LINE, rLineLT );
nOther = nCurLine-1;
CheckPriority( nOther, BOTTOM_LINE, rLineL );
nOther = nCurLine+7;
CheckPriority( nOther, LEFT_LINE, rLineLB );
// rechts
CheckPriority( nCurLine, RIGHT_LINE, rLineRT );
nOther = nCurLine+1;
CheckPriority( nOther, BOTTOM_LINE, rLineR );
nOther = nCurLine+7;
CheckPriority( nOther, RIGHT_LINE, rLineRB );
}
break;
case LEFT_LINE:
{
// linke Linien werden nur in der
// ersten Spalte gemalt:
if ( (nIndex%5) == 0 )
{
// oben
CheckPriority( nCurLine, eLine, rLineD );
CheckPriority( nCurLine, TOP_LINE, rLineLT );
nOther = nCurLine-7;
CheckPriority( nOther, LEFT_LINE, rLineL );
nOther = nCurLine-1;
CheckPriority( nOther, TOP_LINE, rLineLB );
// unten
CheckPriority( nCurLine, BOTTOM_LINE, rLineRT );
nOther = nCurLine+7;
CheckPriority( nOther, LEFT_LINE, rLineR );
nOther = nCurLine-1;
CheckPriority( nOther, BOTTOM_LINE, rLineRB );
}
}
break;
case RIGHT_LINE:
{
// oben
CheckPriority( nCurLine, eLine, rLineD );
nOther = nCurLine+1;
CheckPriority( nOther, TOP_LINE, rLineLT );
nOther = nCurLine-7;
CheckPriority( nOther, RIGHT_LINE, rLineL );
CheckPriority( nCurLine, TOP_LINE, rLineLB );
// unten
nOther = nCurLine+1;
CheckPriority( nOther, BOTTOM_LINE, rLineRT );
nOther = nCurLine+7;
CheckPriority( nOther, RIGHT_LINE, rLineR );
CheckPriority( nCurLine, BOTTOM_LINE, rLineRB );
}
break;
}
}
//------------------------------------------------------------------------
void AutoFmtPreview::DrawFrameLine( const SvxBorderLine& rLineD,
Point from,
Point to,
BOOL bHorizontal,
const SvxBorderLine& rLineLT,
const SvxBorderLine& rLineL,
const SvxBorderLine& rLineLB,
const SvxBorderLine& rLineRT,
const SvxBorderLine& rLineR,
const SvxBorderLine& rLineRB )
{
SwLineStruct dLine;
SwLineStruct ltLine;
SwLineStruct lLine;
SwLineStruct lbLine;
SwLineStruct rtLine;
SwLineStruct rLine;
SwLineStruct rbLine;
short dxArr[4];
lcl_GetLineStruct( dLine, rLineD );
lcl_GetLineStruct( ltLine, rLineLT );
lcl_GetLineStruct( lLine, rLineL );
lcl_GetLineStruct( lbLine, rLineLB );
lcl_GetLineStruct( rtLine, rLineRT );
lcl_GetLineStruct( rLine, rLineR );
lcl_GetLineStruct( rbLine, rLineRB );
if ( dLine.nLeft > 0 )
{
Color oldColor = aVD.GetLineColor();
aVD.SetLineColor( Color(COL_TRANSPARENT) );
Color oldFillColor = aVD.GetFillColor();
aVD.SetFillColor( rLineD.GetColor() );
USHORT nHeight = dLine.nLeft + dLine.nMiddle + dLine.nRight;
Point from2 = from;
Point to2 = to;
lcl_SwLinkLine( dLine,
ltLine, lLine, lbLine,
rtLine, rLine, rbLine,
dxArr );
if ( bHorizontal )
{
from.Y() -= nHeight/2;
to.Y() -= nHeight/2;
to.Y() += (dLine.nLeft-1);
from.X() += dxArr[0];
to.X() += dxArr[2];
aVD.DrawRect( Rectangle( from, to ) );
// noch eine zweite Linie zu malen?
if ( dLine.nRight != 0 )
{
from2.Y() -= nHeight/2;
from2.Y() += dLine.nLeft+dLine.nMiddle;
to2.Y() -= nHeight/2;
to2.Y() += dLine.nMiddle+dLine.nLeft;
to2.Y() += (dLine.nRight-1);
from2.X() += dxArr[1];
to2.X() += dxArr[3];
aVD.DrawRect( Rectangle( from2, to2 ) );
}
}
else
{
from.X() += nHeight/2;
from.X() -= (dLine.nLeft-1);
to.X() += nHeight/2;
from.Y() += dxArr[0];
to.Y() += dxArr[2];
aVD.DrawRect( Rectangle( from, to ) );
// noch eine zweite Linie zu malen?
if ( dLine.nRight != 0 )
{
from2.X() -= nHeight/2;
to2.X() -= nHeight/2;
to2.X() += (dLine.nRight-1);
from2.Y() += dxArr[1];
to2.Y() += dxArr[3];
aVD.DrawRect( Rectangle( from2, to2 ) );
}
}
aVD.SetFillColor( oldFillColor );
aVD.SetLineColor( oldColor );
}
}
//------------------------------------------------------------------------
void AutoFmtPreview::DrawFrame( BYTE nIndex )
{
//----------------------
// Malen des Zellrahmens
//----------------------
SvxBorderLine aLineD;
SvxBorderLine aLineLT;
SvxBorderLine aLineL;
SvxBorderLine aLineLB;
SvxBorderLine aLineRT;
SvxBorderLine aLineR;
SvxBorderLine aLineRB;
Rectangle& cellRect = aCellArray[nIndex];
//---------
// TopLine ---------------------------------------------
//---------
GetLines( nIndex, TOP_LINE, aLineD,
aLineLT, aLineL, aLineLB,
aLineRT, aLineR, aLineRB );
DrawFrameLine( aLineD,
cellRect.TopLeft(), cellRect.TopRight(), TRUE,
aLineLT, aLineL, aLineLB,
aLineRT, aLineR, aLineRB );
//------------
// BottomLine ------------------------------------------
//------------
GetLines( nIndex, BOTTOM_LINE, aLineD,
aLineLT, aLineL, aLineLB,
aLineRT, aLineR, aLineRB );
DrawFrameLine( aLineD,
cellRect.BottomLeft(), cellRect.BottomRight(), TRUE,
aLineLT, aLineL, aLineLB,
aLineRT, aLineR, aLineRB );
//----------
// LeftLine --------------------------------------------
//----------
GetLines( nIndex, LEFT_LINE, aLineD,
aLineLT, aLineL, aLineLB,
aLineRT, aLineR, aLineRB );
DrawFrameLine( aLineD,
cellRect.TopLeft(), cellRect.BottomLeft(), FALSE,
aLineLT, aLineL, aLineLB,
aLineRT, aLineR, aLineRB );
//-----------
// RightLine -------------------------------------------
//-----------
GetLines( nIndex, RIGHT_LINE, aLineD,
aLineLT, aLineL, aLineLB,
aLineRT, aLineR, aLineRB );
DrawFrameLine( aLineD,
cellRect.TopRight(), cellRect.BottomRight(), FALSE,
aLineLT, aLineL, aLineLB,
aLineRT, aLineR, aLineRB );
}
//------------------------------------------------------------------------
void AutoFmtPreview::MakeFont( BYTE nIndex, Font& rFont )
{
const SwBoxAutoFmt& rBoxFmt = aCurData.GetBoxFmt( nIndex );
rFont = GetFont();
const SvxFontItem& rFontItem = rBoxFmt.GetFont();
rFont.SetFamily ( rFontItem.GetFamily() );
rFont.SetName ( rFontItem.GetFamilyName() );
rFont.SetStyleName ( rFontItem.GetStyleName() );
rFont.SetCharSet ( rFontItem.GetCharSet() );
rFont.SetPitch ( rFontItem.GetPitch() );
rFont.SetWeight ( (FontWeight)rBoxFmt.GetWeight().GetValue() );
rFont.SetUnderline ( (FontUnderline)rBoxFmt.GetUnderline().GetValue() );
rFont.SetStrikeout ( (FontStrikeout)rBoxFmt.GetCrossedOut().GetValue() );
rFont.SetItalic ( (FontItalic)rBoxFmt.GetPosture().GetValue() );
rFont.SetOutline ( rBoxFmt.GetContour().GetValue() );
rFont.SetShadow ( rBoxFmt.GetShadowed().GetValue() );
rFont.SetColor ( rBoxFmt.GetColor().GetValue() );
rFont.SetSize ( Size( rFont.GetSize().Width(), 10 ) );
rFont.SetTransparent ( TRUE );
}
//------------------------------------------------------------------------
void AutoFmtPreview::DrawString( BYTE nIndex )
{
//------------------------
// Ausgabe des Zelltextes:
//------------------------
ULONG nNum;
double nVal;
String cellString;
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 MAKENUMSTR;
case 17:
case 7: nVal = nIndex;
nNum = 6;
goto MAKENUMSTR;
case 11:
case 12:
case 13: nVal = nIndex;
nNum = 12 == nIndex ? 10 : 9;
goto MAKENUMSTR;
case 9: nVal = 21; nNum = 7; goto MAKENUMSTR;
case 14: nVal = 36; nNum = 11; goto MAKENUMSTR;
case 19: nVal = 51; nNum = 7; goto MAKENUMSTR;
case 21: nVal = 33; nNum = 13; goto MAKENUMSTR;
case 22: nVal = 36; nNum = 14; goto MAKENUMSTR;
case 23: nVal = 39; nNum = 13; goto MAKENUMSTR;
case 24: nVal = 108; nNum = 15; goto MAKENUMSTR;
MAKENUMSTR:
if( aCurData.IsValueFormat() )
{
String sFmt; LanguageType eLng, eSys;
aCurData.GetBoxFmt( (BYTE)nNum ).GetValueFormat( sFmt, eLng, eSys );
ULONG nKey = 0;
if ( eLng == LANGUAGE_SYSTEM && eSys != ::GetSystemLanguage() )
{
// #53381# wenn System beim Speichern etwas anderes war,
// muss konvertiert werden (geht nur mit eingebauten Formaten)
ULONG nOrig = pNumFmt->GetEntryKey( sFmt, eSys );
if ( nOrig != NUMBERFORMAT_ENTRY_NOT_FOUND )
nKey = pNumFmt->GetFormatForLanguageIfBuiltIn( nOrig, ::GetSystemLanguage() );
}
else // sonst einfach suchen oder anlegen
{
nKey = pNumFmt->GetEntryKey( sFmt, eLng );
if( NUMBERFORMAT_ENTRY_NOT_FOUND == nKey )
{
xub_StrLen nCheckPos;
short nType;
pNumFmt->PutEntry( sFmt, nCheckPos, nType, nKey, eLng );
}
}
Color* pDummy;
pNumFmt->GetOutputString( nVal, nKey, cellString, &pDummy );
}
else
cellString = (USHORT)nVal;
break;
}
if( cellString.Len() )
{
Font oldFont;
Size aStrSize;
BYTE nFmtIndex = (BYTE) aFmtMap[nIndex];
Rectangle& cellRect = aCellArray[nIndex];
Point aPos = aCellArray[nIndex].TopLeft();
USHORT nRightX = 0;
// BOOL bJustify = aCurData.IsJustify();
// ScHorJustifyAttr aHorJustifyItem;
// CellHorJustify eJustification;
Size theMaxStrSize( cellRect.GetWidth() - FRAME_OFFSET,
cellRect.GetHeight() - FRAME_OFFSET );
if( aCurData.IsFont() )
{
Font aFont;
MakeFont( nFmtIndex, aFont );
oldFont = aVD.GetFont();
aVD.SetFont( aFont );
}
aStrSize = Size(aVD.GetTextWidth( cellString ), aVD.GetTextHeight());
if( aCurData.IsFont() &&
theMaxStrSize.Height() < aStrSize.Height() )
{
// wenn der String in diesem Font nicht
// in die Zelle passt, wird wieder der
// Standard-Font genommen:
aVD.SetFont( oldFont );
aStrSize = Size(aVD.GetTextWidth( cellString ), aVD.GetTextHeight());
}
while( theMaxStrSize.Width() <= aStrSize.Width() &&
cellString.Len() > 1 )
{
// if( eJustification == SVX_HOR_JUSTIFY_RIGHT )
// cellString.Erase( 0, 1 );
// else
cellString.Erase( cellString.Len() - 1 );
aStrSize = Size(aVD.GetTextWidth( cellString ), aVD.GetTextHeight());
}
nRightX = (USHORT)( cellRect.GetWidth()
- aStrSize.Width()
- FRAME_OFFSET );
//-------------
// Ausrichtung:
//-------------
/* if ( bJustify )
{
aCurData.GetHorJustify( nFmtIndex, aHorJustifyItem );
eJustification = (CellHorJustify)aHorJustifyItem.GetValue();
}
else
{
eJustification = SC_HOR_JUSTIFY_STANDARD;
}*/
//-----------------------------
// vertikal (immer zentrieren):
//-----------------------------
aPos.Y() += (nRowHeight - (USHORT)aStrSize.Height()) / 2;
//-----------
// horizontal
//-----------
/* if ( eJustification != SC_HOR_JUSTIFY_STANDARD )*/
if (aCurData.IsJustify())
{
USHORT nHorPos = (USHORT)
((cellRect.GetWidth()-aStrSize.Width())/2);
const SvxAdjustItem& rAdj = aCurData.GetBoxFmt(nFmtIndex).GetAdjust();
switch ( rAdj.GetAdjust() )
{
case SVX_ADJUST_LEFT:
aPos.X() += FRAME_OFFSET;
break;
case SVX_ADJUST_RIGHT:
aPos.X() += nRightX;
break;
default:
aPos.X() += nHorPos;
break;
}
}
else
{
//---------------------
// Standardausrichtung:
//---------------------
if ( ((nIndex%5) == 0) || (nIndex == 4) )
{
// Text-Label links oder Summe linksbuendig
aPos.X() += FRAME_OFFSET;
}
else
{
// Zahlen/Datum rechtsbuendig
aPos.X() += nRightX;
}
}
//-------------------------------
aVD.DrawText( aPos, cellString );
//-------------------------------
if ( aCurData.IsFont() )
aVD.SetFont( oldFont );
}
}
#undef FRAME_OFFSET
//------------------------------------------------------------------------
void AutoFmtPreview::DrawBackground( BYTE nIndex )
{
SvxBrushItem aBrushItem( aCurData.GetBoxFmt( aFmtMap[nIndex])
.GetBackground() );
Color oldColor = aVD.GetLineColor();
aVD.SetLineColor( Color(COL_TRANSPARENT) );
Color oldFillColor = aVD.GetFillColor();
aVD.SetFillColor( aBrushItem.GetColor() );
//-----------------------
aVD.DrawRect( aCellArray[nIndex] );
//-----------------------
aVD.SetLineColor( oldColor );
aVD.SetFillColor( oldFillColor );
}
//------------------------------------------------------------------------
void AutoFmtPreview::PaintCells()
{
BYTE i = 0;
//---------------
// 1. Hintergrund
//---------------
if ( aCurData.IsBackground() )
{
for ( i=0; i<=24; i++ )
{
DrawBackground( i );
}
}
//----------
// 2. Rahmen
//----------
if ( aCurData.IsFrame() )
{
for ( i=0; i<=24; i++ )
{
DrawFrame( i );
}
}
//---------
// 3. Werte
//---------
for ( i = 0; i<=24; i++ )
{
DrawString( i );
}
}
//------------------------------------------------------------------------
void __EXPORT AutoFmtPreview::Init()
{
SvxBoxItem aEmptyBoxItem;
aEmptyBoxItem.SetLine ( NULL, BOX_LINE_TOP );
aEmptyBoxItem.SetLine ( NULL, BOX_LINE_BOTTOM );
aEmptyBoxItem.SetLine ( NULL, BOX_LINE_LEFT );
aEmptyBoxItem.SetLine ( NULL, BOX_LINE_RIGHT );
aEmptyBoxItem.SetDistance( 0 );
//------------------------
// Linienattribut-Feld mit
// Null-BoxItems fuellen
//------------------------
for ( USHORT i=0; i<=48; i++ )
{
aLinePtrArray[i] = new SvxBoxItem( aEmptyBoxItem );
}
CalcCellArray( FALSE );
CalcLineMap();
}
//------------------------------------------------------------------------
void AutoFmtPreview::CalcCellArray( BOOL bFitWidth )
{
// Initialisieren des Zellfeldes (5x5 Zellen).
// Rectangles enthalten Position und Groesse einer Zelle.
// abhaengig, ob Zellbreite an Format angepasst werden soll (bFitWidth)
USHORT nRow;
USHORT nDataColWidth = (bFitWidth) ? nDataColWidth2 : nDataColWidth1;
for ( nRow=0; nRow<=4; nRow++ )
{
Point topLeftPos ( 2, (nRowHeight * nRow) + 2 );
Size rectSize ( 0, nRowHeight );
USHORT nCell;
USHORT nFirst = nRow*5;
USHORT nLast = nFirst+4;
for ( nCell=nFirst; nCell<=nLast; nCell++ )
{
//--------------------
// Position berechnen:
//--------------------
if ( nCell == 0 )
{
// erste Zelle benoetigt keine Sonderbehandlung
}
else if ( (nCell <= 4) && (nCell != 0) )
{
// Zelle aus der ersten Zeile
topLeftPos = aCellArray[nCell-1].TopRight();
}
else
{
topLeftPos = aCellArray[nCell-5].BottomLeft();
}
//-------------------
// Groesse berechnen:
//-------------------
if ( (nCell == nFirst) || (nCell == nLast) )
rectSize.Width() = nLabelColWidth;
else
rectSize.Width() = nDataColWidth;
aCellArray[nCell] = Rectangle( topLeftPos, rectSize );
}
}
aPrvSize.Width() = aCellArray[24].BottomRight().X() + 3;
aPrvSize.Height() = aCellArray[24].BottomRight().Y() + 3;
}
//------------------------------------------------------------------------
void AutoFmtPreview::CalcLineMap()
{
//----------------------------------------------------
// Initialisieren des Linenattributfeldes (7x7 Zellen)
// Ein Eintrag dieses Feldes enthaelt einen Verweis
// auf die Linienattribute des zugehoerigen Feldes.
// Dieses Feld "umschliesst" das Zellfeld mit einer
// Reihe "leerer" Zellen.
//----------------------------------------------------
SvxBoxItem aFrameItem;
BYTE nRow;
for ( nRow=0; nRow<=4; nRow++ )
{
USHORT nLine;
BYTE nCell;
BYTE nFirst = (nRow * 5);
BYTE nLast = nFirst+4;
for ( nCell=nFirst; nCell<=nLast; nCell++ )
{
nLine = nCell + 8 + ((nCell/5)*2);
aFrameItem = aCurData.GetBoxFmt( aFmtMap[nCell]).GetBox();
*(aLinePtrArray[nLine]) = aFrameItem;
}
}
}
//------------------------------------------------------------------------
void AutoFmtPreview::NotifyChange( const SwTableAutoFmt& rNewData )
{
aCurData = rNewData;
bFitWidth = aCurData.IsJustify();//TRUE; //???
CalcCellArray( bFitWidth );
CalcLineMap();
DoPaint( Rectangle( Point(0,0), GetSizePixel() ) );
}
//------------------------------------------------------------------------
void AutoFmtPreview::DoPaint( const Rectangle& rRect )
{
Bitmap thePreview;
Point aCenterPos;
Size theWndSize = GetSizePixel();
Size thePrevSize;
Color oldColor;
Font aFont;
aFont = aVD.GetFont();
aFont.SetTransparent( TRUE );
aVD.SetFont ( aFont );
aVD.SetLineColor ( Color(COL_TRANSPARENT));
aVD.SetFillColor ( Color( COL_WHITE ) );
aVD.SetOutputSizePixel ( aPrvSize );
//--------------------------------
// Zellen auf virtual Device malen
// und Ergebnis sichern
//--------------------------------
PaintCells();
thePreview = aVD.GetBitmap( Point(0,0), aPrvSize );
//--------------------------------------
// Rahmen malen und Vorschau zentrieren:
// (virtual Device fuer Fensterausgabe)
//--------------------------------------
aVD.SetOutputSizePixel( theWndSize );
oldColor = aVD.GetLineColor();
aVD.SetLineColor( Color( COL_BLACK ) );
aVD.DrawRect( Rectangle( Point(0,0), theWndSize ) );
SetLineColor( oldColor );
aCenterPos = Point( (theWndSize.Width() - aPrvSize.Width() ) / 2,
(theWndSize.Height() - aPrvSize.Height()) / 2 );
aVD.DrawBitmap( aCenterPos, thePreview );
//----------------------------
// Ausgabe im Vorschaufenster:
//----------------------------
DrawBitmap( Point(0,0), aVD.GetBitmap( Point(0,0), theWndSize ) );
}
//------------------------------------------------------------------------
void __EXPORT AutoFmtPreview::Paint( const Rectangle& rRect )
{
DoPaint( rRect );
}
//------------------------------------------------------------------------
BOOL lcl_HasPriority( const SvxBorderLine* pThis,
const SvxBorderLine* pOther )
{
if (!pThis)
return FALSE;
if (!pOther)
return TRUE;
USHORT nThisSize = pThis->GetOutWidth() + pThis->GetDistance() + pThis->GetInWidth();
USHORT nOtherSize = pOther->GetOutWidth() + pOther->GetDistance() + pOther->GetInWidth();
if (nThisSize > nOtherSize)
return TRUE;
else if (nThisSize < nOtherSize)
return FALSE;
else
{
if ( pOther->GetInWidth() && !pThis->GetInWidth() )
return TRUE;
else if ( pThis->GetInWidth() && !pOther->GetInWidth() )
return FALSE;
else
{
return TRUE; //! ???
}
}
}
void lcl_SwLinkLine(const SwLineStruct& dLine,
const SwLineStruct& ltLine,
const SwLineStruct& lLine,
const SwLineStruct& lbLine,
const SwLineStruct& rtLine,
const SwLineStruct& rLine,
const SwLineStruct& rbLine,
short* dxArr)
{
short nDx;
short nDxDx;
short nltW = ltLine.nLeft + ltLine.nMiddle + ltLine.nRight;
short nlbW = lbLine.nLeft + lbLine.nMiddle + lbLine.nRight;
short nrtW = rtLine.nLeft + rtLine.nMiddle + rtLine.nRight;
short nrbW = rbLine.nLeft + rbLine.nMiddle + rbLine.nRight;
if (dLine.nRight == 0) // einfache Linie
{
dxArr[1] = 0;
dxArr[3] = 0;
// Linker Teil
if ((lLine.nLeft != 0) && (lLine.nRight == 0)) // links einfache Linie
dxArr[0] = 0;
else
{
nDx = Max(nltW, nlbW) / 2;
nDxDx = (Max(nltW, nlbW) + 1) % 2;
if ((nDx == 0) || (ltLine.nRight == 0) || (lbLine.nRight == 0))
{
if (lLine.nLeft == 0)
dxArr[0] = nDxDx - nDx;
else
dxArr[0] = nDxDx + nDx;
}
else
dxArr[0] = nDxDx + nDx;
}
// Rechter Teil
if ((rLine.nLeft != 0) && (rLine.nRight == 0)) // rechts keine Linie
dxArr[2] = 0;
else
{
nDx = Max(nrtW, nrbW) / 2;
if ((nDx == 0) || (rtLine.nRight == 0) || (rbLine.nRight == 0))
{
if (rLine.nLeft == 0)
dxArr[2] = nDx;
else
dxArr[2] = -nDx;
}
else
dxArr[2] = -nDx;
}
}
else
{
// Linker oberer Teil
if ((nltW == 0) || (ltLine.nRight == 0)) // Links oben keine oder einfache Linie
{
nDx = (nlbW + 1) / 2;
nDxDx = (nlbW + 1) % 2;
if (nDx == 0)
dxArr[0] = nDxDx + nDx;
else
dxArr[0] = nDxDx - (nlbW / 2) + ltLine.nLeft;
}
else
{
nDx = (nltW + 1) / 2;
nDxDx = (nltW + 1) % 2;
if (nDx == 0)
dxArr[0] = nDxDx - nDx;
else
dxArr[0] = nDxDx + nDx - ltLine.nRight;
}
// Linker unterer Teil
if ((nlbW == 0) || (lbLine.nRight == 0)) // Links unten keine oder einfache Linie
{
nDx = (nltW + 1) / 2;
nDxDx = (nltW + 1) % 2;
if (nDx == 0)
dxArr[1] = nDxDx + nDx;
else
dxArr[1] = nDxDx - (nltW / 2) + lbLine.nLeft;
}
else
{
nDx = (nlbW + 1) / 2;
nDxDx = (nlbW + 1) % 2;
if (nDx == 0)
dxArr[1] = nDxDx - nDx;
else
dxArr[1] = nDxDx + nDx - lbLine.nRight;
}
// Rechter oberer Teil
if ((nrtW == 0) || (rtLine.nRight == 0)) // Rechts oben keine oder einfache Linie
{
nDx = (nrbW + 1) / 2;
if (nDx == 0)
dxArr[2] = -nDx;
else
dxArr[2] = (nrbW / 2) - rtLine.nLeft;
}
else
{
nDx = (nrtW + 1) / 2;
if (nDx == 0)
dxArr[2] = nDx;
else
dxArr[2] = -nDx + rtLine.nLeft;
}
// Rechter unterer Teil
if ((nrbW == 0) || (rbLine.nRight == 0)) // Rechts unten keine oder einfache Linie
{
nDx = (nrtW + 1) / 2;
if (nDx == 0)
dxArr[3] = -nDx;
else
dxArr[3] = (nrtW / 2) - rbLine.nLeft;
}
else
{
nDx = (nrbW + 1) / 2;
if (nDx == 0)
dxArr[3] = nDx;
else
dxArr[3] = -nDx + rbLine.nLeft;
}
}
}
/*------------------------------------------------------------------------
$Log: not supported by cvs2svn $
Revision 1.46 2000/09/18 16:06:09 willem.vandorp
OpenOffice header added.
Revision 1.45 2000/06/08 09:48:50 os
using UCB
Revision 1.44 2000/05/16 17:31:14 jp
Changes for Unicode
Revision 1.43 2000/05/16 14:32:29 jp
Changes for Unicode
Revision 1.42 2000/04/19 11:22:12 os
UNICODE
Revision 1.41 2000/03/03 15:17:03 os
StarView remainders removed
Revision 1.40 2000/02/11 14:59:03 hr
#70473# changes for unicode ( patched by automated patchtool )
Revision 1.39 1998/09/29 08:15:38 NN
#53381# wenn noetig, Zahlformat in Sprache konvertieren
Rev 1.38 29 Sep 1998 10:15:38 NN
#53381# wenn noetig, Zahlformat in Sprache konvertieren
Rev 1.37 07 Jul 1998 13:20:36 JP
Bug #52273#: Anzeige des Nummernformates berichtigt
Rev 1.36 02 Jun 1998 10:37:40 JP
TabellenAutoFormat: Load/Save ohne Stream - erzeugen diesen selbst
Rev 1.35 29 May 1998 19:07:08 JP
aufgeraeumnt
Rev 1.34 14 May 1998 15:15:44 JP
neu: Numberformat vom Boxen unterstuetzen
Rev 1.33 12 May 1998 23:42:46 JP
neu: InserTable/TextToTable mit optionalen AutoFormat
Rev 1.32 29 Apr 1998 07:59:08 OS
sAutoTblFmtName allg. verfuegbar
Rev 1.31 24 Nov 1997 15:52:20 MA
includes
Rev 1.30 12 Sep 1997 10:40:16 OS
ITEMID_* definiert
Rev 1.29 05 Sep 1997 12:20:02 MH
chg: header
Rev 1.28 01 Sep 1997 13:17:26 OS
DLL-Umstellung
Rev 1.27 23 May 1997 10:10:02 OS
Ableitung von SfxModalDialog
Rev 1.26 02 May 1997 20:28:36 NF
includes...
Rev 1.25 23 Apr 1997 14:29:18 OS
ResId const
Rev 1.24 17 Apr 1997 23:22:06 JP
Umbenennen von AutoFormaten
Rev 1.23 14 Feb 1997 11:54:58 JP
Bug #35729#: sortiert einfuegen
Rev 1.22 09 Feb 1997 19:00:52 JP
Bug #35729#, #35740#: Formate sortiert, Ueberschreibmeldung
Rev 1.21 11 Nov 1996 11:20:40 MA
ResMgr
Rev 1.20 02 Oct 1996 19:06:06 MA
Umstellung Enable/Disable
Rev 1.19 23 Sep 1996 18:44:50 mk
includes fuer Unix raus
Rev 1.18 21 Mar 1996 14:08:18 OM
Umstellung 311
Rev 1.17 06 Feb 1996 15:21:28 JP
Link Umstellung 305
Rev 1.16 01 Dec 1995 12:30:02 sv
SwTableAutoFmt* -> SwTableAutoFmtPtr
Rev 1.15 24 Nov 1995 16:59:00 OM
PCH->PRECOMPILED
Rev 1.14 13 Nov 1995 10:59:22 OM
static entfernt
Rev 1.13 08 Nov 1995 13:34:36 OS
Change => Set
Rev 1.12 31 Oct 1995 18:41:20 OM
GetActive... entfernt
Rev 1.11 21 Aug 1995 08:56:16 mk
hintids.hxx und svxitems.hxx fuer UNX wieder included (MDA)
Rev 1.10 09 Aug 1995 21:57:10 ER
! static data _vor_ seg_eofglobals
Rev 1.9 24 Jul 1995 11:21:00 JP
aufgeraeumt, CTOR/DTOR: Autoformattabelle ist nicht mehr static, sondern wird geladen und ggfs. gespeichert
Rev 1.8 20 Jul 1995 19:40:36 JP
Autoformatdatei umbenannt und wird jetzt im Config-Verzeichnis erwartet
Rev 1.7 27 Apr 1995 10:07:54 OS
Reihenfolge im Ctor
Rev 1.6 20 Apr 1995 17:02:22 OS
Delete-Message
Rev 1.5 19 Apr 1995 18:07:38 OS
BugFix Delete-Box
Rev 1.4 06 Mar 1995 06:05:28 JP
neu: mit Laden und Speichern
Rev 1.3 06 Mar 1995 05:00:18 JP
jetzt auch mit Umrandung
Rev 1.2 06 Mar 1995 04:08:30 JP
Optimierung
Rev 1.1 06 Mar 1995 00:54:48 OS
funktioniert fast
Rev 1.0 05 Mar 1995 19:34:02 OS
Initial revision.
Rev 1.2 04 Mar 1995 23:29:36 ER
add: hintids, svxitems
Rev 1.1 04 Mar 1995 20:52:58 OS
ein wenig weniger Kommentar
Rev 1.0 04 Mar 1995 15:00:08 OS
Initial revision.
------------------------------------------------------------------------*/
|