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
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_features.h>
#include <svl/zforlist.hxx>
#include <svl/currencytable.hxx>
#include <vcl/GraphicObject.hxx>
#include <svtools/langhelp.hxx>
#include <svl/flagitem.hxx>
#include <sfx2/dispatch.hxx>
#include <unotools/lingucfg.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <vcl/configsettings.hxx>
#include <vcl/layout.hxx>
#include <vcl/mnemonic.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <unotools/compatibility.hxx>
#include <unotools/useroptions.hxx>
#include <unotools/fontoptions.hxx>
#include <svtools/menuoptions.hxx>
#include <svl/languageoptions.hxx>
#include <svtools/miscopt.hxx>
#include <unotools/printwarningoptions.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <unotools/configitem.hxx>
#include <sfx2/objsh.hxx>
#include <comphelper/string.hxx>
#include <comphelper/types.hxx>
#include <comphelper/propertysequence.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 <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 <svtools/helpopt.hxx>
#include <unotools/saveopt.hxx>
#include <unotools/searchopt.hxx>
#include <sal/macros.h>
#include <officecfg/Office/Common.hxx>
#include <officecfg/Setup.hxx>
#include <comphelper/configuration.hxx>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
#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/PropertyAttribute.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 <com/sun/star/office/Quickstart.hpp>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/IconThemeInfo.hxx>
#if HAVE_FEATURE_OPENGL
#include <vcl/opengl/OpenGLWrapper.hxx>
#endif
#include "optgdlg.hxx"
#include <svx/ofaitem.hxx>
#include <svtools/apearcfg.hxx>
#include <svtools/optionsdrawinglayer.hxx>
#include <svtools/restartdialog.hxx>
#include <comphelper/solarmutex.hxx>
#include <config_vclplug.h>
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;
namespace svt {
class OpenGLCfg
{
private:
bool mbUseOpenGL;
bool mbForceOpenGL;
bool mbModified;
public:
OpenGLCfg();
~OpenGLCfg();
bool useOpenGL() const;
bool forceOpenGL() const;
void setUseOpenGL(bool bOpenGL);
void setForceOpenGL(bool bOpenGL);
void reset();
};
OpenGLCfg::OpenGLCfg():
mbModified(false)
{
reset();
}
void OpenGLCfg::reset()
{
mbUseOpenGL = officecfg::Office::Common::VCL::UseOpenGL::get();
mbForceOpenGL = officecfg::Office::Common::VCL::ForceOpenGL::get();
mbModified = false;
}
OpenGLCfg::~OpenGLCfg()
{
if (mbModified)
{
try
{
std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
if (!officecfg::Office::Common::VCL::UseOpenGL::isReadOnly())
officecfg::Office::Common::VCL::UseOpenGL::set(mbUseOpenGL, batch);
if (!officecfg::Office::Common::VCL::ForceOpenGL::isReadOnly())
officecfg::Office::Common::VCL::ForceOpenGL::set(mbForceOpenGL, batch);
batch->commit();
}
catch (...)
{
}
}
}
bool OpenGLCfg::useOpenGL() const
{
return mbUseOpenGL;
}
bool OpenGLCfg::forceOpenGL() const
{
return mbForceOpenGL;
}
void OpenGLCfg::setUseOpenGL(bool bOpenGL)
{
if (bOpenGL != mbUseOpenGL)
{
mbUseOpenGL = bOpenGL;
mbModified = true;
}
}
void OpenGLCfg::setForceOpenGL(bool bOpenGL)
{
if (mbForceOpenGL != bOpenGL)
{
mbForceOpenGL = bOpenGL;
mbModified = true;
}
}
}
// class OfaMiscTabPage --------------------------------------------------
DeactivateRC OfaMiscTabPage::DeactivatePage( SfxItemSet* pSet_ )
{
if ( pSet_ )
FillItemSet( pSet_ );
return DeactivateRC::LeavePage;
}
namespace
{
OUString impl_SystemFileOpenServiceName()
{
const OUString &rDesktopEnvironment = Application::GetDesktopEnvironment();
if ( rDesktopEnvironment.equalsIgnoreAsciiCase("kde4") )
{
#if ENABLE_KDE4
return OUString("com.sun.star.ui.dialogs.KDE4FilePicker" );
#else
return OUString();
#endif
}
#if defined(_WIN32)
return OUString("com.sun.star.ui.dialogs.SystemFilePicker");
#elif defined MACOSX
return OUString("com.sun.star.ui.dialogs.AquaFilePicker");
#else
return OUString();
#endif
}
bool lcl_HasSystemFilePicker()
{
if( Application::hasNativeFileSelection() )
return true;
// Otherwise fall-back on querying services
bool bRet = false;
Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
Reference< XContentEnumerationAccess > xEnumAccess( xFactory, UNO_QUERY );
Reference< XSet > xSet( xFactory, UNO_QUERY );
if ( ! xEnumAccess.is() || ! xSet.is() )
return bRet;
try
{
OUString aFileService = impl_SystemFileOpenServiceName();
Reference< XEnumeration > xEnum = xEnumAccess->createContentEnumeration( aFileService );
if ( xEnum.is() && xEnum->hasMoreElements() )
bRet = true;
}
catch (const IllegalArgumentException&)
{
}
catch (const ElementExistException&)
{
}
return bRet;
}
}
OfaMiscTabPage::OfaMiscTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "OptGeneralPage", "cui/ui/optgeneralpage.ui", &rSet)
{
get(m_pExtHelpCB, "exthelp");
if (!lcl_HasSystemFilePicker())
get<VclContainer>("filedlgframe")->Hide();
#if ! ENABLE_GTK
get<VclContainer>("printdlgframe")->Hide();
#else
if (!SvtMiscOptions().IsExperimentalMode())
{
get<VclContainer>("printdlgframe")->Hide();
}
#endif
get(m_pFileDlgCB, "filedlg");
get(m_pFileDlgROImage, "lockimage");
get(m_pPrintDlgCB, "printdlg");
get(m_pDocStatusCB, "docstatus");
get(m_pYearFrame, "yearframe");
get(m_pYearValueField, "year");
get(m_pToYearFT, "toyear");
get(m_pCollectUsageInfo, "collectusageinfo");
get(m_pQuickStarterFrame, "quickstarter");
#if defined(UNX)
get(m_pQuickLaunchCB, "systray");
#else
get(m_pQuickLaunchCB, "quicklaunch");
#endif
if (m_pFileDlgCB->IsVisible() && SvtMiscOptions().IsUseSystemFileDialogReadOnly())
{
m_pFileDlgROImage->Show();
m_pFileDlgCB->Disable();
}
m_pQuickLaunchCB->Show();
//Only available in Win or if building the gtk systray
#if !defined(_WIN32) && ! ENABLE_GTK
m_pQuickStarterFrame->Hide();
#endif
m_aStrDateInfo = m_pToYearFT->GetText();
m_pYearValueField->SetUseThousandSep(false);
m_pYearValueField->SetModifyHdl( LINK( this, OfaMiscTabPage, TwoFigureHdl ) );
SetExchangeSupport();
}
OfaMiscTabPage::~OfaMiscTabPage()
{
disposeOnce();
}
void OfaMiscTabPage::dispose()
{
m_pExtHelpCB.clear();
m_pFileDlgROImage.clear();
m_pFileDlgCB.clear();
m_pPrintDlgCB.clear();
m_pDocStatusCB.clear();
m_pYearFrame.clear();
m_pYearValueField.clear();
m_pToYearFT.clear();
m_pCollectUsageInfo.clear();
m_pQuickStarterFrame.clear();
m_pQuickLaunchCB.clear();
SfxTabPage::dispose();
}
VclPtr<SfxTabPage> OfaMiscTabPage::Create( TabPageParent pParent, const SfxItemSet* rAttrSet )
{
return VclPtr<OfaMiscTabPage>::Create( pParent.pParent, *rAttrSet );
}
bool OfaMiscTabPage::FillItemSet( SfxItemSet* rSet )
{
bool bModified = false;
std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
SvtHelpOptions aHelpOptions;
if ( m_pExtHelpCB->IsChecked() != (m_pExtHelpCB->GetSavedValue() == TRISTATE_TRUE) )
aHelpOptions.SetExtendedHelp( m_pExtHelpCB->IsChecked() );
if ( m_pFileDlgCB->IsValueChangedFromSaved() )
{
SvtMiscOptions aMiscOpt;
aMiscOpt.SetUseSystemFileDialog( !m_pFileDlgCB->IsChecked() );
bModified = true;
}
if ( m_pPrintDlgCB->IsValueChangedFromSaved() )
{
SvtMiscOptions aMiscOpt;
aMiscOpt.SetUseSystemPrintDialog( !m_pPrintDlgCB->IsChecked() );
bModified = true;
}
if ( m_pDocStatusCB->IsValueChangedFromSaved() )
{
SvtPrintWarningOptions aPrintOptions;
aPrintOptions.SetModifyDocumentOnPrintingAllowed( m_pDocStatusCB->IsChecked() );
bModified = true;
}
const SfxUInt16Item* pUInt16Item = dynamic_cast< const SfxUInt16Item* >( GetOldItem( *rSet, SID_ATTR_YEAR2000 ) );
sal_uInt16 nNum = static_cast<sal_uInt16>(m_pYearValueField->GetText().toInt32());
if ( pUInt16Item && pUInt16Item->GetValue() != nNum )
{
bModified = true;
rSet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, nNum ) );
}
if (m_pCollectUsageInfo->IsValueChangedFromSaved())
{
officecfg::Office::Common::Misc::CollectUsageInformation::set(m_pCollectUsageInfo->IsChecked(), batch);
bModified = true;
}
batch->commit();
if( m_pQuickLaunchCB->IsValueChangedFromSaved())
{
rSet->Put(SfxBoolItem(SID_ATTR_QUICKLAUNCHER, m_pQuickLaunchCB->IsChecked()));
bModified = true;
}
return bModified;
}
void OfaMiscTabPage::Reset( const SfxItemSet* rSet )
{
SvtHelpOptions aHelpOptions;
m_pExtHelpCB->Check( aHelpOptions.IsHelpTips() && aHelpOptions.IsExtendedHelp() );
m_pExtHelpCB->SaveValue();
SvtMiscOptions aMiscOpt;
m_pFileDlgCB->Check( !aMiscOpt.UseSystemFileDialog() );
m_pFileDlgCB->SaveValue();
m_pPrintDlgCB->Check( !aMiscOpt.UseSystemPrintDialog() );
m_pPrintDlgCB->SaveValue();
SvtPrintWarningOptions aPrintOptions;
m_pDocStatusCB->Check(aPrintOptions.IsModifyDocumentOnPrintingAllowed());
m_pDocStatusCB->SaveValue();
const SfxPoolItem* pItem = nullptr;
if ( SfxItemState::SET == rSet->GetItemState( SID_ATTR_YEAR2000, false, &pItem ) )
{
m_pYearValueField->SetValue( static_cast<const SfxUInt16Item*>(pItem)->GetValue() );
TwoFigureHdl(*m_pYearValueField);
}
else
m_pYearFrame->Enable(false);
m_pCollectUsageInfo->Check(officecfg::Office::Common::Misc::CollectUsageInformation::get());
m_pCollectUsageInfo->Enable(!officecfg::Office::Common::Misc::CollectUsageInformation::isReadOnly());
m_pCollectUsageInfo->SaveValue();
SfxItemState eState = rSet->GetItemState( SID_ATTR_QUICKLAUNCHER, false, &pItem );
if ( SfxItemState::SET == eState )
m_pQuickLaunchCB->Check( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
else if ( SfxItemState::DISABLED == eState )
{
// quickstart not installed
m_pQuickStarterFrame->Hide();
}
m_pQuickLaunchCB->SaveValue();
}
IMPL_LINK_NOARG( OfaMiscTabPage, TwoFigureHdl, Edit&, void )
{
OUString aOutput( m_aStrDateInfo );
OUString aStr( m_pYearValueField->GetText() );
sal_Int32 nNum = aStr.toInt32();
if ( aStr.getLength() != 4 || nNum < m_pYearValueField->GetMin() || nNum > m_pYearValueField->GetMax() )
aOutput += "????";
else
{
nNum += 99;
aOutput += OUString::number( nNum );
}
m_pToYearFT->SetText( aOutput );
}
class CanvasSettings
{
public:
CanvasSettings();
bool IsHardwareAccelerationEnabled() const;
bool IsHardwareAccelerationAvailable() const;
bool IsHardwareAccelerationRO() const;
void EnabledHardwareAcceleration( bool _bEnabled ) const;
private:
typedef std::vector< std::pair<OUString,Sequence<OUString> > > ServiceVector;
Reference<XNameAccess> mxForceFlagNameAccess;
ServiceVector maAvailableImplementations;
mutable bool mbHWAccelAvailable;
mutable bool mbHWAccelChecked;
};
CanvasSettings::CanvasSettings() :
mxForceFlagNameAccess(),
mbHWAccelAvailable(false),
mbHWAccelChecked(false)
{
try
{
Reference<XMultiServiceFactory> xConfigProvider(
css::configuration::theDefaultProvider::get(
comphelper::getProcessComponentContext()));
Sequence<Any> aArgs1(comphelper::InitAnyPropertySequence(
{
{"nodepath", Any(OUString("/org.openoffice.Office.Canvas"))}
}));
mxForceFlagNameAccess.set(
xConfigProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess",
aArgs1 ),
UNO_QUERY_THROW );
Sequence<Any> aArgs2(comphelper::InitAnyPropertySequence(
{
{"nodepath", Any(OUString("/org.openoffice.Office.Canvas/CanvasServiceList"))}
}));
Reference<XNameAccess> xNameAccess(
xConfigProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess",
aArgs2 ), 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("PreferredImplementations") >>= preferredImplementations )
maAvailableImplementations.emplace_back(*pCurr,preferredImplementations );
}
++pCurr;
}
}
catch (const Exception&)
{
}
}
bool CanvasSettings::IsHardwareAccelerationAvailable() const
{
#if HAVE_FEATURE_OPENGL
if( OpenGLWrapper::isVCLOpenGLEnabled() )
mbHWAccelAvailable = false;
else
#endif
if( !mbHWAccelChecked )
{
mbHWAccelChecked = true;
Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
// check whether any of the service lists has an
// implementation that presents the "HardwareAcceleration" property
for (auto const& availableImpl : maAvailableImplementations)
{
const OUString* pCurrImpl = availableImpl.second.getConstArray();
const OUString* const pEndImpl = pCurrImpl + availableImpl.second.getLength();
while( pCurrImpl != pEndImpl )
{
try
{
Reference<XPropertySet> xPropSet( xFactory->createInstance(
pCurrImpl->trim() ),
UNO_QUERY_THROW );
bool bHasAccel(false);
if( xPropSet->getPropertyValue("HardwareAcceleration") >>= bHasAccel )
if( bHasAccel )
{
mbHWAccelAvailable = true;
return mbHWAccelAvailable;
}
}
catch (const Exception&)
{
}
++pCurrImpl;
}
}
}
return mbHWAccelAvailable;
}
bool CanvasSettings::IsHardwareAccelerationEnabled() const
{
bool bForceLastEntry(false);
if( !mxForceFlagNameAccess.is() )
return true;
if( !(mxForceFlagNameAccess->getByName("ForceSafeServiceImpl") >>= bForceLastEntry) )
return true;
return !bForceLastEntry;
}
bool CanvasSettings::IsHardwareAccelerationRO() const
{
Reference< XPropertySet > xSet(mxForceFlagNameAccess, UNO_QUERY);
if (!xSet.is())
return true;
Reference< XPropertySetInfo > xInfo = xSet->getPropertySetInfo();
Property aProp = xInfo->getPropertyByName("ForceSafeServiceImpl");
return ((aProp.Attributes & css::beans::PropertyAttribute::READONLY ) == css::beans::PropertyAttribute::READONLY);
}
void CanvasSettings::EnabledHardwareAcceleration( bool _bEnabled ) const
{
Reference< XNameReplace > xNameReplace(
mxForceFlagNameAccess, UNO_QUERY );
if( !xNameReplace.is() )
return;
xNameReplace->replaceByName( "ForceSafeServiceImpl", Any(!_bEnabled) );
Reference< XChangesBatch > xChangesBatch(
mxForceFlagNameAccess, UNO_QUERY );
if( !xChangesBatch.is() )
return;
xChangesBatch->commitChanges();
}
// class OfaViewTabPage --------------------------------------------------
OfaViewTabPage::OfaViewTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "OptViewPage", "cui/ui/optviewpage.ui", &rSet)
, nSizeLB_InitialSelection(0)
, nSidebarSizeLB_InitialSelection(0)
, nNotebookbarSizeLB_InitialSelection(0)
, nStyleLB_InitialSelection(0)
, pAppearanceCfg(new SvtTabAppearanceCfg)
, pCanvasSettings(new CanvasSettings)
, mpDrawinglayerOpt(new SvtOptionsDrawinglayer)
, mpOpenGLConfig(new svt::OpenGLCfg)
{
get(m_pIconSizeLB, "iconsize");
get(m_pSidebarIconSizeLB, "sidebariconsize");
get(m_pNotebookbarIconSizeLB, "notebookbariconsize");
get(m_pIconStyleLB, "iconstyle");
get(m_pFontAntiAliasing, "aafont");
get(m_pAAPointLimitLabel, "aafrom");
get(m_pAAPointLimit, "aanf");
get(m_pMenuIconsLB, "menuicons");
get(m_pContextMenuShortcutsLB, "contextmenushortcuts");
get(m_pFontShowCB, "showfontpreview");
get(m_pUseHardwareAccell, "useaccel");
get(m_pUseAntiAliase, "useaa");
get(m_pUseOpenGL, "useopengl");
get(m_pForceOpenGL, "forceopengl");
get(m_pOpenGLStatusEnabled, "openglenabled");
get(m_pOpenGLStatusDisabled, "opengldisabled");
get(m_pMousePosLB, "mousepos");
get(m_pMouseMiddleLB, "mousemiddle");
if (Application::GetToolkitName() == "gtk3")
{
m_pUseOpenGL->Hide();
m_pForceOpenGL->Hide();
m_pOpenGLStatusEnabled->Hide();
m_pOpenGLStatusDisabled->Hide();
}
#if defined( UNX )
m_pFontAntiAliasing->SetToggleHdl( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) );
#else
// on this platform, we do not have the anti aliasing options
m_pFontAntiAliasing->Hide();
m_pAAPointLimitLabel->Hide();
m_pAAPointLimit->Hide();
#endif
// Set known icon themes
OUString sAutoStr( m_pIconStyleLB->GetEntry( 0 ) );
m_pIconStyleLB->Clear();
StyleSettings aStyleSettings = Application::GetSettings().GetStyleSettings();
mInstalledIconThemes = aStyleSettings.GetInstalledIconThemes();
// Start with the automatically chosen icon theme
OUString autoThemeId = aStyleSettings.GetAutomaticallyChosenIconTheme();
const vcl::IconThemeInfo& autoIconTheme = vcl::IconThemeInfo::FindIconThemeById(mInstalledIconThemes, autoThemeId);
OUString entryForAuto = sAutoStr + " (" +
autoIconTheme.GetDisplayName() +
")";
m_pIconStyleLB->InsertEntry(entryForAuto);
for (auto const& installIconTheme : mInstalledIconThemes)
{
m_pIconStyleLB->InsertEntry(installIconTheme.GetDisplayName());
}
// separate auto and other icon themes
m_pIconStyleLB->SetSeparatorPos( 0 );
m_pIconStyleLB->SelectEntryPos(0);
// FIXME: should really add code to show a 'lock' icon here.
if (officecfg::Office::Common::VCL::UseOpenGL::isReadOnly())
m_pUseOpenGL->Enable(false);
if (officecfg::Office::Common::VCL::ForceOpenGL::isReadOnly())
m_pForceOpenGL->Enable(false);
UpdateOGLStatus();
}
OfaViewTabPage::~OfaViewTabPage()
{
disposeOnce();
}
void OfaViewTabPage::dispose()
{
delete mpDrawinglayerOpt;
mpDrawinglayerOpt = nullptr;
delete pCanvasSettings;
pCanvasSettings = nullptr;
delete pAppearanceCfg;
pAppearanceCfg = nullptr;
m_pIconSizeLB.clear();
m_pSidebarIconSizeLB.clear();
m_pNotebookbarIconSizeLB.clear();
m_pIconStyleLB.clear();
m_pFontAntiAliasing.clear();
m_pAAPointLimitLabel.clear();
m_pAAPointLimit.clear();
m_pMenuIconsLB.clear();
m_pContextMenuShortcutsLB.clear();
m_pFontShowCB.clear();
m_pUseHardwareAccell.clear();
m_pUseAntiAliase.clear();
m_pUseOpenGL.clear();
m_pForceOpenGL.clear();
m_pOpenGLStatusEnabled.clear();
m_pOpenGLStatusDisabled.clear();
m_pMousePosLB.clear();
m_pMouseMiddleLB.clear();
SfxTabPage::dispose();
}
#if defined( UNX )
IMPL_LINK_NOARG( OfaViewTabPage, OnAntialiasingToggled, CheckBox&, void )
{
bool bAAEnabled = m_pFontAntiAliasing->IsChecked();
m_pAAPointLimitLabel->Enable( bAAEnabled );
m_pAAPointLimit->Enable( bAAEnabled );
}
#endif
VclPtr<SfxTabPage> OfaViewTabPage::Create( TabPageParent pParent, const SfxItemSet* rAttrSet )
{
return VclPtr<OfaViewTabPage>::Create(pParent.pParent, *rAttrSet);
}
bool OfaViewTabPage::FillItemSet( SfxItemSet* )
{
SvtFontOptions aFontOpt;
SvtMenuOptions aMenuOpt;
bool bModified = false;
bool bMenuOptModified = false;
bool bRepaintWindows(false);
SvtMiscOptions aMiscOptions;
const sal_Int32 nSizeLB_NewSelection = m_pIconSizeLB->GetSelectedEntryPos();
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;
case 3: eSet = SFX_SYMBOLS_SIZE_32; break;
default:
OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_pIconSizeLB should not be possible!" );
}
aMiscOptions.SetSymbolsSize( eSet );
}
const sal_Int32 nSidebarSizeLB_NewSelection = m_pSidebarIconSizeLB->GetSelectedEntryPos();
if( nSidebarSizeLB_InitialSelection != nSidebarSizeLB_NewSelection )
{
// from now on it's modified, even if via auto setting the same size was set as now selected in the LB
ToolBoxButtonSize eSet = ToolBoxButtonSize::DontCare;
switch( nSidebarSizeLB_NewSelection )
{
case 0: eSet = ToolBoxButtonSize::DontCare; break;
case 1: eSet = ToolBoxButtonSize::Small; break;
case 2: eSet = ToolBoxButtonSize::Large; break;
default:
OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_pSidebarIconSizeLB should not be possible!" );
}
aMiscOptions.SetSidebarIconSize( eSet );
}
const sal_Int32 nNotebookbarSizeLB_NewSelection = m_pNotebookbarIconSizeLB->GetSelectedEntryPos();
if( nNotebookbarSizeLB_InitialSelection != nNotebookbarSizeLB_NewSelection )
{
// from now on it's modified, even if via auto setting the same size was set as now selected in the LB
ToolBoxButtonSize eSet = ToolBoxButtonSize::DontCare;
switch( nNotebookbarSizeLB_NewSelection )
{
case 0: eSet = ToolBoxButtonSize::DontCare; break;
case 1: eSet = ToolBoxButtonSize::Small; break;
case 2: eSet = ToolBoxButtonSize::Large; break;
default:
OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_pNotebookbarIconSizeLB should not be possible!" );
}
aMiscOptions.SetNotebookbarIconSize( eSet );
}
const sal_Int32 nStyleLB_NewSelection = m_pIconStyleLB->GetSelectedEntryPos();
if( nStyleLB_InitialSelection != nStyleLB_NewSelection )
{
// 0 means choose style automatically
if (nStyleLB_NewSelection == 0)
aMiscOptions.SetIconTheme("auto");
else
{
const sal_Int32 pos = m_pIconStyleLB->GetSelectedEntryPos();
const vcl::IconThemeInfo& iconThemeId = mInstalledIconThemes.at(pos-1);
aMiscOptions.SetIconTheme(iconThemeId.GetThemeId());
}
nStyleLB_InitialSelection = nStyleLB_NewSelection;
}
bool bAppearanceChanged = false;
// Mouse Snap Mode
SnapType eOldSnap = pAppearanceCfg->GetSnapMode();
SnapType eNewSnap = static_cast<SnapType>(m_pMousePosLB->GetSelectedEntryPos());
if(eNewSnap > SnapType::NONE)
eNewSnap = SnapType::NONE;
if ( eNewSnap != eOldSnap )
{
pAppearanceCfg->SetSnapMode(eNewSnap );
bAppearanceChanged = true;
}
// Middle Mouse Button
MouseMiddleButtonAction eOldMiddleMouse = pAppearanceCfg->GetMiddleMouseButton();
short eNewMiddleMouse = m_pMouseMiddleLB->GetSelectedEntryPos();
if(eNewMiddleMouse > 2)
eNewMiddleMouse = 2;
if ( eNewMiddleMouse != static_cast<short>(eOldMiddleMouse) )
{
pAppearanceCfg->SetMiddleMouseButton( static_cast<MouseMiddleButtonAction>(eNewMiddleMouse) );
bAppearanceChanged = true;
}
#if defined( UNX )
if ( m_pFontAntiAliasing->IsValueChangedFromSaved() )
{
pAppearanceCfg->SetFontAntiAliasing( m_pFontAntiAliasing->IsChecked() );
bAppearanceChanged = true;
}
if ( m_pAAPointLimit->IsValueChangedFromSaved() )
{
pAppearanceCfg->SetFontAntialiasingMinPixelHeight( m_pAAPointLimit->GetValue() );
bAppearanceChanged = true;
}
#endif
if ( m_pFontShowCB->IsValueChangedFromSaved() )
{
aFontOpt.EnableFontWYSIWYG( m_pFontShowCB->IsChecked() );
bModified = true;
}
if(m_pMenuIconsLB->IsValueChangedFromSaved())
{
aMenuOpt.SetMenuIconsState(m_pMenuIconsLB->GetSelectedEntryPos() == 0 ?
TRISTATE_INDET :
static_cast<TriState>(m_pMenuIconsLB->GetSelectedEntryPos() - 1));
bModified = true;
bMenuOptModified = true;
bAppearanceChanged = true;
}
if(m_pContextMenuShortcutsLB->IsValueChangedFromSaved())
{
aMenuOpt.SetContextMenuShortcuts(m_pContextMenuShortcutsLB->GetSelectedEntryPos() == 0 ?
TRISTATE_INDET :
static_cast<TriState>(m_pContextMenuShortcutsLB->GetSelectedEntryPos() - 1));
bModified = true;
bMenuOptModified = true;
bAppearanceChanged = true;
}
// #i95644# if disabled, do not use value, see in ::Reset()
if(m_pUseHardwareAccell->IsEnabled())
{
if(m_pUseHardwareAccell->IsValueChangedFromSaved())
{
pCanvasSettings->EnabledHardwareAcceleration(m_pUseHardwareAccell->IsChecked());
bModified = true;
}
}
// #i95644# if disabled, do not use value, see in ::Reset()
if(m_pUseAntiAliase->IsEnabled())
{
if(m_pUseAntiAliase->IsChecked() != mpDrawinglayerOpt->IsAntiAliasing())
{
mpDrawinglayerOpt->SetAntiAliasing(m_pUseAntiAliase->IsChecked());
bModified = true;
bRepaintWindows = true;
}
}
if (m_pUseOpenGL->IsValueChangedFromSaved() ||
m_pForceOpenGL->IsValueChangedFromSaved())
{
mpOpenGLConfig->setUseOpenGL(m_pUseOpenGL->IsChecked());
mpOpenGLConfig->setForceOpenGL(m_pForceOpenGL->IsChecked());
bModified = true;
}
if( bMenuOptModified )
{
// Set changed settings to the application instance
AllSettings aAllSettings = Application::GetSettings();
StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
aAllSettings.SetStyleSettings(aStyleSettings);
Application::MergeSystemSettings( aAllSettings );
Application::SetSettings(aAllSettings);
}
if ( bAppearanceChanged )
{
pAppearanceCfg->Commit();
pAppearanceCfg->SetApplicationDefaults ( GetpApp() );
}
if(bRepaintWindows)
{
vcl::Window* pAppWindow = Application::GetFirstTopLevelWindow();
while(pAppWindow)
{
pAppWindow->Invalidate();
pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
}
}
if (m_pUseOpenGL->IsValueChangedFromSaved() ||
m_pForceOpenGL->IsValueChangedFromSaved())
{
SolarMutexGuard aGuard;
svtools::executeRestartDialog(
comphelper::getProcessComponentContext(), nullptr,
svtools::RESTART_REASON_OPENGL);
}
return bModified;
}
void OfaViewTabPage::Reset( const SfxItemSet* )
{
SvtMiscOptions aMiscOptions;
mpOpenGLConfig->reset();
if (aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO)
{
nSizeLB_InitialSelection = 1;
if (aMiscOptions.GetSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE)
nSizeLB_InitialSelection = 2;
else if (aMiscOptions.GetSymbolsSize() == SFX_SYMBOLS_SIZE_32)
nSizeLB_InitialSelection = 3;
}
m_pIconSizeLB->SelectEntryPos( nSizeLB_InitialSelection );
m_pIconSizeLB->SaveValue();
if( aMiscOptions.GetSidebarIconSize() == ToolBoxButtonSize::DontCare )
; // do nothing
else if( aMiscOptions.GetSidebarIconSize() == ToolBoxButtonSize::Small )
nSidebarSizeLB_InitialSelection = 1;
else if( aMiscOptions.GetSidebarIconSize() == ToolBoxButtonSize::Large )
nSidebarSizeLB_InitialSelection = 2;
m_pSidebarIconSizeLB->SelectEntryPos( nSidebarSizeLB_InitialSelection );
m_pSidebarIconSizeLB->SaveValue();
if( aMiscOptions.GetNotebookbarIconSize() == ToolBoxButtonSize::DontCare )
; // do nothing
else if( aMiscOptions.GetNotebookbarIconSize() == ToolBoxButtonSize::Small )
nNotebookbarSizeLB_InitialSelection = 1;
else if( aMiscOptions.GetNotebookbarIconSize() == ToolBoxButtonSize::Large )
nNotebookbarSizeLB_InitialSelection = 2;
m_pNotebookbarIconSizeLB->SelectEntryPos( nNotebookbarSizeLB_InitialSelection );
m_pNotebookbarIconSizeLB->SaveValue();
if (aMiscOptions.IconThemeWasSetAutomatically()) {
nStyleLB_InitialSelection = 0;
}
else {
const OUString& selected = aMiscOptions.GetIconTheme();
const vcl::IconThemeInfo& selectedInfo =
vcl::IconThemeInfo::FindIconThemeById(mInstalledIconThemes, selected);
nStyleLB_InitialSelection = m_pIconStyleLB->GetEntryPos(selectedInfo.GetDisplayName());
}
m_pIconStyleLB->SelectEntryPos( nStyleLB_InitialSelection );
m_pIconStyleLB->SaveValue();
// Mouse Snap
m_pMousePosLB->SelectEntryPos(static_cast<sal_Int32>(pAppearanceCfg->GetSnapMode()));
m_pMousePosLB->SaveValue();
// Mouse Snap
m_pMouseMiddleLB->SelectEntryPos(static_cast<short>(pAppearanceCfg->GetMiddleMouseButton()));
m_pMouseMiddleLB->SaveValue();
#if defined( UNX )
m_pFontAntiAliasing->Check( pAppearanceCfg->IsFontAntiAliasing() );
m_pAAPointLimit->SetValue( pAppearanceCfg->GetFontAntialiasingMinPixelHeight() );
#endif
// WorkingSet
SvtFontOptions aFontOpt;
m_pFontShowCB->Check( aFontOpt.IsFontWYSIWYGEnabled() );
SvtMenuOptions aMenuOpt;
m_pMenuIconsLB->SelectEntryPos(aMenuOpt.GetMenuIconsState() == 2 ? 0 : aMenuOpt.GetMenuIconsState() + 1);
m_pMenuIconsLB->SaveValue();
TriState eContextMenuShortcuts = aMenuOpt.GetContextMenuShortcuts();
bool bContextMenuShortcutsNonDefault = eContextMenuShortcuts == TRISTATE_FALSE || eContextMenuShortcuts == TRISTATE_TRUE;
m_pContextMenuShortcutsLB->SelectEntryPos(bContextMenuShortcutsNonDefault ? eContextMenuShortcuts + 1 : 0);
m_pContextMenuShortcutsLB->SaveValue();
{ // #i95644# HW accel (unified to disable mechanism)
if(pCanvasSettings->IsHardwareAccelerationAvailable())
{
m_pUseHardwareAccell->Check(pCanvasSettings->IsHardwareAccelerationEnabled());
m_pUseHardwareAccell->Enable(!pCanvasSettings->IsHardwareAccelerationRO());
}
else
{
m_pUseHardwareAccell->Check(false);
m_pUseHardwareAccell->Disable();
}
m_pUseHardwareAccell->SaveValue();
}
{ // #i95644# AntiAliasing
if(mpDrawinglayerOpt->IsAAPossibleOnThisSystem())
{
m_pUseAntiAliase->Check(mpDrawinglayerOpt->IsAntiAliasing());
}
else
{
m_pUseAntiAliase->Check(false);
m_pUseAntiAliase->Disable();
}
m_pUseAntiAliase->SaveValue();
}
m_pUseOpenGL->Check(mpOpenGLConfig->useOpenGL());
m_pForceOpenGL->Check(mpOpenGLConfig->forceOpenGL());
#if defined( UNX )
m_pFontAntiAliasing->SaveValue();
m_pAAPointLimit->SaveValue();
#endif
m_pFontShowCB->SaveValue();
m_pUseOpenGL->SaveValue();
m_pForceOpenGL->SaveValue();
#if defined( UNX )
LINK( this, OfaViewTabPage, OnAntialiasingToggled ).Call( *m_pFontAntiAliasing );
#endif
}
void OfaViewTabPage::UpdateOGLStatus()
{
if (Application::GetToolkitName() == "gtk3")
return;
// Easier than a custom translation string.
#if HAVE_FEATURE_OPENGL
bool bEnabled = OpenGLWrapper::isVCLOpenGLEnabled();
#else
bool bEnabled = false;
#endif
m_pOpenGLStatusEnabled->Show(bEnabled);
m_pOpenGLStatusDisabled->Show(!bEnabled);
}
struct LanguageConfig_Impl
{
SvtLanguageOptions aLanguageOptions;
SvtSysLocaleOptions aSysLocaleOptions;
SvtLinguConfig aLinguConfig;
};
static bool bLanguageCurrentDoc_Impl = false;
// some things we'll need...
static const char sAccessSrvc[] = "com.sun.star.configuration.ConfigurationAccess";
static const char sAccessUpdSrvc[] = "com.sun.star.configuration.ConfigurationUpdateAccess";
static const char sInstalledLocalesPath[] = "org.openoffice.Setup/Office/InstalledLocales";
static const char sUserLocalePath[] = "org.openoffice.Office.Linguistic/General";
static const char sUserLocaleKey[] = "UILocale";
static Sequence< OUString > seqInstalledLanguages;
static OUString lcl_getDatePatternsConfigString( const LocaleDataWrapper& rLocaleWrapper )
{
Sequence< OUString > aDateAcceptancePatterns = rLocaleWrapper.getDateAcceptancePatterns();
sal_Int32 nPatterns = aDateAcceptancePatterns.getLength();
OUStringBuffer aBuf( nPatterns * 6 ); // 6 := length of Y-M-D;
SAL_WARN_IF( !nPatterns, "cui.options", "No date acceptance pattern");
if (nPatterns)
{
const OUString* pPatterns = aDateAcceptancePatterns.getConstArray();
aBuf.append( pPatterns[0]);
for (sal_Int32 i=1; i < nPatterns; ++i)
aBuf.append(';').append( pPatterns[i]);
}
return aBuf.makeStringAndClear();
}
namespace
{
//what ui language will be selected by default if the user override of General::UILocale is unset ?
LanguageTag GetInstalledLocaleForSystemUILanguage()
{
css::uno::Sequence<OUString> inst(officecfg::Setup::Office::InstalledLocales::get()->getElementNames());
return LanguageTag(getInstalledLocaleForSystemUILanguage(inst, false)).makeFallback();
}
}
OfaLanguagesTabPage::OfaLanguagesTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent,"OptLanguagesPage","cui/ui/optlanguagespage.ui", &rSet)
, pLangConfig(new LanguageConfig_Impl)
, m_bDatePatternsValid(false)
{
get(m_pUserInterfaceLB, "userinterface");
m_pUserInterfaceLB->SetStyle(m_pUserInterfaceLB->GetStyle() | WB_SORT);
get(m_pLocaleSettingLB, "localesetting");
m_pLocaleSettingLB->SetStyle(m_pLocaleSettingLB->GetStyle() | WB_SORT);
get(m_pLocaleSettingFT, "localesettingFT");
get(m_pDecimalSeparatorCB, "decimalseparator");
get(m_pCurrencyFT, "defaultcurrency");
get(m_pCurrencyLB, "currencylb");
m_pCurrencyLB->SetStyle(m_pCurrencyLB->GetStyle() | WB_SORT);
get(m_pDatePatternsFT,"dataaccpatterns");
get(m_pDatePatternsED, "datepatterns");
get(m_pWesternLanguageLB, "westernlanguage");
m_pWesternLanguageLB->SetStyle(m_pWesternLanguageLB->GetStyle() | WB_SORT);
get(m_pWesternLanguageFT, "western");
get(m_pAsianLanguageLB, "asianlanguage");
m_pAsianLanguageLB->SetStyle(m_pAsianLanguageLB->GetStyle() | WB_SORT);
get(m_pComplexLanguageLB, "complexlanguage");
m_pComplexLanguageLB->SetStyle(m_pComplexLanguageLB->GetStyle() | WB_SORT);
get(m_pCurrentDocCB, "currentdoc");
get(m_pAsianSupportCB, "asiansupport");
get(m_pCTLSupportCB, "ctlsupport");
get(m_pIgnoreLanguageChangeCB, "ignorelanguagechange");
// initialize user interface language selection
m_sSystemDefaultString = SvtLanguageTable::GetLanguageString( LANGUAGE_SYSTEM );
OUString aUILang = m_sSystemDefaultString +
" - " +
SvtLanguageTable::GetLanguageString(GetInstalledLocaleForSystemUILanguage().getLanguageType());
m_pUserInterfaceLB->InsertEntry(aUILang);
m_pUserInterfaceLB->SetEntryData(0, nullptr);
m_pUserInterfaceLB->SelectEntryPos(0);
try
{
Reference< XMultiServiceFactory > theConfigProvider(
css::configuration::theDefaultProvider::get(
comphelper::getProcessComponentContext()));
Sequence< Any > theArgs(1);
Reference< XNameAccess > theNameAccess;
// find out which locales are currently installed and add them to the listbox
theArgs[0] <<= NamedValue("nodepath", Any(OUString(sInstalledLocalesPath)));
theNameAccess.set(
theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW );
seqInstalledLanguages = theNameAccess->getElementNames();
LanguageType aLang = LANGUAGE_DONTKNOW;
for (sal_IntPtr i=0; i<seqInstalledLanguages.getLength(); i++)
{
aLang = LanguageTag::convertToLanguageTypeWithFallback(seqInstalledLanguages[i]);
if (aLang != LANGUAGE_DONTKNOW)
{
OUString aLangStr( SvtLanguageTable::GetLanguageString( aLang ) );
const sal_Int32 p = m_pUserInterfaceLB->InsertEntry(aLangStr);
m_pUserInterfaceLB->SetEntryData(p, reinterpret_cast<void*>(i+1));
}
}
// find out whether the user has a specific locale specified
Sequence< Any > theArgs2(1);
theArgs2[0] <<= NamedValue("nodepath", Any(OUString(sUserLocalePath)));
theNameAccess.set(
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.isEmpty())
{
sal_Int32 d = 0;
for (sal_Int32 i=0; i < m_pUserInterfaceLB->GetEntryCount(); i++)
{
d = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(m_pUserInterfaceLB->GetEntryData(i)));
if ( d > 0 && seqInstalledLanguages.getLength() > d-1 && seqInstalledLanguages[d-1] == m_sUserLocaleValue)
m_pUserInterfaceLB->SelectEntryPos(i);
}
}
}
catch (const Exception &e)
{
// we'll just leave the box in its default setting and won't
// even give it event handler...
SAL_WARN("cui.options", "ignoring " << e);
}
m_pWesternLanguageLB->SetLanguageList( SvxLanguageListFlags::WESTERN | SvxLanguageListFlags::ONLY_KNOWN, true, false, true );
m_pWesternLanguageLB->InsertDefaultLanguage( css::i18n::ScriptType::LATIN );
m_pAsianLanguageLB->SetLanguageList( SvxLanguageListFlags::CJK | SvxLanguageListFlags::ONLY_KNOWN, true, false, true );
m_pAsianLanguageLB->InsertDefaultLanguage( css::i18n::ScriptType::ASIAN );
m_pComplexLanguageLB->SetLanguageList( SvxLanguageListFlags::CTL | SvxLanguageListFlags::ONLY_KNOWN, true, false, true );
m_pComplexLanguageLB->InsertDefaultLanguage( css::i18n::ScriptType::COMPLEX );
m_pLocaleSettingLB->SetLanguageList( SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN, false );
m_pLocaleSettingLB->InsertSystemLanguage( );
const NfCurrencyTable& rCurrTab = SvNumberFormatter::GetTheCurrencyTable();
const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( LANGUAGE_SYSTEM );
// insert SYSTEM entry
OUString aDefaultCurr = m_sSystemDefaultString + " - " + rCurr.GetBankSymbol();
m_pCurrencyLB->InsertEntry( aDefaultCurr );
// all currencies
OUString aTwoSpace( " " );
sal_uInt16 nCurrCount = rCurrTab.size();
// first entry is SYSTEM, skip it
for ( sal_uInt16 j=1; j < nCurrCount; ++j )
{
const NfCurrencyEntry* pCurr = &rCurrTab[j];
OUString aStr_ = pCurr->GetBankSymbol() +
aTwoSpace +
pCurr->GetSymbol();
aStr_ = ApplyLreOrRleEmbedding( aStr_ ) +
aTwoSpace +
ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString( pCurr->GetLanguage() ) );
const sal_Int32 nPos = m_pCurrencyLB->InsertEntry( aStr_ );
m_pCurrencyLB->SetEntryData( nPos, const_cast<NfCurrencyEntry *>(pCurr) );
}
m_pLocaleSettingLB->SetSelectHdl( LINK( this, OfaLanguagesTabPage, LocaleSettingHdl ) );
m_pDatePatternsED->SetModifyHdl( LINK( this, OfaLanguagesTabPage, DatePatternsHdl ) );
Link<Button*,void> aLink( LINK( this, OfaLanguagesTabPage, SupportHdl ) );
m_pAsianSupportCB->SetClickHdl( aLink );
m_pCTLSupportCB->SetClickHdl( aLink );
m_bOldAsian = pLangConfig->aLanguageOptions.IsAnyEnabled();
m_pAsianSupportCB->Check(m_bOldAsian);
m_pAsianSupportCB->SaveValue();
bool bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK);
m_pAsianSupportCB->Enable(!bReadonly);
SupportHdl( m_pAsianSupportCB );
m_bOldCtl = pLangConfig->aLanguageOptions.IsCTLFontEnabled();
m_pCTLSupportCB->Check(m_bOldCtl);
m_pCTLSupportCB->SaveValue();
bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT);
m_pCTLSupportCB->Enable(!bReadonly);
SupportHdl( m_pCTLSupportCB );
m_pIgnoreLanguageChangeCB->Check( pLangConfig->aSysLocaleOptions.IsIgnoreLanguageChange() );
}
OfaLanguagesTabPage::~OfaLanguagesTabPage()
{
disposeOnce();
}
void OfaLanguagesTabPage::dispose()
{
delete pLangConfig;
pLangConfig = nullptr;
m_pUserInterfaceLB.clear();
m_pLocaleSettingFT.clear();
m_pLocaleSettingLB.clear();
m_pDecimalSeparatorCB.clear();
m_pCurrencyFT.clear();
m_pCurrencyLB.clear();
m_pDatePatternsFT.clear();
m_pDatePatternsED.clear();
m_pWesternLanguageLB.clear();
m_pWesternLanguageFT.clear();
m_pAsianLanguageLB.clear();
m_pComplexLanguageLB.clear();
m_pCurrentDocCB.clear();
m_pAsianSupportCB.clear();
m_pCTLSupportCB.clear();
m_pIgnoreLanguageChangeCB.clear();
SfxTabPage::dispose();
}
VclPtr<SfxTabPage> OfaLanguagesTabPage::Create( TabPageParent pParent, const SfxItemSet* rAttrSet )
{
return VclPtr<OfaLanguagesTabPage>::Create(pParent.pParent, *rAttrSet);
}
static 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(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] ;
}
}
bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet )
{
// lock configuration broadcasters so that we can coordinate the notifications
pLangConfig->aSysLocaleOptions.BlockBroadcasts( true );
pLangConfig->aLanguageOptions.BlockBroadcasts( true );
pLangConfig->aLinguConfig.BlockBroadcasts( 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 (
m_pCTLSupportCB->IsChecked() &&
(m_pCTLSupportCB->GetSavedValue() != TRISTATE_TRUE ||
m_pComplexLanguageLB->IsValueChangedFromSaved())
)
{
//sequence checking has to be switched on depending on the selected CTL language
LanguageType eCTLLang = m_pComplexLanguageLB->GetSelectedLanguage();
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 = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(m_pUserInterfaceLB->GetSelectedEntryData()));
if( d > 0 && seqInstalledLanguages.getLength() > d-1)
aLangString = seqInstalledLanguages[d-1];
/*
if( m_pUserInterfaceLB->GetSelectedEntryPos() > 0)
aLangString = ConvertLanguageToIsoString(m_pUserInterfaceLB->GetSelectedLanguage());
*/
Reference< XMultiServiceFactory > theConfigProvider(
css::configuration::theDefaultProvider::get(
comphelper::getProcessComponentContext()));
Sequence< Any > theArgs(1);
theArgs[0] <<= NamedValue("nodepath", Any(OUString(sUserLocalePath)));
Reference< XPropertySet >xProp(
theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW );
if ( m_sUserLocaleValue != aLangString)
{
// OSL_FAIL("UserInterface language was changed, restart.");
// write new value
xProp->setPropertyValue(sUserLocaleKey, Any(aLangString));
Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
// display info
SolarMutexGuard aGuard;
svtools::executeRestartDialog(
comphelper::getProcessComponentContext(), GetFrameWeld(),
svtools::RESTART_REASON_LANGUAGE_CHANGE);
// tell quickstarter to stop being a veto listener
Reference< XComponentContext > xContext(
comphelper::getProcessComponentContext());
css::office::Quickstart::createAndSetVeto(xContext, false, false, false/*DisableVeto*/);
}
}
catch (const Exception& e)
{
// we'll just leave the box in its default setting and won't
// even give it event handler...
SAL_WARN("cui.options", "ignoring Exception \"" << e << "\"");
}
LanguageTag aLanguageTag( pLangConfig->aSysLocaleOptions.GetLanguageTag());
LanguageType eOldLocale = (aLanguageTag.isSystemLocale() ? LANGUAGE_SYSTEM :
aLanguageTag.makeFallback().getLanguageType());
LanguageType eNewLocale = m_pLocaleSettingLB->GetSelectedLanguage();
// If the "Default ..." entry was selected that means SYSTEM, the actual
// eNewLocale value is temporary for the dialog only, do not resolve to
// what system currently is.
if (eNewLocale == LANGUAGE_USER_SYSTEM_CONFIG)
eNewLocale = LANGUAGE_SYSTEM;
if ( eOldLocale != eNewLocale )
{
// an empty string denotes SYSTEM locale
OUString sNewLang;
if ( eNewLocale != LANGUAGE_SYSTEM )
sNewLang = LanguageTag::convertToBcp47( eNewLocale);
// 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, true ) );
SvtScriptType nNewType = SvtLanguageOptions::GetScriptTypeOfLanguage( eNewLocale );
bool bNewCJK = bool( nNewType & SvtScriptType::ASIAN );
SvtCompatibilityOptions aCompatOpts;
aCompatOpts.SetDefault( SvtCompatibilityEntry::Index::ExpandWordSpace, !bNewCJK );
}
if(m_pDecimalSeparatorCB->IsValueChangedFromSaved())
pLangConfig->aSysLocaleOptions.SetDecimalSeparatorAsLocale(m_pDecimalSeparatorCB->IsChecked());
if(m_pIgnoreLanguageChangeCB->IsValueChangedFromSaved())
pLangConfig->aSysLocaleOptions.SetIgnoreLanguageChange(m_pIgnoreLanguageChangeCB->IsChecked());
// Configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default.
OUString sOldCurr = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
const NfCurrencyEntry* pCurr = static_cast<const NfCurrencyEntry*>(m_pCurrencyLB->GetSelectedEntryData());
OUString sNewCurr;
if ( pCurr )
sNewCurr = SvtSysLocaleOptions::CreateCurrencyConfigString(
pCurr->GetBankSymbol(), pCurr->GetLanguage() );
if ( sOldCurr != sNewCurr )
pLangConfig->aSysLocaleOptions.SetCurrencyConfigString( sNewCurr );
// Configured date acceptance patterns, for example Y-M-D;M-D or empty for
// locale default.
if (m_bDatePatternsValid && m_pDatePatternsED->IsValueChangedFromSaved())
pLangConfig->aSysLocaleOptions.SetDatePatternsConfigString( m_pDatePatternsED->GetText());
SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
Reference< css::linguistic2::XLinguProperties > xLinguProp = LinguMgr::GetLinguPropertySet();
bool bCurrentDocCBChecked = m_pCurrentDocCB->IsChecked();
if(m_pCurrentDocCB->IsEnabled())
bLanguageCurrentDoc_Impl = bCurrentDocCBChecked;
bool bCurrentDocCBChanged = m_pCurrentDocCB->IsValueChangedFromSaved();
bool bValChanged = m_pWesternLanguageLB->IsValueChangedFromSaved();
if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
{
LanguageType eSelectLang = m_pWesternLanguageLB->GetSelectedLanguage();
if(!bCurrentDocCBChecked)
{
Any aValue;
Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
aValue <<= aLocale;
pLangConfig->aLinguConfig.SetProperty( "DefaultLocale", aValue );
if (xLinguProp.is())
xLinguProp->setDefaultLocale( aLocale );
}
if(pCurrentDocShell)
{
rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, css::i18n::ScriptType::LATIN),
SID_ATTR_LANGUAGE));
}
}
bValChanged = m_pAsianLanguageLB->IsValueChangedFromSaved();
if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
{
LanguageType eSelectLang = m_pAsianLanguageLB->GetSelectedLanguage();
if(!bCurrentDocCBChecked)
{
Any aValue;
Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
aValue <<= aLocale;
pLangConfig->aLinguConfig.SetProperty( "DefaultLocale_CJK", aValue );
if (xLinguProp.is())
xLinguProp->setDefaultLocale_CJK( aLocale );
}
if(pCurrentDocShell)
{
rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, css::i18n::ScriptType::ASIAN),
SID_ATTR_CHAR_CJK_LANGUAGE));
}
}
bValChanged = m_pComplexLanguageLB->IsValueChangedFromSaved();
if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
{
LanguageType eSelectLang = m_pComplexLanguageLB->GetSelectedLanguage();
if(!bCurrentDocCBChecked)
{
Any aValue;
Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
aValue <<= aLocale;
pLangConfig->aLinguConfig.SetProperty( "DefaultLocale_CTL", aValue );
if (xLinguProp.is())
xLinguProp->setDefaultLocale_CTL( aLocale );
}
if(pCurrentDocShell)
{
rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, css::i18n::ScriptType::COMPLEX),
SID_ATTR_CHAR_CTL_LANGUAGE));
}
}
if(m_pAsianSupportCB->IsValueChangedFromSaved() )
{
bool bChecked = m_pAsianSupportCB->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, false);
pBoolItems[1] = new SfxBoolItem(SID_TEXT_FITTOSIZE_VERTICAL, 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 ( m_pCTLSupportCB->IsValueChangedFromSaved() )
{
SvtSearchOptions aOpt;
aOpt.SetIgnoreDiacritics_CTL(true);
aOpt.SetIgnoreKashida_CTL(true);
aOpt.Commit();
pLangConfig->aLanguageOptions.SetCTLFontEnabled( m_pCTLSupportCB->IsChecked() );
const sal_uInt16 STATE_COUNT = 1;
SfxBoolItem* pBoolItems[STATE_COUNT];
pBoolItems[0] = new SfxBoolItem(SID_CTLFONT_STATE, 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( false );
pLangConfig->aLanguageOptions.BlockBroadcasts( false );
pLangConfig->aLinguConfig.BlockBroadcasts( false );
return false;
}
void OfaLanguagesTabPage::Reset( const SfxItemSet* rSet )
{
LanguageTag aLanguageTag( pLangConfig->aSysLocaleOptions.GetLanguageTag());
if ( aLanguageTag.isSystemLocale() )
m_pLocaleSettingLB->SelectLanguage( LANGUAGE_USER_SYSTEM_CONFIG );
else
m_pLocaleSettingLB->SelectLanguage( aLanguageTag.makeFallback().getLanguageType());
bool bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::Locale);
m_pLocaleSettingLB->Enable(!bReadonly);
m_pLocaleSettingFT->Enable(!bReadonly);
m_pDecimalSeparatorCB->Check( pLangConfig->aSysLocaleOptions.IsDecimalSeparatorAsLocale());
m_pDecimalSeparatorCB->SaveValue();
m_pIgnoreLanguageChangeCB->Check( pLangConfig->aSysLocaleOptions.IsIgnoreLanguageChange());
m_pIgnoreLanguageChangeCB->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(*m_pLocaleSettingLB);
// configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default
OUString aAbbrev;
LanguageType eLang;
const NfCurrencyEntry* pCurr = nullptr;
OUString sCurrency = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
if ( !sCurrency.isEmpty() )
{
SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( aAbbrev, eLang, sCurrency );
pCurr = SvNumberFormatter::GetCurrencyEntry( aAbbrev, eLang );
}
// if pCurr==NULL the SYSTEM entry is selected
const sal_Int32 nPos = m_pCurrencyLB->GetEntryPos( static_cast<void const *>(pCurr) );
m_pCurrencyLB->SelectEntryPos( nPos );
bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::Currency);
m_pCurrencyLB->Enable(!bReadonly);
m_pCurrencyFT->Enable(!bReadonly);
// date acceptance patterns
OUString aDatePatternsString = pLangConfig->aSysLocaleOptions.GetDatePatternsConfigString();
if (aDatePatternsString.isEmpty())
{
const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
aDatePatternsString = lcl_getDatePatternsConfigString( rLocaleWrapper);
}
// Let's assume patterns are valid at this point.
m_bDatePatternsValid = true;
m_pDatePatternsED->SetText( aDatePatternsString);
bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::EOption::DatePatterns);
m_pDatePatternsED->Enable(!bReadonly);
m_pDatePatternsFT->Enable(!bReadonly);
m_pDatePatternsED->SaveValue();
//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
m_pCurrentDocCB->Enable(false);
Any aWestLang;
Any aCJKLang;
Any aCTLLang;
try
{
aWestLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale");
Locale aLocale;
aWestLang >>= aLocale;
eCurLang = LanguageTag::convertToLanguageType( aLocale, false);
aCJKLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale_CJK");
aLocale = Locale();
aCJKLang >>= aLocale;
eCurLangCJK = LanguageTag::convertToLanguageType( aLocale, false);
aCTLLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale_CTL");
aLocale = Locale();
aCTLLang >>= aLocale;
eCurLangCTL = LanguageTag::convertToLanguageType( aLocale, false);
}
catch (const Exception&)
{
}
//overwrite them by the values provided by the DocShell
if(pCurrentDocShell)
{
m_pCurrentDocCB->Enable();
m_pCurrentDocCB->Check(bLanguageCurrentDoc_Impl);
const SfxPoolItem* pLang;
if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_LANGUAGE, false, &pLang))
{
LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue();
if (MsLangId::resolveSystemLanguageByScriptType(eCurLang, css::i18n::ScriptType::LATIN) != eTempCurLang)
eCurLang = eTempCurLang;
}
if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, false, &pLang))
{
LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue();
if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK, css::i18n::ScriptType::ASIAN) != eTempCurLang)
eCurLangCJK = eTempCurLang;
}
if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, false, &pLang))
{
LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue();
if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL, css::i18n::ScriptType::COMPLEX) != eTempCurLang)
eCurLangCTL = eTempCurLang;
}
}
if(LANGUAGE_NONE == eCurLang || LANGUAGE_DONTKNOW == eCurLang)
m_pWesternLanguageLB->SelectLanguage(LANGUAGE_NONE);
else
m_pWesternLanguageLB->SelectLanguage(eCurLang);
if(LANGUAGE_NONE == eCurLangCJK || LANGUAGE_DONTKNOW == eCurLangCJK)
m_pAsianLanguageLB->SelectLanguage(LANGUAGE_NONE);
else
m_pAsianLanguageLB->SelectLanguage(eCurLangCJK);
if(LANGUAGE_NONE == eCurLangCTL || LANGUAGE_DONTKNOW == eCurLangCTL)
m_pComplexLanguageLB->SelectLanguage(LANGUAGE_NONE);
else
m_pComplexLanguageLB->SelectLanguage(eCurLangCTL);
m_pWesternLanguageLB->SaveValue();
m_pAsianLanguageLB->SaveValue();
m_pComplexLanguageLB->SaveValue();
m_pIgnoreLanguageChangeCB->SaveValue();
m_pCurrentDocCB->SaveValue();
bool bEnable = !pLangConfig->aLinguConfig.IsReadOnly( "DefaultLocale" );
m_pWesternLanguageFT->Enable( bEnable );
m_pWesternLanguageLB->Enable( bEnable );
// check the box "For the current document only"
// set the focus to the Western Language box
const SfxPoolItem* pLang = nullptr;
if ( SfxItemState::SET == rSet->GetItemState(SID_SET_DOCUMENT_LANGUAGE, false, &pLang ) && static_cast<const SfxBoolItem*>(pLang)->GetValue() )
{
m_pWesternLanguageLB->GrabFocus();
m_pCurrentDocCB->Enable();
m_pCurrentDocCB->Check();
}
}
IMPL_LINK( OfaLanguagesTabPage, SupportHdl, Button*, pButton, void )
{
CheckBox* pBox = static_cast<CheckBox*>(pButton);
DBG_ASSERT( pBox, "OfaLanguagesTabPage::SupportHdl(): pBox invalid" );
bool bCheck = pBox->IsChecked();
if ( m_pAsianSupportCB == pBox )
{
bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly("DefaultLocale_CJK");
bCheck = ( bCheck && !bReadonly );
m_pAsianLanguageLB->Enable( bCheck );
if( pBox->IsEnabled() )
m_bOldAsian = bCheck;
}
else if ( m_pCTLSupportCB == pBox )
{
bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly("DefaultLocale_CTL");
bCheck = ( bCheck && !bReadonly );
m_pComplexLanguageLB->Enable( bCheck );
if( pBox->IsEnabled() )
m_bOldCtl = bCheck;
}
else
SAL_WARN( "cui.options", "OfaLanguagesTabPage::SupportHdl(): wrong pBox" );
}
namespace
{
void lcl_checkLanguageCheckBox(CheckBox* _rCB,bool _bNewValue,bool _bOldValue)
{
if ( _bNewValue )
_rCB->Check();
else
_rCB->Check( _bOldValue );
// #i15082# do not call SaveValue() in running dialog...
// _rCB.SaveValue();
_rCB->Enable( !_bNewValue );
}
}
IMPL_LINK( OfaLanguagesTabPage, LocaleSettingHdl, ListBox&, rListBox, void )
{
SvxLanguageBox* pBox = static_cast<SvxLanguageBox*>(&rListBox);
LanguageType eLang = pBox->GetSelectedLanguage();
SvtScriptType 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 = bool(nType & SvtScriptType::COMPLEX);
lcl_checkLanguageCheckBox(m_pCTLSupportCB, bIsCTLFixed, m_bOldCtl);
SupportHdl( m_pCTLSupportCB );
}
// second check if CJK must be enabled
// #103299# - if CJK support is not readonly
if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK))
{
bool bIsCJKFixed = bool(nType & SvtScriptType::ASIAN);
lcl_checkLanguageCheckBox(m_pAsianSupportCB, bIsCJKFixed, m_bOldAsian);
SupportHdl( m_pAsianSupportCB );
}
const NfCurrencyEntry* pCurr = &SvNumberFormatter::GetCurrencyEntry(
(eLang == LANGUAGE_USER_SYSTEM_CONFIG) ? MsLangId::getSystemLanguage() : eLang);
sal_Int32 nPos = m_pCurrencyLB->GetEntryPos( nullptr );
if (pCurr)
{
// Update the "Default ..." currency.
m_pCurrencyLB->RemoveEntry( nPos );
OUString aDefaultCurr = m_sSystemDefaultString + " - " + pCurr->GetBankSymbol();
nPos = m_pCurrencyLB->InsertEntry( aDefaultCurr );
}
m_pCurrencyLB->SelectEntryPos( nPos );
// obtain corresponding locale data
LanguageTag aLanguageTag( eLang);
LocaleDataWrapper aLocaleWrapper( aLanguageTag );
// update the decimal separator key of the related CheckBox
OUString sTempLabel(m_pDecimalSeparatorCB->GetText());
sTempLabel = sTempLabel.replaceFirst("%1", aLocaleWrapper.getNumDecimalSep() );
m_pDecimalSeparatorCB->SetText(sTempLabel);
// update the date acceptance patterns
OUString aDatePatternsString = lcl_getDatePatternsConfigString( aLocaleWrapper);
m_bDatePatternsValid = true;
m_pDatePatternsED->SetText( aDatePatternsString);
}
IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, Edit&, rEd, void )
{
const OUString aPatterns( rEd.GetText());
OUStringBuffer aBuf( aPatterns);
sal_Int32 nChar = 0;
bool bValid = true;
bool bModified = false;
if (!aPatterns.isEmpty())
{
for (sal_Int32 nIndex=0; nIndex >= 0 && bValid; ++nChar)
{
const OUString aPat( aPatterns.getToken( 0, ';', nIndex));
if (aPat.isEmpty() && nIndex < 0)
{
// Indicating failure when about to append a pattern is too
// confusing. Empty patterns are ignored anyway when sequencing
// to SvtSysLocale.
continue; // for
}
else if (aPat.getLength() < 2)
bValid = false;
else
{
bool bY, bM, bD;
bY = bM = bD = false;
bool bSep = true;
for (sal_Int32 i = 0; i < aPat.getLength() && bValid; /*nop*/)
{
const sal_Int32 j = i;
const sal_uInt32 c = aPat.iterateCodePoints( &i);
// Only one Y,M,D per pattern, separated by any character(s).
switch (c)
{
case 'y':
case 'Y':
if (bY || !bSep)
bValid = false;
else if (c == 'y')
{
aBuf[nChar] = 'Y';
bModified = true;
}
bY = true;
bSep = false;
break;
case 'm':
case 'M':
if (bM || !bSep)
bValid = false;
else if (c == 'm')
{
aBuf[nChar] = 'M';
bModified = true;
}
bM = true;
bSep = false;
break;
case 'd':
case 'D':
if (bD || !bSep)
bValid = false;
else if (c == 'd')
{
aBuf[nChar] = 'D';
bModified = true;
}
bD = true;
bSep = false;
break;
default:
// A pattern must not start with a separator (but
// may end with).
if (!(bY || bM || bD))
bValid = false;
bSep = true;
}
nChar += i-j;
}
// At least one of Y,M,D
bValid &= (bY || bM || bD);
}
}
}
if (bModified)
{
// Do not use SetText(...,GetSelection()) because internally the
// reference's pointer of the selection is obtained resulting in the
// entire text being selected at the end.
Selection aSelection( rEd.GetSelection());
rEd.SetText( aBuf.makeStringAndClear(), aSelection);
}
if (bValid)
{
rEd.SetControlForeground();
rEd.SetControlBackground();
}
else
{
rEd.SetControlForeground( ::Color( 0xf0, 0, 0 ) );
}
m_bDatePatternsValid = bValid;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|