1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
|
/*************************************************************************
*
* $RCSfile: app.cxx,v $
*
* $Revision: 1.53 $
*
* last change: $Author: cd $ $Date: 2001-10-09 12:11:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <unistd.h>
#include "app.hxx"
#include "desktop.hrc"
#include "appinit.hxx"
#include "intro.hxx"
#include "officeipcthread.hxx"
#include "cmdlineargs.hxx"
#include "officeacceptthread.hxx"
#include "pluginacceptthread.hxx"
#include "appsys.hxx"
#include "desktopresid.hxx"
#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_
#include <com/sun/star/frame/XStorable.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
#include <com/sun/star/util/XModifiable.hpp>
#endif
#ifndef _COM_SUN_STAR_SYSTEM_XSYSTEMSHELLEXECUTE_HPP_
#include <com/sun/star/system/XSystemShellExecute.hpp>
#endif
#ifndef _COM_SUN_STAR_SYSTEM_SYSTEMSHELLEXECUTEFLAGS_HPP_
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
#include <com/sun/star/lang/XComponent.hpp>
#endif
#ifndef _COM_SUN_STAR_BRIDGE_XCONNECTIONBROKER_HPP_
#include <com/sun/star/bridge/XConnectionBroker.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_
#include <com/sun/star/frame/XDesktop.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XTYPEDETECTION_HPP_
#include <com/sun/star/document/XTypeDetection.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
#include <com/sun/star/frame/XComponentLoader.hpp>
#endif
#ifndef _COM_SUN_STAR_VIEW_XPRINTABLE_HPP_
#include <com/sun/star/view/XPrintable.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
#include <com/sun/star/lang/XInitialization.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XTASKSSUPPLIER_HPP_
#include <com/sun/star/frame/XTasksSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_XTOPWINDOW_HPP_
#include <com/sun/star/awt/XTopWindow.hpp>
#endif
#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_
#include <com/sun/star/util/XURLTransformer.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
#include <com/sun/star/util/URL.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_
#include <com/sun/star/frame/XDispatch.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
#include <com/sun/star/frame/XDispatchProvider.hpp>
#endif
#ifndef _COM_SUN_STAR_CONFIGURATION_MISSINGBOOTSTRAPFILEEXCEPTION_HPP_
#include <com/sun/star/configuration/MissingBootstrapFileException.hpp>
#endif
#ifndef _COM_SUN_STAR_CONFIGURATION_INVALIDBOOTSTRAPFILEEXCEPTION_HPP_
#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
#endif
#ifndef _COM_SUN_STAR_CONFIGURATION_INSTALLATIONINCOMPLETEEXCEPTION_HPP_
#include <com/sun/star/configuration/InstallationIncompleteException.hpp>
#endif
#ifndef _SOLAR_H
#include <tools/solar.h>
#endif
#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
#include <toolkit/unohlp.hxx>
#endif
#ifndef _VOS_SECURITY_HXX_
#include <vos/security.hxx>
#endif
#ifndef _VOS_TIMER_HXX_
#include <vos/timer.hxx>
#endif
#ifndef _VOS_REF_HXX_
#include <vos/ref.hxx>
#endif
#ifndef _VOS_PROCESS_HXX_
#include <vos/process.hxx>
#endif
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
#ifndef _UTL_CONFIGMGR_HXX_
#include <unotools/configmgr.hxx>
#endif
#ifndef _UTL_CONFIGITEM_HXX_
#include <unotools/configitem.hxx>
#endif
#ifndef _UNOTOOLS_CONFIGNODE_HXX_
#include <unotools/confignode.hxx>
#endif
#ifndef _UNOTOOLS_UCBHELPER_HXX
#include <unotools/ucbhelper.hxx>
#endif
#ifndef _TOOLS_TEMPFILE_HXX
#include <tools/tempfile.hxx>
#endif
#ifndef _URLOBJ_HXX
#include <tools/urlobj.hxx>
#endif
#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
#include <svtools/moduleoptions.hxx>
#endif
#ifndef _OSL_MODULE_H_
#include <osl/module.h>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
#ifndef _OSL_PROCESS_H_
#include <osl/process.h>
#endif
#ifndef AUTOMATION_HXX
#include <automation/automation.hxx>
#endif
#ifndef _Installer_hxx
#include <setup2/installer.hxx>
#endif
#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
#include <svtools/pathoptions.hxx>
#endif
#ifndef _SVTOOLS_CJKOPTIONS_HXX
#include <svtools/cjkoptions.hxx>
#endif
#ifndef INCLUDED_SVTOOLS_INTERNALOPTIONS_HXX
#include <svtools/internaloptions.hxx>
#endif
#ifndef _UNOTOOLS_TEMPFILE_HXX
#include <unotools/tempfile.hxx>
#endif
#ifndef _RTL_LOGFILE_HXX_
#include <rtl/logfile.hxx>
#endif
#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#endif
#ifndef _RTL_STRBUF_HXX_
#include <rtl/strbuf.hxx>
#endif
#ifndef _UTL_CONFIGMGR_HXX_
#include <unotools/configmgr.hxx>
#endif
#ifndef _SV_MSGBOX_HXX
#include <vcl/msgbox.hxx>
#endif
#ifndef _SV_BITMAP_HXX
#include <vcl/bitmap.hxx>
#endif
#ifndef _VCL_STDTEXT_HXX
#include <vcl/stdtext.hxx>
#endif
#ifndef _SV_MSGBOX_HXX
#include <vcl/msgbox.hxx>
#endif
#ifndef _SFX_HRC
#include <sfx2/sfx.hrc>
#endif
#ifndef _UCBHELPER_CONTENTBROKER_HXX
#include <ucbhelper/contentbroker.hxx>
#endif
#ifndef _UTL_BOOTSTRAP_HXX
#include <unotools/bootstrap.hxx>
#endif
#define DEFINE_CONST_UNICODE(CONSTASCII) UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII##))
#define U2S(STRING) ::rtl::OUStringToOString(STRING, RTL_TEXTENCODING_UTF8)
using namespace vos;
using namespace rtl;
using namespace desktop;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::bridge;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::document;
using namespace ::com::sun::star::view;
using namespace ::com::sun::star::system;
using namespace ::com::sun::star::ui::dialogs;
static SalMainPipeExchangeSignalHandler* pSignalHandler = 0;
OOfficeAcceptorThread* pOfficeAcceptThread = 0;
ResMgr* Desktop::pResMgr = 0;
static PluginAcceptThread* pPluginAcceptThread = 0;
static oslModule aTestToolModule = 0;
// ----------------------------------------------------------------------------
char const INSTALLER_INITFILENAME[] = "initialize.ini";
// ----------------------------------------------------------------------------
void InitTestToolLib()
{
#ifndef BUILD_SOSL
RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::InitTestToolLib" );
OUString aFuncName( RTL_CONSTASCII_USTRINGPARAM( "CreateRemoteControl" ));
OUString aModulePath;
::vos::OStartupInfo().getExecutableFile( aModulePath );
sal_uInt32 lastIndex = aModulePath.lastIndexOf('/');
if ( lastIndex > 0 )
aModulePath = aModulePath.copy( 0, lastIndex+1 );
aModulePath += OUString::createFromAscii( SVLIBRARY( "sts" ) );
// Shortcut for Performance: We expect that the test tool library is not installed
// (only for testing purpose). It should be located beside our executable.
// We don't want to pay for searching through LD_LIBRARY_PATH so we check for
// existence only in our executable path!!
osl::DirectoryItem aItem;
osl::FileBase::RC nResult = osl::DirectoryItem::get( aModulePath, aItem );
if ( nResult == osl::FileBase::E_None )
{
aTestToolModule = osl_loadModule( aModulePath.pData, SAL_LOADMODULE_DEFAULT );
if ( aTestToolModule )
{
void* pInitFunc = osl_getSymbol( aTestToolModule, aFuncName.pData );
if ( pInitFunc )
(*(pfunc_CreateRemoteControl)pInitFunc)();
}
}
#endif
}
void DeInitTestToolLib()
{
#ifndef BUILD_SOSL
if ( aTestToolModule )
{
OUString aFuncName( RTL_CONSTASCII_USTRINGPARAM( "DestroyRemoteControl" ));
void* pDeInitFunc = osl_getSymbol( aTestToolModule, aFuncName.pData );
if ( pDeInitFunc )
(*(pfunc_DestroyRemoteControl)pDeInitFunc)();
osl_unloadModule( aTestToolModule );
}
#endif
}
ResMgr* Desktop::GetDesktopResManager()
{
if ( !Desktop::pResMgr )
{
LanguageType aLanguageType;
String aMgrName = String::CreateFromAscii( "dkt" );
aMgrName += String::CreateFromInt32(SOLARUPD);
return ResMgr::SearchCreateResMgr( U2S( aMgrName ), aLanguageType );
}
return Desktop::pResMgr;
}
// ----------------------------------------------------------------------------
// Get a message string securely. There is a fault back string if the resource
// is not available.
OUString Desktop::GetMsgString( USHORT nId, const OUString& aFaultBackMsg )
{
ResMgr* pResMgr = GetDesktopResManager();
if ( !pResMgr )
return aFaultBackMsg;
else
return OUString( ResId( nId, pResMgr ));
}
CommandLineArgs* GetCommandLineArgs()
{
static CommandLineArgs* pArgs = 0;
if ( !pArgs )
{
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
if ( !pArgs )
pArgs = new CommandLineArgs( ::vos::OExtCommandLine() );
}
return pArgs;
}
BOOL InitializeInstallation( const UniString& rAppFilename )
{
UniString aAppPath( rAppFilename );
rtl::OUString aFinishInstallation;
osl::FileBase::getFileURLFromSystemPath( aAppPath, aFinishInstallation );
aAppPath = UniString( aFinishInstallation );
xub_StrLen nPos = aAppPath.SearchBackward( '/' );
aAppPath.Erase( nPos );
aAppPath += '/';
aAppPath += DEFINE_CONST_UNICODE( INSTALLER_INITFILENAME );
osl::DirectoryItem aDI;
if( osl::DirectoryItem::get( aAppPath, aDI ) == osl_File_E_None )
{
// Load initialization code only on demand. This is done if the the 'initialize.ini'
// is written next to the executable. After initialization this file is removed.
// The implementation disposes the old service manager and creates an new one so we
// cannot use a service for InitializeInstallation!!
OUString aFuncName( RTL_CONSTASCII_USTRINGPARAM( INSTALLER_INITIALIZEINSTALLATION_CFUNCNAME ));
OUString aModulePath = OUString::createFromAscii( SVLIBRARY( "set" ) );
oslModule aSetupModule = osl_loadModule( aModulePath.pData, SAL_LOADMODULE_DEFAULT );
if ( aSetupModule )
{
void* pInitFunc = osl_getSymbol( aSetupModule, aFuncName.pData );
if ( pInitFunc )
(*(pfunc_InstallerInitializeInstallation)pInitFunc)( rAppFilename.GetBuffer() );
osl_unloadModule( aSetupModule );
}
return TRUE;
}
return FALSE;
}
Desktop aDesktop;
void PreloadConfigTrees()
{
RTL_LOGFILE_CONTEXT( aLog, "desktop (dg93727) ::PreloadConfigTrees" );
// these tree are preloaded to get a faster startup for the office
Sequence <rtl::OUString> aPreloadPathList(6);
aPreloadPathList[0] = rtl::OUString::createFromAscii("org.openoffice.Office.Common");
aPreloadPathList[1] = rtl::OUString::createFromAscii("org.openoffice.ucb.Configuration");
aPreloadPathList[2] = rtl::OUString::createFromAscii("org.openoffice.Office.Writer");
aPreloadPathList[3] = rtl::OUString::createFromAscii("org.openoffice.Office.WriterWeb");
aPreloadPathList[4] = rtl::OUString::createFromAscii("org.openoffice.Office.Calc");
aPreloadPathList[5] = rtl::OUString::createFromAscii("org.openoffice.Office.Impress");
Reference< XMultiServiceFactory > xProvider(
::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), UNO_QUERY);
if ( xProvider.is() )
{
Any aValue;
aValue <<= aPreloadPathList;
Reference < com::sun::star::beans::XPropertySet > (xProvider, UNO_QUERY)->setPropertyValue(rtl::OUString::createFromAscii("PrefetchNodes"), aValue );
}
else
{
aDesktop.HandleBootstrapErrors( Desktop::BE_UNO_SERVICE_CONFIG_MISSING );
}
}
void ReplaceStringHookProc( UniString& rStr )
{
static String aBrandName;
static String aVersion;
static String aExtension;
static int nAll = 0, nPro = 0;
if ( !aBrandName.Len() )
{
Any aRet = ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME );
rtl::OUString aTmp;
aRet >>= aTmp;
aBrandName = aTmp;
aRet = ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTVERSION );
aRet >>= aTmp;
aVersion = aTmp;
aRet = ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTEXTENSION );
aRet >>= aTmp;
aExtension = aTmp;
}
nAll++;
if ( rStr.SearchAscii( "%PRODUCT" ) != STRING_NOTFOUND )
{
nPro++;
rStr.SearchAndReplaceAllAscii( "%PRODUCTNAME", aBrandName );
rStr.SearchAndReplaceAllAscii( "%PRODUCTVERSION", aVersion );
rStr.SearchAndReplaceAllAscii( "%PRODUCTEXTENSION", aExtension );
}
}
/*
BOOL SVMain()
{
BOOL bInit = InitVCL( Reference < XMultiServiceFactory >() );
if( bInit )
{
GetpApp()->Main();
}
DeInitVCL();
return bInit;
}
*/
Desktop::Desktop() : m_pIntro( 0 ), m_aBootstrapError( BE_OK )
{
RTL_LOGFILE_TRACE( "desktop (cd100003) ::Desktop::Desktop" );
}
void Desktop::Init()
{
RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Init" );
Reference < XMultiServiceFactory > rSMgr = createApplicationServiceManager();
if( ! rSMgr.is() )
{
SetBootstrapError( BE_UNO_SERVICEMANAGER );
}
::comphelper::setProcessServiceFactory( rSMgr );
if ( !Application::IsRemoteServer() )
{
// start ipc thread only for non-remote offices
RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::OfficeIPCThread::EnableOfficeIPCThread" );
OfficeIPCThread::Status aStatus = OfficeIPCThread::EnableOfficeIPCThread();
if ( aStatus == OfficeIPCThread::IPC_STATUS_BOOTSTRAP_ERROR )
{
SetBootstrapError( BE_PATHINFO_MISSING );
}
else if ( aStatus == OfficeIPCThread::IPC_STATUS_2ND_OFFICE )
{
// 2nd office startup should terminate after sending cmdlineargs through pipe
_exit( 0 );
}
pSignalHandler = new SalMainPipeExchangeSignalHandler;
}
}
void Desktop::DeInit()
{
destroyApplicationServiceManager( ::comphelper::getProcessServiceFactory() );
if( !Application::IsRemoteServer() )
{
OfficeIPCThread::DisableOfficeIPCThread();
if( pSignalHandler )
DELETEZ( pSignalHandler );
}
}
BOOL Desktop::QueryExit()
{
return TRUE;
}
void Desktop::StartSetup( const OUString& aParameters )
{
OUString aProgName;
OUString aSysPathFileName;
OUString aDir;
::vos::OStartupInfo aInfo;
aInfo.getExecutableFile( aProgName );
sal_uInt32 lastIndex = aProgName.lastIndexOf('/');
if ( lastIndex > 0 )
{
aProgName = aProgName.copy( 0, lastIndex+1 );
aDir = aProgName;
aProgName += OUString( RTL_CONSTASCII_USTRINGPARAM( "setup" ));
#ifdef WNT
aProgName += OUString( RTL_CONSTASCII_USTRINGPARAM( ".exe" ));
#endif
}
OUString aArgListArray[1];
::vos::OSecurity aSecurity;
::vos::OEnvironment aEnv;
::vos::OArgumentList aArgList;
aArgListArray[0] = aParameters;
OArgumentList aArgumentList( aArgListArray, 1 );
::vos::OProcess aProcess( aProgName, aDir );
::vos::OProcess::TProcessError aProcessError =
aProcess.execute( OProcess::TOption_Detached,
aSecurity,
aArgumentList,
aEnv );
if ( aProcessError != OProcess::E_None )
{
OUString aMessage( GetMsgString(
STR_SETUP_ERR_CANNOT_START,
OUString( RTL_CONSTASCII_USTRINGPARAM( "Couldn't start setup application! Please start it manually." )) ));
ErrorBox aBootstrapFailedBox( NULL, WB_OK, aMessage );
aBootstrapFailedBox.Execute();
}
}
void Desktop::HandleBootstrapPathErrors( ::utl::Bootstrap::Status aBootstrapStatus, const OUString& aDiagnosticMessage )
{
if ( aBootstrapStatus != ::utl::Bootstrap::DATA_OK )
{
sal_Bool bWorkstationInstallation = sal_False;
::rtl::OUString aBaseInstallURL;
::rtl::OUString aUserInstallURL;
::rtl::OUString aProductKey;
::rtl::OUString aTemp;
::vos::OStartupInfo aInfo;
aInfo.getExecutableFile( aProductKey );
sal_uInt32 lastIndex = aProductKey.lastIndexOf('/');
if ( lastIndex > 0 )
aProductKey = aProductKey.copy( lastIndex+1 );
aTemp = ::utl::Bootstrap::getProductKey( aProductKey );
if ( aTemp.getLength() > 0 )
aProductKey = aTemp;
::utl::Bootstrap::PathStatus aBaseInstallStatus = ::utl::Bootstrap::locateBaseInstallation( aBaseInstallURL );
::utl::Bootstrap::PathStatus aUserInstallStatus = ::utl::Bootstrap::locateUserInstallation( aUserInstallURL );
if (( aBaseInstallStatus == ::utl::Bootstrap::PATH_EXISTS &&
aUserInstallStatus == ::utl::Bootstrap::PATH_EXISTS ))
{
if ( aBaseInstallURL != aUserInstallURL )
bWorkstationInstallation = sal_True;
}
if ( Application::IsRemoteServer() )
{
OString aTmpStr = OUStringToOString( aDiagnosticMessage, RTL_TEXTENCODING_ASCII_US );
fprintf( stderr, aTmpStr.getStr() );
}
else
{
OUString aMessage;
OUStringBuffer aBuffer( 100 );
aBuffer.append( aDiagnosticMessage );
aBuffer.appendAscii( "\n" );
if (( aBootstrapStatus == ::utl::Bootstrap::MISSING_USER_INSTALL ) || bWorkstationInstallation )
{
OUString aAskSetupStr( GetMsgString(
STR_ASK_START_SETUP,
OUString( RTL_CONSTASCII_USTRINGPARAM( "Start setup application to check installation?" )) ));
aBuffer.append( aAskSetupStr );
aMessage = aBuffer.makeStringAndClear();
ErrorBox aBootstrapFailedBox( NULL, WB_YES_NO, aMessage );
aBootstrapFailedBox.SetText( aProductKey );
int nResult = aBootstrapFailedBox.Execute();
if ( nResult == RET_YES )
{
OUString aParameters;
StartSetup( aParameters );
}
}
else if (( aBootstrapStatus == utl::Bootstrap::INVALID_USER_INSTALL ) ||
( aBootstrapStatus == utl::Bootstrap::INVALID_BASE_INSTALL ) )
{
OUString aAskSetupRepairStr( GetMsgString(
STR_ASK_START_SETUP_REPAIR,
OUString( RTL_CONSTASCII_USTRINGPARAM( "Start setup application to repair installation?" )) ));
aBuffer.append( aAskSetupRepairStr );
aMessage = aBuffer.makeStringAndClear();
ErrorBox aBootstrapFailedBox( NULL, WB_YES_NO, aMessage );
aBootstrapFailedBox.SetText( aProductKey );
int nResult = aBootstrapFailedBox.Execute();
if ( nResult == RET_YES )
{
OUString aParameters( RTL_CONSTASCII_USTRINGPARAM( "-repair" ));
StartSetup( aParameters );
}
}
}
_exit( 333 );
}
}
// Create a error message depending on bootstrap failure code and an optional file url
::rtl::OUString Desktop::CreateErrorMsgString(
utl::Bootstrap::FailureCode nFailureCode,
const ::rtl::OUString& aFileURL )
{
OUStringBuffer aDiagnosticMessage( 100 );
OUString aMsg;
OUString aFilePath;
sal_Bool bFileInfo = sal_True;
// First sentence. We cannot bootstrap office further!
aDiagnosticMessage.append( GetMsgString( STR_BOOTSTRAP_ERR_CANNOT_START,
OUString( RTL_CONSTASCII_USTRINGPARAM( "The program cannot be started." )) ));
aDiagnosticMessage.appendAscii( "\n" );
switch ( nFailureCode )
{
/// the shared installation directory could not be located
case ::utl::Bootstrap::MISSING_INSTALL_DIRECTORY:
{
aMsg = GetMsgString( STR_BOOTSTRAP_ERR_PATH_INVALID,
OUString( RTL_CONSTASCII_USTRINGPARAM( "The installation path is not available." )) );
bFileInfo = sal_False;
}
break;
/// the bootstrap INI file could not be found or read
case ::utl::Bootstrap::MISSING_BOOTSTRAP_FILE:
{
aMsg = GetMsgString( STR_BOOTSTRAP_ERR_FILE_MISSING,
OUString( RTL_CONSTASCII_USTRINGPARAM( "The configuration file \"$1\" is missing." )) );
}
break;
/// the bootstrap INI is missing a required entry
/// the bootstrap INI contains invalid data
case ::utl::Bootstrap::MISSING_BOOTSTRAP_FILE_ENTRY:
case ::utl::Bootstrap::INVALID_BOOTSTRAP_FILE_ENTRY:
{
aMsg = GetMsgString( STR_BOOTSTRAP_ERR_FILE_CORRUPT,
OUString( RTL_CONSTASCII_USTRINGPARAM( "The configuration file \"$1\" is corrupt." )) );
}
break;
/// the version locator INI file could not be found or read
case ::utl::Bootstrap::MISSING_VERSION_FILE:
{
aMsg = GetMsgString( STR_BOOTSTRAP_ERR_FILE_MISSING,
OUString( RTL_CONSTASCII_USTRINGPARAM( "The configuration file \"$1\" is missing." )) );
}
break;
/// the version locator INI has no entry for this version
case ::utl::Bootstrap::MISSING_VERSION_FILE_ENTRY:
{
aMsg = GetMsgString( STR_BOOTSTRAP_ERR_NO_SUPPORT,
OUString( RTL_CONSTASCII_USTRINGPARAM( "The main configuration file \"$1\" does not support the current version." )) );
}
break;
/// the user installation directory does not exist
case ::utl::Bootstrap::MISSING_USER_DIRECTORY:
{
aMsg = GetMsgString( STR_BOOTSTRAP_ERR_DIR_MISSING,
OUString( RTL_CONSTASCII_USTRINGPARAM( "The configuration directory \"$1\" is missing." )) );
}
break;
/// some bootstrap data was invalid in unexpected ways
case ::utl::Bootstrap::INVALID_BOOTSTRAP_DATA:
{
aMsg = GetMsgString( STR_BOOTSTRAP_ERR_INTERNAL,
OUString( RTL_CONSTASCII_USTRINGPARAM( "An internal failure occurred." )) );
bFileInfo = sal_False;
}
break;
}
if ( bFileInfo )
{
String aMsgString( aMsg );
osl::File::getSystemPathFromFileURL( aFileURL, aFilePath );
aMsgString.SearchAndReplaceAscii( "$1", aFilePath );
aMsg = aMsgString;
}
aDiagnosticMessage.append( aMsg );
return aDiagnosticMessage.makeStringAndClear();
}
void Desktop::HandleBootstrapErrors( BootstrapError aBootstrapError )
{
if ( aBootstrapError == BE_PATHINFO_MISSING )
{
OUString aErrorMsg;
OUString aBuffer;
utl::Bootstrap::Status aBootstrapStatus;
utl::Bootstrap::FailureCode nFailureCode;
aBootstrapStatus = ::utl::Bootstrap::checkBootstrapStatus( aBuffer, nFailureCode );
if ( aBootstrapStatus != ::utl::Bootstrap::DATA_OK )
{
switch ( nFailureCode )
{
case ::utl::Bootstrap::MISSING_INSTALL_DIRECTORY:
case ::utl::Bootstrap::INVALID_BOOTSTRAP_DATA:
{
aErrorMsg = CreateErrorMsgString( nFailureCode, OUString() );
}
break;
/// the bootstrap INI file could not be found or read
/// the bootstrap INI is missing a required entry
/// the bootstrap INI contains invalid data
case ::utl::Bootstrap::MISSING_BOOTSTRAP_FILE_ENTRY:
case ::utl::Bootstrap::INVALID_BOOTSTRAP_FILE_ENTRY:
case ::utl::Bootstrap::MISSING_BOOTSTRAP_FILE:
{
OUString aBootstrapFileURL;
utl::Bootstrap::locateBootstrapFile( aBootstrapFileURL );
aErrorMsg = CreateErrorMsgString( nFailureCode, aBootstrapFileURL );
}
break;
/// the version locator INI file could not be found or read
/// the version locator INI has no entry for this version
/// the version locator INI entry is not a valid directory URL
case ::utl::Bootstrap::INVALID_VERSION_FILE_ENTRY:
case ::utl::Bootstrap::MISSING_VERSION_FILE_ENTRY:
case ::utl::Bootstrap::MISSING_VERSION_FILE:
{
OUString aVersionFileURL;
utl::Bootstrap::locateVersionFile( aVersionFileURL );
aErrorMsg = CreateErrorMsgString( nFailureCode, aVersionFileURL );
}
break;
/// the user installation directory does not exist
case ::utl::Bootstrap::MISSING_USER_DIRECTORY:
{
OUString aUserInstallationURL;
utl::Bootstrap::locateUserInstallation( aUserInstallationURL );
aErrorMsg = CreateErrorMsgString( nFailureCode, aUserInstallationURL );
}
break;
}
HandleBootstrapPathErrors( aBootstrapStatus, aErrorMsg );
}
}
else if ( aBootstrapError == BE_UNO_SERVICEMANAGER || aBootstrapError == BE_UNO_SERVICE_CONFIG_MISSING )
{
// Uno service manager is not available. VCL needs a uno service manager to display a message box!!!
// Currently we are not able to display a message box with a service manager due to this limitations inside VCL.
if ( Application::IsRemoteServer() )
{
OStringBuffer aErrorMsgBuffer( 50 );
aErrorMsgBuffer.append( "The program cannot be started. " );
if ( aBootstrapError == BE_UNO_SERVICEMANAGER )
aErrorMsgBuffer.append( "The service manager is not available.\n" );
else
aErrorMsgBuffer.append( "The configuration service is not available.\n" );
OString aErrorMsg = aErrorMsgBuffer.makeStringAndClear();
fprintf( stderr, aErrorMsg.getStr() );
}
else
{
// First sentence. We cannot bootstrap office further!
OUString aProductKey;
OUString aMessage;
OUString aTemp;
OUStringBuffer aDiagnosticMessage( 100 );
::vos::OStartupInfo aInfo;
aDiagnosticMessage.append( GetMsgString( STR_BOOTSTRAP_ERR_CANNOT_START,
OUString( RTL_CONSTASCII_USTRINGPARAM( "The program cannot be started." )) ));
aDiagnosticMessage.appendAscii( "\n" );
OUString aErrorMsg;
if ( aBootstrapError == BE_UNO_SERVICEMANAGER )
aErrorMsg = GetMsgString( STR_BOOTSTRAP_ERR_NO_SERVICE,
OUString( RTL_CONSTASCII_USTRINGPARAM( "The service manager is not available." )) );
else
aErrorMsg = GetMsgString( STR_BOOTSTRAP_ERR_NO_CFG_SERVICE,
OUString( RTL_CONSTASCII_USTRINGPARAM( "The configuration service is not available." )) );
aDiagnosticMessage.append( aErrorMsg );
aDiagnosticMessage.appendAscii( "\n" );
OUString aAskSetupRepairStr( GetMsgString(
STR_ASK_START_SETUP_REPAIR,
OUString( RTL_CONSTASCII_USTRINGPARAM( "Start setup application to repair installation?" )) ));
aDiagnosticMessage.append( aAskSetupRepairStr );
aMessage = aDiagnosticMessage.makeStringAndClear();
aInfo.getExecutableFile( aProductKey );
sal_uInt32 lastIndex = aProductKey.lastIndexOf('/');
if ( lastIndex > 0 )
aProductKey = aProductKey.copy( lastIndex+1 );
aTemp = ::utl::Bootstrap::getProductKey( aProductKey );
if ( aTemp.getLength() > 0 )
aProductKey = aTemp;
ErrorBox aBootstrapFailedBox( NULL, WB_YES_NO, aMessage );
aBootstrapFailedBox.SetText( aProductKey );
int nResult = aBootstrapFailedBox.Execute();
if ( nResult == RET_YES )
{
OUString aParameters( RTL_CONSTASCII_USTRINGPARAM( "-repair" ));
StartSetup( aParameters );
}
}
}
_exit( 333 );
}
USHORT Desktop::Exception(USHORT nError)
{
// protect against recursive calls
static BOOL bInException = FALSE;
sal_uInt16 nOldMode = Application::GetSystemWindowMode();
Application::SetSystemWindowMode( nOldMode & ~SYSTEMWINDOW_MODE_NOAUTOMODE );
Application::SetDefModalDialogParent( NULL );
if ( bInException )
{
String aDoubleExceptionString;
Application::Abort( aDoubleExceptionString );
}
bInException = TRUE;
BOOL bRecovery = FALSE;
CommandLineArgs* pArgs = GetCommandLineArgs();
// save all modified documents
if( Application::IsInExecute() )
{
// store to backup path
String aSavePath( SvtPathOptions().GetBackupPath() );
SvtInternalOptions aOpt;
// iterate tasks
Reference< ::com::sun::star::frame::XTasksSupplier >
xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( OUSTRING(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
UNO_QUERY );
Reference< ::com::sun::star::frame::XTask > xTask;
Reference< ::com::sun::star::container::XEnumeration > xList = xDesktop->getTasks()->createEnumeration();
while( xList->hasMoreElements() )
{
xList->nextElement() >>= xTask;
// ask for controller
Reference< ::com::sun::star::frame::XController > xCtrl = xTask->getController();
if ( xCtrl.is() )
{
// ask for model
Reference< ::com::sun::star::frame::XModel > xModel( xCtrl->getModel(), UNO_QUERY );
Reference< ::com::sun::star::util::XModifiable > xModifiable( xModel, UNO_QUERY );
if ( xModifiable.is() && xModifiable->isModified() )
{
// ask if modified
Reference< ::com::sun::star::frame::XStorable > xStor( xModel, UNO_QUERY );
if ( xStor.is() )
{
// get the media descriptor and retrieve filter name and password
::rtl::OUString aOrigPassword, aOrigFilterName;
Sequence < PropertyValue > aArgs( xModel->getArgs() );
sal_Int32 nProps = aArgs.getLength();
for ( sal_Int32 nProp = 0; nProp<nProps; nProp++ )
{
const PropertyValue& rProp = aArgs[nProp];
if( rProp.Name == OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName")) )
rProp.Value >>= aOrigFilterName;
if( rProp.Name == OUString(RTL_CONSTASCII_USTRINGPARAM("Password")) )
rProp.Value >>= aOrigPassword;
}
// save document as tempfile in backup directory
// remember old name or title
::rtl::OUString aOrigURL = xModel->getURL();
::rtl::OUString aOldName, aSaveURL;
if ( aOrigURL.getLength() )
{
::utl::TempFile aTempFile( &aSavePath );
aSaveURL = aTempFile.GetURL();
aOldName = aOrigURL;
}
else
{
// untitled document
String aExt( DEFINE_CONST_UNICODE( ".sav" ) );
::utl::TempFile aTempFile( DEFINE_CONST_UNICODE( "exc" ), &aExt, &aSavePath );
aSaveURL = aTempFile.GetURL();
// aOldName = Title;
}
if ( aOrigPassword.getLength() )
{
// if the document was loaded with a password, it should be stored with password
Sequence < PropertyValue > aSaveArgs(1);
aSaveArgs[0].Name = DEFINE_CONST_UNICODE("Password");
aSaveArgs[0].Value <<= aOrigPassword;
xStor->storeToURL( aSaveURL, aSaveArgs );
}
else
xStor->storeToURL( aSaveURL, Sequence < PropertyValue >() );
// remember original name and filter
aOpt.PushRecoveryItem( aOldName, aOrigFilterName, aSaveURL );
bRecovery = TRUE;
}
}
}
}
if ( !pArgs->IsNoRestore() && ( nError & EXC_MAJORTYPE ) != EXC_DISPLAY && ( nError & EXC_MAJORTYPE ) != EXC_REMOTE )
WarningBox( NULL, DesktopResId(STR_RECOVER_PREPARED) ).Execute();
}
// store configuration data
::utl::ConfigManager::GetConfigManager()->StoreConfigItems();
// because there is no method to flush the condiguration data, we must dispose the ConfigManager
Reference < XComponent > xComp( ::utl::ConfigManager::GetConfigManager()->GetConfigurationProvider(), UNO_QUERY );
xComp->dispose();
switch( nError & EXC_MAJORTYPE )
{
/*
case EXC_USER:
if( nError == EXC_OUTOFMEMORY )
{
// not possible without a special NewHandler!
String aMemExceptionString;
Application::Abort( aMemExceptionString );
}
break;
*/
case EXC_RSCNOTLOADED:
{
String aResExceptionString;
Application::Abort( aResExceptionString );
break;
}
case EXC_SYSOBJNOTCREATED:
{
String aSysResExceptionString;
Application::Abort( aSysResExceptionString );
break;
}
default:
{
if ( pArgs->IsNoRestore() )
_exit( 333 );
if( bRecovery && !pPluginAcceptThread && !Application::IsRemoteServer() )
{
OfficeIPCThread::DisableOfficeIPCThread();
if( pSignalHandler )
DELETEZ( pSignalHandler );
::rtl::OUString aProgName, aTmp;
::vos::OStartupInfo aInfo;
aInfo.getExecutableFile( aProgName );
Reference< XSystemShellExecute > xSystemShellExecute( ::comphelper::getProcessServiceFactory()->createInstance(
::rtl::OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" )), UNO_QUERY );
if ( xSystemShellExecute.is() )
{
::rtl::OUString aSysPathFileName;
::osl::FileBase::RC nError = ::osl::FileBase::getSystemPathFromFileURL( aProgName, aSysPathFileName );
if ( nError == ::osl::FileBase::E_None )
xSystemShellExecute->execute( aSysPathFileName, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
}
_exit( 333 );
}
else
{
bInException = sal_False;
return 0;
}
break;
}
}
return 0;
// ConfigManager is disposed, so no way to continue
}
void Desktop::AppEvent( const ApplicationEvent& rAppEvent )
{
HandleAppEvent( rAppEvent );
}
void Desktop::Main()
{
RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::Main" );
// Error handling inside Desktop::Main() because vcl is not
// initialized before!!!
if ( m_aBootstrapError != BE_OK )
{
HandleBootstrapErrors( m_aBootstrapError );
}
CommandLineArgs* pCmdLineArgs = GetCommandLineArgs();
// ---- Startup screen ----
OpenStartupScreen();
ResMgr::SetReadStringHook( ReplaceStringHookProc );
SetAppName( DEFINE_CONST_UNICODE("soffice") );
#ifdef TIMEBOMB
Date aDate;
Date aFinalDate( 31, 03, 2002 );
if ( aFinalDate < aDate )
{
String aMsg;
aMsg += DEFINE_CONST_UNICODE("This Beta Version has expired!\n");
InfoBox aBox( NULL, aMsg );
aBox.Execute();
return;
}
#endif
sal_Bool bTerminate = pCmdLineArgs->IsTerminateAfterInit();
// Read the common configuration items for optimization purpose
// do not do it if terminate flag was specified, to avoid exception
if( !bTerminate )
{
try
{
PreloadConfigTrees();
}
catch( ::com::sun::star::configuration::MissingBootstrapFileException& e )
{
OUString aMsg( CreateErrorMsgString( utl::Bootstrap::MISSING_BOOTSTRAP_FILE,
e.BootstrapFileURL ));
HandleBootstrapPathErrors( ::utl::Bootstrap::INVALID_USER_INSTALL, aMsg );
}
catch( ::com::sun::star::configuration::InvalidBootstrapFileException& e )
{
OUString aMsg( CreateErrorMsgString( utl::Bootstrap::INVALID_BOOTSTRAP_FILE_ENTRY,
e.BootstrapFileURL ));
HandleBootstrapPathErrors( ::utl::Bootstrap::INVALID_BASE_INSTALL, aMsg );
}
catch( ::com::sun::star::configuration::InstallationIncompleteException& )
{
OUString aVersionFileURL;
OUString aMsg;
utl::Bootstrap::PathStatus aPathStatus = utl::Bootstrap::locateVersionFile( aVersionFileURL );
if ( aPathStatus == utl::Bootstrap::PATH_EXISTS )
aMsg = CreateErrorMsgString( utl::Bootstrap::MISSING_VERSION_FILE_ENTRY, aVersionFileURL );
else
aMsg = CreateErrorMsgString( utl::Bootstrap::MISSING_VERSION_FILE, aVersionFileURL );
HandleBootstrapPathErrors( ::utl::Bootstrap::MISSING_USER_INSTALL, aMsg );
}
catch ( ::com::sun::star::configuration::CannotLoadConfigurationException& )
{
OUString aMsg( CreateErrorMsgString( utl::Bootstrap::INVALID_BOOTSTRAP_DATA,
OUString() ));
HandleBootstrapPathErrors( ::utl::Bootstrap::INVALID_BASE_INSTALL, aMsg );
}
catch( ::com::sun::star::uno::Exception& )
{
OUString aMsg( CreateErrorMsgString( utl::Bootstrap::INVALID_BOOTSTRAP_DATA,
OUString() ));
HandleBootstrapPathErrors( ::utl::Bootstrap::INVALID_BASE_INSTALL, aMsg );
}
}
// The only step that should be done if terminate flag was specified
// Typically called by the plugin only
{
RTL_LOGFILE_CONTEXT( aLog, "setup2 (ok93719) ::Installer::InitializeInstallation" );
InitializeInstallation( Application::GetAppFileName() );
}
if( !bTerminate )
{
Reference< XMultiServiceFactory > xSMgr = ::comphelper::getProcessServiceFactory();
RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create SvtPathOptions and SvtCJKOptions" );
SvtPathOptions* pPathOptions = new SvtPathOptions;
SvtCJKOptions* pCJKOPptions = new SvtCJKOptions(sal_True);
RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create SvtPathOptions and SvtCJKOptions" );
registerServices( xSMgr );
OUString aDescription;
Sequence< Any > aSeq( 1 );
if ( pOfficeAcceptThread )
aDescription = pOfficeAcceptThread->GetDescriptionString();
else
pCmdLineArgs->GetPortalConnectString( aDescription );
aSeq[0] <<= aDescription;
RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ createInstance com.sun.star.office.OfficeWrapper" );
Reference < XComponent > xWrapper( xSMgr->createInstanceWithArguments( DEFINE_CONST_UNICODE(
"com.sun.star.office.OfficeWrapper" ), aSeq ),
UNO_QUERY );
RTL_LOGFILE_CONTEXT_TRACE( aLog, "} createInstance com.sun.star.office.OfficeWrapper" );
{
Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_DIALOG );
Reference< XConnectionBroker > xServiceManagerBroker;
Reference< XConnectionBroker > xPalmPilotManagerBroker;
InitTestToolLib();
try
{
// the shutdown icon sits in the systray and allows the user to keep
// the office instance running for quicker restart
// this will only be activated if -quickstart was specified on cmdline
RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) createInstance com.sun.star.office.Quickstart" );
sal_Bool bQuickstart = pCmdLineArgs->IsQuickstart();
Sequence< Any > aSeq( 1 );
aSeq[0] <<= bQuickstart;
// Try to instanciate quickstart service. This service is not mandatory, so
// do nothing if service is not available.
Reference < XComponent > xQuickstart( xSMgr->createInstanceWithArguments(
DEFINE_CONST_UNICODE( "com.sun.star.office.Quickstart" ), aSeq ),
UNO_QUERY );
}
catch( ::com::sun::star::uno::Exception& )
{
}
if ( pCmdLineArgs->IsPlugin() )
{
RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (cd100003) create PluginAcceptThread" );
OSecurity aSecurity;
OUString aUserIdent;
OUString aVersionStr;
aSecurity.getUserIdent( aUserIdent );
OSL_ENSURE( pCmdLineArgs->GetVersionString( aVersionStr ), "No plugin version is specified!\n" );
OUString aAcceptString( RTL_CONSTASCII_USTRINGPARAM( "pipe,name=soffice_plugin" ));
aAcceptString += aVersionStr;
aAcceptString += aUserIdent;
pPluginAcceptThread = new PluginAcceptThread( xSMgr,
new OInstanceProvider( xSMgr ),
aAcceptString );
// We have to acquire the plugin accept thread object to be sure
// that the instance is still alive after an exception was thrown
pPluginAcceptThread->acquire();
pPluginAcceptThread->create();
}
if ( !Application::IsRemoteServer() )
{
// Create TypeDetection service to have filter informations for quickstart feature
RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) createInstance com.sun.star.document.TypeDetection" );
Reference< XTypeDetection > xTypeDetection( xSMgr->createInstance(
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.TypeDetection" ))),
UNO_QUERY );
Reference< XDesktop > xDesktop( xSMgr->createInstance(
OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))),
UNO_QUERY );
if ( xDesktop.is() )
xDesktop->addTerminateListener( new OfficeIPCThreadController );
}
// Release solar mutex just before we wait for our client to connect
int nAcquireCount = 0;
::vos::IMutex& rMutex = Application::GetSolarMutex();
if ( rMutex.tryToAcquire() )
nAcquireCount = Application::ReleaseSolarMutex() - 1;
Application::WaitForClientConnect();
// Post user event to startup first application component window
// We have to send this OpenClients message short before execute() to
// minimize the risk that this message overtakes type detection contruction!!
Application::PostUserEvent( LINK( this, Desktop, OpenClients_Impl ) );
// Acquire solar mutex just before we enter our message loop
if ( nAcquireCount )
Application::AcquireSolarMutex( nAcquireCount );
// call Application::Execute to process messages in vcl message loop
RTL_LOGFILE_CONTEXT_TRACE( aLog, "call ::Application::Execute" );
Execute();
// remove temp directory
removeTemporaryDirectory();
if( xPalmPilotManagerBroker.is() )
xPalmPilotManagerBroker->stopAccepting();
if( xServiceManagerBroker.is() )
xServiceManagerBroker->stopAccepting();
if( pOfficeAcceptThread )
{
pOfficeAcceptThread->stopAccepting();
#ifndef LINUX
pOfficeAcceptThread->join();
delete pOfficeAcceptThread;
#endif
pOfficeAcceptThread = 0;
}
if ( pPluginAcceptThread )
{
pPluginAcceptThread->terminate();
pPluginAcceptThread->release();
}
DeInitTestToolLib();
}
xWrapper->dispose();
xWrapper = 0;
delete pCJKOPptions;
delete pPathOptions;
}
::ucb::ContentBroker::deinitialize();
// instead of removing of the configManager just let it commit all the changes
utl::ConfigManager::GetConfigManager()->StoreConfigItems();
}
void Desktop::SystemSettingsChanging( AllSettings& rSettings, Window* pFrame )
{
// OFF_APP()->SystemSettingsChanging( rSettings, pFrame );
}
// ========================================================================
typedef ::vos::OTimer OFirstOfficeRunInitTimer_Base;
class OFirstOfficeRunInitTimer : public OFirstOfficeRunInitTimer_Base
{
private:
Link m_aAsyncExpireHandler;
public:
OFirstOfficeRunInitTimer( const Link& _rExpireHdl );
private:
virtual void SAL_CALL onShot();
};
// ========================================================================
OFirstOfficeRunInitTimer::OFirstOfficeRunInitTimer( const Link& _rExpireHdl )
:OFirstOfficeRunInitTimer_Base( TTimeValue( 3, 0 ) )
,m_aAsyncExpireHandler( _rExpireHdl )
{
acquire();
}
// ========================================================================
void SAL_CALL OFirstOfficeRunInitTimer::onShot()
{
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
Application::PostUserEvent( m_aAsyncExpireHandler );
}
// delete ourself - we're not needed anymore
release();
}
// ========================================================================
IMPL_LINK( Desktop, AsyncInitFirstRun, void*, NOTINTERESTEDIN )
{
DoFirstRunInitializations();
return 0L;
}
// ========================================================================
IMPL_LINK( Desktop, OpenClients_Impl, void*, pvoid )
{
RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::OpenClients_Impl" );
OpenClients();
CloseStartupScreen();
CheckFirstRun( );
EnableOleAutomation();
return 0;
}
// Registers a COM class factory of the service manager with the windows operating system.
void Desktop::EnableOleAutomation()
{
RTL_LOGFILE_CONTEXT( aLog, "desktop (jl97489) ::Desktop::EnableOleAutomation" );
#ifdef WNT
Reference< XMultiServiceFactory > xSMgr= comphelper::getProcessServiceFactory();
xSMgr->createInstance(DEFINE_CONST_UNICODE("com.sun.star.bridge.OleApplicationRegistration"));
#endif
}
void Desktop::OpenClients()
{
// check if a document has been recovered - if there is one of if a document was loaded by cmdline, no default document
// should be created
Reference < XComponent > xFirst;
BOOL bLoaded = FALSE;
CommandLineArgs* pArgs = GetCommandLineArgs();
SvtInternalOptions aInternalOptions;
if ( !pArgs->IsServer() && !pArgs->IsNoRestore() && !aInternalOptions.IsRecoveryListEmpty() )
{
// crash recovery
sal_Bool bUserCancel = sal_False;
::rtl::OUString sURL;
::rtl::OUString sFilter;
::rtl::OUString sTempName;
Reference< XComponentLoader > xDesktop(
::comphelper::getProcessServiceFactory()->createInstance( OUSTRING(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
::com::sun::star::uno::UNO_QUERY );
// create the parameter array
Sequence < PropertyValue > aArgs( 4 );
aArgs[0].Name = ::rtl::OUString::createFromAscii("Referer");
aArgs[1].Name = ::rtl::OUString::createFromAscii("AsTemplate");
aArgs[2].Name = ::rtl::OUString::createFromAscii("FilterName");
aArgs[3].Name = ::rtl::OUString::createFromAscii("SalvagedFile");
// mark it as a user request
aArgs[0].Value <<= ::rtl::OUString::createFromAscii("private:user");
while( !aInternalOptions.IsRecoveryListEmpty() && !bUserCancel )
{
// Read and delete top recovery item from list
aInternalOptions.PopRecoveryItem( sURL, sFilter, sTempName );
INetURLObject aURL( sURL );
sal_Bool bIsURL = aURL.GetProtocol() != INET_PROT_NOT_VALID;
String sRealFileName( sURL );
String sTempFileName( sTempName );
String aMsg( DesktopResId( STR_RECOVER_QUERY ) );
aMsg.SearchAndReplaceAscii( "$1", sRealFileName );
MessBox aBox( NULL, WB_YES_NO_CANCEL | WB_DEF_YES | WB_3DLOOK, String( DesktopResId( STR_RECOVER_TITLE ) ), aMsg );
switch( aBox.Execute() )
{
case RET_YES:
{
// recover a file
aArgs[2].Value <<= ::rtl::OUString( sFilter );
if ( bIsURL )
{
// get the original URL for the recovered document
aArgs[1].Value <<= sal_False;
aArgs[3].Value <<= ::rtl::OUString( sRealFileName );
}
else
{
// this was an untitled document ( open as template )
aArgs[1].Value <<= sal_True;
aArgs[3].Value <<= ::rtl::OUString();
}
// load the document
Reference < XComponent > xDoc = xDesktop->loadComponentFromURL( sTempFileName, ::rtl::OUString::createFromAscii( "_blank" ), 0, aArgs );
if ( !xFirst.is() )
// remember the first successfully recovered file
xFirst = xDoc;
// backup copy will be removed when document is closed
break;
}
case RET_NO:
{
// skip this file
::utl::UCBContentHelper::Kill( sTempFileName );
break;
}
case RET_CANCEL:
{
// cancel recovering
::utl::UCBContentHelper::Kill( sTempFileName );
bUserCancel = sal_True;
// delete recovery list and all files
while( aInternalOptions.IsRecoveryListEmpty() == sal_False )
{
aInternalOptions.PopRecoveryItem( sURL, sFilter, sTempName );
::utl::UCBContentHelper::Kill( sTempName );
}
break;
}
}
}
}
// check for open parameters
String aEmptyStr;
::rtl::OUString aOpenList;
if ( pArgs->GetOpenList( aOpenList ) )
{
bLoaded = TRUE;
ApplicationEvent* pAppEvt = new ApplicationEvent( aEmptyStr, aEmptyStr,
APPEVENT_OPEN_STRING,
aOpenList );
HandleAppEvent( *pAppEvt );
delete pAppEvt;
}
// check for print parameters
::rtl::OUString aPrintList;
if ( pArgs->GetPrintList( aPrintList ) )
{
bLoaded = TRUE;
ApplicationEvent* pAppEvt = new ApplicationEvent( aEmptyStr, aEmptyStr,
APPEVENT_PRINT_STRING,
aPrintList );
HandleAppEvent( *pAppEvt );
delete pAppEvt;
}
// no default document if a document was loaded by recovery or by command line or if soffice is used as server
if ( bLoaded || xFirst.is() || pArgs->IsServer() )
return;
if( pArgs->IsQuickstart() ||
pArgs->IsInvisible() ||
pArgs->IsPlugin() ||
pArgs->IsBean() )
// soffice was started as tray icon
return;
{
OpenDefault();
}
}
void Desktop::OpenDefault()
{
RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::OpenDefault" );
::rtl::OUString aName;
if ( !aName.getLength() )
{
SvtModuleOptions aOpt;
if ( aOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_WRITER );
else if ( aOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_CALC );
else if ( aOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_IMPRESS );
else if ( aOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
aName = aOpt.GetFactoryEmptyDocumentURL( SvtModuleOptions::E_DRAW );
else
return;
}
Sequence < PropertyValue > aNoArgs;
Reference< XComponentLoader > xDesktop(
::comphelper::getProcessServiceFactory()->createInstance( OUSTRING(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
::com::sun::star::uno::UNO_QUERY );
xDesktop->loadComponentFromURL( aName, ::rtl::OUString::createFromAscii( "_blank" ), 0, aNoArgs );
}
String GetURL_Impl( const String& rName )
{
// if the filename is a physical name, it is the client file system, not the file system
// of the machine where the office is running ( if this are different machines )
// so in the remote case we can't handle relative filenames as arguments, because they
// are parsed relative to the program path
// the file system of the client is addressed through the "file:" protocol
// Get current working directory to support relativ pathes
::rtl::OUString aWorkingDir;
osl_getProcessWorkingDir( &aWorkingDir.pData );
// Add path seperator to these directory and make given URL (rName) absolute by using of current working directory
// Attention: "setFianlSlash()" is neccessary for calling "smartRel2Abs()"!!!
// Otherwhise last part will be ignored and wrong result will be returned!!!
// "smartRel2Abs()" interpret given URL as file not as path. So he truncate last element to get the base path ...
// But if we add a seperator - he doesn't do it anymore.
INetURLObject aObj( aWorkingDir );
aObj.setFinalSlash();
bool bWasAbsolute;
INetURLObject aURL = aObj.smartRel2Abs( rName, bWasAbsolute );
String aFileURL = aURL.GetMainURL(INetURLObject::NO_DECODE);
::osl::FileStatus aStatus( FileStatusMask_FileURL );
::osl::DirectoryItem aItem;
if( ::osl::FileBase::E_None == ::osl::DirectoryItem::get( aFileURL, aItem ) &&
::osl::FileBase::E_None == aItem.getFileStatus( aStatus ) )
aFileURL = aStatus.getFileURL();
return aFileURL;
}
void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
{
if ( rAppEvent.IsOpenEvent() || rAppEvent.IsPrintEvent() )
{
String aPrinterName;
Reference< XComponentLoader > xDesktop(
::comphelper::getProcessServiceFactory()->createInstance( OUSTRING(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
::com::sun::star::uno::UNO_QUERY );
// create parameter array
sal_Int32 nCount = rAppEvent.IsPrintEvent() ? 5 : 1;
Sequence < PropertyValue > aArgs( nCount );
aArgs[0].Name = ::rtl::OUString::createFromAscii("Referer");
if ( rAppEvent.IsPrintEvent() )
{
aArgs[1].Name = ::rtl::OUString::createFromAscii("ReadOnly");
aArgs[2].Name = ::rtl::OUString::createFromAscii("OpenNewView");
aArgs[3].Name = ::rtl::OUString::createFromAscii("Hidden");
aArgs[4].Name = ::rtl::OUString::createFromAscii("Silent");
}
// mark request as user interaction from outside
aArgs[0].Value <<= ::rtl::OUString::createFromAscii("private:OpenEvent");
for( sal_uInt16 i=0; i<rAppEvent.GetParamCount(); i++ )
{
// get file name
String aName( rAppEvent.GetParam(i) );
// is the parameter a printername ?
if( aName.Len()>1 && *aName.GetBuffer()=='@' )
{
aPrinterName = aName.Copy(1);
continue;
}
#ifdef WNT
FATToVFat_Impl( aName );
#endif
aName = GetURL_Impl(aName);
if ( rAppEvent.IsPrintEvent() )
{
// documents opened for printing are opened readonly because they must be opened as a new document and this
// document could be open already
aArgs[1].Value <<= sal_True;
// always open a new document for printing, because it must be disposed afterwards
aArgs[2].Value <<= sal_True;
// printing is done in a hidden view
aArgs[3].Value <<= sal_True;
// load document for printing without user interaction
aArgs[4].Value <<= sal_True;
}
// load the document ... if they are loadable!
// Otherwise try to dispatch it ...
Reference < XPrintable > xDoc;
if(
( aName.CompareToAscii( ".uno" , 4 ) == COMPARE_EQUAL ) ||
( aName.CompareToAscii( "slot:" , 5 ) == COMPARE_EQUAL ) ||
( aName.CompareToAscii( "macro:", 6 ) == COMPARE_EQUAL )
)
{
// Attention: URL must be parsed full. Otherwise some detections on it will fail!
// It doesnt matter, if parser isn't available. Because; We try loading of URL then ...
URL aURL ;
aURL.Complete = aName;
Reference < XDispatch > xDispatcher ;
Reference < XDispatchProvider > xProvider ( xDesktop, UNO_QUERY );
Reference < XURLTransformer > xParser ( ::comphelper::getProcessServiceFactory()->createInstance( OUSTRING(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer")) ), ::com::sun::star::uno::UNO_QUERY );
if( xParser.is() == sal_True )
xParser->parseStrict( aURL );
if( xProvider.is() == sal_True )
xDispatcher = xProvider->queryDispatch( aURL, ::rtl::OUString(), 0 );
if( xDispatcher.is() == sal_True )
xDispatcher->dispatch( aURL, aArgs );
}
else
{
xDoc = Reference < XPrintable >( xDesktop->loadComponentFromURL( aName, ::rtl::OUString::createFromAscii("_blank"), 0, aArgs ), UNO_QUERY );
}
if ( rAppEvent.IsPrintEvent() )
{
if ( xDoc.is() )
{
if ( aPrinterName.Len() )
{
// create the printer
Sequence < PropertyValue > aPrinterArgs( 1 );
aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("Name");
aPrinterArgs[0].Value <<= ::rtl::OUString( aPrinterName );
xDoc->setPrinter( aPrinterArgs );
}
// print ( also without user interaction )
Sequence < PropertyValue > aPrinterArgs( 1 );
aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("Silent");
aPrinterArgs[0].Value <<= ( sal_Bool ) sal_True;
xDoc->print( aPrinterArgs );
}
else
{
// place error message here ...
}
// remove the document
Reference < XComponent > xComp( xDoc, UNO_QUERY );
if ( xComp.is() )
xComp->dispose();
}
}
// remove this pending request
OfficeIPCThread::RequestsCompleted( 1 );
}
else if ( rAppEvent.GetEvent() == "APPEAR" )
{
// find active task - the active task is always a visible task
::com::sun::star::uno::Reference< ::com::sun::star::frame::XTasksSupplier >
xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( OUSTRING(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
::com::sun::star::uno::UNO_QUERY );
::com::sun::star::uno::Reference< ::com::sun::star::frame::XTask > xTask = xDesktop->getActiveTask();
if ( !xTask.is() )
{
// get any task if there is no active one
::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > xList = xDesktop->getTasks()->createEnumeration();
if ( xList->hasMoreElements() )
xList->nextElement() >>= xTask;
}
if ( xTask.is() )
{
Reference< com::sun::star::awt::XTopWindow > xTop( xTask->getContainerWindow(), UNO_QUERY );
xTop->toFront();
}
else
// no visible task that could be activated found
OpenDefault();
}
else if ( rAppEvent.GetEvent() == "QUICKSTART" )
{
CommandLineArgs* pCmdLineArgs = GetCommandLineArgs();
if ( !pCmdLineArgs->IsQuickstart() )
{
// If the office has been started the second time its command line arguments are sent through a pipe
// connection to the first office. We want to reuse the quickstart option for the first office.
// NOTICE: The quickstart service must be initialized inside the "main thread", so we use the
// application events to do this (they are executed inside main thread)!!!
sal_Bool bQuickstart( sal_True );
Sequence< Any > aSeq( 1 );
aSeq[0] <<= bQuickstart;
Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance(
DEFINE_CONST_UNICODE( "com.sun.star.office.Quickstart" )),
UNO_QUERY );
if ( xQuickstart.is() )
xQuickstart->initialize( aSeq );
}
}
}
void Desktop::OpenStartupScreen()
{
RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::OpenStartupScreen" );
::rtl::OUString aTmpString;
CommandLineArgs* pCmdLine = GetCommandLineArgs();
// Show intro only if this is normal start (e.g. no server, no quickstart, no printing )
if ( !Application::IsRemoteServer() &&
!pCmdLine->IsInvisible() &&
!pCmdLine->IsQuickstart() &&
!pCmdLine->IsMinimized() &&
!pCmdLine->IsTerminateAfterInit() &&
!pCmdLine->GetPrintList( aTmpString ) )
{
String aBmpFileName;
::rtl::OUString aProductKey;
::rtl::OUString aIniPath;
::rtl::OUString aLogo( RTL_CONSTASCII_USTRINGPARAM( "1" ) );
Bitmap aIntroBmp;
// load bitmap depends on productname ("StarOffice", "StarSuite",...)
aProductKey = ::utl::Bootstrap::getProductKey( aProductKey );
aLogo = ::utl::Bootstrap::getLogoData( aLogo );
sal_Bool bLogo = (sal_Bool)aLogo.toInt32();
if ( bLogo )
{
xub_StrLen nIndex = 0;
aBmpFileName = aProductKey;
aBmpFileName = aBmpFileName.GetToken( 0, (sal_Unicode)' ', nIndex );
aBmpFileName += String( DEFINE_CONST_UNICODE("_intro.bmp") );
// retrieve our current installation path
::rtl::OUString aExecutePath;
::vos::OStartupInfo().getExecutableFile( aExecutePath );
sal_uInt32 lastIndex = aExecutePath.lastIndexOf('/');
if ( lastIndex > 0 )
aExecutePath = aExecutePath.copy( 0, lastIndex+1 );
INetURLObject aObj( aExecutePath, INET_PROT_FILE );
aObj.insertName( aBmpFileName );
SvFileStream aStrm( aObj.PathToFileName(), STREAM_STD_READ );
if ( !aStrm.GetError() )
{
// Default case, we load the intro bitmap from a seperate file
// (e.g. staroffice_intro.bmp or starsuite_intro.bmp)
aStrm >> aIntroBmp;
}
else
{
// Save case:
// Create resource manager for intro bitmap. Due to our problem that we don't have
// any language specific information, we have to search for the correct resource
// file. The bitmap resource is language independent.
const USHORT nResId = RID_DEFAULTINTRO;
LanguageType aLanguageType;
String aMgrName = String::CreateFromAscii( "iso" );
aMgrName += String::CreateFromInt32(SOLARUPD); // current build version
ResMgr* pLabelResMgr = ResMgr::SearchCreateResMgr( U2S( aMgrName ), aLanguageType );
ResId aIntroBmpRes( nResId, pLabelResMgr );
aIntroBmp = Bitmap( aIntroBmpRes );
delete pLabelResMgr;
}
m_pIntro = new IntroWindow_Impl( aIntroBmp );
}
}
}
void Desktop::CloseStartupScreen()
{
// close splash screen and delete window
delete m_pIntro;
m_pIntro = 0;
RTL_LOGFILE_TRACE( "desktop (cd100003) ::Desktop::CloseStartupScreen" );
}
// ========================================================================
void Desktop::DoFirstRunInitializations()
{
// TODO: as soon as there's more to do than starting this one special pilot,
// we most probably should have a better concept for services to be invoked upon
// running the first time ....
// --------------------------------------------------------------------
// execute the auto pilot which registers the users address book as data source
try
{
const ::rtl::OUString sAddressBookPilotServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.AddressBookSourcePilot" );
// create the pilot's service
Reference< XInterface > xDialog = ::comphelper::getProcessServiceFactory()->createInstance( sAddressBookPilotServiceName );
if ( !xDialog.is() )
{
ShowServiceNotAvailableError( NULL, sAddressBookPilotServiceName, sal_True );
}
else
{
Reference< XExecutableDialog > xExecute( xDialog, UNO_QUERY );
OSL_ENSURE( xExecute.is(), "Desktop::DoFirstRunInitializations: missing an interface (XExecutableDialog)!" );
if ( xExecute.is() )
xExecute->execute();
}
}
catch(const ::com::sun::star::uno::Exception&)
{
OSL_ENSURE( sal_False, "Desktop::DoFirstRunInitializations: caught an exception while executing the Address Book AutoPilot!" );
}
}
// ========================================================================
void Desktop::CheckFirstRun( )
{
const ::rtl::OUString sCommonMiscNodeName = ::rtl::OUString::createFromAscii( "/org.openoffice.Office.Common/Misc" );
const ::rtl::OUString sFirstRunNodeName = ::rtl::OUString::createFromAscii( "FirstRun" );
// --------------------------------------------------------------------
// check if this is the first office start
// for this, open the Common/Misc node where this info is stored
::utl::OConfigurationTreeRoot aCommonMisc = ::utl::OConfigurationTreeRoot::createWithServiceFactory(
::comphelper::getProcessServiceFactory( ),
sCommonMiscNodeName,
2,
::utl::OConfigurationTreeRoot::CM_UPDATABLE
);
// read the flag
OSL_ENSURE( aCommonMisc.isValid(), "Desktop::CheckFirstRun: could not open the config node needed!" );
sal_Bool bIsFirstRun = sal_False;
aCommonMisc.getNodeValue( sFirstRunNodeName ) >>= bIsFirstRun;
if ( !bIsFirstRun )
// nothing to do ....
return;
// --------------------------------------------------------------------
// it is the first run
// do the initialization asynchronously
::vos::ORef< ::vos::OTimer > xInitTimer = new OFirstOfficeRunInitTimer( LINK( this, Desktop, AsyncInitFirstRun ) );
xInitTimer->start();
OSL_ENSURE( xInitTimer->isTicking() && !xInitTimer->isExpired(),
"Desktop::CheckFirstRun: strange timer behaviour!" );
// --------------------------------------------------------------------
// reset the config flag
// set the value
aCommonMisc.setNodeValue( sFirstRunNodeName, makeAny( (sal_Bool)sal_False ) );
// commit the changes
aCommonMisc.commit();
}
|