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
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* 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.
*
************************************************************************/
#include <svl/zforlist.hxx>
#include <svtools/grfmgr.hxx>
#include <svl/flagitem.hxx>
#include <sfx2/dispatch.hxx>
#include <unotools/lingucfg.hxx>
#include <svl/szitem.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/imgmgr.hxx>
#include <vcl/configsettings.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/mnemonic.hxx>
#include <i18npool/mslangid.hxx>
#include <unotools/compatibility.hxx>
#include <unotools/useroptions.hxx>
#include <unotools/cacheoptions.hxx>
#include <unotools/fontoptions.hxx>
#include <svtools/menuoptions.hxx>
#include <unotools/startoptions.hxx>
#include <svl/languageoptions.hxx>
#include <svtools/miscopt.hxx>
#include <unotools/printwarningoptions.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <svtools/accessibilityoptions.hxx>
#include <unotools/configitem.hxx>
#include <sfx2/objsh.hxx>
#include <comphelper/types.hxx>
#include <svl/ctloptions.hxx>
#include <svtools/langtab.hxx>
#include <unotools/localfilehelper.hxx>
#include <unotools/configmgr.hxx>
#include "cuioptgenrl.hxx"
#include "optpath.hxx"
#include "optsave.hxx"
#include "optlingu.hxx"
#include <svx/xpool.hxx>
#include <svx/dlgutil.hxx>
#include "cuitabarea.hxx"
#include <cuires.hrc>
#include <editeng/unolingu.hxx>
#include <editeng/langitem.hxx>
#include <comphelper/processfactory.hxx>
#include <rtl/ustrbuf.hxx>
#include <editeng/editids.hrc>
#include <svx/svxids.hrc>
#include <svl/intitem.hxx>
#include <dialmgr.hxx>
#include <svtools/helpopt.hxx>
#include <unotools/saveopt.hxx>
#include <sal/macros.h>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/container/XSet.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <vcl/svapp.hxx>
#include "optgdlg.hrc"
#include "optgdlg.hxx"
#include <svx/ofaitem.hxx>
#include <svtools/apearcfg.hxx>
#include <svtools/optionsdrawinglayer.hxx>
#define CONFIG_LANGUAGES "OfficeLanguages"
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::util;
using namespace ::utl;
using ::rtl::OString;
using ::rtl::OUString;
#define C2U(cChar) OUString::createFromAscii(cChar)
#define MAX_PROGRAM_ENTRIES 3
// class OfaMiscTabPage --------------------------------------------------
int OfaMiscTabPage::DeactivatePage( SfxItemSet* pSet_ )
{
if ( pSet_ )
FillItemSet( *pSet_ );
return LEAVE_PAGE;
}
namespace
{
::rtl::OUString impl_SystemFileOpenServiceName()
{
const ::rtl::OUString &rDesktopEnvironment =
Application::GetDesktopEnvironment();
if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "gnome" ) )
{
#ifdef ENABLE_GTK
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.dialogs.GtkFilePicker") );
#else
return rtl::OUString();
#endif
}
else if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde4" ) )
{
#ifdef ENABLE_KDE4
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.dialogs.KDE4FilePicker") );
#else
return rtl::OUString();
#endif
}
else if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde" ) )
{
#ifdef ENABLE_KDE
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.dialogs.KDEFilePicker") );
#else
return rtl::OUString();
#endif
}
#if defined WNT
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.dialogs.SystemFilePicker") );
#elif (defined MACOSX && defined QUARTZ)
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.dialogs.AquaFilePicker") );
#else
return rtl::OUString();
#endif
}
sal_Bool lcl_HasSystemFilePicker()
{
Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
sal_Bool bRet = sal_False;
Reference< XContentEnumerationAccess > xEnumAccess( xFactory, UNO_QUERY );
Reference< XSet > xSet( xFactory, UNO_QUERY );
if ( ! xEnumAccess.is() || ! xSet.is() )
return bRet;
try
{
::rtl::OUString aFileService = impl_SystemFileOpenServiceName();
Reference< XEnumeration > xEnum = xEnumAccess->createContentEnumeration( aFileService );
if ( xEnum.is() && xEnum->hasMoreElements() )
bRet = sal_True;
}
catch (const IllegalArgumentException&)
{
}
catch (const ElementExistException&)
{
}
return bRet;
}
}
// -----------------------------------------------------------------------
OfaMiscTabPage::OfaMiscTabPage(Window* pParent, const SfxItemSet& rSet ) :
SfxTabPage( pParent, CUI_RES( OFA_TP_MISC ), rSet ),
aHelpFL ( this, CUI_RES( FL_HELP ) ),
aToolTipsCB ( this, CUI_RES( CB_TOOLTIP ) ),
aExtHelpCB ( this, CUI_RES( CB_EXTHELP ) ),
aHelpAgentCB ( this, CUI_RES( CB_HELPAGENT ) ),
aHelpAgentResetBtn ( this, CUI_RES( PB_HELPAGENT_RESET ) ),
aHelpFormatFT ( this, CUI_RES( FT_HELPFORMAT ) ),
aHelpFormatLB ( this, CUI_RES( LB_HELPFORMAT ) ),
aFileDlgFL ( this, CUI_RES( FL_FILEDLG ) ),
aFileDlgROImage ( this, CUI_RES( FI_FILEDLG_RO ) ),
aFileDlgCB ( this, CUI_RES( CB_FILEDLG ) ),
aODMADlgCB ( this, CUI_RES( CB_ODMADLG ) ),
aPrintDlgFL ( this, CUI_RES( FL_PRINTDLG ) ),
aPrintDlgCB ( this, CUI_RES( CB_PRINTDLG ) ),
aDocStatusFL ( this, CUI_RES( FL_DOCSTATUS ) ),
aDocStatusCB ( this, CUI_RES( CB_DOCSTATUS ) ),
aSaveAlwaysCB ( this, CUI_RES( CB_SAVE_ALWAYS ) ),
aTwoFigureFL ( this, CUI_RES( FL_TWOFIGURE ) ),
aInterpretFT ( this, CUI_RES( FT_INTERPRET ) ),
aYearValueField ( this, CUI_RES( NF_YEARVALUE ) ),
aToYearFT ( this, CUI_RES( FT_TOYEAR ) ),
aExperimentalCB ( this, CUI_RES( CB_EXPERIMENTAL ) )
{
FreeResource();
#if !defined(ENABLE_HELP_FORMATTING)
aHelpFormatFT.Hide();
aHelpFormatLB.Hide();
#endif
if (!lcl_HasSystemFilePicker())
{
aFileDlgFL.Hide();
aFileDlgCB.Hide();
}
#if !defined(QUARTZ)
aPrintDlgFL.Hide();
aPrintDlgCB.Hide();
#endif
#ifdef WNT
aFileDlgCB.SetToggleHdl( LINK( this, OfaMiscTabPage, OnFileDlgToggled ) );
#else
aODMADlgCB.Hide();
#endif
if (!aODMADlgCB.IsVisible())
{
// rearrange the following controls
Point aNewPos = aPrintDlgFL.GetPosPixel();
long nDelta = aNewPos.Y() - aODMADlgCB.GetPosPixel().Y();
Window* pWins[] =
{
&aPrintDlgFL, &aPrintDlgCB, &aDocStatusFL, &aDocStatusCB, &aSaveAlwaysCB,
&aTwoFigureFL, &aInterpretFT, &aYearValueField, &aToYearFT, &aExperimentalCB
};
Window** pCurrent = pWins;
const sal_Int32 nCount = SAL_N_ELEMENTS( pWins );
for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
{
aNewPos = (*pCurrent)->GetPosPixel();
aNewPos.Y() -= nDelta;
(*pCurrent)->SetPosPixel( aNewPos );
}
}
if ( !aFileDlgCB.IsVisible() )
{
// rearrange the following controls
Point aNewPos = aPrintDlgFL.GetPosPixel();
long nDelta = aNewPos.Y() - aFileDlgFL.GetPosPixel().Y();
Window* pWins[] =
{
&aPrintDlgFL, &aPrintDlgCB, &aDocStatusFL, &aDocStatusCB, &aSaveAlwaysCB,
&aTwoFigureFL, &aInterpretFT, &aYearValueField, &aToYearFT, &aExperimentalCB
};
Window** pCurrent = pWins;
const sal_Int32 nCount = SAL_N_ELEMENTS( pWins );
for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
{
aNewPos = (*pCurrent)->GetPosPixel();
aNewPos.Y() -= nDelta;
(*pCurrent)->SetPosPixel( aNewPos );
}
}
else if ( SvtMiscOptions().IsUseSystemFileDialogReadOnly() )
{
aFileDlgROImage.Show();
aFileDlgCB.Disable();
}
if ( !aPrintDlgCB.IsVisible() )
{
// rearrange the following controls
Point aNewPos = aDocStatusFL.GetPosPixel();
long nDelta = aNewPos.Y() - aPrintDlgFL.GetPosPixel().Y();
Window* pWins[] =
{
&aDocStatusFL, &aDocStatusCB, &aSaveAlwaysCB, &aTwoFigureFL,
&aInterpretFT, &aYearValueField, &aToYearFT, &aExperimentalCB
};
Window** pCurrent = pWins;
const sal_Int32 nCount = SAL_N_ELEMENTS( pWins );
for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
{
aNewPos = (*pCurrent)->GetPosPixel();
aNewPos.Y() -= nDelta;
(*pCurrent)->SetPosPixel( aNewPos );
}
}
// at least the button is as wide as its text
long nTxtWidth = aHelpAgentResetBtn.GetTextWidth( aHelpAgentResetBtn.GetText() );
Size aBtnSz = aHelpAgentResetBtn.GetSizePixel();
if ( aBtnSz.Width() < nTxtWidth )
{
aBtnSz.Width() = nTxtWidth;
aHelpAgentResetBtn.SetSizePixel( aBtnSz );
}
aStrDateInfo = aToYearFT.GetText();
aYearValueField.SetModifyHdl( LINK( this, OfaMiscTabPage, TwoFigureHdl ) );
Link aLink = LINK( this, OfaMiscTabPage, TwoFigureConfigHdl );
aYearValueField.SetDownHdl( aLink );
aYearValueField.SetUpHdl( aLink );
aYearValueField.SetLoseFocusHdl( aLink );
aYearValueField.SetFirstHdl( aLink );
TwoFigureConfigHdl( &aYearValueField );
SetExchangeSupport();
aLink = LINK( this, OfaMiscTabPage, HelpCheckHdl_Impl );
aToolTipsCB.SetClickHdl( aLink );
aHelpAgentCB.SetClickHdl( aLink );
aHelpAgentResetBtn.SetClickHdl( LINK( this, OfaMiscTabPage, HelpAgentResetHdl_Impl ) );
//fill default names as user data
static const char* aHelpFormatNames[] =
{
"Default",
"HighContrast1",
"HighContrast2",
"HighContrastBlack",
"HighContrastWhite"
};
for ( sal_uInt16 i = 0; i < aHelpFormatLB.GetEntryCount(); i++ )
{
String* pData = new String( String::CreateFromAscii( aHelpFormatNames[i] ) );
aHelpFormatLB.SetEntryData( i, pData );
}
}
#ifdef WNT
IMPL_LINK( OfaMiscTabPage, OnFileDlgToggled, CheckBox*, EMPTYARG )
{
aODMADlgCB.Enable( !aFileDlgCB.IsChecked() );
return 0;
}
#endif
// -----------------------------------------------------------------------
OfaMiscTabPage::~OfaMiscTabPage()
{
for(sal_uInt16 i = 0; i < aHelpFormatLB.GetEntryCount(); i++)
{
delete static_cast< String* >( aHelpFormatLB.GetEntryData(i) );
}
}
// -----------------------------------------------------------------------
SfxTabPage* OfaMiscTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
{
return new OfaMiscTabPage( pParent, rAttrSet );
}
// -----------------------------------------------------------------------
sal_Bool OfaMiscTabPage::FillItemSet( SfxItemSet& rSet )
{
sal_Bool bModified = sal_False;
SvtHelpOptions aHelpOptions;
sal_Bool bChecked = aToolTipsCB.IsChecked();
if ( bChecked != aToolTipsCB.GetSavedValue() )
aHelpOptions.SetHelpTips( bChecked );
bChecked = ( aExtHelpCB.IsChecked() && aToolTipsCB.IsChecked() );
if ( bChecked != aExtHelpCB.GetSavedValue() )
aHelpOptions.SetExtendedHelp( bChecked );
bChecked = aHelpAgentCB.IsChecked();
if ( bChecked != aHelpAgentCB.GetSavedValue() )
aHelpOptions.SetHelpAgentAutoStartMode( bChecked );
sal_uInt16 nHelpFormatPos = aHelpFormatLB.GetSelectEntryPos();
if ( nHelpFormatPos != LISTBOX_ENTRY_NOTFOUND &&
nHelpFormatPos != aHelpFormatLB.GetSavedValue() )
{
aHelpOptions.SetHelpStyleSheet( *static_cast< String* >( aHelpFormatLB.GetEntryData( nHelpFormatPos ) ) );
}
if ( aFileDlgCB.IsChecked() != aFileDlgCB.GetSavedValue() )
{
SvtMiscOptions aMiscOpt;
aMiscOpt.SetUseSystemFileDialog( !aFileDlgCB.IsChecked() );
bModified = sal_True;
}
if ( aPrintDlgCB.IsChecked() != aPrintDlgCB.GetSavedValue() )
{
SvtMiscOptions aMiscOpt;
aMiscOpt.SetUseSystemPrintDialog( !aPrintDlgCB.IsChecked() );
bModified = sal_True;
}
if ( aODMADlgCB.IsChecked() != aODMADlgCB.GetSavedValue() )
{
SvtMiscOptions aMiscOpt;
aMiscOpt.SetTryODMADialog( aODMADlgCB.IsChecked() );
bModified = sal_True;
}
if ( aDocStatusCB.IsChecked() != aDocStatusCB.GetSavedValue() )
{
SvtPrintWarningOptions aPrintOptions;
aPrintOptions.SetModifyDocumentOnPrintingAllowed( aDocStatusCB.IsChecked() );
bModified = sal_True;
}
if ( aSaveAlwaysCB.IsChecked() != aSaveAlwaysCB.GetSavedValue() )
{
SvtMiscOptions aMiscOpt;
aMiscOpt.SetSaveAlwaysAllowed( aSaveAlwaysCB.IsChecked() );
bModified = sal_True;
}
if ( aExperimentalCB.IsChecked() != aExperimentalCB.GetSavedValue() )
{
SvtMiscOptions aMiscOpt;
aMiscOpt.SetExperimentalMode( aExperimentalCB.IsChecked() );
bModified = sal_True;
}
const SfxUInt16Item* pUInt16Item =
PTR_CAST( SfxUInt16Item, GetOldItem( rSet, SID_ATTR_YEAR2000 ) );
sal_uInt16 nNum = (sal_uInt16)aYearValueField.GetText().ToInt32();
if ( pUInt16Item && pUInt16Item->GetValue() != nNum )
{
bModified = sal_True;
rSet.Put( SfxUInt16Item( SID_ATTR_YEAR2000, nNum ) );
}
return bModified;
}
// -----------------------------------------------------------------------
void OfaMiscTabPage::Reset( const SfxItemSet& rSet )
{
SvtHelpOptions aHelpOptions;
aToolTipsCB.Check( aHelpOptions.IsHelpTips() );
aExtHelpCB.Check( aHelpOptions.IsHelpTips() && aHelpOptions.IsExtendedHelp() );
aHelpAgentCB.Check( aHelpOptions.IsHelpAgentAutoStartMode() );
String sStyleSheet = aHelpOptions.GetHelpStyleSheet();
for ( sal_uInt16 i = 0; i < aHelpFormatLB.GetEntryCount(); ++i )
{
if ( *static_cast< String* >( aHelpFormatLB.GetEntryData(i) ) == sStyleSheet )
{
aHelpFormatLB.SelectEntryPos(i);
break;
}
}
aToolTipsCB.SaveValue();
aExtHelpCB.SaveValue();
aHelpAgentCB.SaveValue();
aHelpFormatLB.SaveValue();
HelpCheckHdl_Impl( &aHelpAgentCB );
SvtMiscOptions aMiscOpt;
aFileDlgCB.Check( !aMiscOpt.UseSystemFileDialog() );
aFileDlgCB.SaveValue();
aPrintDlgCB.Check( !aMiscOpt.UseSystemPrintDialog() );
aPrintDlgCB.SaveValue();
aSaveAlwaysCB.Check( aMiscOpt.IsSaveAlwaysAllowed() );
aSaveAlwaysCB.SaveValue();
aExperimentalCB.Check( aMiscOpt.IsExperimentalMode() );
aExperimentalCB.SaveValue();
aODMADlgCB.Check( aMiscOpt.TryODMADialog() );
aODMADlgCB.SaveValue();
SvtPrintWarningOptions aPrintOptions;
aDocStatusCB.Check(aPrintOptions.IsModifyDocumentOnPrintingAllowed());
aDocStatusCB.SaveValue();
const SfxPoolItem* pItem = NULL;
if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_YEAR2000, sal_False, &pItem ) )
{
aYearValueField.SetValue( ((SfxUInt16Item*)pItem)->GetValue() );
TwoFigureConfigHdl( &aYearValueField );
}
else
{
aYearValueField.Enable(sal_False);
aTwoFigureFL.Enable(sal_False);
aInterpretFT.Enable(sal_False);
aToYearFT.Enable(sal_False);
}
}
// -----------------------------------------------------------------------
IMPL_LINK( OfaMiscTabPage, TwoFigureHdl, NumericField*, pEd )
{
(void)pEd;
String aOutput( aStrDateInfo );
String aStr( aYearValueField.GetText() );
String sSep( SvtSysLocale().GetLocaleData().getNumThousandSep() );
xub_StrLen nIndex = 0;
while ((nIndex = aStr.Search( sSep, nIndex)) != STRING_NOTFOUND)
aStr.Erase( nIndex, sSep.Len());
long nNum = aStr.ToInt32();
if ( aStr.Len() != 4 || nNum < aYearValueField.GetMin() || nNum > aYearValueField.GetMax() )
aOutput.AppendAscii("????");
else
{
nNum += 99;
aOutput += String::CreateFromInt32( nNum );
}
aToYearFT.SetText( aOutput );
return 0;
}
// -----------------------------------------------------------------------
IMPL_LINK( OfaMiscTabPage, TwoFigureConfigHdl, NumericField*, pEd )
{
sal_Int64 nNum = aYearValueField.GetValue();
String aOutput( String::CreateFromInt64( nNum ) );
aYearValueField.SetText( aOutput );
aYearValueField.SetSelection( Selection( 0, aOutput.Len() ) );
TwoFigureHdl( pEd );
return 0;
}
// -----------------------------------------------------------------------
IMPL_LINK( OfaMiscTabPage, HelpCheckHdl_Impl, CheckBox*, EMPTYARG )
{
aExtHelpCB.Enable( aToolTipsCB.IsChecked() );
aHelpAgentResetBtn.Enable( aHelpAgentCB.IsChecked() );
return 0;
}
// -----------------------------------------------------------------------
IMPL_LINK( OfaMiscTabPage, HelpAgentResetHdl_Impl, PushButton*, EMPTYARG )
{
SvtHelpOptions().resetAgentIgnoreURLCounter();
return 0;
}
// -----------------------------------------------------------------------
// -------------------------------------------------------------------
class CanvasSettings
{
public:
CanvasSettings();
sal_Bool IsHardwareAccelerationEnabled() const;
sal_Bool IsHardwareAccelerationAvailable() const;
void EnabledHardwareAcceleration( sal_Bool _bEnabled ) const;
private:
typedef std::vector< std::pair<OUString,Sequence<OUString> > > ServiceVector;
Reference<XNameAccess> mxForceFlagNameAccess;
ServiceVector maAvailableImplementations;
mutable sal_Bool mbHWAccelAvailable;
mutable sal_Bool mbHWAccelChecked;
};
// -------------------------------------------------------------------
CanvasSettings::CanvasSettings() :
mxForceFlagNameAccess(),
mbHWAccelAvailable(sal_False),
mbHWAccelChecked(sal_False)
{
try
{
Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
Reference<XMultiServiceFactory> xConfigProvider(
xFactory->createInstance(
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))),
UNO_QUERY_THROW );
Any propValue(
makeAny( PropertyValue(
OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), -1,
makeAny( OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Canvas")) ),
PropertyState_DIRECT_VALUE ) ) );
mxForceFlagNameAccess.set(
xConfigProvider->createInstanceWithArguments(
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess")),
Sequence<Any>( &propValue, 1 ) ),
UNO_QUERY_THROW );
propValue = makeAny(
PropertyValue(
OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), -1,
makeAny( OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Canvas/CanvasServiceList")) ),
PropertyState_DIRECT_VALUE ) );
Reference<XNameAccess> xNameAccess(
xConfigProvider->createInstanceWithArguments(
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")),
Sequence<Any>( &propValue, 1 ) ), UNO_QUERY_THROW );
Reference<XHierarchicalNameAccess> xHierarchicalNameAccess(
xNameAccess, UNO_QUERY_THROW);
Sequence<OUString> serviceNames = xNameAccess->getElementNames();
const OUString* pCurr = serviceNames.getConstArray();
const OUString* const pEnd = pCurr + serviceNames.getLength();
while( pCurr != pEnd )
{
Reference<XNameAccess> xEntryNameAccess(
xHierarchicalNameAccess->getByHierarchicalName(*pCurr),
UNO_QUERY );
if( xEntryNameAccess.is() )
{
Sequence<OUString> preferredImplementations;
if( (xEntryNameAccess->getByName( OUString(RTL_CONSTASCII_USTRINGPARAM("PreferredImplementations")) ) >>= preferredImplementations) )
maAvailableImplementations.push_back( std::make_pair(*pCurr,preferredImplementations) );
}
++pCurr;
}
}
catch (const Exception&)
{
}
}
// -------------------------------------------------------------------
sal_Bool CanvasSettings::IsHardwareAccelerationAvailable() const
{
if( !mbHWAccelChecked )
{
mbHWAccelChecked = true;
Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
// check whether any of the service lists has an
// implementation that presents the "HardwareAcceleration" property
ServiceVector::const_iterator aCurr=maAvailableImplementations.begin();
const ServiceVector::const_iterator aEnd=maAvailableImplementations.end();
while( aCurr != aEnd )
{
const OUString* pCurrImpl = aCurr->second.getConstArray();
const OUString* const pEndImpl = pCurrImpl + aCurr->second.getLength();
while( pCurrImpl != pEndImpl )
{
try
{
Reference<XPropertySet> xPropSet( xFactory->createInstance(
pCurrImpl->trim() ),
UNO_QUERY_THROW );
bool bHasAccel(false);
if( (xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HardwareAcceleration"))) >>= bHasAccel) )
if( bHasAccel )
{
mbHWAccelAvailable = true;
return mbHWAccelAvailable;
}
}
catch (const Exception&)
{
}
++pCurrImpl;
}
++aCurr;
}
}
return mbHWAccelAvailable;
}
// -------------------------------------------------------------------
sal_Bool CanvasSettings::IsHardwareAccelerationEnabled() const
{
bool bForceLastEntry(false);
if( !mxForceFlagNameAccess.is() )
return true;
if( !(mxForceFlagNameAccess->getByName( OUString(RTL_CONSTASCII_USTRINGPARAM("ForceSafeServiceImpl")) ) >>= bForceLastEntry) )
return true;
return !bForceLastEntry;
}
// -------------------------------------------------------------------
void CanvasSettings::EnabledHardwareAcceleration( sal_Bool _bEnabled ) const
{
Reference< XNameReplace > xNameReplace(
mxForceFlagNameAccess, UNO_QUERY );
if( !xNameReplace.is() )
return;
xNameReplace->replaceByName( OUString(RTL_CONSTASCII_USTRINGPARAM("ForceSafeServiceImpl")),
makeAny(!_bEnabled) );
Reference< XChangesBatch > xChangesBatch(
mxForceFlagNameAccess, UNO_QUERY );
if( !xChangesBatch.is() )
return;
xChangesBatch->commitChanges();
}
// class OfaViewTabPage --------------------------------------------------
OfaViewTabPage::OfaViewTabPage(Window* pParent, const SfxItemSet& rSet ) :
SfxTabPage( pParent, CUI_RES( OFA_TP_VIEW ), rSet ),
aUserInterfaceFL ( this, CUI_RES( FL_USERINTERFACE ) ),
aWindowSizeFT ( this, CUI_RES( FT_WINDOWSIZE ) ),
aWindowSizeMF ( this, CUI_RES( MF_WINDOWSIZE ) ),
aIconSizeStyleFT ( this, CUI_RES( FT_ICONSIZESTYLE ) ),
aIconSizeLB ( this, CUI_RES( LB_ICONSIZE ) ),
aIconStyleLB ( this, CUI_RES( LB_ICONSTYLE ) ),
m_aSystemFont (this, CUI_RES( CB_SYSTEM_FONT ) ),
#if defined( UNX )
aFontAntiAliasing ( this, CUI_RES( CB_FONTANTIALIASING )),
aAAPointLimitLabel ( this, CUI_RES( FT_POINTLIMIT_LABEL )),
aAAPointLimit ( this, CUI_RES( NF_AA_POINTLIMIT )),
aAAPointLimitUnits ( this, CUI_RES( FT_POINTLIMIT_UNIT )),
#endif
aMenuFL ( this, CUI_RES( FL_MENU ) ),
aMenuIconsFT ( this, CUI_RES( FT_MENU_ICONS )),
aMenuIconsLB ( this, CUI_RES( LB_MENU_ICONS )),
aFontListsFL ( this, CUI_RES( FL_FONTLISTS) ),
aFontShowCB ( this, CUI_RES( CB_FONT_SHOW ) ),
aFontHistoryCB ( this, CUI_RES( CB_FONT_HISTORY ) ),
aRenderingFL ( this, CUI_RES( FL_RENDERING ) ),
aUseHardwareAccell ( this, CUI_RES( CB_USE_HARDACCELL ) ),
aUseAntiAliase ( this, CUI_RES( CB_USE_ANTIALIASE ) ),
aMouseFL ( this, CUI_RES( FL_MOUSE ) ),
aMousePosFT ( this, CUI_RES( FT_MOUSEPOS ) ),
aMousePosLB ( this, CUI_RES( LB_MOUSEPOS ) ),
aMouseMiddleFT ( this, CUI_RES( FT_MOUSEMIDDLE ) ),
aMouseMiddleLB ( this, CUI_RES( LB_MOUSEMIDDLE ) ),
// #i97672#
maSelectionFL(this, CUI_RES(FL_SELECTION)),
maSelectionCB(this, CUI_RES(CB_SELECTION)),
maSelectionMF(this, CUI_RES(MF_SELECTION)),
nSizeLB_InitialSelection(0),
nStyleLB_InitialSelection(0),
pAppearanceCfg(new SvtTabAppearanceCfg),
pCanvasSettings(new CanvasSettings),
mpDrawinglayerOpt(new SvtOptionsDrawinglayer)
{
#if defined( UNX )
aFontAntiAliasing.SetToggleHdl( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) );
// depending on the size of the text in aAAPointLimitLabel, we slightly re-arrange aAAPointLimit and aAAPointLimitUnits
//#110391# if the label has no mnemonic and we are in a CJK version the mnemonic "(X)" will be added which
// influences the width calculation
MnemonicGenerator aMnemonicGenerator;
String sLabel(aAAPointLimitLabel.GetText());
aMnemonicGenerator.RegisterMnemonic( sLabel );
aMnemonicGenerator.CreateMnemonic( sLabel );
sLabel.EraseAllChars('~');
sal_Int32 nLabelWidth = aAAPointLimitLabel.GetTextWidth( sLabel );
nLabelWidth += 3; // small gap
// pixels to move both controls to the left
Size aSize = aAAPointLimitLabel.GetSizePixel();
sal_Int32 nMoveLeft = aSize.Width() - nLabelWidth;
// resize the first label
aSize.Width() = nLabelWidth;
aAAPointLimitLabel.SetSizePixel( aSize );
// move the numeric field
Point aPos( aAAPointLimit.GetPosPixel() );
aPos.X() -= nMoveLeft;
aAAPointLimit.SetPosPixel( aPos );
// move (and resize) the units FixedText
aPos = ( aAAPointLimitUnits.GetPosPixel() );
aPos.X() -= nMoveLeft;
aSize = aAAPointLimitUnits.GetSizePixel();
aSize.Width() += nMoveLeft;
aAAPointLimitUnits.SetPosSizePixel( aPos, aSize );
#else
// on this platform, we do not have the anti aliasing options - move the other checkboxes accordingly
// (in the resource, the coordinates are calculated for the AA options beeing present)
Control* pMiscOptions[] =
{
&aMenuFL, &aMenuIconsFT, &aMenuIconsLB,
&aFontListsFL, &aFontShowCB, &aFontHistoryCB
};
// temporaryly create the checkbox for the anti aliasing (we need to to determine it's pos)
CheckBox* pFontAntiAliasing = new CheckBox( this, CUI_RES( CB_FONTANTIALIASING ) );
sal_Int32 nMoveUp = aMenuFL.GetPosPixel().Y() - pFontAntiAliasing->GetPosPixel().Y();
DELETEZ( pFontAntiAliasing );
Point aPos;
for ( sal_Int32 i = 0; i < SAL_N_ELEMENTS( pMiscOptions ); ++i )
{
aPos = pMiscOptions[i]->GetPosPixel( );
aPos.Y() -= nMoveUp;
pMiscOptions[i]->SetPosPixel( aPos );
}
#endif
// #i97672#
maSelectionCB.SetToggleHdl( LINK( this, OfaViewTabPage, OnSelectionToggled ) );
FreeResource();
if( ! Application::ValidateSystemFont() )
{
m_aSystemFont.Check( sal_False );
m_aSystemFont.Enable( sal_False );
}
const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings();
// remove non-installed icon themes
if( aIconStyleLB.GetEntryCount() == STYLE_SYMBOLS_THEMES_MAX )
{
// do not check 0th item == auto; it is not a real theme
aIconStyleItemId[0] = 0;
sal_uLong nItem = 1;
for ( sal_uLong n=0; ++n < STYLE_SYMBOLS_THEMES_MAX; )
{
if ( aStyleSettings.CheckSymbolStyle( n ) )
{
// existing style => save the item id
aIconStyleItemId[n] = nItem++;
}
else
{
// non-existing style => remove item;
aIconStyleLB.RemoveEntry( nItem );
aIconStyleItemId[n] = 0;
}
}
}
// add real theme name to 'auto' theme, e.g. 'auto' => 'auto (classic)'
if( aIconStyleLB.GetEntryCount() > 1 )
{
::rtl::OUString aAutoStr( aIconStyleLB.GetEntry( 0 ) );
aAutoStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (") );
// prefer the icon style set by the desktop native widgets modules
sal_uLong nAutoStyle = aStyleSettings.GetPreferredSymbolsStyle();
// fallback to the statically defined values
if ( nAutoStyle == STYLE_SYMBOLS_AUTO || !aIconStyleItemId[nAutoStyle] )
nAutoStyle = aStyleSettings.GetAutoSymbolsStyle();
if ( aIconStyleItemId[nAutoStyle] )
aAutoStr += aIconStyleLB.GetEntry( aIconStyleItemId[nAutoStyle] );
aIconStyleLB.RemoveEntry( 0 );
aIconStyleLB.InsertEntry( aAutoStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")") ), 0 );
// separate auto and other icon themes
aIconStyleLB.SetSeparatorPos( 0 );
}
}
OfaViewTabPage::~OfaViewTabPage()
{
delete mpDrawinglayerOpt;
delete pCanvasSettings;
delete pAppearanceCfg;
}
#if defined( UNX )
IMPL_LINK( OfaViewTabPage, OnAntialiasingToggled, void*, NOTINTERESTEDIN )
{
(void)NOTINTERESTEDIN;
sal_Bool bAAEnabled = aFontAntiAliasing.IsChecked();
aAAPointLimitLabel.Enable( bAAEnabled );
aAAPointLimit.Enable( bAAEnabled );
aAAPointLimitUnits.Enable( bAAEnabled );
return 0L;
}
#endif
// #i97672#
IMPL_LINK( OfaViewTabPage, OnSelectionToggled, void*, NOTINTERESTEDIN )
{
(void)NOTINTERESTEDIN;
const bool bSelectionEnabled(maSelectionCB.IsChecked());
maSelectionMF.Enable(bSelectionEnabled);
return 0;
}
SfxTabPage* OfaViewTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
{
return new OfaViewTabPage(pParent, rAttrSet);
}
sal_Bool OfaViewTabPage::FillItemSet( SfxItemSet& )
{
SvtFontOptions aFontOpt;
SvtMenuOptions aMenuOpt;
SvtStartOptions aStartOpt;
sal_Bool bModified = sal_False;
sal_Bool bMenuOptModified = sal_False;
bool bRepaintWindows(false);
SvtMiscOptions aMiscOptions;
sal_uInt16 nSizeLB_NewSelection = aIconSizeLB.GetSelectEntryPos();
if( nSizeLB_InitialSelection != nSizeLB_NewSelection )
{
// from now on it's modified, even if via auto setting the same size was set as now selected in the LB
sal_Int16 eSet = SFX_SYMBOLS_SIZE_AUTO;
switch( nSizeLB_NewSelection )
{
case 0: eSet = SFX_SYMBOLS_SIZE_AUTO; break;
case 1: eSet = SFX_SYMBOLS_SIZE_SMALL; break;
case 2: eSet = SFX_SYMBOLS_SIZE_LARGE; break;
default:
OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of aIconSizeLB should not be possible!" );
}
aMiscOptions.SetSymbolsSize( eSet );
}
sal_uInt16 nStyleLB_NewSelection = aIconStyleLB.GetSelectEntryPos();
if( nStyleLB_InitialSelection != nStyleLB_NewSelection )
{
// find the style name in the aIconStyleItemId table
// items from the non-installed icon themes were removed
for ( sal_uLong n=0; n < STYLE_SYMBOLS_THEMES_MAX; n++ )
{
if ( aIconStyleItemId[n] == nStyleLB_NewSelection )
{
aMiscOptions.SetSymbolsStyle( n );
n = STYLE_SYMBOLS_THEMES_MAX;
}
}
}
sal_Bool bAppearanceChanged = sal_False;
// Screen Scaling
sal_uInt16 nOldScale = pAppearanceCfg->GetScaleFactor();
sal_uInt16 nNewScale = (sal_uInt16)aWindowSizeMF.GetValue();
if ( nNewScale != nOldScale )
{
pAppearanceCfg->SetScaleFactor(nNewScale);
bAppearanceChanged = sal_True;
}
// Mouse Snap Mode
short eOldSnap = pAppearanceCfg->GetSnapMode();
short eNewSnap = aMousePosLB.GetSelectEntryPos();
if(eNewSnap > 2)
eNewSnap = 2;
if ( eNewSnap != eOldSnap )
{
pAppearanceCfg->SetSnapMode(eNewSnap );
bAppearanceChanged = sal_True;
}
// Middle Mouse Button
short eOldMiddleMouse = pAppearanceCfg->GetMiddleMouseButton();
short eNewMiddleMouse = aMouseMiddleLB.GetSelectEntryPos();
if(eNewMiddleMouse > 2)
eNewMiddleMouse = 2;
if ( eNewMiddleMouse != eOldMiddleMouse )
{
pAppearanceCfg->SetMiddleMouseButton( eNewMiddleMouse );
bAppearanceChanged = sal_True;
}
#if defined( UNX )
if ( aFontAntiAliasing.IsChecked() != aFontAntiAliasing.GetSavedValue() )
{
pAppearanceCfg->SetFontAntiAliasing( aFontAntiAliasing.IsChecked() );
bAppearanceChanged = sal_True;
}
if ( aAAPointLimit.GetValue() != aAAPointLimit.GetSavedValue().ToInt32() )
{
pAppearanceCfg->SetFontAntialiasingMinPixelHeight( aAAPointLimit.GetValue() );
bAppearanceChanged = sal_True;
}
#endif
if ( aFontShowCB.IsChecked() != aFontShowCB.GetSavedValue() )
{
aFontOpt.EnableFontWYSIWYG( aFontShowCB.IsChecked() );
bModified = sal_True;
}
if(aMenuIconsLB.GetSelectEntryPos() != aMenuIconsLB.GetSavedValue())
{
aMenuOpt.SetMenuIconsState( aMenuIconsLB.GetSelectEntryPos() == 0 ? 2 : aMenuIconsLB.GetSelectEntryPos() - 1);
bModified = sal_True;
bMenuOptModified = sal_True;
bAppearanceChanged = sal_True;
}
if ( aFontHistoryCB.IsChecked() != aFontHistoryCB.GetSavedValue() )
{
aFontOpt.EnableFontHistory( aFontHistoryCB.IsChecked() );
bModified = sal_True;
}
// #i95644# if disabled, do not use value, see in ::Reset()
if(aUseHardwareAccell.IsEnabled())
{
if(aUseHardwareAccell.IsChecked() != aUseHardwareAccell.GetSavedValue())
{
pCanvasSettings->EnabledHardwareAcceleration(aUseHardwareAccell.IsChecked());
bModified = sal_True;
}
}
// #i95644# if disabled, do not use value, see in ::Reset()
if(aUseAntiAliase.IsEnabled())
{
if(aUseAntiAliase.IsChecked() != mpDrawinglayerOpt->IsAntiAliasing())
{
mpDrawinglayerOpt->SetAntiAliasing(aUseAntiAliase.IsChecked());
bModified = sal_True;
bRepaintWindows = true;
}
}
// #i97672#
if(maSelectionCB.IsEnabled())
{
const bool bNewSelection(maSelectionCB.IsChecked());
const sal_uInt16 nNewTransparence((sal_uInt16)maSelectionMF.GetValue());
if(bNewSelection != (bool)mpDrawinglayerOpt->IsTransparentSelection())
{
mpDrawinglayerOpt->SetTransparentSelection(maSelectionCB.IsChecked());
bModified = sal_True;
bRepaintWindows = true;
}
// #i104150# even read the value when maSelectionMF is disabled; it may have been
// modified by enabling-modify-disabling by the user
if(nNewTransparence != mpDrawinglayerOpt->GetTransparentSelectionPercent())
{
mpDrawinglayerOpt->SetTransparentSelectionPercent(nNewTransparence);
bModified = sal_True;
bRepaintWindows = true;
}
}
SvtAccessibilityOptions aAccessibilityOptions;
if( aAccessibilityOptions.GetIsSystemFont() != m_aSystemFont.IsChecked() &&
m_aSystemFont.IsEnabled() )
{
aAccessibilityOptions.SetIsSystemFont( m_aSystemFont.IsChecked() );
bModified = sal_True;
bMenuOptModified = sal_True;
}
if( bMenuOptModified )
{
// Set changed settings to the application instance
AllSettings aAllSettings = Application::GetSettings();
StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
if( m_aSystemFont.IsEnabled() )
aStyleSettings.SetUseSystemUIFonts( m_aSystemFont.IsChecked() );
aAllSettings.SetStyleSettings(aStyleSettings);
Application::MergeSystemSettings( aAllSettings );
Application::SetSettings(aAllSettings);
}
if ( bAppearanceChanged )
{
pAppearanceCfg->Commit();
pAppearanceCfg->SetApplicationDefaults ( GetpApp() );
}
if(bRepaintWindows)
{
Window* pAppWindow = Application::GetFirstTopLevelWindow();
while(pAppWindow)
{
pAppWindow->Invalidate();
pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
}
}
return bModified;
}
void OfaViewTabPage::Reset( const SfxItemSet& )
{
SvtMiscOptions aMiscOptions;
if( aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO )
nSizeLB_InitialSelection = ( aMiscOptions.AreCurrentSymbolsLarge() )? 2 : 1;
aIconSizeLB.SelectEntryPos( nSizeLB_InitialSelection );
aIconSizeLB.SaveValue();
if( aMiscOptions.GetSymbolsStyle() != STYLE_SYMBOLS_AUTO )
nStyleLB_InitialSelection = aIconStyleItemId[aMiscOptions.GetCurrentSymbolsStyle()];
aIconStyleLB.SelectEntryPos( nStyleLB_InitialSelection );
aIconStyleLB.SaveValue();
if( m_aSystemFont.IsEnabled() )
{
SvtAccessibilityOptions aAccessibilityOptions;
m_aSystemFont.Check( aAccessibilityOptions.GetIsSystemFont() );
}
// Screen Scaling
aWindowSizeMF.SetValue ( pAppearanceCfg->GetScaleFactor() );
// Mouse Snap
aMousePosLB.SelectEntryPos(pAppearanceCfg->GetSnapMode());
aMousePosLB.SaveValue();
// Mouse Snap
aMouseMiddleLB.SelectEntryPos(pAppearanceCfg->GetMiddleMouseButton());
aMouseMiddleLB.SaveValue();
#if defined( UNX )
aFontAntiAliasing.Check( pAppearanceCfg->IsFontAntiAliasing() );
aAAPointLimit.SetValue( pAppearanceCfg->GetFontAntialiasingMinPixelHeight() );
#endif
// WorkingSet
SvtFontOptions aFontOpt;
aFontShowCB.Check( aFontOpt.IsFontWYSIWYGEnabled() );
SvtMenuOptions aMenuOpt;
aMenuIconsLB.SelectEntryPos(aMenuOpt.GetMenuIconsState() == 2 ? 0 : aMenuOpt.GetMenuIconsState() + 1);
aMenuIconsLB.SaveValue();
aFontHistoryCB.Check( aFontOpt.IsFontHistoryEnabled() );
{ // #i95644# HW accel (unified to disable mechanism)
if(pCanvasSettings->IsHardwareAccelerationAvailable())
{
aUseHardwareAccell.Check(pCanvasSettings->IsHardwareAccelerationEnabled());
}
else
{
aUseHardwareAccell.Check(false);
aUseHardwareAccell.Disable();
}
aUseHardwareAccell.SaveValue();
}
{ // #i95644# AntiAliasing
if(mpDrawinglayerOpt->IsAAPossibleOnThisSystem())
{
aUseAntiAliase.Check(mpDrawinglayerOpt->IsAntiAliasing());
}
else
{
aUseAntiAliase.Check(false);
aUseAntiAliase.Disable();
}
aUseAntiAliase.SaveValue();
}
{
// #i97672# Selection
// check if transparent selection is possible on this system
const bool bTransparentSelectionPossible(
!GetSettings().GetStyleSettings().GetHighContrastMode()
&& supportsOperation(OutDevSupport_TransparentRect));
// enter values
if(bTransparentSelectionPossible)
{
maSelectionCB.Check(mpDrawinglayerOpt->IsTransparentSelection());
}
else
{
maSelectionCB.Enable(false);
}
maSelectionMF.SetValue(mpDrawinglayerOpt->GetTransparentSelectionPercent());
maSelectionMF.Enable(mpDrawinglayerOpt->IsTransparentSelection() && bTransparentSelectionPossible);
}
#if defined( UNX )
aFontAntiAliasing.SaveValue();
aAAPointLimit.SaveValue();
#endif
aFontShowCB.SaveValue();
aFontHistoryCB.SaveValue();
#if defined( UNX )
LINK( this, OfaViewTabPage, OnAntialiasingToggled ).Call( NULL );
#endif
}
struct LanguageConfig_Impl
{
SvtLanguageOptions aLanguageOptions;
SvtSysLocaleOptions aSysLocaleOptions;
SvtLinguConfig aLinguConfig;
};
static sal_Bool bLanguageCurrentDoc_Impl = sal_False;
// some things we'll need...
static const OUString sConfigSrvc(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"));
static const OUString sAccessSrvc(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess"));
static const OUString sAccessUpdSrvc(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess"));
static const OUString sInstalledLocalesPath(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup/Office/InstalledLocales"));
static OUString sUserLocalePath(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Linguistic/General"));
//static const OUString sUserLocalePath(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office/Linguistic"));
static const OUString sUserLocaleKey(RTL_CONSTASCII_USTRINGPARAM("UILocale"));
static const OUString sSystemLocalePath(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.System/L10N"));
static const OUString sSystemLocaleKey(RTL_CONSTASCII_USTRINGPARAM("UILocale"));
static const OUString sOfficeLocalePath(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office/L10N"));
static const OUString sOfficeLocaleKey(RTL_CONSTASCII_USTRINGPARAM("ooLocale"));
static Sequence< OUString > seqInstalledLanguages;
OfaLanguagesTabPage::OfaLanguagesTabPage( Window* pParent, const SfxItemSet& rSet ) :
SfxTabPage( pParent, CUI_RES( OFA_TP_LANGUAGES ), rSet ),
aUILanguageGB(this, CUI_RES(FL_UI_LANG )),
aLocaleSettingFI(this, CUI_RES(FI_LOCALESETTING)),
aUserInterfaceFT(this, CUI_RES(FT_USERINTERFACE)),
aUserInterfaceLB(this, CUI_RES(LB_USERINTERFACE)),
aLocaleSettingFT(this, CUI_RES(FT_LOCALESETTING)),
aLocaleSettingLB(this, CUI_RES(LB_LOCALESETTING)),
aCurrencyFI( this, CUI_RES(FI_CURRENCY )),
aDecimalSeparatorFT(this, CUI_RES(FT_DECIMALSEPARATOR)),
aDecimalSeparatorCB(this, CUI_RES(CB_DECIMALSEPARATOR)),
aCurrencyFT( this, CUI_RES(FT_CURRENCY )),
aCurrencyLB( this, CUI_RES(LB_CURRENCY )),
aLinguLanguageGB(this, CUI_RES(FL_LINGU_LANG )),
aWesternLanguageFI(this, CUI_RES(FI_WEST_LANG )),
aWesternLanguageFT(this, CUI_RES(FT_WEST_LANG )),
aWesternLanguageLB(this, CUI_RES(LB_WEST_LANG )),
aAsianLanguageFI(this, CUI_RES(FI_ASIAN_LANG )),
aAsianLanguageFT(this, CUI_RES(FT_ASIAN_LANG )),
aAsianLanguageLB(this, CUI_RES(LB_ASIAN_LANG )),
aComplexLanguageFI(this, CUI_RES(FI_COMPLEX_LANG )),
aComplexLanguageFT(this, CUI_RES(FT_COMPLEX_LANG )),
aComplexLanguageLB(this, CUI_RES(LB_COMPLEX_LANG )),
aCurrentDocCB(this, CUI_RES(CB_CURRENT_DOC )),
aEnhancedFL(this, CUI_RES(FL_ENHANCED )),
aAsianSupportFI(this, CUI_RES(FI_ASIANSUPPORT )),
aAsianSupportCB(this, CUI_RES(CB_ASIANSUPPORT )),
aCTLSupportFI(this, CUI_RES(FI_CTLSUPPORT )),
aCTLSupportCB(this, CUI_RES(CB_CTLSUPPORT )),
sDecimalSeparatorLabel(aDecimalSeparatorCB.GetText()),
pLangConfig(new LanguageConfig_Impl)
{
FreeResource();
// initialize user interface language selection
SvtLanguageTable* pLanguageTable = new SvtLanguageTable;
const String aStr( pLanguageTable->GetString( LANGUAGE_SYSTEM ) );
String aUILang(aStr);
aUILang += String::CreateFromAscii(" - ");
aUILang += pLanguageTable->GetString( Application::GetSettings().GetUILanguage() );
aUserInterfaceLB.InsertEntry(aUILang);
aUserInterfaceLB.SetEntryData(0, 0);
aUserInterfaceLB.SelectEntryPos(0);
try
{
OUString sOfficeLocaleValue;
OUString sSystemLocaleValue;
Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory();
Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > (
theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW);
Sequence< Any > theArgs(2);
Reference< XNameAccess > theNameAccess;
// find out which locales are currently installed and add them to the listbox
theArgs[0] = makeAny(NamedValue(OUString(RTL_CONSTASCII_USTRINGPARAM("NodePath")), makeAny(sInstalledLocalesPath)));
theArgs[1] = makeAny(NamedValue(OUString(RTL_CONSTASCII_USTRINGPARAM("reload")), makeAny(sal_True)));
theNameAccess = Reference< XNameAccess > (
theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW );
seqInstalledLanguages = theNameAccess->getElementNames();
LanguageType aLang = LANGUAGE_DONTKNOW;
for (sal_IntPtr i=0; i<seqInstalledLanguages.getLength(); i++)
{
aLang = MsLangId::convertIsoStringToLanguage(seqInstalledLanguages[i]);
if (aLang != LANGUAGE_DONTKNOW)
{
//sal_uInt16 p = aUserInterfaceLB.InsertLanguage(aLang);
String aLangStr( pLanguageTable->GetString( aLang ) );
sal_uInt16 p = aUserInterfaceLB.InsertEntry(aLangStr);
aUserInterfaceLB.SetEntryData(p, (void*)(i+1));
}
}
// find out whether the user has a specific locale specified
Sequence< Any > theArgs2(1);
theArgs2[0] = makeAny(NamedValue(OUString(RTL_CONSTASCII_USTRINGPARAM("NodePath")), makeAny(sUserLocalePath)));
theNameAccess = Reference< XNameAccess > (
theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs2 ), UNO_QUERY_THROW );
if (theNameAccess->hasByName(sUserLocaleKey))
theNameAccess->getByName(sUserLocaleKey) >>= m_sUserLocaleValue;
// select the user specified locale in the listbox
if (m_sUserLocaleValue.getLength() > 0)
{
sal_Int32 d = 0;
for (sal_uInt16 i=0; i < aUserInterfaceLB.GetEntryCount(); i++)
{
d = (sal_Int32)(sal_IntPtr)aUserInterfaceLB.GetEntryData(i);
if ( d > 0 && seqInstalledLanguages.getLength() > d-1 && seqInstalledLanguages[d-1].equals(m_sUserLocaleValue))
aUserInterfaceLB.SelectEntryPos(i);
}
}
}
catch (const Exception &e)
{
// we'll just leave the box in it's default setting and won't
// even give it event handler...
OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
OSL_FAIL(aMsg.getStr());
}
aWesternLanguageLB.SetLanguageList( LANG_LIST_WESTERN | LANG_LIST_ONLY_KNOWN, sal_True, sal_False, sal_True );
aWesternLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::LATIN );
aAsianLanguageLB.SetLanguageList( LANG_LIST_CJK | LANG_LIST_ONLY_KNOWN, sal_True, sal_False, sal_True );
aAsianLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::ASIAN );
aComplexLanguageLB.SetLanguageList( LANG_LIST_CTL | LANG_LIST_ONLY_KNOWN, sal_True, sal_False, sal_True );
aComplexLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::COMPLEX );
aLocaleSettingLB.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, sal_False, sal_False, sal_False);
aLocaleSettingLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::WEAK );
const NfCurrencyTable& rCurrTab = SvNumberFormatter::GetTheCurrencyTable();
const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( LANGUAGE_SYSTEM );
// insert SYSTEM entry
String aDefaultCurr(aStr);
aDefaultCurr += String::CreateFromAscii(" - ");
aDefaultCurr += rCurr.GetBankSymbol();
aCurrencyLB.InsertEntry( aDefaultCurr );
// all currencies
String aTwoSpace( RTL_CONSTASCII_USTRINGPARAM( " " ) );
sal_uInt16 nCurrCount = rCurrTab.Count();
// first entry is SYSTEM, skip it
for ( sal_uInt16 j=1; j < nCurrCount; ++j )
{
const NfCurrencyEntry* pCurr = rCurrTab[j];
String aStr_( pCurr->GetBankSymbol() );
aStr_ += aTwoSpace;
aStr_ += pCurr->GetSymbol();
aStr_ = ApplyLreOrRleEmbedding( aStr_ );
aStr_ += aTwoSpace;
aStr_ += ApplyLreOrRleEmbedding( pLanguageTable->GetString( pCurr->GetLanguage() ) );
sal_uInt16 nPos = aCurrencyLB.InsertEntry( aStr_ );
aCurrencyLB.SetEntryData( nPos, (void*) pCurr );
}
delete pLanguageTable;
aLocaleSettingLB.SetSelectHdl( LINK( this, OfaLanguagesTabPage, LocaleSettingHdl ) );
Link aLink( LINK( this, OfaLanguagesTabPage, SupportHdl ) );
aAsianSupportCB.SetClickHdl( aLink );
aCTLSupportCB.SetClickHdl( aLink );
aAsianSupportCB.Check( m_bOldAsian = pLangConfig->aLanguageOptions.IsAnyEnabled() );
aAsianSupportCB.SaveValue();
sal_Bool bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK);
aAsianSupportCB.Enable(!bReadonly);
aAsianSupportFI.Show(bReadonly);
SupportHdl( &aAsianSupportCB );
aCTLSupportCB.Check( m_bOldCtl = pLangConfig->aLanguageOptions.IsCTLFontEnabled() );
aCTLSupportCB.SaveValue();
bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT);
aCTLSupportCB.Enable(!bReadonly);
aCTLSupportFI.Show(bReadonly);
SupportHdl( &aCTLSupportCB );
}
OfaLanguagesTabPage::~OfaLanguagesTabPage()
{
delete pLangConfig;
}
SfxTabPage* OfaLanguagesTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
{
return new OfaLanguagesTabPage(pParent, rAttrSet);
}
LanguageType lcl_LangStringToLangType(const OUString& rLang)
{
Locale aLocale;
sal_Int32 nSep = rLang.indexOf('-');
if (nSep < 0)
aLocale.Language = rLang;
else
{
aLocale.Language = rLang.copy(0, nSep);
if (nSep < rLang.getLength())
aLocale.Country = rLang.copy(nSep+1, rLang.getLength() - (nSep+1));
}
LanguageType eLangType = SvxLocaleToLanguage( aLocale );
return eLangType;
}
void lcl_UpdateAndDelete(SfxVoidItem* pInvalidItems[], SfxBoolItem* pBoolItems[], sal_uInt16 nCount)
{
SfxViewFrame* pCurrentFrm = SfxViewFrame::Current();
SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst();
while(pViewFrm)
{
SfxBindings& rBind = pViewFrm->GetBindings();
for(sal_Int16 i = 0; i < nCount; i++)
{
if(pCurrentFrm == pViewFrm)
rBind.InvalidateAll(sal_False);
rBind.SetState( *pInvalidItems[i] );
rBind.SetState( *pBoolItems[i] );
}
pViewFrm = SfxViewFrame::GetNext(*pViewFrm);
}
for(sal_Int16 i = 0; i < nCount; i++)
{
delete pInvalidItems[i];
delete pBoolItems[i] ;
}
}
sal_Bool OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet )
{
// lock configuration broadcasters so that we can coordinate the notifications
pLangConfig->aSysLocaleOptions.BlockBroadcasts( sal_True );
pLangConfig->aLanguageOptions.BlockBroadcasts( sal_True );
pLangConfig->aLinguConfig.BlockBroadcasts( sal_True );
/*
* Sequence checking only matters when CTL support is enabled.
*
* So we only need to check for sequence checking if
* a) previously it was unchecked and is now checked or
* b) it was already checked but the CTL language has changed
*/
if (
aCTLSupportCB.IsChecked() &&
(aCTLSupportCB.GetSavedValue() != STATE_CHECK ||
aComplexLanguageLB.GetSavedValue() != aComplexLanguageLB.GetSelectEntryPos())
)
{
//sequence checking has to be switched on depending on the selected CTL language
LanguageType eCTLLang = aComplexLanguageLB.GetSelectLanguage();
sal_Bool bOn = MsLangId::needsSequenceChecking( eCTLLang);
pLangConfig->aLanguageOptions.SetCTLSequenceCheckingRestricted(bOn);
pLangConfig->aLanguageOptions.SetCTLSequenceChecking(bOn);
pLangConfig->aLanguageOptions.SetCTLSequenceCheckingTypeAndReplace(bOn);
}
try
{
// handle settings for UI Language
// a change of setting needs to bring up a warning message
OUString aLangString;
sal_Int32 d = (sal_Int32)(sal_IntPtr)aUserInterfaceLB.GetEntryData(aUserInterfaceLB.GetSelectEntryPos());
if( d > 0 && seqInstalledLanguages.getLength() > d-1)
aLangString = seqInstalledLanguages[d-1];
/*
if( aUserInterfaceLB.GetSelectEntryPos() > 0)
aLangString = ConvertLanguageToIsoString(aUserInterfaceLB.GetSelectLanguage());
*/
Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory();
Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > (
theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW);
Sequence< Any > theArgs(1);
theArgs[0] = makeAny(sUserLocalePath);
Reference< XPropertySet >xProp(
theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW );
if ( !m_sUserLocaleValue.equals(aLangString))
{
// OSL_FAIL("UserInterface language was changed, restart.");
// write new value
xProp->setPropertyValue(sUserLocaleKey, makeAny(aLangString));
Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
// display info
InfoBox aBox(this, CUI_RES(RID_SVX_MSGBOX_LANGUAGE_RESTART));
aBox.Execute();
// tell quickstarter to stop being a veto listener
Reference< XInitialization > xInit(theMSF->createInstance(
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.office.Quickstart"))), UNO_QUERY);
if (xInit.is())
{
Sequence< Any > args(3);
args[0] = makeAny(sal_False); // will be ignored
args[1] = makeAny(sal_False); // will be ignored
args[2] = makeAny(sal_False); // disable veto
xInit->initialize(args);
}
}
}
catch (const Exception& e)
{
// we'll just leave the box in it's default setting and won't
// even give it event handler...
OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
OSL_FAIL(aMsg.getStr());
}
OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
LanguageType eOldLocale = (sLang.getLength() ?
lcl_LangStringToLangType( sLang ) : LANGUAGE_SYSTEM);
LanguageType eNewLocale = aLocaleSettingLB.GetSelectLanguage();
if ( eOldLocale != eNewLocale )
{
// an empty string denotes SYSTEM locale
OUString sNewLang;
if ( eNewLocale != LANGUAGE_SYSTEM )
{
Locale aLocale;
SvxLanguageToLocale( aLocale, eNewLocale );
sNewLang = aLocale.Language;
if ( aLocale.Country.getLength() > 0 )
{
sNewLang += C2U("-");
sNewLang += aLocale.Country;
}
}
// locale nowadays get to AppSettings via notification
// this will happen after releasing the lock on the ConfigurationBroadcaster at
// the end of this method
pLangConfig->aSysLocaleOptions.SetLocaleConfigString( sNewLang );
rSet.Put( SfxBoolItem( SID_OPT_LOCALE_CHANGED, sal_True ) );
sal_uInt16 nNewType = SvtLanguageOptions::GetScriptTypeOfLanguage( eNewLocale );
bool bNewCJK = ( nNewType & SCRIPTTYPE_ASIAN ) != 0;
SvtCompatibilityOptions aCompatOpts;
aCompatOpts.SetDefault( COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE, !bNewCJK );
}
if(aDecimalSeparatorCB.GetSavedValue() != aDecimalSeparatorCB.IsChecked())
pLangConfig->aSysLocaleOptions.SetDecimalSeparatorAsLocale(aDecimalSeparatorCB.IsChecked());
// Configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default.
OUString sOldCurr = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
sal_uInt16 nCurrPos = aCurrencyLB.GetSelectEntryPos();
const NfCurrencyEntry* pCurr = (const NfCurrencyEntry*)
aCurrencyLB.GetEntryData( nCurrPos );
OUString sNewCurr;
if ( pCurr )
sNewCurr = SvtSysLocaleOptions::CreateCurrencyConfigString(
pCurr->GetBankSymbol(), pCurr->GetLanguage() );
if ( sOldCurr != sNewCurr )
pLangConfig->aSysLocaleOptions.SetCurrencyConfigString( sNewCurr );
SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
Reference< XPropertySet > xLinguProp( LinguMgr::GetLinguPropertySet(), UNO_QUERY );
sal_Bool bCurrentDocCBChecked = aCurrentDocCB.IsChecked();
if(aCurrentDocCB.IsEnabled())
bLanguageCurrentDoc_Impl = bCurrentDocCBChecked;
sal_Bool bCurrentDocCBChanged = bCurrentDocCBChecked != aCurrentDocCB.GetSavedValue();
sal_Bool bValChanged = aWesternLanguageLB.GetSavedValue() != aWesternLanguageLB.GetSelectEntryPos();
if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
{
LanguageType eSelectLang = aWesternLanguageLB.GetSelectLanguage();
if(!bCurrentDocCBChecked)
{
Any aValue;
Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
aValue <<= aLocale;
OUString aPropName( C2U("DefaultLocale") );
pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
if (xLinguProp.is())
xLinguProp->setPropertyValue( aPropName, aValue );
}
if(pCurrentDocShell)
{
rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::LATIN),
SID_ATTR_LANGUAGE));
}
}
bValChanged = aAsianLanguageLB.GetSavedValue() != aAsianLanguageLB.GetSelectEntryPos();
if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
{
LanguageType eSelectLang = aAsianLanguageLB.GetSelectLanguage();
if(!bCurrentDocCBChecked)
{
Any aValue;
Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
aValue <<= aLocale;
OUString aPropName( C2U("DefaultLocale_CJK") );
pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
if (xLinguProp.is())
xLinguProp->setPropertyValue( aPropName, aValue );
}
if(pCurrentDocShell)
{
rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::ASIAN),
SID_ATTR_CHAR_CJK_LANGUAGE));
}
}
bValChanged = aComplexLanguageLB.GetSavedValue() != aComplexLanguageLB.GetSelectEntryPos();
if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
{
LanguageType eSelectLang = aComplexLanguageLB.GetSelectLanguage();
if(!bCurrentDocCBChecked)
{
Any aValue;
Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
aValue <<= aLocale;
OUString aPropName( C2U("DefaultLocale_CTL") );
pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
if (xLinguProp.is())
xLinguProp->setPropertyValue( aPropName, aValue );
}
if(pCurrentDocShell)
{
rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::COMPLEX),
SID_ATTR_CHAR_CTL_LANGUAGE));
}
}
if(aAsianSupportCB.GetSavedValue() != aAsianSupportCB.IsChecked() )
{
sal_Bool bChecked = aAsianSupportCB.IsChecked();
pLangConfig->aLanguageOptions.SetAll(bChecked);
//iterate over all bindings to invalidate vertical text direction
const sal_uInt16 STATE_COUNT = 2;
SfxBoolItem* pBoolItems[STATE_COUNT];
pBoolItems[0] = new SfxBoolItem(SID_VERTICALTEXT_STATE, sal_False);
pBoolItems[1] = new SfxBoolItem(SID_TEXT_FITTOSIZE_VERTICAL, sal_False);
SfxVoidItem* pInvalidItems[STATE_COUNT];
pInvalidItems[0] = new SfxVoidItem(SID_VERTICALTEXT_STATE);
pInvalidItems[1] = new SfxVoidItem(SID_TEXT_FITTOSIZE_VERTICAL);
lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
}
if ( aCTLSupportCB.GetSavedValue() != aCTLSupportCB.IsChecked() )
{
pLangConfig->aLanguageOptions.SetCTLFontEnabled( aCTLSupportCB.IsChecked() );
const sal_uInt16 STATE_COUNT = 1;
SfxBoolItem* pBoolItems[STATE_COUNT];
pBoolItems[0] = new SfxBoolItem(SID_CTLFONT_STATE, sal_False);
SfxVoidItem* pInvalidItems[STATE_COUNT];
pInvalidItems[0] = new SfxVoidItem(SID_CTLFONT_STATE);
lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
}
if ( pLangConfig->aSysLocaleOptions.IsModified() )
pLangConfig->aSysLocaleOptions.Commit();
// first release the lock on the ConfigurationBroadcaster for Locale changes
// it seems that our code relies on the fact that before other changes like e.g. currency
// are broadcasted locale changes have been done
pLangConfig->aSysLocaleOptions.BlockBroadcasts( sal_False );
pLangConfig->aLanguageOptions.BlockBroadcasts( sal_False );
pLangConfig->aLinguConfig.BlockBroadcasts( sal_False );
return sal_False;
}
//-----------------------------------------------------------------------------
void OfaLanguagesTabPage::Reset( const SfxItemSet& rSet )
{
OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
if ( sLang.getLength() )
aLocaleSettingLB.SelectLanguage(lcl_LangStringToLangType(sLang));
else
aLocaleSettingLB.SelectLanguage( LANGUAGE_SYSTEM );
sal_Bool bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_LOCALE);
aLocaleSettingLB.Enable(!bReadonly);
aLocaleSettingFT.Enable(!bReadonly);
aLocaleSettingFI.Show(bReadonly);
//
aDecimalSeparatorCB.Check( pLangConfig->aSysLocaleOptions.IsDecimalSeparatorAsLocale());
aDecimalSeparatorCB.SaveValue();
// let LocaleSettingHdl enable/disable checkboxes for CJK/CTL support
// #i15812# must be done *before* the configured currency is set
// and update the decimal separator used for the given locale
LocaleSettingHdl(&aLocaleSettingLB);
// configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default
String aAbbrev;
LanguageType eLang;
const NfCurrencyEntry* pCurr = NULL;
sLang = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
if ( sLang.getLength() )
{
SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( aAbbrev, eLang, sLang );
pCurr = SvNumberFormatter::GetCurrencyEntry( aAbbrev, eLang );
}
// if pCurr==NULL the SYSTEM entry is selected
sal_uInt16 nPos = aCurrencyLB.GetEntryPos( (void*) pCurr );
aCurrencyLB.SelectEntryPos( nPos );
bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_CURRENCY);
aCurrencyLB.Enable(!bReadonly);
aCurrencyFT.Enable(!bReadonly);
aCurrencyFI.Show(bReadonly);
//western/CJK/CLK language
LanguageType eCurLang = LANGUAGE_NONE;
LanguageType eCurLangCJK = LANGUAGE_NONE;
LanguageType eCurLangCTL = LANGUAGE_NONE;
SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
//collect the configuration values first
aCurrentDocCB.Enable(sal_False);
//
Any aWestLang;
Any aCJKLang;
Any aCTLLang;
try
{
aWestLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale"));
Locale aLocale;
aWestLang >>= aLocale;
eCurLang = MsLangId::convertLocaleToLanguage( aLocale );
aCJKLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale_CJK"));
aLocale = Locale();
aCJKLang >>= aLocale;
eCurLangCJK = MsLangId::convertLocaleToLanguage( aLocale );
aCTLLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale_CTL"));
aLocale = Locale();
aCTLLang >>= aLocale;
eCurLangCTL = MsLangId::convertLocaleToLanguage( aLocale );
}
catch (const Exception&)
{
}
//overwrite them by the values provided by the DocShell
if(pCurrentDocShell)
{
aCurrentDocCB.Enable(sal_True);
aCurrentDocCB.Check(bLanguageCurrentDoc_Impl);
const SfxPoolItem* pLang;
if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_LANGUAGE, sal_False, &pLang))
{
LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
if (MsLangId::resolveSystemLanguageByScriptType(eCurLang, ::com::sun::star::i18n::ScriptType::LATIN) != eTempCurLang)
eCurLang = eTempCurLang;
}
if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, sal_False, &pLang))
{
LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK, ::com::sun::star::i18n::ScriptType::ASIAN) != eTempCurLang)
eCurLangCJK = eTempCurLang;
}
if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, sal_False, &pLang))
{
LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL, ::com::sun::star::i18n::ScriptType::COMPLEX) != eTempCurLang)
eCurLangCTL = eTempCurLang;
}
}
if(LANGUAGE_NONE == eCurLang || LANGUAGE_DONTKNOW == eCurLang)
aWesternLanguageLB.SelectLanguage(LANGUAGE_NONE);
else
aWesternLanguageLB.SelectLanguage(eCurLang);
if(LANGUAGE_NONE == eCurLangCJK || LANGUAGE_DONTKNOW == eCurLangCJK)
aAsianLanguageLB.SelectLanguage(LANGUAGE_NONE);
else
aAsianLanguageLB.SelectLanguage(eCurLangCJK);
if(LANGUAGE_NONE == eCurLangCTL || LANGUAGE_DONTKNOW == eCurLangCTL)
aComplexLanguageLB.SelectLanguage(LANGUAGE_NONE);
else
aComplexLanguageLB.SelectLanguage(eCurLangCTL);
aWesternLanguageLB.SaveValue();
aAsianLanguageLB.SaveValue();
aComplexLanguageLB.SaveValue();
aCurrentDocCB.SaveValue();
sal_Bool bEnable = !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale") );
aWesternLanguageFT.Enable( bEnable );
aWesternLanguageLB.Enable( bEnable );
aWesternLanguageFI.Show(!bEnable);
// #i15812# controls for CJK/CTL already enabled/disabled from LocaleSettingHdl
#if 0
bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CJK") ) && aAsianSupportCB.IsChecked() );
aAsianLanguageFT.Enable( bEnable );
aAsianLanguageLB.Enable( bEnable );
bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CTL") ) && aCTLSupportCB.IsChecked() );
aComplexLanguageFT.Enable( bEnable );
aComplexLanguageLB.Enable( bEnable );
#endif
// check the box "For the current document only"
// set the focus to the Western Language box
const SfxPoolItem* pLang = 0;
if ( SFX_ITEM_SET == rSet.GetItemState(SID_SET_DOCUMENT_LANGUAGE, sal_False, &pLang ) &&( (const SfxBoolItem*)pLang)->GetValue() == sal_True )
{
aWesternLanguageLB.GrabFocus();
aCurrentDocCB.Enable(sal_True);
aCurrentDocCB.Check(sal_True);
}
}
IMPL_LINK( OfaLanguagesTabPage, SupportHdl, CheckBox*, pBox )
{
DBG_ASSERT( pBox, "OfaLanguagesTabPage::SupportHdl(): pBox invalid" );
sal_Bool bCheck = pBox->IsChecked();
if ( &aAsianSupportCB == pBox )
{
sal_Bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CJK"));
bCheck = ( bCheck && !bReadonly );
aAsianLanguageFT.Enable( bCheck );
aAsianLanguageLB.Enable( bCheck );
aAsianLanguageFI.Show(bReadonly);
if( pBox->IsEnabled() )
m_bOldAsian = bCheck;
}
else if ( &aCTLSupportCB == pBox )
{
sal_Bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CTL"));
bCheck = ( bCheck && !bReadonly );
aComplexLanguageFT.Enable( bCheck );
aComplexLanguageLB.Enable( bCheck );
aComplexLanguageFI.Show(bReadonly);
if( pBox->IsEnabled() )
m_bOldCtl = bCheck;
}
else
{
DBG_ERRORFILE( "OfaLanguagesTabPage::SupportHdl(): wrong pBox" );
}
return 0;
}
namespace
{
void lcl_checkLanguageCheckBox(CheckBox& _rCB,sal_Bool _bNewValue,sal_Bool _bOldValue)
{
if ( _bNewValue )
_rCB.Check(sal_True);
else
_rCB.Check( _bOldValue );
// #i15082# do not call SaveValue() in running dialog...
// _rCB.SaveValue();
_rCB.Enable( !_bNewValue );
}
}
IMPL_LINK( OfaLanguagesTabPage, LocaleSettingHdl, SvxLanguageBox*, pBox )
{
LanguageType eLang = pBox->GetSelectLanguage();
sal_uInt16 nType = SvtLanguageOptions::GetScriptTypeOfLanguage(eLang);
// first check if CTL must be enabled
// #103299# - if CTL font setting is not readonly
if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT))
{
bool bIsCTLFixed = (nType & SCRIPTTYPE_COMPLEX) != 0;
lcl_checkLanguageCheckBox(aCTLSupportCB, bIsCTLFixed, m_bOldCtl);
SupportHdl( &aCTLSupportCB );
}
// second check if CJK must be enabled
// #103299# - if CJK support is not readonly
if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK))
{
bool bIsCJKFixed = (nType & SCRIPTTYPE_ASIAN) != 0;
lcl_checkLanguageCheckBox(aAsianSupportCB, bIsCJKFixed, m_bOldAsian);
SupportHdl( &aAsianSupportCB );
}
sal_uInt16 nPos;
if ( eLang == LANGUAGE_SYSTEM )
nPos = aCurrencyLB.GetEntryPos( (void*) NULL );
else
{
const NfCurrencyEntry* pCurr = &SvNumberFormatter::GetCurrencyEntry( eLang );
nPos = aCurrencyLB.GetEntryPos( (void*) pCurr );
}
aCurrencyLB.SelectEntryPos( nPos );
//update the decimal separator key of the related CheckBox
Locale aTempLocale;
SvxLanguageToLocale( aTempLocale, eLang );
LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), aTempLocale );
String sTempLabel(sDecimalSeparatorLabel);
sTempLabel.SearchAndReplaceAscii("%1", aLocaleWrapper.getNumDecimalSep() );
aDecimalSeparatorCB.SetText(sTempLabel);
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|