summaryrefslogtreecommitdiff
path: root/binfilter/bf_sfx2/source/doc/sfx2_objstor.cxx
blob: dfba43054cbbfd7a35e4ac507efc770a81b2d432 (plain)
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
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#include <bf_svtools/eitem.hxx>
#include <bf_svtools/stritem.hxx>
#include <bf_so3/svstor.hxx>
#include <tools/zcodec.hxx>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/frame/XFrame.hpp>

#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/document/FilterOptionsRequest.hpp>
#include <com/sun/star/document/XInteractionFilterOptions.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>

#include <com/sun/star/lang/XInitialization.hpp>

#include <com/sun/star/document/MacroExecMode.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>

#include <com/sun/star/lang/XMultiServiceFactory.hpp>

#include <com/sun/star/beans/XPropertyAccess.hpp>

#include <com/sun/star/beans/PropertyValue.hpp>

#include <com/sun/star/container/XNameAccess.hpp>

#include <comphelper/processfactory.hxx>

#ifdef _MSC_VER
#pragma hdrstop
#endif
#include <bf_svtools/itemset.hxx>

#include <bf_svtools/sfxecode.hxx>

#include <cppuhelper/weak.hxx>
#include <comphelper/processfactory.hxx>

#include <comphelper/classids.hxx>
#include <tools/cachestr.hxx>
#include <bf_svtools/addxmltostorageoptions.hxx>
#include <unotools/streamwrap.hxx>

#include <bf_svtools/saveopt.hxx>
#include <bf_svtools/useroptions.hxx>
#include <bf_svtools/pathoptions.hxx>
#include <tools/urlobj.hxx>
#include <unotools/localfilehelper.hxx>
#include <unotools/ucbhelper.hxx>
#include <unotools/tempfile.hxx>
#include <ucbhelper/content.hxx>
#include <sot/storinfo.hxx>

#include "objsh.hxx"
#include "request.hxx"
#include "docfile.hxx"
#include "fltfnc.hxx"
#include "docfilt.hxx"
#include "docinf.hxx"
#include "docfac.hxx"
#include "cfgmgr.hxx"
#include "objshimp.hxx"
#include "sfxtypes.hxx"
#include "appdata.hxx"
#include "sfxsids.hrc"
#include "interno.hxx"
#include "module.hxx"
#include "app.hxx"
#include "openflag.hxx"
#include "helper.hxx"
#include "dlgcont.hxx"
#include "appuno.hxx"

#include "bf_basic/basmgr.hxx"

#include "scriptcont.hxx"
#include "event.hxx"
#include "fltoptint.hxx"

