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
|
/* -*- 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 .
*/
#ifndef INCLUDED_VCL_SVAPP_HXX
#define INCLUDED_VCL_SVAPP_HXX
#include <config_features.h>
#include <sal/config.h>
#include <cassert>
#include <stdexcept>
#include <vector>
#include <comphelper/solarmutex.hxx>
#include <rtl/ustring.hxx>
#include <osl/thread.hxx>
#include <tools/gen.hxx>
#include <tools/link.hxx>
#include <tools/solar.h>
#include <vcl/dllapi.h>
#include <vcl/apptypes.hxx>
#include <vcl/vclevent.hxx>
#include <vcl/metric.hxx>
#include <unotools/localedatawrapper.hxx>
class BitmapEx;
class Link;
class AllSettings;
class DataChangedEvent;
class Accelerator;
class Help;
class OutputDevice;
class Window;
class WorkWindow;
class MenuBar;
class UnoWrapperBase;
class Reflection;
class KeyCode;
class NotifyEvent;
class KeyEvent;
class MouseEvent;
class ZoomEvent;
class ScrollEvent;
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/connection/XConnection.hpp>
namespace com {
namespace sun {
namespace star {
namespace uno {
class XComponentContext;
}
namespace ui {
namespace dialogs {
class XFilePicker2;
class XFolderPicker2;
}
}
namespace awt {
class XToolkit;
class XDisplayConnection;
}
} } }
// helper needed by SalLayout implementations as well as svx/source/dialog/svxbmpnumbalueset.cxx
VCL_DLLPUBLIC sal_UCS4 GetMirroredChar( sal_UCS4 );
VCL_DLLPUBLIC sal_UCS4 GetLocalizedChar( sal_UCS4, LanguageType );
#define SYSTEMWINDOW_MODE_NOAUTOMODE ((sal_uInt16)0x0001)
#define SYSTEMWINDOW_MODE_DIALOG ((sal_uInt16)0x0002)
typedef long (*VCLEventHookProc)( NotifyEvent& rEvt, void* pData );
// ATTENTION: ENUM duplicate in daemon.cxx under Unix!
#ifdef UNX
enum Service { SERVICE_OLE, SERVICE_APPEVENT, SERVICE_IPC };
#endif
/** An application can be notified of a number of different events:
- TYPE_ACCEPT - listen for connection to the application (a connection
string is passed via the event)
- TYPE_UNACCEPT - stops listening for a connection to the app (determined by
a connection string passed via the event)
- TYPE_APPEAR - brings the app to the front (i.e. makes it "appear")
- TYPE_VERSION - display the app version
- TYPE_HELP - opens a help topic (help topic passed as string)
- TYPE_OPENHELP_URL - opens a help URL (URL passed as a string)
- TYPE_SHOWDIALOG - shows a dialog (dialog passed as a string)
- TYPE_OPEN - opens a document or group of documents (documents passed
as an array of strings)
- TYPE_PRINT - print a document or group of documents (documents passed
as an array of strings
- TYPE_PRIVATE_DOSHUTDOWN - shutdown the app
*/
class VCL_DLLPUBLIC ApplicationEvent
{
public:
enum Type {
TYPE_ACCEPT, ///< Listen for connections
TYPE_APPEAR, ///< Make application appear
TYPE_HELP, ///< Bring up help options (command-line help)
TYPE_VERSION, ///< Display product version
TYPE_OPEN, ///< Open a document
TYPE_OPENHELPURL, ///< Open a help URL
TYPE_PRINT, ///< Print document
TYPE_PRIVATE_DOSHUTDOWN, ///< Shutdown application
TYPE_QUICKSTART, ///< Start QuickStart
TYPE_SHOWDIALOG, ///< Show a dialog
TYPE_UNACCEPT ///< Stop listening for connections
};
/** Explicit constructor for ApplicationEvent.
@attention TYPE_APPEAR, TYPE_VERSION, TYPE_PRIVATE_DOSHUTDOWN and
TYPE_QUICKSTART are the \em only events that don't need to include
a data string with the event. No other events should use this
constructor!
*/
explicit ApplicationEvent(Type type): aEvent(type) {
assert(
type == TYPE_APPEAR || type == TYPE_VERSION
|| type == TYPE_PRIVATE_DOSHUTDOWN || type == TYPE_QUICKSTART);
}
/** Constructor for ApplicationEvent, accepts a string for the data
associated with the event.
@attention TYPE_ACCEPT, TYPE_HELP, TYPE_OPENHELPURL, TYPE_SHOWDIALOG
and TYPE_UNACCEPT are the \em only events that accept a single
string as event data. No other events should use this constructor!
*/
ApplicationEvent(Type type, OUString const & data): aEvent(type) {
assert(
type == TYPE_ACCEPT || type == TYPE_HELP || type == TYPE_OPENHELPURL
|| type == TYPE_SHOWDIALOG || type == TYPE_UNACCEPT);
aData.push_back(data);
}
/** Constructor for ApplicationEvnet, accepts an array of strings for
the data associated with the event.
@attention TYPE_OPEN and TYPE_PRINT can apply to multiple documents,
and are the \em only events that accept an array of strings. No other
events should use this constructor.
*/
ApplicationEvent(Type type, std::vector<OUString> const & data):
aEvent(type), aData(data)
{ assert(type == TYPE_OPEN || type == TYPE_PRINT); }
/** Get the type of event.
@returns The type of event.
*/
Type GetEvent() const { return aEvent; }
/** Gets the application event's data string.
@attention The \em only events that need a single string TYPE_ACCEPT,
TYPE_HELP, TYPE_OPENHELPURL, TYPE_SHOWDIALOG and TYPE_UNACCEPT
@returns The event's data string.
*/
OUString GetStringData() const {
assert(
aEvent == TYPE_ACCEPT || aEvent == TYPE_HELP
|| aEvent == TYPE_OPENHELPURL || aEvent == TYPE_SHOWDIALOG
|| aEvent == TYPE_UNACCEPT);
assert(aData.size() == 1);
return aData[0];
}
/** Gets the event's array of strings.
@attention The \em only events that need an array of strings
are TYPE_OPEN and TYPE_PRINT.
*/
std::vector<OUString> const & GetStringsData() const {
assert(aEvent == TYPE_OPEN || aEvent == TYPE_PRINT);
return aData;
}
private:
Type aEvent;
std::vector<OUString> aData;
};
/**
@brief Abstract base class used mainly for the LibreOffice Desktop class.
The Application class is an abstract class with one pure virtual
function: Main(), however, there are a \em lot of static functions
that are vital for applications. It is really meant to be subclassed
to provide a global singleton, and heavily relies on a single data
structure ImplSVData
The reason Application exists is because the VCL used to be a
standalone framework, long since abandoned by anything other than
our application.
@see Desktop, ImplSVData
*/
class VCL_DLLPUBLIC Application
{
public:
enum DialogCancelMode {
DIALOG_CANCEL_OFF, ///< do not automatically cancel dialogs
DIALOG_CANCEL_SILENT, ///< silently cancel any dialogs
DIALOG_CANCEL_FATAL ///< cancel any dialogs by std::abort
};
/** @name Initialization
The following functions perform initialization and deinitialization
of the application.
*/
///@{
/** Default constructor for Application class.
Initializes the LibreOffice global instance data structure if needed,
and then sets itself to be the Application class. Also initializes any
platform specific data structures.
@attention The initialization of the application itself is done in Init()
@see InitSalData is implemented by platform specific code.
ImplInitSVData initializes the global instance data
*/
Application();
/** Virtual destructor for Application class.
Deinitializes the LibreOffice global instance data structure, then
deinitializes any platform specific data structures.
@see ImplDeInitSVData deinitializes the global instance data,
DeInitSalData is implemented by platform specific code
*/
virtual ~Application();
/** Initialize the application itself.
@attention Note that the global data structures and platform specific
initialization is done in the constructor.
@see InitFinished, DeInit
*/
virtual void Init();
/** Finish initialization of the application.
@see Init, DeInit
*/
virtual void InitFinished();
/** Deinitialized the application itself.
@attention Note that the global data structures and platform specific
deinitialization is done in the destructor.
@see Init, InitFinished
*/
virtual void DeInit();
///@}
/** @brief Pure virtual entrypoint to the application.
Main() is the pure virtual entrypoint to your application. You
inherit your class from Application and subclass this function to
implement an application.
The Main() function does not pass in command line parameters,
you must use the functions GetCommandLineParamCount() and
GetCommandLineParam() to get these values as these are platform
independent ways of getting the command line (use GetAppFileName()
to get the invoked executable filename).
Once in this function, you create windows, etc. then call on
Execute() to start the application's main event loop.
An example code snippet follows (it won't compile, this just gives the
general flavour of the framework and is adapted from an old HelloWorld
example program that Star Division used to provide as part of their
library).
\code{.cpp}
class TheApplication : public Application
{
public:
virtual void Main();
};
class TheWindow : public WorkWindow
{
public:
TheWindow(Window *parent, WinBits windowStyle) :
WorkWindow(parent, windowStyle) {}
virtual void Paint(const Rectangle &);
};
void TheWindow::Paint(const Rectangle&)
{
DrawText(Point(100,100), String("Hello World!"));
}
void TheApplication::Main()
{
TheWindow aWindow(NULL, WB_APP | WB_STDWORK);
aWindow.Show();
Execute();
}
TheApplication anApplication;
\endcode
Some examples in the source tree can be found here:
vcl/workben/svdem.cxx
This is an example of how to use the Application and WorkWindow. Unfortunately, it
no longer compiles.
vcl/fpicker/test/svdem.cxx
*/
virtual int Main() = 0;
/** Exit from the application
@returns true if exited successfully, false if not able to fully exit
*/
virtual bool QueryExit();
/** Send user event.
@param nEvent The numeric ID of the event
@param pEventData Pointer to a data associated with the event. Use
a reinterpret_cast<void*> to pass in the parameter.
*/
virtual void UserEvent( sal_uLong nEvent, void* pEventData );
/** @name Change Notification Functions
Functions that notify when changes occur in the application.
*/
///@{
/** Notify that the application is no longer the "focused" (or current)
application - needed for Windowing systems where an end user can switch
from one application to another.
@see DataChanged
*/
virtual void FocusChanged();
/** Notify the application that data has changed via an event.
@param rDCEvt Const reference to a DataChangedEvent object
@see FocusChanged, NotifyAllWindows
*/
virtual void DataChanged( const DataChangedEvent& rDCEvt );
/** Notify all windows that the application has changed data.
@param rDCEvt Reference to a DataChangedEvent object
@see DataChanged
*/
static void NotifyAllWindows( DataChangedEvent& rDCEvt );
///@}
/** @name Command Line Processing
Command line processing is done via the following functions. They
give the number of parameters, the parameters themselves and a way
to get the name of the invoking application.
*/
///@{
/** Gets the number of command line parameters passed to the application
@return sal_uInt16 - the number of parameters
@see GetCommandLineParam, GetAppFileName
*/
static sal_uInt16 GetCommandLineParamCount();
/** Gets a particular command line parameter
@param nParam The index of the parameter to return.
@return The command line parameter as an OUString
@see GetCommandLineParamCount, GetAppFileName
*/
static OUString GetCommandLineParam( sal_uInt16 nParam );
/** Get the name of the file used to start the application
@return The filename as an OUString
@see GetCommandLineParamCount, GetCommandLineParam
*/
static OUString GetAppFileName();
///@}
/** @name Error Handling
\em Very rudimentary error handling is done by these
functions.
@{
*/
/** Handles an error code.
@remark This is not actually an exception. It merely takes an
error code, then in most cases aborts. The list of exception
identifiers can be found at include/vcl/apptypes.hxx - each
one starts with EXC_*
@param nError The error code identifier
@returns sal_uInt16 value - if it is 0, then the error wasn't handled.
@see Abort
*/
virtual sal_uInt16 Exception( sal_uInt16 nError );
/** Ends the program prematurely with an error message.
If the \code --norestore \endcode command line argument is given (assuming
this process is run by developers who are interested in cores,
vs. end users who are not) then it does a coredump.
@param rErrorText The error message to report.
@see Exception
*/
static void Abort( const OUString& rErrorText );
///@}
/** @name Event Loop Functions
Functions that handle the LibreOffice main event loop are here,
including a global lock called the Solar Mutex.
*/
///@{
/** Run the main event processing loop until it is quit by Quit().
@see Quit, Reschedule, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
RemovePostYieldListener
*/
static void Execute();
/** Quit the program
@see Execute, Reschedule, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
RemovePostYieldListener
*/
static void Quit();
/** Attempt to reschedule in processing of current event(s)
@param bAllEvents If set to true, then try to process all the
events. If set to false, then only process the current
event. Defaults to false.
@see Execute, Quit, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
RemovePostYieldListener
*/
static void Reschedule( bool bAllEvents = false );
/** Allow processing of the next event.
@see Execute, Quit, Reschedule, EndYield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
RemovePostYieldListener
*/
static void Yield();
/**
@see Execute, Quit, Reschedule, Yield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
RemovePostYieldListener
*/
static void EndYield();
/** @brief Get the Solar Mutex for this thread.
Get the Solar Mutex that prevents other threads from accessing VCL
concurrently.
@returns SolarMutex reference
@see Execute, Quit, Reschedule, Yield, EndYield,
GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
RemovePostYieldListener
*/
static comphelper::SolarMutex& GetSolarMutex();
/** Get the main thread ID.
@returns oslThreadIdentifier that contains the thread ID
@see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
ReleaseSolarMutex, AcquireSolarMutex,
EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
RemovePostYieldListener
*/
static oslThreadIdentifier GetMainThreadIdentifier();
/** @brief Release Solar Mutex(es) for this thread
Release the Solar Mutex(es) that prevents other threads from accessing
VCL concurrently.
@returns The number of mutexes that were acquired by this thread.
@see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, AcquireSolarMutex,
EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
RemovePostYieldListener
*/
static sal_uLong ReleaseSolarMutex();
/** @brief Acquire Solar Mutex(es) for this thread.
Acquire the Solar Mutex(es) that prevents other threads from accessing
VCL concurrently.
@see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex,
EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
RemovePostYieldListener
*/
static void AcquireSolarMutex( sal_uLong nCount );
/** @brief Enables "no yield" mode
"No yield" mode prevents Yield() from waiting for events.
@remarks This was originally implemented in OOo bug 98792 to improve
Impress slideshows.
@see DisableNoYieldMode, Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
DisableNoYield, AddPostYieldListener, RemovePostYieldListener
*/
static void EnableNoYieldMode();
/** @brief Disables "no yield" mode
"No yield" mode prevents Yield() from waiting for events.
@remarks This was originally implemented in OOo bug 98792 to improve
Impress slideshows.
@see EnableNoYieldMode, Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
EnableNoYield, AddPostYieldListener, RemovePostYieldListener
*/
static void DisableNoYieldMode();
/** Add a listener for yield events
@param i_rListener Listener to add
@see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
EnableNoYieldMode, DisableNoYieldMode, RemovePostYieldListener
*/
static void AddPostYieldListener( const Link& i_rListener );
/** Remove listener for yield events
@param i_rListener Listener to remove
@see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
AddPostYieldListener, EnableNoYieldMode, DisableNoYieldMode
*/
static void RemovePostYieldListener( const Link& i_rListener );
/** Queries whether the application is in "main", i.e. not yet in
the event loop
@returns true if in main, false if not in main
@see IsInExecute, IsInModalMode
*/
static bool IsInMain();
/** Queries whether the application is in the event loop
@returns true if in the event loop, false if not
@see IsInMain, IsInModalMode
*/
static bool IsInExecute();
/** Queries whether application has a modal dialog active.
@returns true if a modal dialog is active, false if not
@see IsInMain, IsInExecute
*/
static bool IsInModalMode();
/** Return how many events are being dispatched.
@returns the number of events currently being dispatched
*/
static sal_uInt16 GetDispatchLevel();
/** Determine if there are any pending input events.
@param nType input identifier, defined in include/vcl/apptypes.hxx
The default is VCL_INPUT_ANY.
@returns true if there are pending events, false if not.
@see GetLastInputInterval
*/
static bool AnyInput( sal_uInt16 nType = VCL_INPUT_ANY );
/** The interval from the last time that input was received.
@returns system ticks - last input time
@see AnyInput
*/
static sal_uLong GetLastInputInterval();
///@}
/* Determines if the UI is captured.
The UI is considered captured if a system dialog is open (e.g. printer setup),
a floating window, menu or toolbox dropdown is open, or a window has been
captured by the mouse.
@returns true if UI is captured, false if not
*/
static bool IsUICaptured();
/** @name Settings
The following functions set system settings (e.g. tab color, etc.). There are functions
that set settings objects, and functions that set and get the actual system settings for
the application.
*/
///@{
/** Sets user settings in settings object to override system settings
The system settings that can be overridden are:
- window dragging options (on or off, including live scrolling!)
- style settings (e.g. checkbox color, border color, 3D colors,
button rollover colors, etc.)
- mouse settings
- menu options, including the mouse follows the menu and whether menu
icons are used
@param rSettings Reference to the settings object to change.
@see MergeSystemSettings, SetSettings, GetSettings
*/
virtual void OverrideSystemSettings( AllSettings& rSettings );
/** Set the settings object to the platform/desktop environment system
settings.
@param rSettings Reference to the settings object to change.
@see OverrideSystemSettings, SetSettings, GetSettings
*/
static void MergeSystemSettings( AllSettings& rSettings );
/** Sets the application's settings and notifies all windows of the
change.
@param rSettings const reference to settings object used to
change the application's settings.
@see OverrideSystemSettings, MergeSystemSettings, GetSettings
*/
static void SetSettings( const AllSettings& rSettings );
/** Gets the application's settings. If the application hasn't initialized
it's settings, then it does so (lazy initialization).
@returns AllSettings instance that contains the current settings of the
application.
@see OverrideSystemSettings, MergeSystemSettings, SetSettings
*/
static const AllSettings& GetSettings();
/** Validate that the currently selected system UI font is suitable
to display the application's UI.
A localized test string will be checked if it can be displayed in the currently
selected system UI font. If no glyphs are missing it can be assumed that the font
is proper for display of the application's UI.
@returns true if the system font is suitable for our UI and false if the test
string could not be displayed with the system font.
*/
static bool ValidateSystemFont();
/** Get the application's locale data wrapper.
@returns reference to a LocaleDataWrapper object
*/
static const LocaleDataWrapper& GetAppLocaleDataWrapper();
///@}
/** @name Event Listeners/Handlers
A set of event listeners and callers. Note that in this code there is
platform specific functions - namely for zoom and scroll events.
*/
///@{
/** Call on all event hooks
@param rEvt Reference to the notification event to send
to the event hook.
@return If any of the event hooks called upon fail with a non-zero
status, then it stops processing any more event hooks and returns
the error code as a long.
*/
static long CallEventHooks( NotifyEvent& rEvt );
/** Add a VCL event listener to the application. If no event listener exists,
then initialize the application's event listener with a new one, then add
the event listener.
@param rEventListener Const reference to the event listener to add.
@see RemoveEventListener, AddKeyListener, RemoveKeyListener
*/
static void AddEventListener( const Link& rEventListener );
/** Remove a VCL event listener from the application.
@param rEventListener Const refernece to the event listener to be removed
@see AddEventListener, AddKeyListener, RemoveKeyListener
*/
static void RemoveEventListener( const Link& rEventListener );
/** Add a keypress listener to the application. If keypress listener exists,
then initialize the application's keypress event listener with a new one, then
add the keypress listener.
@param rKeyListener Const reference to the keypress event listener to add
@see AddEventListener, RemoveEventListener, RemoveKeyListener
*/
static void AddKeyListener( const Link& rKeyListener );
/** Remove a keypress listener from the application.
@param rKeyListener Const reference to the keypress event listener to be removed
@see AddEventListener, RemoveEventListener, AddKeyListener
*/
static void RemoveKeyListener( const Link& rKeyListener );
/** Send event to all VCL application event listeners
@param nEvent Event ID
@param pWin Pointer to window to send event
@param pData Pointer to data to send with event
@see ImplCallEventListeners(VclSimpleEvent* pEvent)
*/
static void ImplCallEventListeners( sal_uLong nEvent, Window* pWin, void* pData );
/** Send event to all VCL application event listeners
@param pEvent Pointer to VclSimpleEvent
@see ImplCallEventListeners(sal_uLong nEvent, Windows* pWin, void* pData);
*/
static void ImplCallEventListeners( VclSimpleEvent* pEvent );
/** Handle keypress event
@param nEvent Event ID for keypress
@param pWin Pointer to window that receives the event
@param pKeyEvent Received key event
@see PostKeyEvent
*/
static bool HandleKey( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent );
/** Send keypress event
@param nEvent Event ID for keypress
@param pWin Pointer to window to which the event is sent
@param pKeyEvent Key event to send
@see HandleKey
*/
static sal_uLong PostKeyEvent( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent );
/** Send mouse event
@param nEvent Event ID for mouse event
@param pWin Pointer to window to which the event is sent
@param pKeyEvent Mouse event to send
*/
static sal_uLong PostMouseEvent( sal_uLong nEvent, Window *pWin, MouseEvent* pMouseEvent );
#if !HAVE_FEATURE_DESKTOP
/** Send zoom event
@param nEvent Event ID for zoom event
@param pWin Pointer to window to which the event is sent
@param pZoomEvent Zoom event to send
*/
static sal_uLong PostZoomEvent( sal_uLong nEvent, Window *pWin, ZoomEvent* pZoomEvent );
/* Send scroll event
@param nEvent Event ID for scroll event
@param pWin Pointer to window to which the event is sent
@param pScrollEvent Scroll event to send
*/
static sal_uLong PostScrollEvent( sal_uLong nEvent, Window *pWin, ScrollEvent* pScrollEvent );
#endif
/** Remove mouse and keypress events from a window... any also zoom and scroll events
if the platform supports it.
@param pWin Window to remove events from
@see HandleKey, PostKeyEvent, PostMouseEvent, PostZoomEvent, PostScrollEvent
*/
static void RemoveMouseAndKeyEvents( Window *pWin );
/** Post a user event to the default window.
User events allow for the deferral of work to later in the main-loop - at idle.
@param rLink Link to event callback function
@param pCaller Pointer to data sent to the event by the caller. Optional.
@return the event ID used to post the event.
*/
static sal_uLong PostUserEvent( const Link& rLink, void* pCaller = NULL );
/** Post a user event to the default window.
@param rEventID Reference to event ID to be posted
@param rLink Link to event callback function
@param pCaller Pointer to data sent to teh event by the caller. Optional.
@return true if there is a default window and the event could be posted to it successfully.
*/
static bool PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller = NULL );
/** Remove user event based on event ID
@param nUserEvent Numeric user event to remove
*/
static void RemoveUserEvent( sal_uLong nUserEvent );
/** Insert an idle handler into the application.
If the idle event manager doesn't exist, then initialize it.
@param rLink const reference to the idle handler
@param nPrio The priority of the idle handler - idle handlers of a higher
priority will be processed before this handler.
@return true if the handler was inserted successfully, false if it couldn't be inserted.
*/
static bool InsertIdleHdl( const Link& rLink, sal_uInt16 nPriority );
/** Remove an idle handler from the application.
@param rLink const reference to the idle handler to remove
*/
static void RemoveIdleHdl( const Link& rLink );
/*** Get the DisplayConnection.
It is a reference to XDisplayConnection, which allows toolkits to send display
events to the application.
@returns UNO reference to an object that implements the css:awt:XDisplayConnection
interface.
*/
static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayConnection > GetDisplayConnection();
/** @deprecated AppEvent is used only in the Desktop class now. However, it is
intended to notify the application that an event has occured. It was in oldsv.cxx,
but is still needed by a number of functions.
@param rAppEvent const reference to ApplicationEvent event
*/
virtual void AppEvent( const ApplicationEvent& rAppEvent );
///@}
/** @name Application Window Functions
Functions that deal with the application's windows
*/
///@{
/** Get the main application window.
@remark the main application window (or App window) has a style of WB_APP,
there can only be on WorkWindow with this style, if a dialog or floating
window cannot find a parent, then the parent becomes the app window.
It also becomes the "default window", is used for help, is a fallback if
the application has no name, and a number of other things.
returns Pointer to main application window.
@see GetFocusWindow, GetDefaultDevice
*/
static WorkWindow* GetAppWindow();
/** Get the currently focussed window.
@returns Pointer to focused window.
@see GetAppWindow, GetDefaultDevice
*/
static Window* GetFocusWindow();
/** Get the default "device" (in this case the default window).
@returns Pointer to an OutputDevice. However, it is a Window object -
Window class subclasses OutputDevice.
@see GetAppWindow, GetFocusWindow
*/
static OutputDevice* GetDefaultDevice();
/** Get the first top-level window of the application.
@returns Pointer to top-level window (a Window object)
@see GetNextTopLevelWindow, GetTopWindowCount, GetTopWindow,
GetActiveTopWindow
*/
static Window* GetFirstTopLevelWindow();
/** Get the next top level window.
@param pWindow Pointer to Window object you wish to get the next
window from.
@returns Pointer to next top window.
*/
static Window* GetNextTopLevelWindow( Window* pWindow );
/** Return the number of top-level windows being used by the application
@returns the number of top-level windows
@see GetFirstTopLevelWindow, GetNextTopLevelWindow, GetTopWindow,
GetActiveTopWindow
*/
static long GetTopWindowCount();
/** Get the nth top window.
@remark Top windows are actually implemented in a one-way linked list.
This iterates through top level windows n times.
@param nIndex The index of the top-level window
@returns The nth top-level window of the application
@see GetFirstTopLevelWindow, GetNextTopLevelWindow, GetTopWindowCount,
GetActiveTopWindow
*/
static Window* GetTopWindow( long nIndex );
/** Get the "active" top window.
An "active" top window is one that has a child window that has the
application's focus.
@returns the active top window
@see GetFirstTopLevelWindow, GetNextTopLevelWindow, GetTopWindowCount,
GetTopWindow
*/
static Window* GetActiveTopWindow();
///@}
/** Set the application's name.
@param rUniqueName What to set the application name to
@see GetAppName
*/
static void SetAppName( const OUString& rUniqueName );
/** @name Application Name, Branding
*/
///@{
/** Get the application's name.
@returns The application name.
*/
static OUString GetAppName();
/** Load a localized branding PNG file as a bitmap.
@param pName Name of the bitmap to load.
@param rBitmap Reference to BitmapEx object to load PNG into
@returns true if the PNG could be loaded, otherwise returns false.
*/
static bool LoadBrandBitmap (const char* pName, BitmapEx &rBitmap);
///@}
/** @name Display and Screen
*/
///@{
/** Set the default name of the application for message dialogs and printing.
@param rDisplayName const reference to string to set the Display name to.
@see GetDisplayName
*/
static void SetDisplayName( const OUString& rDisplayName );
/** Get the default name of the application for messag dialogs and printing.
@returns The display name of the application.
*/
static OUString GetDisplayName();
/** Get the number of screens available for the display.
@returns The number of screens available.
@see GetScreenPosSizePixel
*/
static unsigned int GetScreenCount();
/** Get a screen's rectangular area.
@param nScreen The number of the screen requested.
@returns The area of the screen in a Rectangle object.
@see GetScreenCount
*/
static Rectangle GetScreenPosSizePixel( unsigned int nScreen );
/** Determines if the screens that make up a display are seperate or
form one large display area.
@returns true when screens form up one large display area windows can be
moved between single screens (e.g. Xserver with Xinerama, Windows)
and false when different screens are separate and windows cannot be moved
between them (e.g. Xserver with multiple screens)
@see GetBestScreen, GetDisplayBuiltInScreen
*/
static bool IsUnifiedDisplay();
/** Get the "best" screen.
@returns If IsUnifiedDisplay() == true the return value will be
nearest screen of the target rectangle.
In case of IsUnifiedDisplay() == false the return value
will always be GetDisplayDefaultScreen().
@see IsUnifiedDisplay, GetDisplayBuiltInScreen
*/
SAL_DLLPRIVATE static unsigned int GetBestScreen( const Rectangle& );
/** Get the built-in screen.
@return
This returns the LCD screen number for a laptop, or the primary
external VGA display for a desktop machine - it is where a presenter
console should be rendered if there are other (non-built-in) screens
present.
@see IsUnifiedDisplay, GetBestScreen
*/
static unsigned int GetDisplayBuiltInScreen();
/** Get the display's external screen.
Practically, this means - Get the screen we should run a presentation on.
@returns 0 or 1 currently, will fallback to the first available screen if
there are more than one external screens. May be changed in the future.
*/
static unsigned int GetDisplayExternalScreen();
///@}
/** @name Accelerators and Mnemonics
Accelerators allow a user to hold down Ctrl+key (or CMD+key on OS X)
combination to gain quick access to functionality.
Mnemonics are underline letters in things like menus and dialog boxes
that allow a user to type in the letter to activate the menu or option.
*/
///@{
/** Insert accelerator
@param pAccel Pointer to an Accelerator object to insert
@returns true if successful, false if otherwise
@see RemoveAccel
*/
static bool InsertAccel( Accelerator* pAccel );
/** Remove accelerator
@param pAccel Pointer to Accelerator object to remove
@see InsertAccel
*/
static void RemoveAccel( Accelerator* pAccel );
/** Enable auto-mnemonics
@param bEnabled True enables auto-mnemonics, and false disables it
@see IsAutoMnemonicEnabled
*/
static void EnableAutoMnemonic( bool bEnabled = true );
/** Determines if auto-mnemonics are enabled.
@returns True if auto-mnemonics is enabled, false if not.
@see EnableAutoMnemonic
*/
static bool IsAutoMnemonicEnabled();
/** Get the number of reserved key codes used by the application.
@returns number of reserved key codes
@see GetReservedKeyCode
*/
static sal_uLong GetReservedKeyCodeCount();
/** Get the reserved key code.
@param i The keycode number to retrieve
@returns Const pointer to a KeyCode object
@see GetReservedKeyCodeCount
*/
static const KeyCode* GetReservedKeyCode( sal_uLong i );
///@}
/** @name Application Help
Deals with the help system, and "auto-help", where a user hovers a mouse above
a UI element and a tooltip with an explanation pops up.
*/
///@{
/** Sets up help
@param pHelp Pointer to a Help object (optional, can by NULL)
@see GetHelp
*/
static void SetHelp( Help* pHelp = NULL );
/** Gets the application's help
@returns Pointer to application's help object. Note that the application may
not have a help object, so it might return NULL.
@see SetHelp
*/
static Help* GetHelp();
/** Turns on "auto-help" (hover mouse above UI element and a tooltip with an
explanation pops up.
@param bEnabled Enables/disables auto-help.
@see EnableAutoHelpId
*/
static void EnableAutoHelpId( bool bEnabled = true );
/** Determines if auto-help is enabled or disabled.
@return true if auto-help is enabled, false if it is disabled.
@see EnableAutoHelpId
*/
static bool IsAutoHelpIdEnabled();
///@}
/** @name Dialogs
@remark "Dialog cancel mode" tells a headless install whether to
cancel dialogs when they appear. See the DialogCancelMode
enumerator.
*/
///@{
/** Set the default parent window for dialog boxes.
@param pWindow Pointer to window that should be the default parent.
@remark You can set pWindow to NULL, which means there \em is no default parent.
@see GetDefDialogParent
*/
static void SetDefDialogParent( Window* pWindow );
/** Get the default parent window for dialog boxes.
@remark GetDefDialogParent does all sorts of things find a useful parent
window for dialogs. If it can't find one (it wasn't set!) then it
first uses the topmost parent of the active window to avoid using
floating windows or other dialog boxes. If there are no active
windows, then it will take a random stab and choose the first visible
top window. Otherwise, it defaults to the desktop.
@returns Pointer to the default window.
*/
static Window* GetDefDialogParent();
/** Gets the dialog cancel mode for headless environments.
@return DialogCancelMode value
@see SetDialogCancelMode, IsDialogCancelEnabled
*/
static DialogCancelMode GetDialogCancelMode();
/** Sets the dialog cancel mode for headless environments.
@param mode DialogCancel mode value
@see GetDialogCancelMode, IsDialogCancelEnabled
*/
static void SetDialogCancelMode( DialogCancelMode mode );
/** Determines if dialog cancel mode is enabled.
@returns True if dialog cancel mode is enabled, false if disabled.
@see GetDialogCancelMode, SetDialogCancelMode
*/
static bool IsDialogCancelEnabled();
/** Make a dialog box a system window or not.
@param nMode Can be either: SYSTEMWINDOW_MODE_NOAUTOMODE (0x0001) or
SYSTEMWINDOW_MODE_DIALOG (0x0002)
@see GetSystemWindowMode
*/
static void SetSystemWindowMode( sal_uInt16 nMode );
/** Get the system window mode of dialogs.
@returns SYSTEMWINDOW_MODE_NOAUTOMODE (0x0001) or SYSTEMWINDOW_MODE_DIALOG (0x0002)
@see SetSystemWindowMode
*/
static sal_uInt16 GetSystemWindowMode();
/** Set a dialog scaling factor. Used for localization.
@param nScale Scaling factor
*/
static void SetDialogScaleX( short nScale );
///@}
/** @name VCL Toolkit and UNO Wrapper
The VCL Toolkit implements the UNO XToolkit interface, which specifies a
factory interface for the window toolkit. It is similar to the abstract window
toolkit (AWT) in Java.
*/
///@{
/** Gets the VCL toolkit.
@attention The global service manager has to be created before getting the toolkit!
@returns UNO reference to VCL toolkit
*/
static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > GetVCLToolkit();
/** Get the application's UNO wrapper object.
Note that this static function will only ever try to create UNO wrapper object once, and
if it fails then it will not ever try again, even if the function is called multiple times.
@param bCreateIfNotExists Create the UNO wrapper object if it doesn't exist when true.
@return UNO wrapper object.
*/
static UnoWrapperBase* GetUnoWrapper( bool bCreateIfNotExists = true );
/** Sets the application's UNO Wrapper object.
@param pWrapper Pointer to UNO wrapper object.
*/
static void SetUnoWrapper( UnoWrapperBase* pWrapper );
///@}
/*** @name Graphic Filters
*/
///@{
/** Setup a new graphics filter
@param rLink Const reference to a Link object, which the filter calls upon.
@see GetFilterHdl
*/
static void SetFilterHdl( const Link& rLink );
/*** Get a new graphics filter
@return Const reference to the Link object (the filter)
*/
static const Link& GetFilterHdl();
///@}
/** @name Headless Mode
*/
/** Enables headless mode.
@param dialogsAreFatal Set to true if a dialog ends the session, false if not.
@see IsHeadlessModeEnabled, IsHeadlessModeRequested
*/
static void EnableHeadlessMode( bool dialogsAreFatal );
/** Determines if headless mode is enabled
@return True if headless mode is enabled, false if not.
@see EnableHeadlessMode, IsHeadlessModeRequested
*/
static bool IsHeadlessModeEnabled();
/** Check command line arguments for \code --headless \endcode
@return True if headless mode was requested, false if not
@see EnableHeadlessMode, IsHeadlessModeEnabled
*/
static bool IsHeadlessModeRequested();
/** Enable Console Only mode
Used to disable Mac specific app init that requires an app bundle.
*/
static void EnableConsoleOnly();
/** Determines if console only mode is enabled.
Used to see if Mac specific app init has been disabled.
@returns True if console only mode is on, false if not.
@see EnableConsoleOnly
*/
static bool IsConsoleOnly();
///@}
/** @name IME Status Window Control
*/
///@{
/** Determine application can toggle the IME status window on and off.
@attention Must only be called with the Solar mutex locked.
@return true if any IME status window can be toggled on and off
externally.
@see ShowImeStatusWindow, GetShowImeStatusWindowDefault,
GetShowImeStatusWindowDefault
*/
static bool CanToggleImeStatusWindow();
/** Toggle any IME status window on and off.
This only works if CanToggleImeStatusWindow returns true (otherwise,
any calls of this method are ignored).
@remark Can be called without the Solar mutex locked.
@param bShow If true, then show the IME status window
@see GetShowImeStatusWindowDefault, CanToggleImeStatusWindow,
GetShowImeStatusWindow
*/
static void ShowImeStatusWindow(bool bShow);
/** Determines if the IME status window should be turned of by default.
@return true if any IME status window should be turned on by default
(this decision can be locale dependent, for example).
@see ShowImeStatusWindow, GetShowImeStatusWindowDefault,
CanToggleImeStatusWindow
*/
static bool GetShowImeStatusWindowDefault();
///@}
/** Get the desktop environment the process is currently running in
@returns String representing the desktop environment
*/
static const OUString& GetDesktopEnvironment();
/*** @name Platform Functionality
*/
///@{
/** Add a file to the system shells recent document list if there is any.
This function may have no effect under Unix because there is no standard
API among the different desktop managers.
@param rFileUrl The file url of the document.
@param rMimeType The mime content type of the document specified by aFileUrl.
If an empty string will be provided "application/octet-stream"
will be used.
*/
static void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService);
/*** Show a native error messagebox
@param sTitle Title of error messagebox
@param sMessage Message displayed in messagebox
*/
static void ShowNativeErrorBox(const OUString& sTitle ,
const OUString& sMessage);
/** Do we have a native / system file selector available?
@returns True if native file selector is available, false otherwise.
*/
static bool hasNativeFileSelection();
/** Create a platform specific file picker, if one is available, otherwise return an
empty reference.
@param rServiceManager Const reference to a UNO component context (service manager).
@returns File picker if available, otherwise an empty reference.
*/
static css::uno::Reference< css::ui::dialogs::XFilePicker2 >
createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& rServiceManager );
/** Create a platform specific folder picker, if one is available, otherwise return an
empty reference
@param rServiceManager Const reference to a UNO component context (service manager).
@returns Folder picker if available, otherwise an empty reference.
*/
static css::uno::Reference< css::ui::dialogs::XFolderPicker2 >
createFolderPicker( const css::uno::Reference< css::uno::XComponentContext >& rServiceManager );
/** Is the access interface enabled?
@returns true
*/
static bool IsEnableAccessInterface() { return true; }
///@}
private:
static void InitSettings();
DECL_STATIC_LINK( Application, PostEventHandler, void* );
};
class VCL_DLLPUBLIC SolarMutexGuard
{
private:
SolarMutexGuard( const SolarMutexGuard& );
const SolarMutexGuard& operator = ( const SolarMutexGuard& );
comphelper::SolarMutex& m_solarMutex;
public:
/** Acquires the object specified as parameter.
*/
SolarMutexGuard() :
m_solarMutex(Application::GetSolarMutex())
{
m_solarMutex.acquire();
}
/** Releases the mutex or interface. */
~SolarMutexGuard()
{
m_solarMutex.release();
}
};
class VCL_DLLPUBLIC SolarMutexClearableGuard
{
SolarMutexClearableGuard( const SolarMutexClearableGuard& );
const SolarMutexClearableGuard& operator = ( const SolarMutexClearableGuard& );
bool m_bCleared;
public:
/** Acquires mutex
*/
SolarMutexClearableGuard()
: m_bCleared(false)
, m_solarMutex( Application::GetSolarMutex() )
{
m_solarMutex.acquire();
}
/** Releases mutex. */
virtual ~SolarMutexClearableGuard()
{
if( !m_bCleared )
{
m_solarMutex.release();
}
}
/** Releases mutex. */
void SAL_CALL clear()
{
if( !m_bCleared )
{
m_solarMutex.release();
m_bCleared = true;
}
}
protected:
comphelper::SolarMutex& m_solarMutex;
};
class VCL_DLLPUBLIC SolarMutexResettableGuard
{
SolarMutexResettableGuard( const SolarMutexResettableGuard& );
const SolarMutexResettableGuard& operator = ( const SolarMutexResettableGuard& );
bool m_bCleared;
public:
/** Acquires mutex
*/
SolarMutexResettableGuard()
: m_bCleared(false)
, m_solarMutex( Application::GetSolarMutex() )
{
m_solarMutex.acquire();
}
/** Releases mutex. */
virtual ~SolarMutexResettableGuard()
{
if( !m_bCleared )
{
m_solarMutex.release();
}
}
/** Releases mutex. */
void SAL_CALL clear()
{
if( !m_bCleared)
{
m_solarMutex.release();
m_bCleared = true;
}
}
/** Releases mutex. */
void SAL_CALL reset()
{
if( m_bCleared)
{
m_solarMutex.acquire();
m_bCleared = false;
}
}
protected:
comphelper::SolarMutex& m_solarMutex;
};
/**
A helper class that calls Application::ReleaseSolarMutex() in its constructor
and restores the mutex in its destructor.
*/
class SolarMutexReleaser
{
sal_uLong mnReleased;
public:
SolarMutexReleaser(): mnReleased(Application::ReleaseSolarMutex()) {}
~SolarMutexReleaser()
{
Application::AcquireSolarMutex( mnReleased );
}
};
VCL_DLLPUBLIC Application* GetpApp();
VCL_DLLPUBLIC bool InitVCL();
VCL_DLLPUBLIC void DeInitVCL();
VCL_DLLPUBLIC bool InitAccessBridge();
// only allowed to call, if no thread is running. You must call JoinMainLoopThread to free all memory.
VCL_DLLPUBLIC void CreateMainLoopThread( oslWorkerFunction pWorker, void * pThreadData );
VCL_DLLPUBLIC void JoinMainLoopThread();
inline void Application::EndYield()
{
PostUserEvent( Link() );
}
#endif // _APP_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|