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
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
|
/*************************************************************************
*
* $RCSfile: objserv.cxx,v $
*
* $Revision: 1.53 $
*
* last change: $Author: gt $ $Date: 2002-11-21 09:27:18 $
*
* 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 <so3/svstor.hxx>
#ifndef _COM_SUN_STAR_UI_DIALOGS_EXTENDEDFILEPICKERELEMENTIDS_HPP_
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#endif
#ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERCONTROLACCESS_HPP_
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_UI_DIALOGS_COMMONFILEPICKERELEMENTIDS_HPP_
#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
#endif
#ifndef _COM_SUN_STAR_UI_DIALOGS_XCONTROLACCESS_HPP_
#include <com/sun/star/ui/dialogs/XControlAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HPP_
#include <com/sun/star/beans/XPropertyAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
#include <com/sun/star/beans/PropertyValue.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_
#include <com/sun/star/document/XExporter.hpp>
#endif
#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
#include <com/sun/star/task/XInteractionHandler.hpp>
#endif
#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
#ifndef _URLOBJ_HXX //autogen
#include <tools/urlobj.hxx>
#endif
#if SUPD<613//MUSTINI
#ifndef _SFX_INIMGR_HXX //autogen
#include <inimgr.hxx>
#endif
#endif
#ifndef _SFX_WHITER_HXX //autogen
#include <svtools/whiter.hxx>
#endif
#if SUPD<613//MUSTINI
#ifndef _SFXINIMGR_HXX //autogen
#include <svtools/iniman.hxx>
#endif
#endif
#ifndef _MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SFXINTITEM_HXX //autogen
#include <svtools/intitem.hxx>
#endif
#ifndef _SFXENUMITEM_HXX //autogen
#include <svtools/eitem.hxx>
#endif
#include <vcl/wrkwin.hxx>
#ifndef _SFXECODE_HXX
#include <svtools/sfxecode.hxx>
#endif
#ifndef _EHDL_HXX
#include <svtools/ehdl.hxx>
#endif
#include <svtools/sbx.hxx>
#include <svtools/pathoptions.hxx>
#include <svtools/useroptions.hxx>
#include <svtools/asynclink.hxx>
#include <svtools/saveopt.hxx>
#pragma hdrstop
#include "sfxresid.hxx"
#include "event.hxx"
#include "request.hxx"
#include "printer.hxx"
#include "viewsh.hxx"
#include "doctdlg.hxx"
#include "docfilt.hxx"
#include "docfile.hxx"
#include "docinf.hxx"
#include "dispatch.hxx"
#include "dinfdlg.hxx"
#include "objitem.hxx"
#include "objsh.hxx"
#include "objshimp.hxx"
#include "sfxtypes.hxx"
#include "interno.hxx"
#include "module.hxx"
#include "topfrm.hxx"
#include "versdlg.hxx"
#include "doc.hrc"
#include "docfac.hxx"
#include "fcontnr.hxx"
#include "filedlghelper.hxx"
#include "sfxhelp.hxx"
#ifndef _SFX_HELPID_HRC
#include "helpid.hrc"
#endif
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::document;
using namespace ::com::sun::star::task;
//====================================================================
// Helper class to initialize an export dialog for PDF
class PDFExportFileDialog : public sfx2::FileDialogHelper
{
public:
PDFExportFileDialog( const short nDialogType, sal_uInt32 nFlags, sal_Bool bNoOptionsDlg ) :
sfx2::FileDialogHelper( nDialogType, nFlags ), m_bInitialized( sal_False ), m_bNoOptionsDlg( bNoOptionsDlg )
{}
virtual void SAL_CALL DirectoryChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent );
private:
sal_Bool m_bInitialized;
sal_Bool m_bNoOptionsDlg;
};
void SAL_CALL PDFExportFileDialog::DirectoryChanged( const ::com::sun::star::ui::dialogs::FilePickerEvent& aEvent )
{
::vos::OGuard aGuard( Application::GetSolarMutex() );
if ( !m_bInitialized )
{
m_bInitialized = sal_True;
Reference< ::com::sun::star::ui::dialogs::XFilePicker > xFilePicker = GetFilePicker();
Reference< ::com::sun::star::ui::dialogs::XFilePickerControlAccess > xControlAccess =
Reference< ::com::sun::star::ui::dialogs::XFilePickerControlAccess >( xFilePicker, UNO_QUERY );
if ( xControlAccess.is() )
{
String aResStr;
if ( m_bNoOptionsDlg )
aResStr = String( SfxResId( STR_EXPORTBUTTON ));
else
aResStr = String( SfxResId( STR_EXPORTWITHCFGBUTTON ));
::rtl::OUString aStrExport = aResStr;
xControlAccess->setLabel( ::com::sun::star::ui::dialogs::CommonFilePickerElementIds::PUSHBUTTON_OK, aStrExport );
aResStr = String( SfxResId( STR_LABEL_FILEFORMAT ));
aStrExport = aResStr;
xControlAccess->setLabel( ::com::sun::star::ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER_LABEL, aStrExport );
}
}
FileDialogHelper::DirectoryChanged( aEvent );
}
//====================================================================
class SfxSaveAsContext_Impl
{
String& _rNewNameVar;
String _aNewName;
public:
SfxSaveAsContext_Impl( String &rNewNameVar,
const String &rNewName )
: _rNewNameVar( rNewNameVar ),
_aNewName( rNewName )
{ rNewNameVar = rNewName; }
~SfxSaveAsContext_Impl()
{ _rNewNameVar.Erase(); }
};
//====================================================================
BOOL ShallSetBaseURL_Impl( SfxMedium &rMed );
#define SfxObjectShell
#include "sfxslots.hxx"
svtools::AsynchronLink* pPendingCloser = 0;
//=========================================================================
SFX_IMPL_INTERFACE(SfxObjectShell,SfxShell,SfxResId(0))
{
}
long SfxObjectShellClose_Impl( void* pObj, void* pArg )
{
SfxObjectShell *pObjSh = (SfxObjectShell*) pArg;
if ( pObjSh->Get_Impl()->bHiddenLockedByAPI )
{
pObjSh->Get_Impl()->bHiddenLockedByAPI = FALSE;
pObjSh->OwnerLock(FALSE);
}
else if ( !pObjSh->Get_Impl()->bClosing )
// GCC stuerzt ab, wenn schon im dtor, also vorher Flag abfragen
pObjSh->DoClose();
return 0;
}
//=========================================================================
void SfxObjectShell::PrintExec_Impl(SfxRequest &rReq)
{
SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this);
if ( pFrame )
{
rReq.SetSlot( SID_PRINTDOC );
pFrame->GetViewShell()->ExecuteSlot(rReq);
}
}
//--------------------------------------------------------------------
void SfxObjectShell::PrintState_Impl(SfxItemSet &rSet)
{
FASTBOOL bPrinting = FALSE;
SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this, TYPE(SfxTopViewFrame));
if ( pFrame )
{
SfxPrinter *pPrinter = pFrame->GetViewShell()->GetPrinter();
bPrinting = pPrinter && pPrinter->IsPrinting();
}
rSet.Put( SfxBoolItem( SID_PRINTOUT, bPrinting ) );
}
//--------------------------------------------------------------------
sal_Bool SfxObjectShell::APISaveAs_Impl
(
const String& aFileName,
SfxItemSet* aParams
)
{
BOOL bOk = sal_False;
{DBG_CHKTHIS(SfxObjectShell, 0);}
pImp->bSetStandardName=FALSE;
if ( GetMedium() )
{
SFX_ITEMSET_ARG( aParams, pSaveToItem, SfxBoolItem, SID_SAVETO, sal_False );
sal_Bool bSaveTo = pSaveToItem && pSaveToItem->GetValue();
String aFilterName;
SFX_ITEMSET_ARG( aParams, pFilterNameItem, SfxStringItem, SID_FILTER_NAME, sal_False );
if( pFilterNameItem )
aFilterName = pFilterNameItem->GetValue();
// in case no filter defined use default one
if( !aFilterName.Len() )
{
sal_uInt16 nActFilt = 0;
for( const SfxFilter* pFilt = GetFactory().GetFilter( 0 );
pFilt && ( !pFilt->CanExport()
|| !bSaveTo && !pFilt->CanImport() // SaveAs case
|| pFilt->IsInternal() );
pFilt = GetFactory().GetFilter( ++nActFilt ) );
DBG_ASSERT( pFilt, "No default filter!\n" );
if( pFilt )
aFilterName = pFilt->GetFilterName();
aParams->Put(SfxStringItem( SID_FILTER_NAME, aFilterName));
}
{
SfxObjectShellRef xLock( this ); // ???
// since saving a document modified its DocumentInfo, the current DocumentInfo must be saved on "SaveTo", because
// it must be restored after saving
SfxDocumentInfo aSavedInfo;
sal_Bool bCopyTo = bSaveTo || GetCreateMode() == SFX_CREATE_MODE_EMBEDDED;
if ( bCopyTo )
aSavedInfo = GetDocInfo();
bOk = CommonSaveAs_Impl( aFileName, aFilterName, aParams );
if ( bCopyTo )
{
// restore DocumentInfo if only a copy was created
SfxDocumentInfo &rDocInfo = GetDocInfo();
rDocInfo = aSavedInfo;
}
}
// Picklisten-Eintrag verhindern
GetMedium()->SetUpdatePickList( FALSE );
}
return bOk;
}
//-------------------------------------------------------------------------
sal_Bool SfxObjectShell::GUISaveAs_Impl(sal_Bool bUrl, SfxRequest *pRequest)
{
INetURLObject aURL;
SFX_REQUEST_ARG( (*pRequest), pSaveToItem, SfxBoolItem, SID_SAVETO, sal_False );
sal_Bool bSaveTo = pSaveToItem ? pSaveToItem->GetValue() : sal_False;
sal_Bool bIsPDFExport = (( pRequest->GetSlot() == SID_EXPORTDOCASPDF ) ||
( pRequest->GetSlot() == SID_DIRECTEXPORTDOCASPDF ));
sal_Bool bIsExport = ( pRequest->GetSlot() == SID_EXPORTDOC ) || bIsPDFExport;
sal_Bool bSuppressFilterOptionsDialog = sal_False;
// Parameter to return if user cancelled a optional configuration dialog and
// there for cancelled the whole save procedure.
DBG_ASSERT( !bIsExport || bSaveTo, "Export mode should use SaveTo mechanics!\n" );
const SfxFilter* pFilt = NULL;
if ( pRequest->GetSlot() == SID_EXPORTDOCASPDF ||
pRequest->GetSlot() == SID_DIRECTEXPORTDOCASPDF )
{
// Preselect PDF-Filter for EXPORT
pFilt = GetFactory().GetFilterContainer()->GetFilter4Extension( String::CreateFromAscii( ".pdf" ), SFX_FILTER_EXPORT );
}
else
{
sal_uInt16 nActFilt = 0;
for( pFilt = GetFactory().GetFilter( 0 );
pFilt && ( !pFilt->CanExport()
|| bIsExport && pFilt->CanImport() // Export case ( only for GUI )
|| !bSaveTo && !pFilt->CanImport() // SaveAs case
|| pFilt->IsInternal() );
pFilt = GetFactory().GetFilter( ++nActFilt ) );
}
DBG_ASSERT( pFilt, "Kein Filter zum Speichern" );
if ( !pFilt )
return sal_False;
String aFilterName;
if( pFilt )
aFilterName = pFilt->GetFilterName();
SfxItemSet *pParams = new SfxAllItemSet( SFX_APP()->GetPool() );
SFX_REQUEST_ARG( (*pRequest), pFileNameItem, SfxStringItem, SID_FILE_NAME, sal_False );
if ( pRequest->GetArgs() )
pParams->Put( *pRequest->GetArgs() );
SfxItemSet* pMedSet = pMedium->GetItemSet();
SFX_ITEMSET_ARG( pMedSet, pOptionsItem, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
if ( pOptionsItem && pParams->GetItemState(SID_FILE_FILTEROPTIONS) != SFX_ITEM_SET )
pParams->Put( *pOptionsItem );
SFX_ITEMSET_ARG( pMedSet, pDataItem, SfxUsrAnyItem, SID_FILTER_DATA, sal_False );
if ( pDataItem && pParams->GetItemState(SID_FILTER_DATA) != SFX_ITEM_SET )
pParams->Put( *pDataItem );
sal_Bool bDialogUsed = sal_False;
sal_Bool bUseFilterOptions = sal_False;
Reference< XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
Reference< XNameAccess > xFilterCFG;
if( xServiceManager.is() )
{
xFilterCFG = Reference< XNameAccess >(
xServiceManager->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.document.FilterFactory" ) ),
UNO_QUERY );
}
if ( !pFileNameItem )
{
// we need to show the file dialog
bDialogUsed = sal_True;
if(! bUrl )
{
// check if we have a filter which allows for filter options, so we need a corresponding checkbox in the dialog
sal_Bool bAllowOptions = sal_False;
const SfxFilter* pFilter;
SfxFilterFlags nMust = SFX_FILTER_EXPORT | ( bSaveTo ? 0 : SFX_FILTER_IMPORT );
SfxFilterFlags nDont = SFX_FILTER_INTERNAL | SFX_FILTER_NOTINFILEDLG | ( bIsExport ? SFX_FILTER_IMPORT : 0 );
SfxFilterMatcher aMatcher( GetFactory().GetFilterContainer() );
SfxFilterMatcherIter aIter( &aMatcher, nMust, nDont );
if( !bIsExport )
{
// in case of Export, filter options dialog is used if available
for ( pFilter = aIter.First(); pFilter && !bAllowOptions; pFilter = aIter.Next() )
{
if( xFilterCFG.is() )
{
try {
Sequence < PropertyValue > aProps;
Any aAny = xFilterCFG->getByName( pFilter->GetName() );
if ( aAny >>= aProps )
{
::rtl::OUString aServiceName;
sal_Int32 nPropertyCount = aProps.getLength();
for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty )
if( aProps[nProperty].Name.equals( ::rtl::OUString::createFromAscii("UIComponent")) )
{
::rtl::OUString aServiceName;
aProps[nProperty].Value >>= aServiceName;
if( aServiceName.getLength() )
bAllowOptions = sal_True;
}
}
}
catch( Exception& )
{
}
}
}
}
// get the filename by dialog ...
// create the file dialog
sal_Int16 aDialogMode = bAllowOptions ?
::sfx2::FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS :
::sfx2::FILESAVE_AUTOEXTENSION_PASSWORD;
sal_uInt32 aDialogFlags = 0;
if( bIsExport )
{
aDialogMode = ::sfx2::FILESAVE_AUTOEXTENSION_SELECTION;
aDialogFlags = SFXWB_EXPORT;
}
sfx2::FileDialogHelper* pFileDlg = NULL;
if ( bIsPDFExport )
{
// Create file dialog for PDF export
pFileDlg = new PDFExportFileDialog( aDialogMode, aDialogFlags, ( pRequest->GetSlot() == SID_DIRECTEXPORTDOCASPDF ) );
String aFilterExtension = pFilt->GetWildcard()();
String aFilterUIName = pFilt->GetUIName();
pFileDlg->AddFilter( aFilterUIName, aFilterExtension );
pFileDlg->SetTitle( String( SfxResId( STR_EXPORTASPDF_TITLE )) );
pFileDlg->SetDialogHelpId( HID_FILEDLG_EXPORTASPDF );
pFileDlg->CreateMatcher( GetFactory() );
}
else if ( bIsExport )
{
// This is the normal dialog
SfxObjectFactory& rFact = GetFactory();
pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, rFact, nMust, nDont );
if( strcmp( rFact.GetShortName(), "sdraw" ) != 0 )
pFileDlg->SetContext( sfx2::FileDialogHelper::SD_EXPORT );
else if( strcmp( rFact.GetShortName(), "simpress" ) != 0 )
pFileDlg->SetContext( sfx2::FileDialogHelper::SI_EXPORT );
pFileDlg->CreateMatcher( rFact );
Reference< ::com::sun::star::ui::dialogs::XFilePicker > xFilePicker = pFileDlg->GetFilePicker();
Reference< ::com::sun::star::ui::dialogs::XFilePickerControlAccess > xControlAccess =
Reference< ::com::sun::star::ui::dialogs::XFilePickerControlAccess >( xFilePicker, UNO_QUERY );
if ( xControlAccess.is() )
{
String aResStr = String( SfxResId( STR_EXPORTBUTTON ));
::rtl::OUString aCtrlText = aResStr;
xControlAccess->setLabel( ::com::sun::star::ui::dialogs::CommonFilePickerElementIds::PUSHBUTTON_OK, aCtrlText );
aResStr = String( SfxResId( STR_LABEL_FILEFORMAT ));
aCtrlText = aResStr;
xControlAccess->setLabel( ::com::sun::star::ui::dialogs::CommonFilePickerElementIds::LISTBOX_FILTER_LABEL, aCtrlText );
}
}
else
{
// This is the normal dialog
pFileDlg = new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, GetFactory(), nMust, nDont );
pFileDlg->CreateMatcher( GetFactory() );
}
if ( HasName() )
{
String aLastName = QueryTitle( SFX_TITLE_QUERY_SAVE_NAME_PROPOSAL );
const SfxFilter* pMedFilter = GetMedium()->GetFilter();
if( pImp->bSetStandardName && !IsTemplate()
|| !pMedFilter
|| !pMedFilter->CanExport()
|| bIsExport && pMedFilter->CanImport() // Export case ( only for GUI )
|| !bSaveTo && !pMedFilter->CanImport() // SaveAs case
/*!!!|| pMedFilter->GetVersion() != SOFFICE_FILEFORMAT_CURRENT*/ )
{
if( aLastName.Len() )
{
String aPath( aLastName );
bool bWasAbsolute = sal_False;
INetURLObject aObj( SvtPathOptions().GetWorkPath() );
aObj.setFinalSlash();
aObj = INetURLObject( aObj.RelToAbs( aPath, bWasAbsolute ) );
aObj.SetExtension( pFilt->GetDefaultExtension().Copy(2) );
pFileDlg->SetDisplayDirectory( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
}
pFileDlg->SetCurrentFilter( pFilt->GetUIName() );
}
else
{
if( aLastName.Len() )
pFileDlg->SetDisplayDirectory( aLastName );
pFileDlg->SetCurrentFilter( pMedFilter->GetUIName() );
}
}
else
{
pFileDlg->SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
}
SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pPassItem, SfxStringItem, SID_PASSWORD, FALSE );
if ( pPassItem != NULL )
pParams->Put( SfxStringItem( SID_PASSWORD, ::rtl::OUString() ) );
if ( pFileDlg->Execute( pParams, aFilterName ) != ERRCODE_NONE )
{
SetError(ERRCODE_IO_ABORT);
delete pFileDlg;
return sal_False;
}
// get the path from the dialog
aURL.SetURL( pFileDlg->GetPath() );
// gibt es schon ein Doc mit dem Namen?
if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
{
SfxObjectShell* pDoc = 0;
for ( SfxObjectShell* pTmp = SfxObjectShell::GetFirst();
pTmp && !pDoc;
pTmp = SfxObjectShell::GetNext(*pTmp) )
{
if( ( pTmp != this ) && pTmp->GetMedium() )
{
INetURLObject aCompare( pTmp->GetMedium()->GetName() );
if ( aCompare == aURL )
pDoc = pTmp;
}
}
if ( pDoc )
{
// dann Fehlermeldeung: "schon offen"
SetError(ERRCODE_SFX_ALREADYOPEN);
delete pFileDlg;
return sal_False;
}
}
// old filter options should be cleared in case different filter is used
SFX_ITEMSET_ARG( pMedSet, pOldFilterNameItem, SfxStringItem, SID_FILTER_NAME, sal_False );
if ( !pOldFilterNameItem || pOldFilterNameItem->GetValue().CompareTo( aFilterName ) != COMPARE_EQUAL )
{
pParams->ClearItem( SID_FILTER_DATA );
pParams->ClearItem( SID_FILE_FILTEROPTIONS );
}
// --**-- pParams->Put( *pDlg->GetItemSet() );
Reference< XFilePickerControlAccess > xExtFileDlg( pFileDlg->GetFilePicker(), UNO_QUERY );
if ( xExtFileDlg.is() )
{
try
{
if( xFilterCFG.is() )
{
try {
Sequence < PropertyValue > aProps;
Any aAny = xFilterCFG->getByName( aFilterName );
if ( aAny >>= aProps )
{
::rtl::OUString aServiceName;
sal_Int32 nPropertyCount = aProps.getLength();
for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty )
if( aProps[nProperty].Name.equals( ::rtl::OUString::createFromAscii("UIComponent")) )
{
::rtl::OUString aServiceName;
aProps[nProperty].Value >>= aServiceName;
if( aServiceName.getLength() )
bUseFilterOptions = sal_True;
}
}
}
catch( Exception& )
{
}
}
if ( !bIsExport && bUseFilterOptions )
{
// for exporters: always show dialog if format uses options
// for save: show dialog if format uses options and no options given or if forced by user
Any aValue = xExtFileDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS, 0 );
aValue >>= bUseFilterOptions;
if ( !bUseFilterOptions )
bUseFilterOptions = pParams->GetItemState( SID_FILTER_DATA ) != SFX_ITEM_SET &&
pParams->GetItemState( SID_FILE_FILTEROPTIONS ) != SFX_ITEM_SET;
}
//pParams->Put( SfxBoolItem( SID_USE_FILTEROPTIONS, bUseFilterOptions ) );
}
catch( IllegalArgumentException ){}
}
delete pFileDlg;
}
else
{
SfxUrlDialog aDlg( 0 );
if( aDlg.Execute() == RET_OK )
aURL.SetURL( aDlg.GetUrl() );
else
{
SetError(ERRCODE_IO_ABORT);
return sal_False;
}
}
// merge in results of the dialog execution
pParams->Put( SfxStringItem( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE )) );
pParams->Put( SfxStringItem( SID_FILTER_NAME, aFilterName) );
// Request mit Dateiname und Filter vervollst"andigen
pRequest->AppendItem(SfxStringItem( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE )) );
pRequest->AppendItem(SfxStringItem( SID_FILTER_NAME, aFilterName));
const SfxPoolItem* pItem=0;
pRequest->GetArgs()->GetItemState( SID_FILE_NAME, sal_False, &pItem );
pFileNameItem = PTR_CAST( SfxStringItem, pItem );
}
// neuen Namen an der Object-Shell merken
SfxSaveAsContext_Impl aSaveAsCtx( pImp->aNewName, aURL.GetMainURL( INetURLObject::NO_DECODE ) );
// now we can get the filename from the SfxRequest
DBG_ASSERT( pRequest->GetArgs() != 0, "fehlerhafte Parameter");
if ( !pFileNameItem && bSaveTo )
{
bDialogUsed = sal_True;
// get the filename by dialog ...
// create the file dialog
sfx2::FileDialogHelper aFileDlg( ::sfx2::FILESAVE_AUTOEXTENSION_PASSWORD,
0L, GetFactory() );
SfxItemSet* pTempSet = NULL;
if ( aFileDlg.Execute( pParams, aFilterName ) != ERRCODE_NONE )
{
SetError(ERRCODE_IO_ABORT);
return sal_False;
}
// get the path from the dialog
aURL.SetURL( aFileDlg.GetPath() );
// merge in results of the dialog execution
if( pTempSet )
pParams->Put( *pTempSet );
// old filter options should be cleared in case different filter is used
SFX_ITEMSET_ARG( pMedSet, pOldFilterNameItem, SfxStringItem, SID_FILTER_NAME, sal_False );
if ( !pOldFilterNameItem || pOldFilterNameItem->GetValue().CompareTo( aFilterName ) != COMPARE_EQUAL )
{
pParams->ClearItem( SID_FILTER_DATA );
pParams->ClearItem( SID_FILE_FILTEROPTIONS );
}
pParams->Put( SfxStringItem( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE )) );
pParams->Put( SfxStringItem( SID_FILTER_NAME, aFilterName) );
pRequest->AppendItem(SfxStringItem( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE )) );
pRequest->AppendItem(SfxStringItem( SID_FILTER_NAME, aFilterName));
}
else if ( pFileNameItem )
{
aURL.SetURL(((const SfxStringItem *)pFileNameItem)->GetValue() );
DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "Illegal URL!" );
const SfxPoolItem* pFilterNameItem=0;
const SfxItemState eState = pRequest->GetArgs()->GetItemState(SID_FILTER_NAME, sal_True, &pFilterNameItem);
if ( SFX_ITEM_SET == eState )
{
DBG_ASSERT(pFilterNameItem->IsA( TYPE(SfxStringItem) ), "Fehler Parameter");
aFilterName = ((const SfxStringItem *)pFilterNameItem)->GetValue();
}
}
else
{
SetError( ERRCODE_IO_INVALIDPARAMETER );
return sal_False;
}
// check if a "SaveTo" is wanted, no "SaveAs"
sal_Bool bCopyTo = GetCreateMode() == SFX_CREATE_MODE_EMBEDDED || bSaveTo;
// because saving a document modified its DocumentInfo, the current DocumentInfo must be saved on "SaveTo", because
// it must be restored after saving
SfxDocumentInfo aSavedInfo;
if ( bCopyTo )
aSavedInfo = GetDocInfo();
// if it is defenitly SaveAs then update doc info
SfxBoolResetter aDocInfoReset( pImp->bDoNotTouchDocInfo );
SfxMedium *pActMed = GetMedium();
const INetURLObject aActName(pActMed->GetName());
// Don't show filter options dialog
if ( pRequest->GetSlot() == SID_DIRECTEXPORTDOCASPDF )
bSuppressFilterOptionsDialog = sal_True;
if( !bSuppressFilterOptionsDialog &&
( bSaveTo || bUseFilterOptions ))
{
// call filter dialog
if( xFilterCFG.is() )
{
try {
Sequence < PropertyValue > aProps;
Any aAny = xFilterCFG->getByName( aFilterName );
if ( aAny >>= aProps )
{
::rtl::OUString aServiceName;
sal_Int32 nPropertyCount = aProps.getLength();
for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty )
if( aProps[nProperty].Name.equals( ::rtl::OUString::createFromAscii("UIComponent")) )
{
::rtl::OUString aServiceName;
aProps[nProperty].Value >>= aServiceName;
if( aServiceName.getLength() )
{
Reference< XExecutableDialog > xFilterDialog( xServiceManager->createInstance( aServiceName ), UNO_QUERY );
Reference< XPropertyAccess > xFilterProperties( xFilterDialog, UNO_QUERY );
if( xFilterDialog.is() && xFilterProperties.is() )
{
bDialogUsed = sal_True;
Reference< XExporter > xExporter( xFilterDialog, UNO_QUERY );
if( xExporter.is() )
xExporter->setSourceDocument( Reference< XComponent >( GetModel(), UNO_QUERY ) );
Sequence< PropertyValue > aPropsForDialog;
TransformItems( pRequest->GetSlot(), *pParams, aPropsForDialog, NULL );
xFilterProperties->setPropertyValues( aPropsForDialog );
if( xFilterDialog->execute() )
{
SfxAllItemSet aNewParams( GetPool() );
TransformParameters( pRequest->GetSlot(),
xFilterProperties->getPropertyValues(),
aNewParams,
NULL );
pParams->Put( aNewParams );
}
else
{
SetError(ERRCODE_IO_ABORT);
return sal_False; // cancel
}
}
}
break;
}
}
}
catch( NoSuchElementException& )
{
// the filter name is unknown
SetError( ERRCODE_IO_INVALIDPARAMETER );
return sal_False;
}
catch( Exception& )
{
}
}
}
if ( aURL != aActName )
{
// this is defenitly not a Save
pImp->bIsSaving = sal_False; // here it's already clear
// ggf. DocInfo Dialog
if( bCopyTo && IsEnableSetModified() )
{
EnableSetModified( sal_False );
UpdateDocInfoForSave();
EnableSetModified( sal_True );
}
else
UpdateDocInfoForSave();
if ( eCreateMode == SFX_CREATE_MODE_STANDARD && 0 == ( pImp->eFlags & SFXOBJECTSHELL_NODOCINFO ) )
{
SvtSaveOptions aOptions;
if ( aOptions.IsDocInfoSave() )
{
DocInfoDlg_Impl( GetDocInfo() );
pImp->bDoNotTouchDocInfo = sal_True;
}
}
}
sal_Bool bOk = CommonSaveAs_Impl( aURL, aFilterName, pParams );
if ( bCopyTo )
{
// restore DocumentInfo if only a copy was created
SfxDocumentInfo &rDocInfo = GetDocInfo();
rDocInfo = aSavedInfo;
}
if( bOk )
{
const SfxFilter* pFilter = GetMedium()->GetFilter();
if ( bDialogUsed && pFilter
&& pFilter->IsOwnFormat()
&& pFilter->UsesStorage()
&& pFilter->GetVersion() >= SOFFICE_FILEFORMAT_60
)
{
SfxViewFrame* pDocViewFrame = SfxViewFrame::GetFirst( this );
SfxFrame* pDocFrame = pDocViewFrame ? pDocViewFrame->GetFrame() : NULL;
if ( pDocFrame )
SfxHelp::OpenHelpAgent( pDocFrame, HID_DID_SAVE_PACKED_XML );
}
return sal_True;
}
else
return sal_False;
}
//--------------------------------------------------------------------
void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
{
{DBG_CHKTHIS(SfxObjectShell, 0);}
pImp->bSetStandardName=FALSE;
USHORT nId = rReq.GetSlot();
if ( !GetMedium() && nId != SID_CLOSEDOC )
{
rReq.Ignore();
return;
}
if( nId == SID_SAVEDOC || nId == SID_UPDATEDOC )
{
// Embedded?
SfxInPlaceObject *pObj=GetInPlaceObject();
if( pObj && pObj->GetProtocol().IsEmbed() )
{
BOOL bRet = pObj->GetClient()->SaveObject();
rReq.SetReturnValue( SfxBoolItem(0, bRet) );
rReq.Done();
return;
}
SFX_REQUEST_ARG( rReq, pVersionItem, SfxStringItem, SID_DOCINFO_COMMENTS, FALSE);
if ( !IsModified() && !pVersionItem )
{
rReq.SetReturnValue( SfxBoolItem(0, FALSE) );
rReq.Done();
return;
}
}
SFX_REQUEST_ARG( rReq, pFileNameItem, SfxStringItem, SID_FILE_NAME, FALSE);
SFX_REQUEST_ARG( rReq, pFilterItem, SfxStringItem, SID_FILTER_NAME, FALSE);
const SfxFilter *pCurFilter = GetMedium()->GetFilter();
const SfxFilter *pDefFilter = GetFactory().GetFilter(0);
if ( nId == SID_SAVEDOC && pCurFilter && !pCurFilter->CanExport() && pDefFilter && pDefFilter->IsInternal() )
nId = SID_SAVEASDOC;
// in case of saving an interaction handler can be required for authentication
if ( nId == SID_SAVEDOC || nId == SID_SAVEASDOC || nId == SID_SAVEASURL || nId == SID_EXPORTDOC )
{
Reference< XInteractionHandler > xInteract;
SFX_REQUEST_ARG( rReq, pxInteractionItem, SfxUnoAnyItem, SID_INTERACTIONHANDLER, sal_False );
DBG_ASSERT( !pxInteractionItem || ( ( pxInteractionItem->GetValue() >>= xInteract ) && xInteract.is() ),
"Broken InteractionHandler!\n" );
if ( !pxInteractionItem )
{
Reference< XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
if( xServiceManager.is() )
{
xInteract = Reference< XInteractionHandler >(
xServiceManager->createInstance( DEFINE_CONST_UNICODE("com.sun.star.task.InteractionHandler") ),
UNO_QUERY );
rReq.AppendItem( SfxUnoAnyItem( SID_INTERACTIONHANDLER, makeAny( xInteract ) ) );
}
}
}
// interaktiv speichern via (nicht-Default) Filter?
if ( !pFilterItem && GetMedium()->GetFilter() && HasName() && (nId == SID_SAVEDOC || nId == SID_UPDATEDOC) )
{
// aktuellen und Default-Filter besorgen
// Filter kann nicht exportieren und Default-Filter ist verf"ugbar?
if ( !pCurFilter->CanExport() && !pDefFilter->IsInternal() )
{
// fragen, ob im default-Format gespeichert werden soll
String aWarn(SfxResId(STR_QUERY_MUSTOWNFORMAT));
aWarn = SearchAndReplace( aWarn, DEFINE_CONST_UNICODE( "$(FORMAT)" ),
GetMedium()->GetFilter()->GetUIName() );
aWarn = SearchAndReplace( aWarn, DEFINE_CONST_UNICODE( "$(OWNFORMAT)" ),
GetFactory().GetFilter(0)->GetUIName() );
QueryBox aWarnBox(0,WB_OK_CANCEL|WB_DEF_OK,aWarn);
if ( aWarnBox.Execute() == RET_OK )
{
// ja: Save-As in eigenem Foramt
rReq.SetSlot(nId = SID_SAVEASDOC);
pImp->bSetStandardName=TRUE;
}
else
{
// nein: Abbruch
rReq.Ignore();
return;
}
}
else
{
// fremdes Format mit m"oglichem Verlust (aber nicht per API) wenn noch nicht gewarnt und anschlieend im
// alien format gespeichert wurde
if ( !( pCurFilter->IsOwnFormat() && pCurFilter->GetVersion() == SOFFICE_FILEFORMAT_CURRENT || ( pCurFilter->GetFilterFlags() & SFX_FILTER_SILENTEXPORT ) )
&& ( !pImp->bDidWarnFormat || !pImp->bDidDangerousSave ) )
{
// Default-Format verf"ugbar?
if ( !pDefFilter->IsInternal() && pCurFilter != pDefFilter )
{
// fragen, ob im default-Format gespeichert werden soll
String aWarn(SfxResId(STR_QUERY_SAVEOWNFORMAT));
aWarn = SearchAndReplace( aWarn, DEFINE_CONST_UNICODE( "$(FORMAT)" ),
GetMedium()->GetFilter()->GetUIName());
aWarn = SearchAndReplace( aWarn, DEFINE_CONST_UNICODE( "$(OWNFORMAT)" ),
GetFactory().GetFilter(0)->GetUIName());
SfxViewFrame *pFrame = SfxObjectShell::Current() == this ?
SfxViewFrame::Current() : SfxViewFrame::GetFirst( this );
while ( pFrame && (pFrame->GetFrameType() & SFXFRAME_SERVER ) )
pFrame = SfxViewFrame::GetNext( *pFrame, this );
if ( pFrame )
{
SfxFrame* pTop = pFrame->GetTopFrame();
SFX_APP()->SetViewFrame( pTop->GetCurrentViewFrame() );
pFrame->GetFrame()->Appear();
QueryBox aWarnBox(&pFrame->GetWindow(),WB_YES_NO_CANCEL|WB_DEF_YES,aWarn);
switch(aWarnBox.Execute())
{
case RET_YES:
{
// ja: in Save-As umsetzen
rReq.SetSlot(nId = SID_SAVEASDOC);
SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pPassItem, SfxStringItem, SID_PASSWORD, FALSE );
if ( pPassItem )
rReq.AppendItem( *pPassItem );
pImp->bSetStandardName = TRUE;
break;
}
case RET_CANCEL:
// nein: Abbruch
rReq.Ignore();
return;
}
pImp->bDidWarnFormat=TRUE;
}
}
}
}
}
// Speichern eines namenslosen oder readonly Dokumentes
BOOL bMediumRO = IsReadOnlyMedium();
if ( ( nId == SID_SAVEDOC || nId == SID_UPDATEDOC ) && ( !HasName() || bMediumRO ) )
{
if ( pFileNameItem )
{
// FALSE zur"uckliefern
rReq.SetReturnValue( SfxBoolItem( 0, FALSE ) );
rReq.Done();
return;
}
else
{
// in SaveAs umwandlen
rReq.SetSlot(nId = SID_SAVEASDOC);
if ( SFX_APP()->IsPlugin() && !HasName() )
{
SFX_REQUEST_ARG( rReq, pWarnItem, SfxBoolItem, SID_FAIL_ON_WARNING, FALSE);
if ( pWarnItem && pWarnItem->GetValue() == TRUE )
{
// saving done from PrepareClose without UI
INetURLObject aObj( SvtPathOptions().GetWorkPath() );
aObj.insertName( GetTitle(), false, INetURLObject::LAST_SEGMENT, true, INetURLObject::ENCODE_ALL );
const SfxFilter* pFilter = GetFactory().GetFilter(0);
String aExtension( pFilter->GetDefaultExtension().Copy(2) );
aObj.setExtension( aExtension, INetURLObject::LAST_SEGMENT, true, INetURLObject::ENCODE_ALL );
rReq.AppendItem( SfxStringItem( SID_FILE_NAME, aObj.GetMainURL( INetURLObject::NO_DECODE ) ) );
rReq.AppendItem( SfxBoolItem( SID_RENAME, TRUE ) );
}
}
}
}
switch(nId)
{
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case SID_SAVE_VERSION_ON_CLOSE:
{
BOOL bSet = GetDocInfo().IsSaveVersionOnClose();
SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, nId, FALSE);
if ( pItem )
bSet = pItem->GetValue();
GetDocInfo().SetSaveVersionOnClose( bSet );
SetModified( TRUE );
if ( !pItem )
rReq.AppendItem( SfxBoolItem( nId, bSet ) );
rReq.Done();
return;
break;
}
case SID_VERSION:
{
SfxViewFrame* pFrame = GetFrame();
if ( !pFrame )
pFrame = SfxViewFrame::GetFirst( this );
if ( !pFrame )
return;
if ( pFrame->GetFrame()->GetParentFrame() )
{
pFrame->GetTopViewFrame()->GetObjectShell()->ExecuteSlot( rReq );
return;
}
if ( !IsOwnStorageFormat_Impl( *GetMedium() ) )
return;
SfxVersionDialog *pDlg = new SfxVersionDialog( pFrame, NULL );
pDlg->Execute();
delete pDlg;
return;
break;
}
case SID_LOAD_LIBRARY:
case SID_UNLOAD_LIBRARY:
case SID_REMOVE_LIBRARY:
case SID_ADD_LIBRARY:
{
// Diese Funktionen sind nur f"ur Aufrufe aus dem Basic gedacht
SfxApplication *pApp = SFX_APP();
if ( pApp->IsInBasicCall() )
pApp->BasicLibExec_Impl( rReq, GetBasicManager() );
return;
break;
}
case SID_SAVEDOC:
{
//!! detaillierte Auswertung eines Fehlercodes
SfxObjectShellRef xLock( this );
SfxErrorContext aEc(ERRCTX_SFX_SAVEDOC,GetTitle());
SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_SAVEDOC,this));
BOOL bOk = Save_Impl( rReq.GetArgs() );
ULONG lErr=GetErrorCode();
if( !lErr && !bOk )
lErr=ERRCODE_IO_GENERAL;
if ( lErr && bOk )
{
SFX_REQUEST_ARG( rReq, pWarnItem, SfxBoolItem, SID_FAIL_ON_WARNING, FALSE);
if ( pWarnItem && pWarnItem->GetValue() )
bOk = FALSE;
}
if( !ErrorHandler::HandleError( lErr ) )
SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEFINISHED, this ) );
ResetError();
rReq.SetReturnValue( SfxBoolItem(0, bOk) );
if ( bOk )
SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_SAVEDOCDONE,this));
break;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case SID_UPDATEDOC:
{
return;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case SID_DOCINFO:
{
SFX_REQUEST_ARG(rReq, pDocInfItem, SfxDocumentInfoItem, SID_DOCINFO, FALSE);
// keine Parameter vorhanden?
if ( !pDocInfItem )
{
// Dialog ausf"uhren
SfxDocumentInfo *pOldInfo = new SfxDocumentInfo;
if ( pImp->pDocInfo )
// r/o-flag korrigieren falls es zu frueh gesetzt wurde
pImp->pDocInfo->SetReadOnly( IsReadOnly() );
*pOldInfo = GetDocInfo();
DocInfoDlg_Impl( GetDocInfo() );
// ge"andert?
if( !(*pOldInfo == GetDocInfo()) )
{
// Dokument gilt als ver"andert
FlushDocInfo();
// ggf. Recorden
if ( !rReq.IsRecording() )
rReq.AppendItem( SfxDocumentInfoItem( GetTitle(), GetDocInfo() ) );
rReq.Done();
}
else
rReq.Ignore();
delete pOldInfo;
}
else
{
// DocInfo aus Parameter anwenden
GetDocInfo() = (*pDocInfItem)();
FlushDocInfo();
}
return;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case SID_EXPORTDOC:
case SID_EXPORTDOCASPDF:
case SID_DIRECTEXPORTDOCASPDF:
rReq.AppendItem( SfxBoolItem( SID_SAVETO, sal_True ) );
// another part is pretty the same as for SID_SAVEASDOC
case SID_SAVEASURL:
case SID_SAVEASDOC:
{
//!! detaillierte Auswertung eines Fehlercodes
SfxObjectShellRef xLock( this );
SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC,GetTitle());
// Bei Calls "uber StarOne OverWrite-Status checken
SFX_REQUEST_ARG( rReq, pOverwriteItem, SfxBoolItem, SID_OVERWRITE, FALSE );
if ( pOverwriteItem )
{
// because there is no "exist" function, the overwrite handling is done in the SfxMedium
SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, SID_FILE_NAME, FALSE );
if ( !pItem )
// In diesem Falle mu\s ein Dateiname mitkommen
SetError( ERRCODE_IO_INVALIDPARAMETER );
}
BOOL bOk = GUISaveAs_Impl(nId == SID_SAVEASURL, &rReq);
ULONG lErr=GetErrorCode();
if ( !lErr && !bOk )
lErr=ERRCODE_IO_GENERAL;
if ( lErr && bOk )
{
SFX_REQUEST_ARG( rReq, pWarnItem, SfxBoolItem, SID_FAIL_ON_WARNING, FALSE );
if ( pWarnItem && pWarnItem->GetValue() )
bOk = FALSE;
}
if ( lErr!=ERRCODE_IO_ABORT )
ErrorHandler::HandleError(lErr);
if ( nId == SID_EXPORTDOCASPDF )
{
// This function is used by the SendMail function that needs information if a export
// file was written or not. This could be due to cancellation of the export
// or due to an error. So IO abort must be handled like an error!
bOk = ( lErr != ERRCODE_IO_ABORT ) & bOk;
}
rReq.SetReturnValue( SfxBoolItem(0, bOk) );
ResetError();
Invalidate();
break;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case SID_CLOSEDOC:
{
SfxViewFrame *pFrame = GetFrame();
if ( pFrame && pFrame->GetFrame()->GetParentFrame() )
{
// Wenn SID_CLOSEDOC "uber Menue etc. ausgef"uhrt wird, das
// aktuelle Dokument aber in einem Frame liegt, soll eigentlich
// das FrameSetDocument geclosed werden
pFrame->GetTopViewFrame()->GetObjectShell()->ExecuteSlot( rReq );
rReq.Done();
return;
}
BOOL bInFrameSet = FALSE;
USHORT nFrames=0;
pFrame = SfxViewFrame::GetFirst( this );
while ( pFrame )
{
if ( pFrame->GetFrame()->GetParentFrame() )
{
// Auf dieses Dokument existiert noch eine Sicht, die
// in einem FrameSet liegt; diese darf nat"urlich nicht
// geclosed werden
bInFrameSet = TRUE;
}
else
nFrames++;
pFrame = SfxViewFrame::GetNext( *pFrame, this );
}
if ( bInFrameSet )
{
// Alle Sichten, die nicht in einem FrameSet liegen, closen
pFrame = SfxViewFrame::GetFirst( this );
while ( pFrame )
{
if ( !pFrame->GetFrame()->GetParentFrame() )
pFrame->GetFrame()->DoClose();
pFrame = SfxViewFrame::GetNext( *pFrame, this );
}
}
// Parameter auswerten
SFX_REQUEST_ARG(rReq, pSaveItem, SfxBoolItem, SID_CLOSEDOC_SAVE, FALSE);
SFX_REQUEST_ARG(rReq, pNameItem, SfxStringItem, SID_CLOSEDOC_FILENAME, FALSE);
if ( pSaveItem )
{
if ( pSaveItem->GetValue() )
{
if ( !pNameItem )
{
SbxBase::SetError( SbxERR_WRONG_ARGS );
rReq.Ignore();
return;
}
SfxAllItemSet aArgs( GetPool() );
SfxStringItem aTmpItem( SID_FILE_NAME, pNameItem->GetValue() );
aArgs.Put( aTmpItem, aTmpItem.Which() );
SfxRequest aSaveAsReq( SID_SAVEASDOC, SFX_CALLMODE_API, aArgs );
ExecFile_Impl( aSaveAsReq );
if ( !aSaveAsReq.IsDone() )
{
rReq.Ignore();
return;
}
}
else
SetModified(FALSE);
}
// Benutzer bricht ab?
if ( !PrepareClose( 2 ) )
{
rReq.SetReturnValue( SfxBoolItem(0, FALSE) );
rReq.Done();
return;
}
SetModified( FALSE );
ULONG lErr = GetErrorCode();
ErrorHandler::HandleError(lErr);
rReq.SetReturnValue( SfxBoolItem(0, TRUE) );
rReq.Done();
rReq.ReleaseArgs(); // da der Pool in Close zerst"ort wird
if ( SfxApplication::IsPlugin() )
{
for ( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, this ) )
{
String aName = String::CreateFromAscii("vnd.sun.star.cmd:close");
SfxStringItem aNameItem( SID_FILE_NAME, aName );
SfxStringItem aReferer( SID_REFERER, DEFINE_CONST_UNICODE( "private/user" ) );
SfxFrameItem aFrame( SID_DOCFRAME, pFrame->GetFrame() );
SFX_APP()->GetAppDispatcher_Impl()->Execute( SID_OPENDOC, SFX_CALLMODE_SLOT, &aNameItem, &aReferer, 0L );
return;
}
}
/*
com::sun::star::uno::Reference < ::com::sun::star::frame::XFramesSupplier >
xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
com::sun::star::uno::UNO_QUERY );
com::sun::star::uno::Reference < ::com::sun::star::container::XIndexAccess > xList ( xDesktop->getFrames(), ::com::sun::star::uno::UNO_QUERY );
sal_Int32 nCount = xList->getCount();
if ( nCount == nFrames )
{
SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
SfxViewFrame* pLastFrame = SfxViewFrame::Current();
if ( pLastFrame->GetObjectShell() != this )
pLastFrame = pFrame;
SfxViewFrame* pNextFrame = pFrame;
while ( pNextFrame )
{
pNextFrame = SfxViewFrame::GetNext( *pFrame, this );
if ( pFrame != pLastFrame )
pFrame->GetFrame()->DoClose();
pFrame = pNextFrame;
}
pLastFrame->GetFrame()->CloseDocument_Impl();
}
else
*/
DoClose();
return;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case SID_DOCTEMPLATE:
{
// speichern als Dokumentvorlagen
SfxDocumentTemplateDlg *pDlg = 0;
SfxErrorContext aEc(ERRCTX_SFX_DOCTEMPLATE,GetTitle());
SfxDocumentTemplates *pTemplates = new SfxDocumentTemplates;
// Find the template filter with the highest version number
const SfxFilter* pFilter;
const SfxObjectFactory& rFactory = GetFactory();
USHORT nFilterCount = rFactory.GetFilterCount();
ULONG nVersion = 0;
int n;
for( n=0; n<nFilterCount; n++)
{
const SfxFilter* pTemp = rFactory.GetFilter( n );
if( pTemp && pTemp->IsOwnFormat() &&
pTemp->IsOwnTemplateFormat() &&
( pTemp->GetVersion() > nVersion ) )
{
pFilter = pTemp;
nVersion = pTemp->GetVersion();
}
}
DBG_ASSERT( pFilter, "Template Filter nicht gefunden" );
if( !pFilter )
pFilter = rFactory.GetFilter(0);
if ( !rReq.GetArgs() )
{
pDlg = new SfxDocumentTemplateDlg(0, pTemplates);
if ( RET_OK == pDlg->Execute() && pDlg->GetTemplateName().Len())
{
String aTargetURL = pTemplates->GetTemplatePath(
pDlg->GetRegion(),
pDlg->GetTemplateName());
if ( aTargetURL.Len() )
{
INetURLObject aTargetObj( aTargetURL );
String aTplExtension( pFilter->GetDefaultExtension().Copy(2) );
aTargetObj.setExtension( aTplExtension );
aTargetURL = aTargetObj.GetMainURL( INetURLObject::NO_DECODE );
}
rReq.AppendItem( SfxStringItem( SID_FILE_NAME, aTargetURL ) );
rReq.AppendItem(SfxStringItem(
SID_TEMPLATE_NAME, pDlg->GetTemplateName()));
rReq.AppendItem(SfxUInt16Item(
SID_TEMPLATE_REGION, pDlg->GetRegion()));
}
else
{
delete pDlg;
rReq.Ignore();
return;
}
}
// Region und Name aus Parameter holen
SFX_REQUEST_ARG(rReq, pRegionItem, SfxStringItem, SID_TEMPLATE_REGIONNAME, FALSE);
SFX_REQUEST_ARG(rReq, pNameItem, SfxStringItem, SID_TEMPLATE_NAME, FALSE);
SFX_REQUEST_ARG(rReq, pRegionNrItem, SfxUInt16Item, SID_TEMPLATE_REGION, FALSE);
if ( (!pRegionItem && !pRegionNrItem ) || !pNameItem )
{
DBG_ASSERT( rReq.IsAPI(), "non-API call without Arguments" );
SbxBase::SetError( SbxERR_WRONG_ARGS );
rReq.Ignore();
return;
}
String aTemplateName = pNameItem->GetValue();
// Region-Nr besorgen
USHORT nRegion;
if( pRegionItem )
{
// Region-Name finden (eigentlich nicht unbedingt eindeutig)
nRegion = pTemplates->GetRegionNo( pRegionItem->GetValue() );
if ( nRegion == USHRT_MAX )
{
SbxBase::SetError( ERRCODE_IO_INVALIDPARAMETER );
rReq.Ignore();
return;
}
}
if ( pRegionNrItem )
nRegion = pRegionNrItem->GetValue();
// kein File-Name angegeben?
if ( SFX_ITEM_SET != rReq.GetArgs()->GetItemState( SID_FILE_NAME ) )
{
// TemplatePath nicht angebgeben => aus Region+Name ermitteln
// Dateiname zusammenbauen lassen
String aTemplPath = pTemplates->GetTemplatePath( nRegion, aTemplateName );
INetURLObject aURLObj( aTemplPath );
String aExtension( pFilter->GetDefaultExtension().Copy(2) );
aURLObj.setExtension( aExtension, INetURLObject::LAST_SEGMENT, true, INetURLObject::ENCODE_ALL );
rReq.AppendItem( SfxStringItem( SID_FILE_NAME, aURLObj.GetMainURL( INetURLObject::NO_DECODE ) ) );
}
// Dateiname
SFX_REQUEST_ARG(rReq, pFileItem, SfxStringItem, SID_FILE_NAME, FALSE);
const String aFileName(((const SfxStringItem *)pFileItem)->GetValue());
// Medium zusammenbauen
SfxItemSet* pSet = new SfxAllItemSet( *rReq.GetArgs() );
SfxMedium aMedium( aFileName, STREAM_STD_READWRITE, FALSE, pFilter, pSet);
// als Vorlage speichern
BOOL bModified = IsModified();
BOOL bHasTemplateConfig = HasTemplateConfig();
SetTemplateConfig( FALSE );
BOOL bOK = FALSE;
const String aOldURL( INetURLObject::GetBaseURL() );
if( ShallSetBaseURL_Impl( aMedium ) )
INetURLObject::SetBaseURL( aMedium.GetBaseURL() );
else
INetURLObject::SetBaseURL( String() );
aMedium.CreateTempFileNoCopy();
// Because we can't save into a storage directly ( only using tempfile ), we must save the DocInfo first, then
// we can call SaveTo_Impl and Commit
if ( pFilter->UsesStorage() && ( pFilter->GetVersion() < SOFFICE_FILEFORMAT_60 ) )
{
SfxDocumentInfo *pInfo = new SfxDocumentInfo;
pInfo->CopyUserData(GetDocInfo());
pInfo->SetTitle( aTemplateName );
pInfo->SetChanged( SfxStamp(SvtUserOptions().GetFullName()));
SvStorageRef aRef = aMedium.GetStorage();
if ( aRef.Is() )
{
pInfo->SetTime(0L);
pInfo->Save(aRef);
}
delete pInfo;
}
if ( SaveTo_Impl(aMedium,NULL,FALSE) )
{
bOK = TRUE;
pTemplates->NewTemplate( nRegion, aTemplateName, aFileName );
}
INetURLObject::SetBaseURL( aOldURL );
DELETEX(pDlg);
SetError(aMedium.GetErrorCode());
ULONG lErr=GetErrorCode();
if(!lErr && !bOK)
lErr=ERRCODE_IO_GENERAL;
ErrorHandler::HandleError(lErr);
ResetError();
delete pTemplates;
DoSaveCompleted();
SetTemplateConfig( bHasTemplateConfig );
SetModified(bModified);
rReq.SetReturnValue( SfxBoolItem( 0, bOK ) );
if ( !bOK )
return;
break;
}
}
// Picklisten-Eintrag verhindern
if ( rReq.IsAPI() )
GetMedium()->SetUpdatePickList( FALSE );
else if ( rReq.GetArgs() )
{
SFX_ITEMSET_GET( *rReq.GetArgs(), pPicklistItem, SfxBoolItem, SID_PICKLIST, FALSE );
if ( pPicklistItem )
GetMedium()->SetUpdatePickList( pPicklistItem->GetValue() );
}
// Ignore()-Zweige haben schon returnt
rReq.Done();
}
//--------------------------------------------------------------------
void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
{
DBG_CHKTHIS(SfxObjectShell, 0);
SfxWhichIter aIter( rSet );
SfxInPlaceObject *pObj=GetInPlaceObject();
for ( USHORT nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich() )
{
switch ( nWhich )
{
case SID_SAVE_VERSION_ON_CLOSE:
{
rSet.Put( SfxBoolItem( nWhich, GetDocInfo().IsSaveVersionOnClose() ) );
break;
}
case SID_DOCTEMPLATE :
{
if ( !GetFactory().GetTemplateFilter() )
rSet.DisableItem( nWhich );
break;
}
case SID_VERSION:
{
SfxObjectShell *pDoc = this;
SfxViewFrame* pFrame = GetFrame();
if ( !pFrame )
pFrame = SfxViewFrame::GetFirst( this );
if ( pFrame )
{
if ( pFrame->GetFrame()->GetParentFrame() )
{
pFrame = pFrame->GetTopViewFrame();
pDoc = pFrame->GetObjectShell();
}
}
if ( !pFrame || !pDoc->HasName() ||
!IsOwnStorageFormat_Impl( *pDoc->GetMedium() ) ||
pDoc->GetMedium()->GetStorage()->GetVersion() < SOFFICE_FILEFORMAT_50 )
rSet.DisableItem( nWhich );
break;
}
case SID_SAVEDOC:
case SID_UPDATEDOC:
if (pObj && pObj->GetProtocol().IsEmbed())
{
String aEntry (SfxResId(STR_UPDATEDOC));
aEntry += ' ';
aEntry += GetInPlaceObject()->GetDocumentName();
rSet.Put(SfxStringItem(nWhich, aEntry));
}
else
{
BOOL bMediumRO = IsReadOnlyMedium();
if ( !bMediumRO && GetMedium() && IsModified() )
rSet.Put(SfxStringItem(
nWhich, String(SfxResId(STR_SAVEDOC))));
else
rSet.DisableItem(nWhich);
}
break;
case SID_DOCINFO:
if ( 0 != ( pImp->eFlags & SFXOBJECTSHELL_NODOCINFO ) )
rSet.DisableItem( nWhich );
break;
case SID_CLOSEDOC:
{
SfxObjectShell *pDoc = this;
SfxViewFrame *pFrame = GetFrame();
if ( pFrame && pFrame->GetFrame()->GetParentFrame() )
{
// Wenn SID_CLOSEDOC "uber Menue etc. ausgef"uhrt wird, das
// aktuelle Dokument aber in einem Frame liegt, soll eigentlich
// das FrameSetDocument geclosed werden
pDoc = pFrame->GetTopViewFrame()->GetObjectShell();
}
if ( pDoc->GetFlags() & SFXOBJECTSHELL_DONTCLOSE )
rSet.DisableItem(nWhich);
else if ( pObj && pObj->GetProtocol().IsEmbed() )
{
String aEntry (SfxResId(STR_CLOSEDOC_ANDRETURN));
aEntry += pObj->GetDocumentName();
rSet.Put( SfxStringItem(nWhich, aEntry) );
}
else
rSet.Put(SfxStringItem(nWhich, String(SfxResId(STR_CLOSEDOC))));
break;
}
case SID_SAVEASDOC:
{
if( ( pImp->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ) != SFX_LOADED_MAINDOCUMENT )
{
rSet.DisableItem( nWhich );
break;
}
if ( !GetMedium() )
rSet.DisableItem(nWhich);
else if ( pObj && pObj->GetProtocol().IsEmbed() )
rSet.Put( SfxStringItem( nWhich, String( SfxResId( STR_SAVECOPYDOC ) ) ) );
else
rSet.Put( SfxStringItem( nWhich, String( SfxResId( STR_SAVEASDOC ) ) ) );
break;
}
case SID_EXPORTDOCASPDF:
case SID_DIRECTEXPORTDOCASPDF:
{
SfxFactoryFilterContainer* pFilterContainer = GetFactory().GetFilterContainer();
if ( pFilterContainer )
{
String aPDFExtension = String::CreateFromAscii( ".pdf" );
const SfxFilter* pFilter = pFilterContainer->GetFilter4Extension( aPDFExtension, SFX_FILTER_EXPORT );
if ( pFilter != NULL )
break;
}
rSet.DisableItem( nWhich );
break;
}
case SID_DOC_MODIFIED:
{
rSet.Put( SfxStringItem( SID_DOC_MODIFIED, IsModified() ? '*' : ' ' ) );
break;
}
case SID_MODIFIED:
{
rSet.Put( SfxBoolItem( SID_MODIFIED, IsModified() ) );
break;
}
case SID_DOCINFO_TITLE:
{
rSet.Put( SfxStringItem(
SID_DOCINFO_TITLE, GetDocInfo().GetTitle() ) );
break;
}
case SID_FILE_NAME:
{
if( GetMedium() && HasName() )
rSet.Put( SfxStringItem(
SID_FILE_NAME, GetMedium()->GetName() ) );
break;
}
}
}
}
//--------------------------------------------------------------------
void SfxObjectShell::ExecProps_Impl(SfxRequest &rReq)
{
switch ( rReq.GetSlot() )
{
case SID_MODIFIED:
{
SetModified( ( (SfxBoolItem&) rReq.GetArgs()->Get(SID_MODIFIED)).GetValue() );
rReq.Done();
break;
}
case SID_DOCTITLE:
SetTitle( ( (SfxStringItem&) rReq.GetArgs()->Get(SID_DOCTITLE)).GetValue() );
rReq.Done();
break;
case SID_ON_CREATEDOC:
case SID_ON_OPENDOC:
case SID_ON_PREPARECLOSEDOC:
case SID_ON_CLOSEDOC:
case SID_ON_SAVEDOC:
case SID_ON_SAVEASDOC:
case SID_ON_ACTIVATEDOC:
case SID_ON_DEACTIVATEDOC:
case SID_ON_PRINTDOC:
case SID_ON_SAVEDOCDONE:
case SID_ON_SAVEASDOCDONE:
SFX_APP()->EventExec_Impl( rReq, this );
break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case SID_PLAYMACRO:
{
SFX_APP()->PlayMacro_Impl( rReq, GetBasic() );
break;
}
case SID_DOCINFO_AUTHOR :
{
String aStr = ( (SfxStringItem&)rReq.GetArgs()->Get(rReq.GetSlot())).GetValue();
SfxStamp aStamp( GetDocInfo().GetCreated() );
aStamp.SetName( aStr );
GetDocInfo().SetCreated( aStamp );
break;
}
case SID_DOCINFO_COMMENTS :
{
String aStr = ( (SfxStringItem&)rReq.GetArgs()->Get(rReq.GetSlot())).GetValue();
GetDocInfo().SetComment( aStr );
break;
}
case SID_DOCINFO_KEYWORDS :
{
String aStr = ( (SfxStringItem&)rReq.GetArgs()->Get(rReq.GetSlot())).GetValue();
GetDocInfo().SetKeywords( aStr );
break;
}
}
}
//--------------------------------------------------------------------
void SfxObjectShell::StateProps_Impl(SfxItemSet &rSet)
{
SfxWhichIter aIter(rSet);
for ( USHORT nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
{
switch ( nSID )
{
case SID_DOCINFO_AUTHOR :
{
String aStr = GetDocInfo().GetCreated().GetName();
rSet.Put( SfxStringItem( nSID, aStr ) );
break;
}
case SID_DOCINFO_COMMENTS :
{
String aStr = GetDocInfo().GetComment();
rSet.Put( SfxStringItem( nSID, aStr ) );
break;
}
case SID_DOCINFO_KEYWORDS :
{
String aStr = GetDocInfo().GetKeywords();
rSet.Put( SfxStringItem( nSID, aStr ) );
break;
}
case SID_DOCPATH:
{
DBG_ERROR( "Not supported anymore!" );
break;
}
case SID_DOCFULLNAME:
{
rSet.Put( SfxStringItem( SID_DOCFULLNAME, GetTitle(SFX_TITLE_FULLNAME) ) );
break;
}
case SID_DOCTITLE:
{
rSet.Put( SfxStringItem( SID_DOCTITLE, GetTitle() ) );
break;
}
case SID_DOC_READONLY:
{
rSet.Put( SfxBoolItem( SID_DOC_READONLY, IsReadOnly() ) );
break;
}
case SID_DOC_SAVED:
{
rSet.Put( SfxBoolItem( SID_DOC_SAVED, !IsModified() ) );
break;
}
case SID_CLOSING:
{
rSet.Put( SfxBoolItem( SID_CLOSING, Get_Impl()->bInCloseEvent ) );
break;
}
case SID_ON_CREATEDOC:
case SID_ON_OPENDOC:
case SID_ON_PREPARECLOSEDOC:
case SID_ON_CLOSEDOC:
case SID_ON_SAVEDOC:
case SID_ON_SAVEASDOC:
case SID_ON_ACTIVATEDOC:
case SID_ON_DEACTIVATEDOC:
case SID_ON_PRINTDOC:
case SID_ON_SAVEDOCDONE:
case SID_ON_SAVEASDOCDONE:
SFX_APP()->EventState_Impl( nSID, rSet, this );
break;
case SID_DOC_LOADING:
rSet.Put( SfxBoolItem( nSID, SFX_LOADED_MAINDOCUMENT !=
( pImp->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ) ) );
break;
case SID_IMG_LOADING:
rSet.Put( SfxBoolItem( nSID, SFX_LOADED_IMAGES !=
( pImp->nLoadedFlags & SFX_LOADED_IMAGES ) ) );
break;
}
}
}
//--------------------------------------------------------------------
void SfxObjectShell::ExecView_Impl(SfxRequest &rReq)
{
switch ( rReq.GetSlot() )
{
case SID_ACTIVATE:
{
SfxViewFrame *pFrame =
SfxViewFrame::GetFirst( this, TYPE(SfxTopViewFrame), TRUE );
if ( pFrame )
pFrame->GetFrame()->Appear();
rReq.SetReturnValue( SfxObjectItem( 0, pFrame ) );
rReq.Done();
break;
}
case SID_NEWWINDOWFOREDIT:
{
SfxViewFrame* pFrame = SfxViewFrame::Current();
if( pFrame->GetObjectShell() == this &&
( pFrame->GetFrameType() & SFXFRAME_HASTITLE ) )
pFrame->ExecuteSlot( rReq );
else
{
String aFileName( GetObjectShell()->GetMedium()->GetName() );
if ( aFileName.Len() )
{
SfxStringItem aName( SID_FILE_NAME, aFileName );
SfxBoolItem aCreateView( SID_OPEN_NEW_VIEW, TRUE );
SFX_APP()->GetAppDispatcher_Impl()->Execute(
SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aName,
&aCreateView, 0L);
}
}
}
}
}
//--------------------------------------------------------------------
void SfxObjectShell::StateView_Impl(SfxItemSet &rSet)
{
}
|