#include <legacysmgr/legacy_binfilters_smgr.hxx>	//STRIP002
#include "bf_so3/staticbaseurl.hxx"
namespace binfilter {

#define S2BS(s) ByteString( s, RTL_TEXTENCODING_MS_1252 )


extern sal_uInt32 CheckPasswd_Impl( SfxObjectShell*, SfxItemPool&, SfxMedium* );


using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
//using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::document;
using namespace ::rtl;
using namespace ::cppu;

//=========================================================================

/*N*/ sal_Bool ShallSetBaseURL_Impl( SfxMedium &rMed )
/*N*/ {
/*N*/     SvtSaveOptions aOpt;
/*N*/ 	sal_Bool bIsRemote = rMed.IsRemote();
/*N*/     return  aOpt.IsSaveRelINet() && bIsRemote || aOpt.IsSaveRelFSys() && !bIsRemote;
/*N*/ }

//=========================================================================

/*N*/ sal_Bool SfxObjectShell::Save()
/*N*/ {
/*N*/     if( SOFFICE_FILEFORMAT_60 <= GetStorage()->GetVersion() )
/*N*/         return sal_True;
/*N*/     else
/*N*/         return SaveInfoAndConfig_Impl( GetMedium()->GetStorage() );
/*N*/ }

//--------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::SaveAs( SvStorage* pNewStg )
/*N*/ {
/*N*/     if( SOFFICE_FILEFORMAT_60 <= pNewStg->GetVersion() )
/*N*/         return sal_True;
/*N*/     else
/*N*/         return SaveInfoAndConfig_Impl( pNewStg );
/*N*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool GetPasswd_Impl( const SfxItemSet* pSet, String& rPasswd )
/*N*/ {
/*N*/ 	const SfxPoolItem* pItem = NULL;
/*N*/ 	if ( pSet && SFX_ITEM_SET == pSet->GetItemState( SID_PASSWORD, sal_True, &pItem ) )
/*N*/ 	{
/*?*/ 		DBG_ASSERT( pItem->IsA( TYPE(SfxStringItem) ), "wrong item type" );
/*?*/ 		rPasswd = ( (const SfxStringItem*)pItem )->GetValue();
/*?*/ 		return sal_True;
/*N*/ 	}
/*N*/ 	return sal_False;
/*N*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::DoInitNew( SvStorage * pStor )

/*  [Beschreibung]

    Diese von SvPersist geerbte virtuelle Methode wird gerufen, um
    die SfxObjectShell-Instanz aus einem Storage (pStor != 0) bzw.
    (pStor == 0) ganz neu zu initialisieren.

    Wie alle Do...-Methoden liegt hier eine Steuerung vor, die eigentliche
    Implementierung erfolgt, indem die ebenfalls virtuellen Methode
    InitNew(SvStorate*) von der SfxObjectShell-Subclass implementiert wird.

    F"ur pStor == 0 wird ein die SfxObjectShell-Instanz mit einem leeren
    SfxMedium verbunden, sonst mit einem SfxMedium, welches auf den
    als Parameter "ubergeben SvStorage verweist.

    Erst nach InitNew() oder Load() ist das Objekt korrekt initialisiert.

    [R"uckgabewert]
    sal_True            Das Objekt wurde initialisiert.
    sal_False           Das Objekt konnte nicht initialisiert werden
*/

/*N*/ {
/*N*/ 	ModifyBlocker_Impl aBlock( this );
/*N*/ 	if ( pStor )
/*N*/ 		pMedium = new SfxMedium( pStor );
/*N*/ 	else
/*N*/ 	{
/*N*/ 		bIsTmp = sal_True;
/*N*/ 		pMedium = new SfxMedium;
/*N*/ 	}
/*N*/
/*N*/ 	if ( InitNew( pStor ) )
/*N*/ 	{
/*N*/ 		// empty documents always get their macros from the user, so there is no reason to restrict access
/*N*/ 		pImp->nMacroMode = MacroExecMode::ALWAYS_EXECUTE_NO_WARN;
/*N*/
/*N*/ 		::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >  xModel ( GetModel(), ::com::sun::star::uno::UNO_QUERY );
/*N*/ 		if ( xModel.is() )
/*N*/ 		{
/*N*/ 			SfxItemSet *pSet = GetMedium()->GetItemSet();
/*N*/             pSet->Put( SfxStringItem( SID_FILTER_NAME, GetFactory().GetFilter(0)->GetFilterName() ) );
/*N*/ 			::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs;
/*N*/ 			TransformItems( SID_OPENDOC, *pSet, aArgs );
/*N*/             sal_Int32 nLength = aArgs.getLength();
/*N*/             aArgs.realloc( nLength + 1 );
/*N*/             aArgs[nLength].Name = DEFINE_CONST_UNICODE("Title");
/*N*/             aArgs[nLength].Value <<= ::rtl::OUString( GetTitle( SFX_TITLE_DETECT ) );
/*N*/             xModel->attachResource( ::rtl::OUString(), aArgs );
/*N*/ 		}
/*N*/
/*N*/         SetActivateEvent_Impl( SFX_EVENT_CREATEDOC );
/*N*/ 		return sal_True;
/*N*/ 	}
/*N*/ 	return sal_False;
/*N*/ }

//-------------------------------------------------------------------------

void SfxObjectShell::DoHandsOffNoMediumClose()
/*N*/ {
/*N*/     const SfxFilter *pFilter = pMedium->GetFilter();
/*N*/     if( !pFilter || pFilter->IsOwnFormat() || ( pFilter->GetFilterFlags() & SFX_FILTER_PACKED ) )
/*N*/ 		HandsOff();
/*N*/
/*N*/ 	// Force document library containers to release storage
/*N*/ 	SotStorageRef xDummyStorage;
/*N*/ 	SfxDialogLibraryContainer* pDialogCont = pImp->pDialogLibContainer;
/*N*/ 	if( pDialogCont )
/*N*/ 		pDialogCont->setStorage( xDummyStorage );
/*N*/
/*N*/ 	SfxScriptLibraryContainer* pBasicCont = pImp->pBasicLibContainer;
/*N*/ 	if( pBasicCont )
/*N*/ 		pBasicCont->setStorage( xDummyStorage );
/*N*/ }

//-------------------------------------------------------------------------

/*N*/ void SfxObjectShell::DoHandsOff()

/*  [Beschreibung]

    Diese von SvPersist geerbte virtuelle Methode wird gerufen, um
    das Objekt aufzufordern, den ihm zugeteilten SvStorage freizugeben,
    insbesondere Substorages und Streams zu schlie"sen.

    Als Do...-Methode liegt hier nur die Steuerung. Der Implementierer
    von Subclasses kann die ebenfalls virtuelle Methode HandsOff()
    implementieren, um seine Substorages und Streams zu schlie"sen.

    Nach dem Aufruf dieser Methode, ist dem Objekt kein SfxMedium mehr
    zugeordnet, bis SaveCompleted() durchlaufen ist.
*/

/*N*/ {
/*N*/ 	DoHandsOffNoMediumClose();
/*N*/ 	pMedium->Close();
/*N*/ //  DELETEZ( pMedium );
/*N*/ }

//-------------------------------------------------------------------------

/*?*/ sal_Bool SfxObjectShell::DoLoad(
/*?*/ 	const String& rFileName, StreamMode nStreamMode, StorageMode nStorageMode)
/*?*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001
/*?*/ 	return sal_False;
/*?*/ }


//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::DoLoad( SvStorage * pStor )

/*  [Beschreibung]

    Diese von SvPersist geerbte virtuelle Methode steuert das Laden
    des Objektes aus einem Storage. Dabei wird der SvStorage zun"achst
    in einem SfxMedium verpackt und SfxObjectShell::DoLoad(SfxMedium*)
    mit diesem gerufen.

    [R"uckgabewert]
    sal_True                Das Objekt wurde initialisiert.
    sal_False               Das Objekt konnte nicht initialisiert werden
*/

/*N*/ {
/*N*/ 	pMedium = new SfxMedium( pStor );
/*N*/ 	if ( DoLoad(pMedium) )
/*N*/ 	{
/*N*/ 		if ( SFX_CREATE_MODE_EMBEDDED == eCreateMode )
/*N*/ 		{
/*N*/ 			ModifyBlocker_Impl aBlock( this );
/*N*/ 			// bei Embedded Objekten setzt sonst keiner den Namen
/*N*/ //            DBG_ASSERT( pStor->GetName().Len(),
/*N*/ //                        "StorageName hat Laenge Null" );
/*N*/ 			SetTitle( pStor->GetName() );
/*N*/ 		}
/*N*/ 		return sal_True;
/*N*/ 	}
/*N*/
/*N*/ 	return sal_False;
/*N*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::DoLoad( SfxMedium *pMed )

/*  [Beschreibung]

    Diese Methode steuert das Laden des Objektes aus dem von dem
    "ubergebenen SfxMedium beschriebenen Medium. Hinterher ist das Objekt
    mit diesem SfxMedium verbunden.

    Handelt es sich bei dem SfxMedium um einen Storage im eigenen Format,
    wird die virtuelle Methode SvPersit::Load(SvStorage*) gerufen, welche
    die Implementierer von Subclasses "uberladen m"ussen, um das Objekt
    aus einem eigenen Storage zu laden (=> Swapping m"oeglich).

    Handelt es sich bei dem SfxMedium um einen Storage in einem fremden
    Format, oder um ein Flat-File, dann wird die virtuelle Methode
    <SfxObjectShell::ConvertFrom(SfxMedium*)> gerufen, welche die
    Implementierer von Subclasses "uberladen m"ussen, um das Objekt
    aus dem SfxMedium zu konvertieren. W"ahrend der Bearbeitung ist
    das Objekt dann mit einem tempor"aren SvStorage verbunden.

    Erst nach InitNew() oder Load() ist das Objekt korrekt
    initialisiert.

    [R"uckgabewert]
    sal_True                Das Objekt wurde geladen.
    sal_False           Das Objekt konnte nicht geladen werden
*/

/*N*/ {
/*N*/ 	SfxApplication *pSfxApp = SFX_APP();
/*N*/ 	ModifyBlocker_Impl aBlock( this );
/*N*/
/*N*/ 	pMedium = pMed;
/*N*/ 	sal_Bool bOk = sal_False;
/*N*/ 	const SfxFilter* pFilter = pMed->GetFilter();
/*N*/ 	SfxItemSet* pSet = pMedium->GetItemSet();
/*N*/ 	if( !pImp->nEventId )
/*N*/ 	{
/*N*/ 		SFX_ITEMSET_ARG(
/*N*/ 			pSet, pTemplateItem, SfxBoolItem,
/*N*/ 			SID_TEMPLATE, sal_False);
/*N*/         SetActivateEvent_Impl(
/*N*/ 			( pTemplateItem && pTemplateItem->GetValue() )
/*N*/             ? SFX_EVENT_CREATEDOC : SFX_EVENT_OPENDOC );
/*N*/ 	}
/*N*/
/*N*/
/*N*/ 	SFX_ITEMSET_ARG( pSet, pBaseItem, SfxStringItem,
/*N*/ 					 SID_BASEURL, sal_False);
/*N*/ 	String aBaseURL;
/*N*/ 	SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSalvageItem, SfxStringItem, SID_DOC_SALVAGE, sal_False);
/*N*/ 	if( pBaseItem )
/*N*/ 		aBaseURL = pBaseItem->GetValue();
/*N*/ 	else
/*N*/ 	{
/*N*/ 		if( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
/*N*/ 		{
/*N*/ 			aBaseURL = ::binfilter::StaticBaseUrl::GetBaseURL();
/*N*/ 			SetBaseURL( aBaseURL );
/*N*/ 		}
/*N*/ 		else if ( pSalvageItem )
/*N*/ 		{
/*N*/             String aName( pMed->GetPhysicalName() );
/*N*/             ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aName, aBaseURL );
/*N*/ 		}
/*N*/ 		else
/*N*/ 			aBaseURL = pMed->GetBaseURL();
/*N*/ 	}
/*N*/
/*N*/ 	SfxApplication* pApp = SFX_APP();
/*N*/ 	pImp->nLoadedFlags = 0;
/*N*/     sal_Bool bHasStorage = !pFilter || ( pFilter->IsOwnFormat() && pFilter->UsesStorage() );
/*N*/ 	if ( !bHasStorage && pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PACKED ) )
/*N*/ 	{
/*N*/ 		bHasStorage = pMed->TryStorage();
/*N*/ 		if ( bHasStorage )
/*N*/ 		{
/*N*/             String aName( pMed->GetPhysicalName() );
/*N*/             ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aName, aBaseURL );
/*N*/ 		}
/*N*/ 	}
/*N*/
/*N*/ 	if ( pMedium->GetFilter() )
/*N*/ 	{
/*N*/ 		sal_uInt32 nError = HandleFilter( pMedium, this );
/*N*/ 		if ( nError != ERRCODE_NONE )
/*N*/ 			SetError( nError );
/*N*/ 	}
/*N*/
/*N*/     if ( GetError() == ERRCODE_NONE && pMed->IsStorage() ) // STRIP003 && bHasStorage && ( !pFilter || !( pFilter->GetFilterFlags() & SFX_FILTER_STARONEFILTER ) ) )
/*N*/ 	{
/*N*/ 		SvStorageRef xStor( pMed->GetStorage() );
/*N*/ 		if( pMed->GetLastStorageCreationState() == ERRCODE_NONE )
/*N*/ 		{
/*N*/         	DBG_ASSERT( pFilter, "No filter for storage found!" );
/*N*/         	if( xStor.Is() && !xStor->GetError() && pMed->GetFilter() && pMed->GetFilter()->GetVersion() < SOFFICE_FILEFORMAT_60 )
/*N*/ 			{
/*N*/             	// Undoobjekte aufraeumen, muss vor dem eigentlichen Laden erfolgen
/*N*/ 				SvEmbeddedObjectRef xThis = this;
/*N*/ 				SvPersistRef xPer;
/*N*/ 				if ( xThis.Is() )
/*N*/ 					xPer = new SvEmbeddedObject;
/*N*/ 				else
/*?*/ 					xPer = new SvPersist;
/*N*/
/*N*/ 				xPer->DoOwnerLoad(xStor);
/*N*/ 				xPer->CleanUp();
/*N*/ 				xPer->DoSave();
/*N*/ 				xPer->DoSaveCompleted( 0 );
/*N*/ 			}
/*N*/
/*N*/         	if ( xStor.Is() )
/*N*/         	{
/*N*/             	SvStorageInfoList aList;
/*N*/             	xStor->FillInfoList( &aList );
/*N*/             	if ( !aList.Count() && !xStor->IsOLEStorage() )
/*?*/                 	SetError( ERRCODE_IO_BROKENPACKAGE );
/*N*/             	else
/*N*/             	{
/*N*/                 	BOOL bHasMacros = FALSE;
/*N*/                 	if ( xStor->IsOLEStorage() )
/*N*/                     	bHasMacros = BasicManager::HasBasicWithModules(
                                *xStor,
                                ::binfilter::StaticBaseUrl::GetBaseURL(
                                    INetURLObject::NO_DECODE) );
/*N*/                 	else
/*?*/                     	bHasMacros = xStor->IsStorage( String::CreateFromAscii("Basic") );
/*N*/
/*N*/                 	if ( bHasMacros )
/*N*/                     	AdjustMacroMode( String() );
/*N*/ 					else
/*N*/ 					{
/*N*/ 						// if macros will be added by the user later, the security check is obsolete
/*N*/ 						pImp->nMacroMode = MacroExecMode::ALWAYS_EXECUTE_NO_WARN;
/*N*/ 					}
/*N*/             	}
/*N*/         	}
/*N*/
/*N*/         	// Load
/*N*/         	if ( !GetError() )
/*N*/         	{
/*N*/             	const String aOldURL( ::binfilter::StaticBaseUrl::GetBaseURL() );
/*N*/             	if( aBaseURL.Len() ) ::binfilter::StaticBaseUrl::SetBaseURL( aBaseURL );
/*N*/             	pImp->nLoadedFlags = 0;
/*N*/             	bOk = xStor.Is() && LoadOwnFormat( *pMed );
/*N*/             	::binfilter::StaticBaseUrl::SetBaseURL( aOldURL );
/*N*/             	if ( bOk )
/*N*/             	{
/*N*/                 	GetDocInfo().Load(xStor);
/*N*/                 	bHasName = sal_True;
/*N*/             	}
/*N*/             	else
/*?*/                 	SetError( ERRCODE_ABORT );
/*N*/         	}
/*N*/ 		}
/*N*/      else
/*?*/ 			SetError( pMed->GetLastStorageCreationState() );
/*N*/    }
         else if ( GetError() == ERRCODE_NONE && InitNew(0) )
/*?*/    {
/*?*/        // Name vor ConvertFrom setzen, damit GetSbxObject() schon funktioniert
/*?*/        bHasName = sal_True;
/*?*/
/*?*/        // Importieren
/*?*/        const String aOldURL( ::binfilter::StaticBaseUrl::GetBaseURL() );
/*?*/        if( aBaseURL.Len() ) ::binfilter::StaticBaseUrl::SetBaseURL( aBaseURL );
/*?*/         if( !pMedium->GetFilter()->UsesStorage() )
/*?*/            pMedium->GetInStream();
/*?*/         else
/*?*/             pMedium->GetStorage();
/*?*/
/*?*/        pImp->nLoadedFlags = 0;
/*?*/        bOk = ConvertFrom(*pMedium);
/*?*/
/*?*/        ::binfilter::StaticBaseUrl::SetBaseURL( aOldURL );
/*?*/
/*?*/         if( bOk && pMedium->GetOpenMode() & STREAM_WRITE )
/*?*/        //Medium offen halten um andere Zugriffe zu verhindern
/*?*/        {
/*?*/            if(pMedium->GetFilter() && pMedium->GetFilter()->UsesStorage())
/*?*/            {
/*?*/                pMedium->GetStorage();
/*?*/                if( pMedium->GetLastStorageCreationState() != ERRCODE_NONE )
/*?*/                    pMedium->SetError( pMedium->GetLastStorageCreationState() );
/*?*/            }
/*?*/            else
/*?*/                pMedium->GetInStream();
/*?*/            if(pMedium->GetError())
/*?*/                bOk = sal_False;
/*?*/        }
/*?*/    }
/*N*/
/*N*/  if ( bOk )
/*N*/  {
/*N*/         try
/*?*/ /*N*/         {
/*?*/             ::ucbhelper::Content aContent( pMedium->GetName(), ::com::sun::star::uno::Reference < XCommandEnvironment >() );
/*?*/             ::com::sun::star::uno::Reference < XPropertySetInfo > xProps = aContent.getProperties();
/*?*/             if ( xProps.is() )
/*?*/             {
/*?*/                 ::rtl::OUString aAuthor( RTL_CONSTASCII_USTRINGPARAM("Author") );
/*?*/                 ::rtl::OUString aKeywords( RTL_CONSTASCII_USTRINGPARAM("Keywords") );
/*?*/                 ::rtl::OUString aSubject( RTL_CONSTASCII_USTRINGPARAM("Subject") );
/*?*/                 Any aAny;
/*?*/                 ::rtl::OUString aValue;
/*?*/                 SfxDocumentInfo& rInfo = GetDocInfo();
/*?*/                 if ( xProps->hasPropertyByName( aAuthor ) )
/*?*/                 {
/*?*/                     aAny = aContent.getPropertyValue( aAuthor );
/*?*/                     if ( ( aAny >>= aValue ) )
/*?*/                         rInfo.SetCreated( SfxStamp( String( aValue ) ) );
/*?*/                 }
/*?*/                 if ( xProps->hasPropertyByName( aKeywords ) )
/*?*/                 {
/*?*/                     aAny = aContent.getPropertyValue( aKeywords );
/*?*/                     if ( ( aAny >>= aValue ) )
/*?*/                         rInfo.SetKeywords( aValue );
/*?*/                 }
/*?*/                 if ( xProps->hasPropertyByName( aSubject ) )
/*?*/                 {
/*?*/                     aAny = aContent.getPropertyValue( aSubject );
/*?*/                     if ( ( aAny >>= aValue ) )
/*?*/                         rInfo.SetTheme( aValue );
/*?*/                 }
/*?*/             }
/*?*/         }
/*N*/         catch( Exception& )
/*N*/         {
/*N*/         }
/*N*/
/*N*/         ::rtl::OUString aTitle = GetTitle( SFX_TITLE_DETECT );
/*N*/
/*N*/ 		// Falls nicht asynchron geladen wird selbst FinishedLoading aufrufen
/*N*/ 		if ( !( pImp->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ) &&
/*N*/             ( !pMedium->GetFilter() ||
/*N*/                pMedium->GetFilter()->UsesStorage() ||
/*N*/                !( pMedium->GetFilter()->GetFilterFlags() & SFX_FILTER_ASYNC ) ) )
/*N*/ 			FinishedLoading( SFX_LOADED_MAINDOCUMENT );
/*N*/
/*N*/ 		if ( pSalvageItem )
/*N*/ 		{
/*?*/             pImp->aTempName = pMedium->GetPhysicalName();
/*?*/ 			pMedium->GetItemSet()->ClearItem( SID_DOC_SALVAGE );
/*?*/ 			pMedium->GetItemSet()->ClearItem( SID_FILE_NAME );
/*N*/ 		}
/*N*/ 		else
/*N*/ 		{
/*N*/ 			pMedium->GetItemSet()->ClearItem( SID_PROGRESS_STATUSBAR_CONTROL );
/*N*/ 			pMedium->GetItemSet()->ClearItem( SID_DOCUMENT );
/*N*/ 		}
/*N*/
/*N*/ 		pMedium->GetItemSet()->ClearItem( SID_REFERER );
/*N*/ 		::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >  xModel ( GetModel(), ::com::sun::star::uno::UNO_QUERY );
/*N*/ 		if ( xModel.is() )
/*N*/ 		{
/*N*/ 			::rtl::OUString aURL = GetMedium()->GetOrigURL();
/*N*/ 			SfxItemSet *pSet = GetMedium()->GetItemSet();
/*N*/             if ( !GetMedium()->IsReadOnly() )
/*N*/                 pSet->ClearItem( SID_INPUTSTREAM );
/*N*/ 			::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs;
/*N*/ 			TransformItems( SID_OPENDOC, *pSet, aArgs );
/*N*/ 			xModel->attachResource( aURL, aArgs );
/*N*/ 		}
/*N*/
/*N*/         if( IsOwnStorageFormat_Impl(*pMed) && pMed->GetFilter() )
/*N*/ 		{
/*N*/ //???? dv			DirEntry aDirEntry( pMed->GetPhysicalName() );
/*N*/ //???? dv			SetFileName( aDirEntry.GetFull() );
/*N*/ 		}
/*N*/ 		Broadcast( SfxSimpleHint(SFX_HINT_NAMECHANGED) );
/*N*/ 	}
/*N*/
/*N*/ 	if ( SFX_CREATE_MODE_EMBEDDED != eCreateMode )
/*N*/ 	{
/*N*/ 		GetpApp()->HideStatusText();
/*N*/ 	}
/*N*/
/*N*/ 	return bOk;
/*N*/ }

/*N*/ sal_uInt32 SfxObjectShell::HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDoc )
/*N*/ {
/*N*/ 	sal_uInt32 nError = ERRCODE_NONE;
/*N*/ 	SfxItemSet* pSet = pMedium->GetItemSet();
/*N*/ 	SFX_ITEMSET_ARG( pSet, pOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
/*N*/ 	SFX_ITEMSET_ARG( pSet, pData, SfxUsrAnyItem, SID_FILTER_DATA, sal_False );
/*N*/ 	if ( !pData && !pOptions )
/*N*/ 	{
/*N*/     	::com::sun::star::uno::Reference< XMultiServiceFactory > xServiceManager = ::legacy_binfilters::getLegacyProcessServiceFactory();
/*N*/ 		::com::sun::star::uno::Reference< XNameAccess > xFilterCFG;
/*N*/ 		if( xServiceManager.is() )
/*N*/ 		{
/*N*/ 			xFilterCFG = ::com::sun::star::uno::Reference< XNameAccess >(
/*N*/ 				xServiceManager->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.document.FilterFactory" ) ),
/*N*/ 				UNO_QUERY );
/*N*/ 		}
/*N*/
/*N*/ 		if( xFilterCFG.is() )
/*N*/     	{
/*N*/         	BOOL bAbort = FALSE;
/*N*/         	try {
/*N*/ 				const SfxFilter* pFilter = pMedium->GetFilter();
/*N*/             	Sequence < PropertyValue > aProps;
/*N*/             	Any aAny = xFilterCFG->getByName( pFilter->GetName() );
/*N*/             	if ( aAny >>= aProps )
/*N*/             	{
/*N*/                 	::rtl::OUString aServiceName;
/*N*/                 	sal_Int32 nPropertyCount = aProps.getLength();
/*N*/                 	for( sal_Int32 nProperty=0; nProperty < nPropertyCount; ++nProperty )
/*N*/                     	if( aProps[nProperty].Name.equals( ::rtl::OUString::createFromAscii("UIComponent")) )
/*N*/                     	{
/*N*/                         	::rtl::OUString aServiceName;
/*N*/                         	aProps[nProperty].Value >>= aServiceName;
/*N*/                         	if( aServiceName.getLength() )
/*?*/                         	{
/*?*/ 								::com::sun::star::uno::Reference< XInteractionHandler > rHandler = pMedium->GetInteractionHandler();
/*?*/ 								if( rHandler.is() )
/*?*/ 								{
/*?*/ 									// we need some properties in the media descriptor, so we have to make sure that they are in
/*?*/ 									Any aAny;
/*?*/ 									aAny <<= pMedium->GetInputStream();
/*?*/ 									if ( pSet->GetItemState( SID_INPUTSTREAM ) < SFX_ITEM_SET )
/*?*/ 									pSet->Put( SfxUsrAnyItem( SID_INPUTSTREAM, aAny ) );
/*?*/ 									if ( pSet->GetItemState( SID_FILE_NAME ) < SFX_ITEM_SET )
/*?*/ 										pSet->Put( SfxStringItem( SID_FILE_NAME, pMedium->GetName() ) );
/*?*/ 									if ( pSet->GetItemState( SID_FILTER_NAME ) < SFX_ITEM_SET )
/*?*/ 										pSet->Put( SfxStringItem( SID_FILTER_NAME, pFilter->GetName() ) );
/*?*/
/*?*/ 									Sequence< PropertyValue > rProperties;
/*?*/                                 	TransformItems( SID_OPENDOC, *pSet, rProperties );
/*?*/ 									RequestFilterOptions* pFORequest = new RequestFilterOptions( pDoc->GetModel(), rProperties );
/*?*/
/*?*/ 									::com::sun::star::uno::Reference< XInteractionRequest > rRequest( pFORequest );
/*?*/ 									rHandler->handle( rRequest );
/*?*/
/*?*/ 									if ( !pFORequest->isAbort() )
/*?*/ 									{
/*?*/                                    		SfxAllItemSet aNewParams( pDoc->GetPool() );
/*?*/                                    		TransformParameters( SID_OPENDOC,
/*?*/ 														 	pFORequest->getFilterOptions(),
/*?*/                                                          	aNewParams );
/*?*/
/*?*/                                    		SFX_ITEMSET_ARG( &aNewParams,
/*?*/ 													 	pOptions,
/*?*/ 													 	SfxStringItem,
/*?*/ 													 	SID_FILE_FILTEROPTIONS,
/*?*/ 													 	sal_False );
/*?*/                                    		if ( pOptions )
/*?*/                                        		pSet->Put( *pOptions );
/*?*/
/*?*/                                    		SFX_ITEMSET_ARG( &aNewParams,
/*?*/ 													 	pData,
/*?*/ 													 	SfxUsrAnyItem,
/*?*/ 													 	SID_FILTER_DATA,
/*?*/ 													 	sal_False );
/*?*/                                    		if ( pData )
/*?*/                                        		pSet->Put( *pData );
/*?*/ 									}
/*?*/                                 	else
/*?*/                                     	bAbort = TRUE;
/*?*/ 								}
/*?*/                         	}
/*N*/
/*N*/                         	break;
/*N*/                     	}
/*N*/             	}
/*N*/
/*N*/             	if( bAbort )
/*N*/ 				{
/*N*/ 					// filter options were not entered
/*N*/ 					nError = ERRCODE_ABORT;
/*N*/ 				}
/*N*/         	}
/*N*/         	catch( NoSuchElementException& )
/*N*/         	{
/*N*/             	// the filter name is unknown
/*N*/             	nError = ERRCODE_IO_INVALIDPARAMETER;
/*N*/         	}
/*N*/         	catch( Exception& )
/*N*/         	{
/*N*/ 				nError = ERRCODE_ABORT;
/*N*/         	}
/*N*/     	}
/*N*/ 	}
/*N*/
/*N*/ 	return nError;
/*N*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::IsOwnStorageFormat_Impl(const SfxMedium &rMedium) const
/*N*/ {
/*N*/ 	return !rMedium.GetFilter() || // Embedded
/*N*/ 		   ( rMedium.GetFilter()->IsOwnFormat() &&
/*N*/ 			 rMedium.GetFilter()->UsesStorage() );
/*N*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::DoSave()
// DoSave wird nur noch ueber OLE aufgerufen. Sichern eigener Dokumente im SFX
// laeuft uber DoSave_Impl, um das Anlegen von Backups zu ermoeglichen.
// Save in eigenes Format jetzt auch wieder Hierueber
/*N*/ {
/*N*/ 	sal_Bool bOk = sal_False ;
/*N*/ 	{
/*N*/ 		ModifyBlocker_Impl aBlock( this );
/*N*/ 		SfxForceLinkTimer_Impl aFLT( this );
/*N*/ 		pImp->bIsSaving = sal_True;
/*N*/ 		String aPasswd;
/*N*/ 		if ( IsOwnStorageFormat_Impl( *GetMedium() ) &&
/*N*/ 			 GetPasswd_Impl( GetMedium()->GetItemSet(), aPasswd ) )
/*N*/ 			GetMedium()->GetStorage()->SetKey( S2BS( aPasswd ) );	//!!! (pb) needs new implementation
/*N*/ 		GetStorage()->SetVersion( GetMedium()->GetFilter()->GetVersion() );
/*N*/ 		bOk = Save();
/*N*/ 	}

//#88046
//    if ( bOk )
//        SetModified( sal_False );
/*N*/ 	return bOk;
/*N*/ }

/*N*/ void Lock_Impl( SfxObjectShell* pDoc, BOOL bLock )
/*N*/ {
/*N*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::SaveTo_Impl
/*N*/ (
/*N*/ 	 SfxMedium &rMedium, // Medium, in das gespeichert werden soll
/*N*/      const SfxItemSet* pSet,
/*N*/      BOOL bPrepareForDirectAccess
/*N*/ )

/*  [Beschreibung]

    Schreibt den aktuellen Inhalt in das Medium rMedium.
    Ist das Zielmedium kein Storage, so wird ueber ein temporaeres
    Medium gespeichert, sonst direkt, da das Medium transacted
    geschaltet ist, wenn wir es selbst geoeffnet haben und falls wir
    Server sind entweder der Container einen transacted Storage zur
    Verfuegung stellt oder selbst einen temporaeren Storage erzeugt hat.
*/

/*N*/ {
/*N*/ 	SfxForceLinkTimer_Impl aFLT( this );
/*N*/     EnableSetModified( FALSE );
/*N*/
/*N*/ 	const SfxFilter *pFilter = rMedium.GetFilter();
/*N*/ 	if ( !pFilter )
/*N*/ 	{
/*N*/         // if no filter was set, use the default filter
/*N*/         // this should be changed in the feature, it should be an error!
/*?*/ 		pFilter = GetFactory().GetFilter(0);
/*?*/ 		rMedium.SetFilter(pFilter);
/*N*/ 	}
/*N*/
/*N*/     if( pFilter->UsesStorage() )
/*N*/         // create an output storage in the correct format
/*N*/         rMedium.GetOutputStorage( SOFFICE_FILEFORMAT_60 <= pFilter->GetVersion() );
/*N*/ 	else
/*?*/ 		rMedium.GetOutStream();
/*N*/
/*N*/ 	if( rMedium.GetErrorCode() )
/*N*/ 		return sal_False;
/*N*/
/*N*/ 	sal_Bool bOldStat = pImp->bForbidReload;
/*N*/ 	pImp->bForbidReload = sal_True;
/*N*/
/*N*/     // lock user interface while saving the document
/*N*/     Lock_Impl( this, sal_True );
/*N*/
/*N*/ 	sal_Bool bOk = sal_False;
/*N*/	if( sal_True ) // STRIP003 IsOwnStorageFormat_Impl(rMedium) && !(pFilter->GetFilterFlags() & SFX_FILTER_STARONEFILTER))
/*N*/ 	{
/*N*/ 		SvStorageRef aMedRef = rMedium.GetStorage();
/*N*/ 		if ( !aMedRef.Is() )
/*N*/         {
/*?*/             // no saving without storage, unlock UI and return
/*?*/             Lock_Impl( this, sal_False );
/*?*/ 			return sal_False;
/*N*/         }
/*N*/
/*N*/         // transfer password from the parameters to the storage
/*N*/         String aPasswd;
/*N*/ 		if ( GetPasswd_Impl( rMedium.GetItemSet(), aPasswd ) )
/*N*/ 			aMedRef->SetKey( S2BS( aPasswd ) ); //!!! (pb) needs new implementation
/*N*/
/*N*/ 		const SfxFilter* pFilter = rMedium.GetFilter();
/*N*/ 		if(  ((SvStorage *)aMedRef) == ((SvStorage *)GetStorage() ) )
/*N*/ 		{
/*N*/             // target storage and object storage are identical, should never happen here
/*?*/             DBG_ERROR( "Saving storage without copy!");
/*?*/ 			aMedRef->SetVersion( pFilter->GetVersion() );
/*?*/ 			bOk = Save();
/*N*/ 		}
/*N*/ 		else
/*N*/             // save to target
/*N*/ 			bOk = SaveAsOwnFormat( rMedium );
/*N*/
/*N*/         // look for a "version" parameter
/*N*/ 		const SfxStringItem *pVersionItem = pSet ? (const SfxStringItem*)
/*N*/             SfxRequest::GetItem( pSet, SID_DOCINFO_COMMENTS, sal_False, TYPE(SfxStringItem) ) : NULL;
/*N*/
/*N*/ 		if ( pVersionItem )
/*N*/ 		{DBG_BF_ASSERT(0, "STRIP"); //STRIP001
/*N*/ 		}
/*N*/ 		else if ( pImp->bIsSaving )
/*N*/ 		{DBG_BF_ASSERT(0, "STRIP"); //STRIP001
/*N*/ 		}
/*N*/ 	}
//STRIP003/*N*/ 	else
//STRIP003/*N*/ 	{
//STRIP003/*?*/         // it's a "SaveAs" in an alien format
//STRIP003/*?*/ 		if ( rMedium.GetFilter() && ( rMedium.GetFilter()->GetFilterFlags() & SFX_FILTER_STARONEFILTER ) )
//STRIP003/*?*/             bOk = ExportTo( rMedium );
//STRIP003/*?*/ 		else
//STRIP003/*?*/             bOk = ConvertTo( rMedium );
//STRIP003/*?*/
//STRIP003/*?*/         // after saving the document, the temporary object storage must be updated
//STRIP003/*?*/         // if the old object storage was not a temporary one, it will be updated also, because it will be used
//STRIP003/*?*/         // as a source for copying the objects into the new temporary storage that will be created below
//STRIP003/*?*/         // updating means: all child objects must be stored into it
//STRIP003/*?*/         // ( same as on loading, where these objects are copied to the temporary storage )
//STRIP003/*?*/         // but don't commit these changes, because in the case when the old object storage is not a temporary one,
//STRIP003/*?*/         // all changes will be written into the original file !
//STRIP003/*?*/         if( bOk )
//STRIP003/*?*/             bOk = SaveChilds() && SaveCompletedChilds( NULL );
//STRIP003/*N*/ 	}

    // SetModified must be enabled when SaveCompleted is called, otherwise the modified flag of child objects will not be cleared
/*N*/     EnableSetModified( sal_True );
/*N*/
/*N*/     sal_Bool bCopyTo = sal_False;
/*N*/     SfxItemSet *pMedSet = rMedium.GetItemSet();
/*N*/     if( pMedSet )
/*N*/     {
/*N*/         SFX_ITEMSET_ARG( pMedSet, pSaveToItem, SfxBoolItem, SID_SAVETO, sal_False );
/*N*/         bCopyTo =   GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ||
/*N*/                     pSaveToItem && pSaveToItem->GetValue();
/*N*/     }
/*N*/
/*N*/     if( bOk )
/*N*/ 	{
/*N*/         // remember new object storage, if it is a temporary one, because we will need it for a "SaveCompleted" later
/*N*/         SvStorageRef xNewTempRef;
/*N*/         if ( bOk && bPrepareForDirectAccess )
/*N*/         {
/*N*/             // if the target medium is an alien format and the "old" medium was an own format, the object storage
/*N*/             // must be exchanged, because now we need a new temporary storage as object storage
/*N*/             BOOL bNeedsStorage = !bCopyTo && IsOwnStorageFormat_Impl(*pMedium) && !IsOwnStorageFormat_Impl(rMedium);
/*N*/             if ( bNeedsStorage )
/*N*/             {
/*?*/                 if( !pMedium->GetName().Len() )
/*?*/                     // if the old object storage was a temporary one too, we can continue with it
/*?*/                     xNewTempRef = GetStorage();
/*?*/                 else
/*?*/                 {
/*?*/                     // copy storage of old medium to new temporary storage and take this over
/*?*/                     if( ConnectTmpStorage_Impl( pMedium->GetStorage() ) )
/*?*/                         xNewTempRef = GetStorage();
/*?*/                     else
/*?*/                         bOk = sal_False;
/*?*/                 }
/*N*/             }
/*N*/
/*N*/             // When the new medium ( rMedium ) has the same name as the current one,
/*N*/             // we need to call DoHandsOff() so Commit() can overwrite the old version
/*N*/             if ( bOk && pMedium && ( rMedium.GetName().EqualsIgnoreCaseAscii( pMedium->GetName() ) )
/*N*/ 			  && rMedium.GetName().CompareIgnoreCaseToAscii( "private:stream", 14 ) != COMPARE_EQUAL )
/*?*/                 DoHandsOff();
/*N*/         }
/*N*/
/*N*/         if ( bOk && pMedium && ( rMedium.GetName() == pMedium->GetName() ) )
/*N*/         {
/*N*/             // before we overwrite the original file, we will make a backup if there is a demand for that
/*N*/             const sal_Bool bDoBackup = SvtSaveOptions().IsBackup();
/*N*/             if ( bDoBackup )
/*N*/ 			{{DBG_BF_ASSERT(0, "STRIP");}//STRIP001
/*N*/ 			}
/*N*/         }
/*N*/
/*N*/         if ( bOk )
/*N*/         {
/*N*/             // transfer data to its destinated location
/*N*/             EnableSetModified( sal_False );
/*N*/             RegisterTransfer( rMedium );
/*N*/             bOk = rMedium.Commit();
/*N*/             EnableSetModified( sal_True );
/*N*/
/*N*/ 			if ( bOk )
/*N*/ 			{
/*N*/             	// watch: if the document was successfully saved into an own format, no "SaveCompleted" was called,
/*N*/             	// this must be done by the caller ( because they want to do different calls )
/*N*/ 				if( xNewTempRef.Is() && xNewTempRef != GetStorage() )
/*N*/                 	// if the new object storage is a temporary one, because the target format is an alien format
/*?*/                 	SaveCompleted( xNewTempRef );
/*N*/ 			}
/*N*/ 			else
/*N*/ 			{
/*?*/ 				// if the storing process fails on medium commit step it means that
/*?*/ 				// the new medium should contain successfully written temporary representation
/*?*/ 				// of the document, so the docshell can just switch to new medium.
/*?*/ 				// it is reasonable in case an open document suddenly became unavailable.
/*?*/
/*?*/ 				OUString aOrigName = pMedium ? OUString(pMedium->GetName()) : OUString();
/*?*/ 				if ( aOrigName.getLength() && aOrigName.compareToAscii( "private:", 8 ) != COMPARE_EQUAL
/*?*/ 				  	&& !::utl::UCBContentHelper::Exists( aOrigName ) )
/*?*/ 				{DBG_BF_ASSERT(0, "STRIP");//STRIP001
/*?*/ 				}
/*N*/ 			}
/*N*/         }
/*N*/ 	}
/*N*/
/*N*/     // unlock user interface
/*N*/     Lock_Impl( this, sal_False );
/*N*/     pImp->bForbidReload = bOldStat;
/*N*/
/*N*/     if ( bOk )
/*N*/     {
/*N*/         DBG_ASSERT( pFilter, "No filter after successful save?!" );
/*N*/         if( pFilter )
/*N*/             if( !bCopyTo && pFilter->IsAlienFormat() )
/*N*/                 // set flag, that the user will be warned for possible data loss on closing this document
/*N*/                 pImp->bDidDangerousSave=sal_True;
/*N*/             else
/*?*/                 pImp->bDidDangerousSave=sal_False;
/*N*/
/*N*/
/*N*/         try
/*N*/         {
/*?*/             ::ucbhelper::Content aContent( rMedium.GetName(), ::com::sun::star::uno::Reference < XCommandEnvironment >() );
/*?*/             ::com::sun::star::uno::Reference < XPropertySetInfo > xProps = aContent.getProperties();
/*?*/             if ( xProps.is() )
/*?*/             {
/*?*/                 ::rtl::OUString aAuthor( RTL_CONSTASCII_USTRINGPARAM("Author") );
/*?*/                 ::rtl::OUString aKeywords( RTL_CONSTASCII_USTRINGPARAM("Keywords") );
/*?*/                 ::rtl::OUString aSubject( RTL_CONSTASCII_USTRINGPARAM("Subject") );
/*?*/                 Any aAny;
/*?*/                 if ( xProps->hasPropertyByName( aAuthor ) )
/*?*/                 {
/*?*/                     aAny <<= ::rtl::OUString( GetDocInfo().GetCreated().GetName() );
/*?*/                     aContent.setPropertyValue( aAuthor, aAny );
/*?*/                 }
/*?*/                 if ( xProps->hasPropertyByName( aKeywords ) )
/*?*/                 {
/*?*/                     aAny <<= ::rtl::OUString( GetDocInfo().GetKeywords() );
/*?*/                     aContent.setPropertyValue( aKeywords, aAny );
/*?*/                 }
/*?*/                 if ( xProps->hasPropertyByName( aSubject ) )
/*?*/                 {
/*?*/                     aAny <<= ::rtl::OUString( GetDocInfo().GetTheme() );
/*?*/                     aContent.setPropertyValue( aSubject, aAny );
/*?*/                 }
/*?*/             }
/*N*/         }
/*N*/         catch( Exception& )
/*N*/         {
/*N*/         }
/*N*/     }
/*N*/
/*N*/ 	return bOk;
/*N*/ }

//------------------------------------------------------------------------

/*?*/ sal_Bool SfxObjectShell::ConnectTmpStorage_Impl( SvStorage* pStg)

/*   [Beschreibung]

     Arbeitet die Applikation auf einem temporaeren Storage,
     so darf der temporaere Storage nicht aus dem SaveCompleted
     genommen werden. Daher wird in diesem Fall schon hier an
     den neuen Storage connected. SaveCompleted tut dann nichts.

     */

/*?*/ {
/*?*/ 	// wenn es kein temp. Storage ist, einen anlegen
/*?*/     SvStorageRef aTmpMed = new SvStorage( (pStg->GetVersion() >= SOFFICE_FILEFORMAT_60), String() );
/*?*/
/*?*/ 	// nach HandsOff muss der alte Storage wieder eingesetzt werden
/*?*/ 	if ( !pStg->CopyTo(aTmpMed) )
/*?*/ 	{
/*?*/ 		SetError(aTmpMed->GetErrorCode());
/*?*/ 		aTmpMed.Clear();
/*?*/ 		return sal_False;
/*?*/ 	}
/*?*/
/*?*/ 	SetError(GetMedium()->GetErrorCode());
/*?*/ 	SaveCompleted(aTmpMed); // neuer temp. Storage; gibt alten frei
/*?*/ 	return sal_True;
/*?*/ }


//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::DoSaveAs( SvStorage * pNewStor )
/*N*/ {
/*N*/ // DoSaveAs wird nur noch ueber OLE aufgerufen
/*N*/ 	sal_Bool bOk;
/*N*/ 	{
/*N*/ 		SfxForceLinkTimer_Impl aFLT( this );
/*N*/ 		ModifyBlocker_Impl aBlock( this );
/*N*/ 		//Abwehr gegen feindlich gesinnte Applikationen.
/*N*/ 		if ( !pNewStor->GetFormat() )
/*N*/ 			SetupStorage( pNewStor );
/*N*/
/*N*/ 		pImp->bIsSaving = sal_False;
/*N*/ 		SfxMedium* pNewMed = new SfxMedium( pNewStor );
/*N*/ 		const String aOldURL( ::binfilter::StaticBaseUrl::GetBaseURL() );
/*N*/
/*N*/ 		bOk = SaveAsOwnFormat( *pNewMed );
/*N*/ 		::binfilter::StaticBaseUrl::SetBaseURL( aOldURL );
/*N*/ 		delete pNewMed;
/*N*/ 	}
/*N*/ 	return bOk;
/*N*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::DoSaveCompleted( SfxMedium * pNewMed )
/*N*/ {
    sal_Bool bOk = sal_True;
    sal_Bool bMedChanged = pNewMed && pNewMed!=pMedium;
/*	sal_Bool bCreatedTempStor = pNewMed && pMedium &&
        IsOwnStorageFormat_Impl(*pMedium) &&
        !IsOwnStorageFormat_Impl(*pNewMed) &&
        pMedium->GetName().Len();
*/
/*N*/     DBG_ASSERT( !pNewMed || pNewMed->GetError() == ERRCODE_NONE, "DoSaveCompleted: Medium has error!" );
/*N*/ 	if ( bMedChanged )
/*N*/ 	{
/*N*/ 		delete pMedium;
/*N*/ 		pMedium = pNewMed;
/*N*/ 		//MI? DELETEZ(pImp->pDocInfo);
/*N*/ 	}
/*N*/
/*N*/ 	const SfxFilter *pFilter = pMedium ? pMedium->GetFilter() : 0;
/*N*/ 	if ( pNewMed )
/*N*/ 	{
/*N*/ 		if( bMedChanged )
/*N*/ 		{
/*N*/ 			if( pNewMed->GetName().Len() )
/*N*/ 				bHasName = sal_True;
/*N*/ 			String aBase = GetBaseURL();
/*N*/ 			if( Current() == this && aBase.Len() )
/*N*/ 				::binfilter::StaticBaseUrl::SetBaseURL( aBase );
/*N*/ 			Broadcast( SfxSimpleHint(SFX_HINT_NAMECHANGED) );
/*N*/ 		}
/*N*/
/*N*/ 		SvStorage *pStorage=NULL;
/*N*/ 		if ( !pFilter||sal_True  ) //STRIP007 if ( !pFilter || pFilter->IsOwnFormat() )
/*N*/ 		{
/*N*/ 			pStorage = pMedium->GetStorage();
/*N*/ 			bOk = SaveCompleted( pStorage );
/*N*/ 		}
/*N*/ 		else
/*N*/ 		{
/*?*/ 			pStorage = GetStorage();
/*?*/ 			if( pFilter->UsesStorage() )
/*?*/ 				pMedium->GetStorage();
/*?*/ 			else if( pMedium->GetOpenMode() & STREAM_WRITE )
/*?*/ 				pMedium->GetInStream();
/*N*/ 		}
/*N*/
/*N*/ 		// Set storage in document library containers
/*N*/ 		SfxDialogLibraryContainer* pDialogCont = pImp->pDialogLibContainer;
/*N*/ 		if( pDialogCont )
/*N*/ 			pDialogCont->setStorage( pStorage );
/*N*/
/*N*/ 		SfxScriptLibraryContainer* pBasicCont = pImp->pBasicLibContainer;
/*N*/ 		if( pBasicCont )
/*N*/ 			pBasicCont->setStorage( pStorage );
/*N*/ 	}
/*N*/ 	else
/*N*/ 	{
/*N*/ 		if( pMedium )
/*N*/ 		{
/*N*/ 			const SfxFilter* pFilter = pMedium->GetFilter();
/*N*/ 			if( pFilter && !pFilter->IsOwnFormat() &&
/*N*/ 				(pMedium->GetOpenMode() & STREAM_WRITE ))
/*N*/ 				 pMedium->ReOpen();
/*N*/ 			else
/*N*/ 				SaveCompleted( 0 );
/*N*/ 		}
/*N*/ 		// entweder Save oder ConvertTo
/*N*/ 		else
/*?*/ 			bOk = SaveCompleted( NULL );
/*N*/ 	}
/*N*/
/*N*/ 	if ( bOk && pNewMed )
/*N*/ 	{
/*N*/ 		if( bMedChanged )
/*N*/ 		{
/*N*/ 			// Titel neu setzen
/*N*/ 			if ( pNewMed->GetName().Len() &&
/*N*/ 				 SFX_CREATE_MODE_EMBEDDED != eCreateMode )
/*N*/ 				InvalidateName();
/*N*/ 			SetModified(sal_False); // nur bei gesetztem Medium zur"ucksetzen
/*N*/             Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) );
/*N*/ 		}
/*N*/ 	}
/*N*/
/*N*/ 	return bOk;
/*N*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::DoSaveCompleted( SvStorage * pNewStor )
/*N*/ {
/*N*/ 	return DoSaveCompleted(pNewStor? new SfxMedium( pNewStor ): 0);
/*N*/ }

//-------------------------------------------------------------------------

/*?*/ sal_Bool SfxObjectShell::ConvertFrom
/*?*/ (
/*?*/ 	SfxMedium&  rMedium     /*  <SfxMedium>, welches die Quell-Datei beschreibt
                                (z.B. Dateiname, <SfxFilter>, Open-Modi etc.) */
/*?*/ )

/*  [Beschreibung]

    Diese Methode wird zum Laden von Dokumenten "uber alle Filter gerufen,
    die nicht SFX_FILTER_OWN sind oder f"ur die kein Clipboard-Format
    registriert wurde (also kein Storage-Format benutzen). Mit anderen Worten:
    mit dieser Methode wird importiert.

    Das hier zu "offende File sollte "uber 'rMedium' ge"offnet werden,
    um die richtigen Open-Modi zu gew"ahrleisten. Insbesondere wenn das
    Format beibehalten wird (nur m"oglich bei SFX_FILTER_SIMULATE oder
    SFX_FILTER_ONW) mu\s die Datei STREAM_SHARE_DENYWRITE ge"offnet werden.


    [R"uckgabewert]

    sal_Bool                sal_True
                        Das Dokument konnte geladen werden.

                        sal_False
                        Das Dokument konnte nicht geladen werden, ein
                        Fehlercode ist mit <SvMedium::GetError()const> zu
                        erhalten.


    [Beispiel]

    sal_Bool DocSh::ConvertFrom( SfxMedium &rMedium )
    {
        SvStreamRef xStream = rMedium.GetInStream();
        if( xStream.is() )
        {
            xStream->SetBufferSize(4096);
            *xStream >> ...;

            // NICHT 'rMedium.CloseInStream()' rufen! File gelockt halten!
            return SVSTREAM_OK == rMedium.GetError();
        }

        return sal_False;
    }


    [Querverweise]

    <SfxObjectShell::ConvertTo(SfxMedium&)>
    <SFX_FILTER_REGISTRATION>
*/
/*?*/ {
/*?*/ 	return sal_False;
/*?*/ }

//-------------------------------------------------------------------------

/*?*/ sal_Bool SfxObjectShell::ConvertTo
/*?*/ (
/*?*/ 	SfxMedium&  rMedium     /*  <SfxMedium>, welches die Ziel-Datei beschreibt
                                (z.B. Dateiname, <SfxFilter>, Open-Modi etc.) */
/*?*/ )

/*  [Beschreibung]

    Diese Methode wird zum Speichern von Dokumenten "uber alle Filter gerufen,
    die nicht SFX_FILTER_OWN sind oder f"ur die kein Clipboard-Format
    registriert wurde (also kein Storage-Format benutzen). Mit anderen Worten:
    mit dieser Methode wird exportiert.

    Das hier zu "offende File sollte "uber 'rMedium' ge"offnet werden,
    um die richtigen Open-Modi zu gew"ahrleisten. Insbesondere wenn das
    Format beibehalten wird (nur m"oglich bei SFX_FILTER_SIMULATE oder
    SFX_FILTER_ONW) mu\s die Datei auch nach dem Speichern im Modus
    STREAM_SHARE_DENYWRITE ge"offnet bleiben.


    [R"uckgabewert]

    sal_Bool                sal_True
                        Das Dokument konnte gespeichert werden.

                        sal_False
                        Das Dokument konnte nicht gespeichert werden, ein
                        Fehlercode ist mit <SvMedium::GetError()const> zu
                        erhalten.


    [Beispiel]

    sal_Bool DocSh::ConvertTo( SfxMedium &rMedium )
    {
        SvStreamRef xStream = rMedium.GetOutStream();
        if ( xStream.is() )
        {
            xStream->SetBufferSize(4096);
            *xStream << ...;

            rMedium.CloseOutStream(); // "offnet automatisch wieder den InStream
            return SVSTREAM_OK == rMedium.GetError();
        }
        return sal_False ;
    }


    [Querverweise]

    <SfxObjectShell::ConvertFrom(SfxMedium&)>
    <SFX_FILTER_REGISTRATION>
*/

/*?*/ {
/*?*/ 	return sal_False;
/*?*/ }

//-------------------------------------------------------------------------


/*?*/ sal_Bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs )
/*?*/ {DBG_BF_ASSERT(0, "STRIP"); return sal_False; //STRIP001
/*?*/ }

//-------------------------------------------------------------------------

/*?*/ sal_Bool SfxObjectShell::Save_Impl( const SfxItemSet* pSet )
/*?*/ {DBG_BF_ASSERT(0, "STRIP"); return sal_False;//STRIP001
/*?*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::CommonSaveAs_Impl
/*N*/ (
/*N*/ 	const INetURLObject&   aURL,
/*N*/ 	const String&   aFilterName,
/*N*/ 	SfxItemSet*     aParams
/*N*/ )
/*N*/ {
/*N*/ 	SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_SAVEASDOC,this));
/*N*/ 	BOOL bWasReadonly = IsReadOnly();
/*N*/
/*N*/ 	if( aURL.HasError() )
/*N*/ 	{
/*N*/ 		SetError( ERRCODE_IO_INVALIDPARAMETER );
/*N*/ 		return sal_False;
/*N*/ 	}
/*N*/
/*N*/     DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "Illegal URL!" );
/*N*/     DBG_ASSERT( aParams->Count() != 0, "fehlerhafte Parameter");
/*N*/
/*N*/     SFX_ITEMSET_ARG( aParams, pSaveToItem, SfxBoolItem, SID_SAVETO, sal_False );
/*N*/     sal_Bool bSaveTo = pSaveToItem ? pSaveToItem->GetValue() : sal_False;
/*N*/
/*N*/     const SfxFilter* pFilter = GetFactory().GetFilterContainer()->GetFilter( aFilterName );
/*N*/     if ( !pFilter
/*N*/ 		|| !pFilter->CanExport()
/*N*/ 		|| !bSaveTo && !pFilter->CanImport() )
/*N*/     {
/*N*/         SetError( ERRCODE_IO_INVALIDPARAMETER );
/*N*/         return sal_False;
/*N*/     }
/*N*/
/*N*/ 	pImp->bPasswd = aParams && SFX_ITEM_SET == aParams->GetItemState(SID_PASSWORD);
/*N*/
/*N*/ 	SfxMedium *pActMed = GetMedium();
/*N*/ 	const INetURLObject aActName(pActMed->GetName());
/*N*/
/*N*/ 	if ( aURL == aActName
/*N*/ 		&& aURL != INetURLObject( OUString::createFromAscii( "private:stream" ) ) )
/*N*/ 	{
/*?*/ 		if ( IsReadOnly() )
/*?*/ 		{
/*?*/ 			SetError(ERRCODE_SFX_DOCUMENTREADONLY);
/*?*/ 			return sal_False;
/*?*/ 		}
/*?*/ 		// gleicher Filter? -> Save()
/*?*/ 		const SfxFilter *pFilter = pActMed->GetFilter();
/*?*/         if ( pFilter && pFilter->GetFilterName() == aFilterName )
/*?*/ 		{
/*?*/ 			pImp->bIsSaving=sal_False;
/*?*/ 			if ( aParams )
/*?*/ 			{
/*?*/ 				SfxItemSet* pSet = pMedium->GetItemSet();
/*?*/ 				pSet->ClearItem( SID_PASSWORD );
/*?*/ 				pSet->Put( *aParams );
/*?*/ 			}
/*?*/ 			return DoSave_Impl();
/*?*/ 		}
/*N*/ 	}

/*N*/     if( SFX_ITEM_SET != aParams->GetItemState(SID_UNPACK) && SvtSaveOptions().IsSaveUnpacked() )
/*N*/         aParams->Put( SfxBoolItem( SID_UNPACK, sal_False ) );
/*N*/
/*N*/ 	if ( PreDoSaveAs_Impl(aURL.GetMainURL( INetURLObject::NO_DECODE ),aFilterName,aParams))
/*N*/ 	{
/*N*/ 		pImp->bWaitingForPicklist = sal_True;
/*N*/ 		if (!pImp->bSetStandardName)
/*N*/ 			pImp->bDidWarnFormat=sal_False;
/*N*/
/*N*/ 		// Daten am Medium updaten
/*N*/ 		SfxItemSet *pSet = GetMedium()->GetItemSet();
/*N*/ 		pSet->ClearItem( SID_INTERACTIONHANDLER );
/*N*/
/*N*/ 		if ( !bSaveTo )
/*N*/ 		{
/*N*/ 			pSet->ClearItem( SID_REFERER );
/*N*/ 			pSet->ClearItem( SID_POSTDATA );
/*N*/ 			pSet->ClearItem( SID_TEMPLATE );
/*N*/ 			pSet->ClearItem( SID_DOC_READONLY );
/*N*/ 			pSet->ClearItem( SID_CONTENTTYPE );
/*N*/ 			pSet->ClearItem( SID_CHARSET );
/*N*/ 			pSet->ClearItem( SID_FILTER_NAME );
/*N*/ 			pSet->ClearItem( SID_OPTIONS );
/*N*/ 			//pSet->ClearItem( SID_FILE_FILTEROPTIONS );
/*N*/ 			pSet->ClearItem( SID_VERSION );
/*N*/ 			//pSet->ClearItem( SID_USE_FILTEROPTIONS );
/*N*/ 			pSet->ClearItem( SID_EDITDOC );
/*N*/
/*N*/ 			SFX_ITEMSET_GET( (*aParams), pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False );
/*N*/ 			if ( pFilterItem )
/*N*/ 				pSet->Put( *pFilterItem );
/*N*/
/*N*/ 			SFX_ITEMSET_GET( (*aParams), pOptionsItem, SfxStringItem, SID_OPTIONS, sal_False );
/*N*/ 			if ( pOptionsItem )
/*N*/ 				pSet->Put( *pOptionsItem );
/*N*/
/*N*/ 			SFX_ITEMSET_GET( (*aParams), pFilterOptItem, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
/*N*/ 			if ( pFilterOptItem )
/*N*/ 				pSet->Put( *pFilterOptItem );
/*N*/ 		}
/*N*/
/*N*/ 		SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_SAVEASDOCDONE,this));
/*N*/
/*N*/ 		if ( bWasReadonly && !bSaveTo )
/*N*/ 			Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) );
/*N*/
/*N*/ 		return sal_True;
/*N*/ 	}
/*N*/ 	else
/*N*/ 		return sal_False;
/*N*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::PreDoSaveAs_Impl
/*N*/ (
/*N*/ 	const String&   rFileName,
/*N*/ 	const String&   aFilterName,
/*N*/ 	SfxItemSet*     pParams
/*N*/ )
/*N*/ {
/*N*/     // copy all items stored in the itemset of the current medium
/*N*/     SfxAllItemSet* pMergedParams = new SfxAllItemSet( *pMedium->GetItemSet() );
/*N*/
/*N*/     // in "SaveAs" title and password will be cleared ( maybe the new itemset contains new values, otherwise they will be empty )
/*N*/ 	pMergedParams->ClearItem( SID_PASSWORD );
/*N*/ 	pMergedParams->ClearItem( SID_DOCINFO_TITLE );
/*N*/
/*N*/ 	pMergedParams->ClearItem( SID_INPUTSTREAM );
/*N*/ 	pMergedParams->ClearItem( SID_CONTENT );
/*N*/
/*N*/ 	pMergedParams->ClearItem( SID_REPAIRPACKAGE );
/*N*/
/*N*/     // "SaveAs" will never store any version information - it's a complete new file !
/*N*/     pMergedParams->ClearItem( SID_VERSION );
/*N*/
/*N*/     // merge the new parameters into the copy
/*N*/     // all values present in both itemsets will be overwritten by the new parameters
/*N*/     if( pParams )
/*N*/ 		pMergedParams->Put( *pParams );
/*N*/     //DELETEZ( pParams );
/*N*/
/*N*/ #ifdef DBG_UTIL
/*N*/     if ( pMergedParams->GetItemState( SID_DOC_SALVAGE) >= SFX_ITEM_SET )
/*N*/         DBG_ERROR("Salvage item present in Itemset, check the parameters!");
/*N*/ #endif
/*N*/
/*N*/     // should be unneccessary - too hot to handle!
/*N*/ 	pMergedParams->ClearItem( SID_DOC_SALVAGE );
/*N*/
/*N*/     // take over the new merged itemset
/*N*/ 	pParams = pMergedParams;
/*N*/
/*N*/     // create a medium for the target URL
/*N*/     SfxMedium *pNewFile = new SfxMedium( rFileName, STREAM_READWRITE | STREAM_SHARE_DENYWRITE, sal_False, 0, pParams );
/*N*/
/*N*/     // set filter; if no filter is given, take the default filter of the factory
/*N*/     if ( aFilterName.Len() )
/*N*/         pNewFile->SetFilter( GetFactory(), aFilterName );
/*N*/ 	else
/*N*/         pNewFile->SetFilter( GetFactory().GetFilterContainer()->GetFilter(0) );
/*N*/
/*N*/     // saving is alway done using a temporary file
/*N*/     pNewFile->CreateTempFileNoCopy();
/*N*/     if ( pNewFile->GetErrorCode() != ERRCODE_NONE )
/*N*/     {
/*N*/         // creating temporary file failed ( f.e. floppy disk not inserted! )
/*N*/         SetError( pNewFile->GetError() );
/*N*/         delete pNewFile;
/*N*/         return sal_False;
/*N*/     }
/*N*/
/*N*/     // check if a "SaveTo" is wanted, no "SaveAs"
/*N*/     SFX_ITEMSET_ARG( pParams, pSaveToItem, SfxBoolItem, SID_SAVETO, sal_False );
/*N*/     sal_Bool bCopyTo = GetCreateMode() == SFX_CREATE_MODE_EMBEDDED || pSaveToItem && pSaveToItem->GetValue();
/*N*/
/*N*/     // some base URL stuff ( awful, but not avoidable ... )
/*N*/     const String aOldURL( ::binfilter::StaticBaseUrl::GetBaseURL() );
/*N*/ 	if( GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
/*N*/ 		if ( ShallSetBaseURL_Impl(*pNewFile) )
/*N*/ 			::binfilter::StaticBaseUrl::SetBaseURL( pNewFile->GetBaseURL() );
/*N*/ 		else
/*N*/ 			::binfilter::StaticBaseUrl::SetBaseURL( String() );
/*N*/
/*N*/     // distinguish between "Save" and "SaveAs"
/*N*/     pImp-> bIsSaving = sal_False;
/*N*/
/*N*/ 	sal_Bool bToOwnFormat = sal_True;//STRIP007 IsOwnStorageFormat_Impl(*pNewFile);
/*N*/ 	if ( bToOwnFormat )
/*N*/ 	{
/*N*/         // If the filter is a "cross export" filter ( f.e. a filter for exporting an impress document from
/*N*/         // a draw document ), the ClassId of the destination storage is different from the ClassId of this
/*N*/         // document. It can be retrieved from the default filter for the desired target format
/*N*/         long nFormat = pNewFile->GetFilter()->GetFormat();
/*N*/ 		SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher();
/*N*/ 		const SfxFilter *pFilt = rMatcher.GetFilter4ClipBoardId( nFormat );
/*N*/ 		if ( pFilt )
/*N*/ 		{
/*N*/             if ( pFilt->GetFilterContainer() != pNewFile->GetFilter()->GetFilterContainer() )
/*N*/                 pNewFile->GetStorage()->SetClass( SvFactory::GetServerName( nFormat ), nFormat, pFilt->GetTypeName() );
/*N*/ 		}
/*N*/ 	}
/*N*/
/*N*/ 	if ( GetMedium()->GetFilter() && ( GetMedium()->GetFilter()->GetFilterFlags() & SFX_FILTER_PACKED ) )
/*N*/ 	{DBG_BF_ASSERT(0, "STRIP"); //STRIP001
/*N*/ 	}
/*N*/
/*N*/     // Save the document ( first as temporary file, then transfer to the target URL by committing the medium )
/*N*/     sal_Bool bOk = sal_False;
/*N*/     if ( !pNewFile->GetErrorCode() && SaveTo_Impl( *pNewFile, NULL, sal_True ) )
/*N*/ 	{
/*N*/ 		bOk = sal_True;
/*N*/
/*N*/         // restore old BaseURL
/*N*/ 		::binfilter::StaticBaseUrl::SetBaseURL( aOldURL );
/*N*/
/*N*/         // transfer a possible error from the medium to the document
/*N*/         SetError( pNewFile->GetErrorCode() );
/*N*/
/*N*/         // notify the document that saving was done successfully
/*N*/         if ( bCopyTo )
/*N*/ 		{
/*N*/         	if ( IsHandsOff() )
/*N*/ 				bOk = DoSaveCompleted( pMedium );
/*N*/ 		}
/*N*/ 		else
/*N*/ 		{
/*N*/ 			// Muss !!!
/*N*/ 			if ( bToOwnFormat )
/*N*/ 				SetFileName( pNewFile->GetPhysicalName() );
/*N*/
/*N*/ 			bOk = DoSaveCompleted( pNewFile );
/*N*/ 		}
/*N*/
/*N*/ 		if( bOk )
/*N*/ 		{
/*N*/             if( !bCopyTo )
/*N*/                 SetModified( sal_False );
/*N*/ 		}
/*N*/ 		else
/*N*/ 		{
/*N*/             DBG_ASSERT( !bCopyTo, "Error while reconnecting to medium, can't be handled!");
/*N*/ 			SetError( pNewFile->GetErrorCode() );
/*N*/
/*N*/             if ( !bCopyTo )
/*N*/             {
/*N*/                 // reconnect to the old medium
/*?*/                 BOOL bRet = DoSaveCompleted( pMedium );
/*?*/                 DBG_ASSERT( bRet, "Error in DoSaveCompleted, can't be handled!");
/*N*/             }
/*N*/
/*N*/ 			DELETEZ( pNewFile );
/*N*/ 		}
/*N*/
/*N*/ 		String aPasswd;
/*N*/ 		if ( IsOwnStorageFormat_Impl( *GetMedium() ) && GetPasswd_Impl( GetMedium()->GetItemSet(), aPasswd ) )
/*?*/ 			GetMedium()->GetStorage()->SetKey( S2BS( aPasswd ) );	//!!! (pb) needs new implementation
/*N*/ 	}
/*N*/ 	else
/*N*/ 	{
/*?*/ 		::binfilter::StaticBaseUrl::SetBaseURL( aOldURL );
/*?*/         SetError( pNewFile->GetErrorCode() );
/*?*/
/*?*/         // reconnect to the old storage
/*?*/         if ( IsHandsOff() )
/*?*/             DoSaveCompleted( pMedium );
/*?*/         else
/*?*/             DoSaveCompleted( (SvStorage*)0 );
/*?*/
/*?*/         DELETEZ( pNewFile );
/*N*/ 	}
/*N*/
/*N*/     if( !bOk )
/*?*/         SetModified( sal_True );
/*N*/
/*N*/ 	if ( bCopyTo )
/*N*/         DELETEZ( pNewFile );
/*N*/
/*N*/ 	return bOk;
/*N*/ }

//------------------------------------------------------------------------

/*?*/ sal_Bool SfxObjectShell::LoadFrom( SvStorage *pStor )
/*?*/ {
/*?*/ 	GetConfigManager();
/*?*/ 	GetDocInfo().Load(pStor);
/*?*/ 	return sal_True;
/*?*/ }

//-------------------------------------------------------------------------

/*N*/ sal_Bool SfxObjectShell::IsInformationLost()
/*N*/ {
/*N*/ 	const SfxFilter *pFilt = GetMedium()->GetFilter();
/*N*/     if ( pFilt == GetFactory().GetFilterContainer()->GetFilter(0) )
/*N*/         return sal_False;
/*N*/     return pFilt && pFilt->IsAlienFormat() && pImp->bDidDangerousSave && !(pFilt->GetFilterFlags() & SFX_FILTER_SILENTEXPORT);
/*N*/ }

/*N*/ sal_Bool SfxObjectShell::LoadOwnFormat( SfxMedium& rMedium )
/*N*/ {
/*N*/ 	SvStorageRef xStor = rMedium.GetStorage();
/*N*/ 	if ( xStor.Is() )
/*N*/ 	{
/*N*/ 		if ( rMedium.GetFileVersion() )
/*N*/ 			xStor->SetVersion( rMedium.GetFileVersion() );
/*N*/
/*N*/ 		// Password
/*N*/         SFX_ITEMSET_ARG( rMedium.GetItemSet(), pPasswdItem, SfxStringItem, SID_PASSWORD, sal_False );
/*N*/         if ( pPasswdItem || ERRCODE_IO_ABORT != CheckPasswd_Impl( this, SFX_APP()->GetPool(), pMedium ) )
/*N*/ 		{
/*N*/ 			String aPasswd;
/*N*/ 			if ( GetPasswd_Impl(pMedium->GetItemSet(), aPasswd) )
/*N*/ 				xStor->SetKey( S2BS( aPasswd ) ); //!!! (pb) needs new implementation
/*N*/
/*N*/ 			// load document
                sal_Bool bRet = Load( xStor );
                if ( bRet )
                    GetConfigManager( TRUE );
                return bRet;
/*N*/ 		}
/*N*/ 		return sal_False;
/*N*/ 	}
/*N*/ 	else
/*N*/ 		return sal_False;
/*N*/ }

/*N*/ sal_Bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium )
/*N*/ {
/*N*/ 	SvStorageRef xStor = rMedium.GetStorage();
/*N*/ 	if( xStor.Is() )
/*N*/ 	{
/*N*/ 		ULONG nVersion = rMedium.GetFilter()->GetVersion();
/*N*/ 		xStor->SetVersion( nVersion );
/*N*/
/*N*/ 		// Initialize Basic
/*N*/ 		GetBasicManager();
/*N*/
/*N*/ 		// Save dialog container
/*N*/ 		if( nVersion >= 6200 )
/*N*/ 		{
/*N*/ 			SfxDialogLibraryContainer* pDialogCont = pImp->pDialogLibContainer;
/*N*/ 			if( pDialogCont )
/*N*/ 				pDialogCont->storeLibrariesToStorage( (SotStorage*)(SvStorage*)xStor );
/*N*/
/*N*/ 			SfxScriptLibraryContainer* pBasicCont = pImp->pBasicLibContainer;
/*N*/ 			if( pBasicCont )
/*N*/ 				pBasicCont->storeLibrariesToStorage( (SotStorage*)(SvStorage*)xStor );
/*N*/
/*N*/ 			// Konfiguration schreiben
/*N*/ 			if ( GetConfigManager() )
/*N*/ 			{
/* //!MBA
                if ( rDocInfo.HasTemplateConfig() )
                {
                    const String aTemplFileName( rDocInfo.GetTemplateFileName() );
                    if ( aTemplFileName.Len() )
                    {
                        INetURLObject aURL( aTemplFileName );
                        DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "Illegal URL !" );

                        SvStorageRef aStor = new SvStorage( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
                        if ( SVSTREAM_OK == aStor->GetError() )
                        {
                            GetConfigManager()->StoreConfiguration(aStor);
                            if (aRef->IsStream(SfxConfigManager::GetStreamName()))
                                aRef->Remove(SfxConfigManager::GetStreamName());
                        }
                    }
                }
                else
 */
/*N*/ 				{
//! MBA                    GetConfigManager()->SetModified( sal_True );
/*N*/ 					SotStorageRef xCfgStor = pImp->pCfgMgr->GetConfigurationStorage( xStor );
/*N*/                     if ( pImp->pCfgMgr->StoreConfiguration( xCfgStor ) )
/*N*/ 						xCfgStor->Commit();
/*N*/ 				}
/*N*/ 			}
/*N*/
/*N*/ 		}
/*N*/
/*N*/ 		const SfxFilter* pFilter = rMedium.GetFilter();
/*N*/ 		return SaveAs( xStor );
/*N*/ 	}
/*N*/ 	else return sal_False;
/*N*/ }


/*N*/ void SfxObjectShell::AddXMLAsZipToTheStorage( SvStorage& rRoot )
/*N*/ {
/*N*/ 	static struct _ObjExpType {
/*N*/ 		sal_Bool (SvtAddXMLToStorageOptions:: *fnIsAdd)() const;
/*N*/ 		const sal_Char* pModuleNm;
/*N*/ 		// GlobalNameId
/*N*/ 		UINT32 n1;
/*N*/ 		USHORT n2, n3;
/*N*/ 		BYTE b8, b9, b10, b11, b12, b13, b14, b15;
/*N*/ 	} aArr[] = {
/*N*/ 		{ &SvtAddXMLToStorageOptions::IsWriter_Add_XML_to_Storage,
/*N*/ 			"Writer", BF_SO3_SW_CLASSID_50 },
/*N*/ 		{ &SvtAddXMLToStorageOptions::IsCalc_Add_XML_to_Storage,
/*N*/ 			"Calc", BF_SO3_SC_CLASSID_50 },
/*N*/ 		{ &SvtAddXMLToStorageOptions::IsImpress_Add_XML_to_Storage,
/*N*/ 			"Impress", BF_SO3_SIMPRESS_CLASSID_50 },
/*N*/ 		{ &SvtAddXMLToStorageOptions::IsDraw_Add_XML_to_Storage,
/*N*/ 			"Draw", BF_SO3_SDRAW_CLASSID_50 },
/*N*/ 		{ 0 }
/*N*/ 	};
/*N*/
/*N*/ 	for( const _ObjExpType* pArr = aArr; pArr->fnIsAdd; ++pArr )
/*N*/ 	{
/*N*/ 		SvGlobalName aGlbNm( pArr->n1, pArr->n2, pArr->n3,
/*N*/ 							pArr->b8, pArr->b9, pArr->b10, pArr->b11,
/*N*/ 							pArr->b12, pArr->b13, pArr->b14, pArr->b15 );
/*N*/ 		if( *GetSvFactory() == aGlbNm )
/*N*/ 		{
/*?*/ 			// 1. check if the option is set and unequal 0 or is not set
/*?*/ 			SvtAddXMLToStorageOptions aOpt;
/*?*/ 			if( (aOpt.*pArr->fnIsAdd)() )
/*?*/ 			{
/*?*/ 				// the flag is set
/*?*/ 				String sStr;
/*?*/ 				sStr.AssignAscii( "StarOffice XML (" );
/*?*/ 				sStr.AppendAscii( pArr->pModuleNm );
/*?*/ 				sStr += ')';
/*?*/ 				// 2. exist the XML filter? "StarOffice XML (<Application>)"?
/*?*/ 				const SfxFilter* pFilter = GetFactory().GetFilterContainer()->
/*?*/ 												GetFilter4FilterName( sStr );
/*?*/ 				if( pFilter )
/*?*/ 				{
/*?*/ 					::utl::TempFile aTempFile;
/*?*/ 					SfxMedium		aTmpMed( aTempFile.GetURL(), STREAM_READ | STREAM_WRITE, sal_True );
/*?*/
/*?*/ 					aTmpMed.SetFilter( pFilter );
/*?*/
/*?*/ 					if( ConvertTo( aTmpMed ) )
/*?*/ 					{
/*?*/                         SvStorage* pXMLStor = aTmpMed.GetStorage();
/*?*/
/*?*/ 						if( pXMLStor )
/*?*/ 						{
/*?*/ 							const String	aContent( String::CreateFromAscii( "Content" ) );
/*?*/ 							const String	aContentXML( String::CreateFromAscii( "Content.xml" ) );
/*?*/ 							const String	aXMLFormatName( String::CreateFromAscii( "XMLFormat2" ) );
/*?*/ 							String			aContentName;
/*?*/
/*?*/ 							if( pXMLStor->IsContained( aContentXML ) )
/*?*/ 								aContentName = aContentXML;
/*?*/ 							else if( pXMLStor->IsContained( aContent ) )
/*?*/ 								aContentName = aContent;
/*?*/
/*?*/ 							if( aContentName.Len() )
/*?*/ 							{
/*?*/ 								SvStorageStreamRef	xOStm( rRoot.OpenStream( aXMLFormatName, STREAM_WRITE | STREAM_TRUNC ) );
/*?*/ 								SvStorageStreamRef	xIStm( pXMLStor->OpenStream( aContentName, STREAM_READ | STREAM_NOCREATE ) );
/*?*/
/*?*/ 								if( xOStm.Is() && xIStm.Is() )
/*?*/ 								{
/*?*/ 									ZCodec aCodec;
/*?*/
/*?*/ 									xIStm->Seek( 0 );
/*?*/ 									aCodec.BeginCompression( ZCODEC_BEST_COMPRESSION );
/*?*/ 									aCodec.Compress( *xIStm, *xOStm );
/*?*/ 									aCodec.EndCompression();
/*?*/ 									xOStm->Commit();
/*?*/ 								}
/*?*/ 							}
/*?*/ 						}
/*?*/ 					}
/*?*/ 				}
/*?*/ 			}
/*?*/ 			// that's all
/*?*/ 			break;
/*N*/ 		}
/*N*/ 	}
/*N*/ }
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */