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
|
/*************************************************************************
*
* 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.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/frame/XDispatchHelper.hpp>
#include <comphelper/processfactory.hxx>
#include <hintids.hxx>
#include <tools/urlobj.hxx>
#include <unotools/tempfile.hxx>
#include <vcl/wrkwin.hxx>
#include <vcl/msgbox.hxx>
#include <svl/lckbitem.hxx>
#include <svl/eitem.hxx>
#include <svl/zforlist.hxx>
#include <svl/zformat.hxx>
#include <unotools/pathoptions.hxx>
#include <svtools/transfer.hxx>
#include <sfx2/dialogs.hrc>
#include <sfx2/dinfdlg.hxx>
#include <sfx2/request.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/new.hxx>
#include <sfx2/filedlghelper.hxx>
#include <sfx2/printer.hxx>
#include <sfx2/evntconf.hxx>
#include <svtools/sfxecode.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx>
#include <svx/svxids.hrc>
#include <svx/drawitem.hxx>
#include <editeng/svxacorr.hxx>
#include <editeng/langitem.hxx>
#include <svx/fmshell.hxx>
#include <sfx2/linkmgr.hxx>
#include <svtools/htmlcfg.hxx>
#include <svx/ofaitem.hxx>
#include <SwSmartTagMgr.hxx>
#include <sfx2/app.hxx>
#include <basic/sbstar.hxx>
#include <basic/basmgr.hxx>
#include <sot/storage.hxx>
#include <sot/clsids.hxx>
#include <swunodef.hxx>
#include <fmtcol.hxx>
#include <swevent.hxx>
#include <view.hxx> // fuer die aktuelle Sicht
#include <docsh.hxx> // Dokumenterzeugung
#include <wrtsh.hxx>
#include <fldbas.hxx>
#include <viewopt.hxx>
#include <globdoc.hxx>
#include <fldwrap.hxx>
#include <redlndlg.hxx>
#include <docstyle.hxx>
#include <doc.hxx>
#include <pagedesc.hxx>
#include <shellio.hxx>
#include <pview.hxx>
#include <srcview.hxx>
#include <poolfmt.hxx>
#include <usrpref.hxx>
#include <wdocsh.hxx>
#include <unotxdoc.hxx>
#include <acmplwrd.hxx>
#include <swmodule.hxx>
#include <unobaseclass.hxx>
#include <swwait.hxx>
#include <swcli.hxx>
#include <cmdid.h>
#include <globals.h>
#include <helpid.h>
#include <app.hrc>
#include <poolfmt.hrc>
#include <globals.hrc>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
#ifdef FUTURE_VBA
#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
#include <com/sun/star/script/vba/VBAEventId.hpp>
#endif
#include <editeng/acorrcfg.hxx>
#include <SwStyleNameMapper.hxx>
#include <sfx2/fcontnr.hxx>
#include "swabstdlg.hxx"
#include "dialog.hrc"
#include "swabstdlg.hxx"
#include <ndtxt.hxx> //#outline level,add by zhaojianwei
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
using ::rtl::OUString;
using namespace ::sfx2;
extern BOOL FindPhyStyle( SwDoc& , const String& , SfxStyleFamily );
/*--------------------------------------------------------------------
Beschreibung: DocInfo kreieren (virtuell)
--------------------------------------------------------------------*/
SfxDocumentInfoDialog* SwDocShell::CreateDocumentInfoDialog(
Window *pParent, const SfxItemSet &rSet)
{
SfxDocumentInfoDialog* pDlg = new SfxDocumentInfoDialog(pParent, rSet);
//nur mit Statistik, wenn dieses Doc auch angezeigt wird, nicht
//aus dem Doc-Manager
SwDocShell* pDocSh = (SwDocShell*) SfxObjectShell::Current();
if( pDocSh == this )
{
//Nicht fuer SourceView.
SfxViewShell *pVSh = SfxViewShell::Current();
if ( pVSh && !pVSh->ISA(SwSrcView) )
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
pDlg->AddTabPage(TP_DOC_STAT, SW_RESSTR(STR_DOC_STAT),pFact->GetTabPageCreatorFunc( TP_DOC_STAT ),0);
}
}
return pDlg;
}
/// update text fields on document properties changes
void SwDocShell::DoFlushDocInfo()
{
if ( !pDoc ) return;
bool bUnlockView(true);
if ( pWrtShell ) {
bUnlockView = !pWrtShell->IsViewLocked();
pWrtShell->LockView( TRUE ); // lock visible section
pWrtShell->StartAllAction();
}
pDoc->DocInfoChgd();
if ( pWrtShell ) {
pWrtShell->EndAllAction();
if ( bUnlockView ) {
pWrtShell->LockView( FALSE );
}
}
}
#ifdef FUTURE_VBA
void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XVBAEventProcessor >& xVbaEvents, const SfxHint& rHint )
{
using namespace com::sun::star::script::vba::VBAEventId;
if ( rHint.ISA( SfxEventHint ) )
{
uno::Sequence< uno::Any > aArgs;
ULONG nEventId = ((SfxEventHint&)rHint).GetEventId();
switch( nEventId )
{
case SFX_EVENT_CREATEDOC:
xVbaEvents->processVbaEvent( DOCUMENT_NEW, aArgs );
break;
case SFX_EVENT_OPENDOC:
xVbaEvents->processVbaEvent( DOCUMENT_OPEN, aArgs );
break;
}
}
}
#endif
/*--------------------------------------------------------------------
Beschreibung: Benachrichtigung bei geaenderter DocInfo
--------------------------------------------------------------------*/
void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
if( !pDoc )
{
return ;
}
#ifdef FUTURE_VBA
uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor();
if( xVbaEvents.is() )
lcl_processCompatibleSfxHint( xVbaEvents, rHint );
#endif
USHORT nAction = 0;
if( rHint.ISA(SfxSimpleHint) )
{
// swithc for more actions
switch( ((SfxSimpleHint&) rHint).GetId() )
{
case SFX_HINT_TITLECHANGED:
if( GetMedium() )
nAction = 2;
break;
}
}
else if( rHint.ISA(SfxEventHint) &&
((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_LOADFINISHED )
{
// --> OD 2004-12-03 #i38126# - own action id
nAction = 3;
// <--
}
if( nAction )
{
BOOL bUnlockView = sal_True; //initializing prevents warning
if( pWrtShell )
{
bUnlockView = !pWrtShell->IsViewLocked();
pWrtShell->LockView( TRUE ); //lock visible section
pWrtShell->StartAllAction();
}
switch( nAction )
{
case 2:
pDoc->GetSysFldType( RES_FILENAMEFLD )->UpdateFlds();
break;
// --> OD 2004-12-03 #i38126# - own action for event LOADFINISHED
// in order to avoid a modified document.
// --> OD 2005-02-01 #i41679# - Also for the instance of <SwDoc>
// it has to be assured, that it's not modified.
// Perform the same as for action id 1, but disable <SetModified>.
case 3:
{
const bool bResetModified = IsEnableSetModified();
if ( bResetModified )
EnableSetModified( FALSE );
// #i41679#
const bool bIsDocModified = pDoc->IsModified();
pDoc->DocInfoChgd( );
// #i41679#
if ( !bIsDocModified )
pDoc->ResetModified();
if ( bResetModified )
EnableSetModified( TRUE );
}
break;
// <--
}
if( pWrtShell )
{
pWrtShell->EndAllAction();
if( bUnlockView )
pWrtShell->LockView( FALSE );
}
}
}
/*--------------------------------------------------------------------
Beschreibung: Benachrichtigung Doc schliessen
--------------------------------------------------------------------*/
USHORT SwDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing )
{
USHORT nRet = SfxObjectShell::PrepareClose( bUI, bForBrowsing );
if( TRUE == nRet ) //Unbedingt auf TRUE abfragen! (RET_NEWTASK)
EndListening( *this );
#ifdef FUTURE_VBA
if( pDoc && IsInPrepareClose() )
{
uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor();
if( xVbaEvents.is() )
{
using namespace com::sun::star::script::vba::VBAEventId;
uno::Sequence< uno::Any > aArgs;
xVbaEvents->processVbaEvent( DOCUMENT_CLOSE, aArgs );
}
}
#endif
return nRet;
}
/*--------------------------------------------------------------------
Beschreibung: Organizer
--------------------------------------------------------------------*/
BOOL SwDocShell::Insert( SfxObjectShell &rSource,
USHORT nSourceIdx1, // SourcePool: oberste Inhaltsebene (Vorlagen/Makros)
USHORT nSourceIdx2, // Index in den Inhalt
USHORT nSourceIdx3, // Index in die Inhaltsebene
USHORT &rIdx1, // und das gleiche fuer den DestinationPool
USHORT &rIdx2, // ""
USHORT &rIdx3, // ""
USHORT &rRemovedIdx ) // falls doppelte geloescht werden, Pos zurueck
{
// --> OD 2005-05-10 #i48949# - actions aren't undoable. Thus, allow no undo
// actions
// Note: The undo action stack is cleared at the end of this method.
bool bDoesUndo( GetDoc()->DoesUndo() );
GetDoc()->DoUndo( sal_False );
// <--
BOOL bRet = FALSE;
if (INDEX_IGNORE == rIdx1 && CONTENT_STYLE == nSourceIdx1)
rIdx1 = CONTENT_STYLE;
if (CONTENT_STYLE == nSourceIdx1 && CONTENT_STYLE == rIdx1)
{
SfxStyleSheetBasePool* pHisPool = rSource.GetStyleSheetPool();
SwDocStyleSheetPool* pMyPool =
(SwDocStyleSheetPool*)GetStyleSheetPool();
// wir koennen nicht in uns selbst hin und her moven
if( pHisPool == pMyPool )
return FALSE;
if( INDEX_IGNORE == rIdx2 )
rIdx2 = pMyPool->Count();
// erstmal auf die Such-Maske "positionieren"
pHisPool->First();
SfxStyleSheetBase* pHisSheet = (*pHisPool)[nSourceIdx2];
// wenn so eine Vorlage schon existiert: loeschen!
const String& rOldName = pHisSheet->GetName();
SfxStyleFamily eOldFamily( pHisSheet->GetFamily() );
// dflt. PageDesc und StandardZeichenvorlage nie loeschen !!!
if( ( SFX_STYLE_FAMILY_PAGE == eOldFamily &&
const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetName() ==
rOldName ) ||
( SFX_STYLE_FAMILY_CHAR == eOldFamily &&
rOldName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
RES_POOLCOLL_TEXT_BEGIN ] ))
return FALSE;
SfxStyleFamily eMyOldFamily( pMyPool->GetSearchFamily() );
USHORT nMySrchMask = pMyPool->GetSearchMask();
SfxStyleSheetBase* pExist;
if( ::FindPhyStyle( *pDoc, rOldName, eOldFamily ) )
{
// Bug 20365: nur uebernehmen, wenn das gewuenscht ist!
if( ERRCODE_BUTTON_OK != ErrorHandler::HandleError(
*new MessageInfo( ERRCODE_SFXMSG_STYLEREPLACE, rOldName )) )
{
return FALSE;
}
// Da Replace den aStyleSheet-Member selbst benoetigt, muss
// das Ergebnis vom Find kopiert werden (s.u.))
rtl::Reference< SwDocStyleSheet > xExist( new SwDocStyleSheet(
*(SwDocStyleSheet*)pMyPool->Find( rOldName, eOldFamily ) ) );
pMyPool->Replace( *pHisSheet, *xExist.get() );
// An der Reihenfolge der Vorlagen im Pool aendert sich nichts.
rIdx2 = rIdx1 = INDEX_IGNORE;
GetDoc()->SetModified();
return TRUE;
}
pMyPool->SetSearchMask( eOldFamily, nMySrchMask );
// MIB 18.12.98: SwDocStyleSheetPool::Make liefert einen
// Pointer auf SwDocStyleSheetPool::aStyleSheet zurueck.
// Der gleiche Member von SwDocStyleSheetPool::Find benutzt.
// Deshalb muss hier mit einer Kopie gearbeitet werden.
// Vorsicht: SfxStyleSheetBase::SetFollow ruft seinerseits
// ein SwDocStyleSheetPool::Find auf, do dass es nicht genuegt
// die Find-Aufrufe in dieser Methode zu eleminieren.
rtl::Reference< SwDocStyleSheet > xNewSheet( new SwDocStyleSheet( (SwDocStyleSheet&)pMyPool
->Make(rOldName, eOldFamily, pHisSheet->GetMask() ) ) );
if( SFX_STYLE_FAMILY_PAGE == eOldFamily && rSource.ISA(SwDocShell) )
{
// gesondert behandeln!!
SwPageDesc* pDestDsc = (SwPageDesc*)xNewSheet->GetPageDesc();
SwPageDesc* pCpyDsc = (SwPageDesc*)((SwDocStyleSheet*)pHisSheet)->GetPageDesc();
pDoc->CopyPageDesc( *pCpyDsc, *pDestDsc );
}
else
// die neue Vorlage mit den Attributen fuellen
xNewSheet->SetItemSet( pHisSheet->GetItemSet() );
pMyPool->SetSearchMask( SFX_STYLE_FAMILY_ALL, nMySrchMask );
if( xNewSheet->IsUserDefined() || xNewSheet->IsUsed() )
{
// Benutzte und Benutzer-definierte Vorlagen werden angezeigt.
// Dshalb muss hier der Index der neuen Vorlage im Pool
// ermittelt werden.
pExist = pMyPool->First();
USHORT nIdx = 0;
while( pExist )
{
if( pExist->GetName() == rOldName &&
eOldFamily == pExist->GetFamily() )
{
rIdx2 = nIdx;
break;
}
pExist = pMyPool->Next();
nIdx++;
}
}
else
{
// Andere Vorlagen werden nicht angezeigt.
rIdx1 = rIdx2 = INDEX_IGNORE;
}
// wer bekommt den Neuen als Parent? wer benutzt den Neuen als Follow?
// (immer nur ueber die Instanziierten!!!)
pMyPool->SetSearchMask( eOldFamily, nMySrchMask );
pMyPool->SetOrganizerMode( TRUE );
SfxStyleSheetBase* pTestSheet = pMyPool->First();
while (pTestSheet)
{
if (pTestSheet->GetFamily() == eOldFamily &&
pTestSheet->HasParentSupport() &&
pTestSheet->GetParent() == rOldName)
{
pTestSheet->SetParent(rOldName); // Verknuepfung neu aufbauen
}
if (pTestSheet->GetFamily() == eOldFamily &&
pTestSheet->HasFollowSupport() &&
pTestSheet->GetFollow() == rOldName)
{
pTestSheet->SetFollow(rOldName); // Verknuepfung neu aufbauen
}
pTestSheet = pMyPool->Next();
}
pMyPool->SetOrganizerMode( SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
// hat der Neue einen Parent? wenn ja, mit gleichem Namen bei uns suchen
if (pHisSheet->HasParentSupport())
{
const String& rParentName = pHisSheet->GetParent();
if (0 != rParentName.Len())
{
SfxStyleSheetBase* pParentOfNew = pMyPool->Find(rParentName,
eOldFamily);
if (pParentOfNew)
{
xNewSheet->SetParent(rParentName);
}
pMyPool->SetSearchMask( eOldFamily, nMySrchMask );
}
}
// hat der Neue einen Follow? wenn ja, mit gleichem Namen bei uns suchen
if (pHisSheet->HasFollowSupport())
{
const String& rFollowName = pHisSheet->GetFollow();
if (0 != rFollowName.Len())
{
SfxStyleSheetBase* pFollowOfNew = pMyPool->Find(rFollowName,
eOldFamily);
if (pFollowOfNew)
{
xNewSheet->SetFollow(rFollowName);
}
pMyPool->SetSearchMask( eOldFamily, nMySrchMask );
}
}
// Bug 27347: alte Einstellung wieder setzen
pMyPool->SetSearchMask( eMyOldFamily, nMySrchMask );
// Model geaendert
ASSERT(pDoc, "Doc fehlt");
GetDoc()->SetModified();
bRet = TRUE;
}
else
bRet = SfxObjectShell::Insert( rSource,
nSourceIdx1,
nSourceIdx2,
nSourceIdx3,
rIdx1,
rIdx2,
rIdx3,
rRemovedIdx);
// --> OD 2005-05-10 #i48949# - actions aren't undoable and could have change
// the document node array. Thus, clear the undo action stack.
if ( bDoesUndo )
{
GetDoc()->DelAllUndoObj();
}
GetDoc()->DoUndo( bDoesUndo );
// <--
return bRet;
}
/*--------------------------------------------------------------------
Beschreibung: Vorlagen Remove
--------------------------------------------------------------------*/
BOOL SwDocShell::Remove(USHORT nIdx1, // siehe Insert
USHORT nIdx2,
USHORT nIdx3)
{
BOOL bRet = FALSE;
if (CONTENT_STYLE == nIdx1)
{
SwDocStyleSheetPool* pMyPool = (SwDocStyleSheetPool*)GetStyleSheetPool();
pMyPool->First(); // vorm Zugriff Pool aktualisieren!!
SfxStyleSheetBase* pMySheet = (*pMyPool)[nIdx2];
String aName( pMySheet->GetName() );
SfxStyleFamily eFamily( pMySheet->GetFamily() );
// dflt. PageDesc und StandardZeichenvorlage nie loeschen !!!
if( ( SFX_STYLE_FAMILY_PAGE == eFamily &&
const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetName()
== aName ) ||
( SFX_STYLE_FAMILY_CHAR == eFamily &&
aName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
RES_POOLCOLL_TEXT_BEGIN ] ))
return FALSE;
// also loeschen
pMyPool->Remove( pMySheet );
// jetzt noch die Parents/Follows aller Instanziierten korrigieren
pMyPool->SetOrganizerMode( TRUE );
SfxStyleSheetBase* pTestSheet = pMyPool->First();
while (pTestSheet)
{
if (pTestSheet->GetFamily() == eFamily &&
pTestSheet->HasParentSupport() &&
pTestSheet->GetParent() == aName)
{
pTestSheet->SetParent( aEmptyStr ); // Verknuepfung aufloesen
}
if (pTestSheet->GetFamily() == eFamily &&
pTestSheet->HasFollowSupport() &&
pTestSheet->GetFollow() == aName)
{
pTestSheet->SetFollow( aEmptyStr ); // Verknuepfung aufloesen
}
pTestSheet = pMyPool->Next();
}
pMyPool->SetOrganizerMode( SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
bRet = TRUE;
}
else
bRet = SfxObjectShell::Remove( nIdx1,
nIdx2,
nIdx3 );
// Model geaendert
ASSERT(pDoc, "Doc fehlt");
GetDoc()->SetModified();
return bRet;
}
/*--------------------------------------------------------------------
Beschreibung:
--------------------------------------------------------------------*/
void SwDocShell::Execute(SfxRequest& rReq)
{
const SfxItemSet* pArgs = rReq.GetArgs();
const SfxPoolItem* pItem;
USHORT nWhich = rReq.GetSlot();
BOOL bDone = FALSE;
switch ( nWhich )
{
case SID_AUTO_CORRECT_DLG:
{
SvxSwAutoFmtFlags* pAFlags = &SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags();
SwAutoCompleteWord& rACW = SwDoc::GetAutoCompleteWords();
bool bOldLocked = rACW.IsLockWordLstLocked(),
bOldAutoCmpltCollectWords = pAFlags->bAutoCmpltCollectWords;
rACW.SetLockWordLstLocked( true );
SvStringsISortDtor aTmpLst;
aTmpLst.Insert( &rACW.GetWordList() );
pAFlags->pAutoCmpltList = &aTmpLst;
SfxApplication* pApp = SFX_APP();
SfxRequest aAppReq(SID_AUTO_CORRECT_DLG, SFX_CALLMODE_SYNCHRON, pApp->GetPool());
SfxBoolItem aSwOptions( SID_AUTO_CORRECT_DLG, TRUE );
aAppReq.AppendItem(aSwOptions);
// SMARTTAGS
pAFlags->pSmartTagMgr = &SwSmartTagMgr::Get();
SfxItemSet aSet( pApp->GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG, SID_OPEN_SMARTTAGOPTIONS, SID_OPEN_SMARTTAGOPTIONS, 0 );
aSet.Put( aSwOptions );
const SfxPoolItem* pOpenSmartTagOptionsItem = 0;
if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_OPEN_SMARTTAGOPTIONS, FALSE, &pOpenSmartTagOptionsItem ) )
aSet.Put( *static_cast<const SfxBoolItem*>(pOpenSmartTagOptionsItem) );
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL );
pDlg->Execute();
delete pDlg;
rACW.SetLockWordLstLocked( bOldLocked );
SwEditShell::SetAutoFmtFlags( pAFlags );
rACW.SetMinWordLen( pAFlags->nAutoCmpltWordLen );
rACW.SetMaxCount( pAFlags->nAutoCmpltListLen );
if( pAFlags->pAutoCmpltList ) // any changes?
{
rACW.CheckChangedList( aTmpLst );
// clear the temp WordList pointer
pAFlags->pAutoCmpltList = 0;
}
// remove all pointer we never delete the strings
aTmpLst.Remove( (USHORT)0, aTmpLst.Count() );
if( !bOldAutoCmpltCollectWords && bOldAutoCmpltCollectWords !=
pAFlags->bAutoCmpltCollectWords )
{
// call on all Docs the idle formatter to start
// the collection of Words
TypeId aType = TYPE(SwDocShell);
for( SwDocShell *pDocSh = (SwDocShell*)SfxObjectShell::GetFirst(&aType);
pDocSh;
pDocSh = (SwDocShell*)SfxObjectShell::GetNext( *pDocSh, &aType ) )
{
SwDoc* pTmp = pDocSh->GetDoc();
if ( pTmp->GetRootFrm() )
pTmp->InvalidateAutoCompleteFlag();
}
}
}
break;
case SID_PRINTPREVIEW:
{
BOOL bSet = FALSE, bFound = FALSE, bOnly = TRUE;
SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this);
SfxViewShell* pViewShell = SfxViewShell::Current();
SwView* pCurrView = dynamic_cast< SwView *> ( pViewShell );
BOOL bCurrent = IS_TYPE( SwPagePreView, pViewShell );
while( pTmpFrm ) // search PreView
{
if( IS_TYPE( SwView, pTmpFrm->GetViewShell()) )
bOnly = FALSE;
else if( IS_TYPE( SwPagePreView, pTmpFrm->GetViewShell()))
{
pTmpFrm->GetFrame().Appear();
bFound = TRUE;
}
if( bFound && !bOnly )
break;
pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this);
}
if( pArgs && SFX_ITEM_SET ==
pArgs->GetItemState( SID_PRINTPREVIEW, FALSE, &pItem ))
bSet = ((SfxBoolItem*)pItem)->GetValue();
else
bSet = !bCurrent;
USHORT nSlotId = 0;
if( bSet && !bFound ) // Keine gefunden, daher neue Preview anlegen
{
//Keine neue anlegen fuer BrowseView!
if( !GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE) )
nSlotId = SID_VIEWSHELL1;
}
else if( bFound && !bSet )
nSlotId = bOnly ? SID_VIEWSHELL0 : SID_VIEWSHELL1;
if( nSlotId )
{
//JP 23.8.2001: Bug 91360 - PagePreView in the WebDocShell
// is found under Id ViewShell2.
if( ISA(SwWebDocShell) && SID_VIEWSHELL1 == nSlotId )
nSlotId = SID_VIEWSHELL2;
if( pCurrView && pCurrView->GetDocShell() == this )
pTmpFrm = pCurrView->GetViewFrame();
else
pTmpFrm = SfxViewFrame::GetFirst( this );
pTmpFrm->GetDispatcher()->Execute( nSlotId, 0, 0, SFX_CALLMODE_ASYNCHRON );
}
rReq.SetReturnValue(SfxBoolItem(SID_PRINTPREVIEW, bSet ));
}
break;
case SID_TEMPLATE_LOAD:
{
String aFileName;
static BOOL bText = TRUE;
static BOOL bFrame = FALSE;
static BOOL bPage = FALSE;
static BOOL bNum = FALSE;
static BOOL bMerge = FALSE;
USHORT nRet = USHRT_MAX;
USHORT nFlags = bFrame ? SFX_LOAD_FRAME_STYLES : 0;
if(bPage)
nFlags|= SFX_LOAD_PAGE_STYLES;
if(bNum)
nFlags|= SFX_LOAD_NUM_STYLES;
if(!nFlags || bText)
nFlags|= SFX_LOAD_TEXT_STYLES;
if(bMerge)
nFlags|= SFX_MERGE_STYLES;
if ( pArgs )
{
SFX_REQUEST_ARG( rReq, pTemplateItem, SfxStringItem, SID_TEMPLATE_NAME, FALSE );
if ( pTemplateItem )
{
aFileName = pTemplateItem->GetValue();
SFX_REQUEST_ARG( rReq, pFlagsItem, SfxInt32Item, SID_TEMPLATE_LOAD, FALSE );
if ( pFlagsItem )
nFlags = (USHORT) pFlagsItem->GetValue();
}
}
if ( !aFileName.Len() )
{
SvtPathOptions aPathOpt;
SfxNewFileDialog* pNewFileDlg =
new SfxNewFileDialog(&GetView()->GetViewFrame()->GetWindow(), SFXWB_LOAD_TEMPLATE);
pNewFileDlg->SetTemplateFlags(nFlags);
nRet = pNewFileDlg->Execute();
if(RET_TEMPLATE_LOAD == nRet)
{
FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
SfxObjectFactory &rFact = GetFactory();
SfxFilterMatcher aMatcher( String::CreateFromAscii(rFact.GetShortName()) );
SfxFilterMatcherIter aIter( &aMatcher );
uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
const SfxFilter* pFlt = aIter.First();
while( pFlt )
{
if( pFlt && pFlt->IsAllowedAsTemplate() )
{
const String sWild = ((WildCard&)pFlt->GetWildcard()).GetWildCard();
xFltMgr->appendFilter( pFlt->GetUIName(), sWild );
}
pFlt = aIter.Next();
}
BOOL bWeb = 0 != dynamic_cast< SwWebDocShell *>( this );
const SfxFilter *pOwnFlt =
SwDocShell::Factory().GetFilterContainer()->
GetFilter4FilterName(String::CreateFromAscii("writer8"));
//#b6439685# make sure the default file format is also available
if(bWeb)
{
const String sWild = ((WildCard&)pOwnFlt->GetWildcard()).GetWildCard();
xFltMgr->appendFilter( pOwnFlt->GetUIName(), sWild );
}
bool bError = false;
//#b6439685# catch expception if wrong filter is selected - should not happen anymore
try
{
xFltMgr->setCurrentFilter( pOwnFlt->GetUIName() );
}
catch( const uno::Exception& )
{
bError = true;
}
if( !bError && ERRCODE_NONE == aDlgHelper.Execute() )
{
aFileName = xFP->getFiles().getConstArray()[0];
}
}
else if( RET_OK == nRet)
{
aFileName = pNewFileDlg->GetTemplateFileName();
}
nFlags = pNewFileDlg->GetTemplateFlags();
rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) );
rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, (long) nFlags ) );
delete pNewFileDlg;
}
if( aFileName.Len() )
{
SwgReaderOption aOpt;
aOpt.SetTxtFmts( bText = (0 != (nFlags&SFX_LOAD_TEXT_STYLES) ));
aOpt.SetFrmFmts( bFrame = (0 != (nFlags&SFX_LOAD_FRAME_STYLES)));
aOpt.SetPageDescs( bPage = (0 != (nFlags&SFX_LOAD_PAGE_STYLES )));
aOpt.SetNumRules( bNum = (0 != (nFlags&SFX_LOAD_NUM_STYLES )));
//different meaning between SFX_MERGE_STYLES and aOpt.SetMerge!
bMerge = 0 != (nFlags&SFX_MERGE_STYLES);
aOpt.SetMerge( !bMerge );
SetError( LoadStylesFromFile( aFileName, aOpt, FALSE ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
if ( !GetError() )
rReq.Done();
}
}
break;
case SID_SOURCEVIEW:
{
SfxViewShell* pViewShell = GetView()
? (SfxViewShell*)GetView()
: SfxViewShell::Current();
SfxViewFrame* pViewFrm = pViewShell->GetViewFrame();
SwSrcView* pSrcView = dynamic_cast< SwSrcView *>( pViewShell );
if(!pSrcView)
{
// 3 possible state:
// 1 - file unsaved -> save as HTML
// 2 - file modified and HTML filter active -> save
// 3 - file saved in non-HTML -> QueryBox to save as HTML
const SfxFilter* pHtmlFlt =
SwIoSystem::GetFilterOfFormat(
String::CreateFromAscii("HTML"),
SwWebDocShell::Factory().GetFilterContainer() );
BOOL bLocalHasName = HasName();
if(bLocalHasName)
{
//check for filter type
const SfxFilter* pFlt = GetMedium()->GetFilter();
if(!pFlt || pFlt->GetUserData() != pHtmlFlt->GetUserData())
{
QueryBox aQuery(&pViewFrm->GetWindow(), SW_RES(MSG_SAVEAS_HTML_QUERY));
if(RET_YES == aQuery.Execute())
bLocalHasName = FALSE;
else
break;
}
}
if(!bLocalHasName)
{
FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
aDlgHelper.AddFilter( pHtmlFlt->GetFilterName(), pHtmlFlt->GetDefaultExtension() );
aDlgHelper.SetCurrentFilter( pHtmlFlt->GetFilterName() );
if( ERRCODE_NONE != aDlgHelper.Execute())
{
break;
}
String sPath = aDlgHelper.GetPath();
SfxStringItem aName(SID_FILE_NAME, sPath);
SfxStringItem aFilter(SID_FILTER_NAME, pHtmlFlt->GetName());
const SfxBoolItem* pBool = (const SfxBoolItem*)
pViewFrm->GetDispatcher()->Execute(
SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON, &aName, &aFilter, 0L );
if(!pBool || !pBool->GetValue())
break;
}
}
#ifdef DBG_UTIL
{
BOOL bWeb = 0 != dynamic_cast<SwWebDocShell*>(this);
DBG_ASSERT(bWeb == TRUE, "SourceView nur in der WebDocShell");
}
#endif
// die SourceView ist fuer die SwWebDocShell die 1
USHORT nSlot = SID_VIEWSHELL1;
BOOL bSetModified = FALSE;
SfxPrinter* pSavePrinter = 0;
if( 0 != pSrcView)
{
SfxPrinter* pTemp = GetDoc()->getPrinter( false );
if(pTemp)
pSavePrinter = new SfxPrinter(*pTemp);
bSetModified = IsModified() || pSrcView->IsModified();
if(pSrcView->IsModified()||pSrcView->HasSourceSaved())
{
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
pSrcView->SaveContent(aTempFile.GetURL());
bDone = TRUE;
SfxEventConfiguration* pEvent = SFX_APP()->GetEventConfig();
SvxMacro aMac(aEmptyStr, aEmptyStr, STARBASIC);
pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ), aMac, this);
pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ), aMac, this);
pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), aMac, this);
pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ), aMac, this);
ReloadFromHtml(aTempFile.GetURL(), pSrcView);
nSlot = 0;
}
else
{
nSlot = SID_VIEWSHELL0;
}
}
if(nSlot)
pViewFrm->GetDispatcher()->Execute(nSlot, SFX_CALLMODE_SYNCHRON);
if(bSetModified)
GetDoc()->SetModified();
if(pSavePrinter)
{
GetDoc()->setPrinter( pSavePrinter, true, true);
//pSavePrinter darf nicht wieder geloescht werden
}
pViewFrm->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, nSlot == SID_VIEWSHELL2));
pViewFrm->GetBindings().Invalidate( SID_BROWSER_MODE );
pViewFrm->GetBindings().Invalidate( FN_PRINT_LAYOUT );
}
break;
case SID_GET_COLORTABLE:
{
SvxColorTableItem* pColItem = (SvxColorTableItem*)GetItem(SID_COLOR_TABLE);
XColorTable* pTable = pColItem->GetColorTable();
rReq.SetReturnValue(OfaPtrItem(SID_GET_COLORTABLE, pTable));
}
break;
case FN_ABSTRACT_STARIMPRESS:
case FN_ABSTRACT_NEWDOC:
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
AbstractSwInsertAbstractDlg* pDlg = pFact->CreateSwInsertAbstractDlg(0, DLG_INSERT_ABSTRACT );
DBG_ASSERT(pDlg, "Dialogdiet fail!");
if(RET_OK == pDlg->Execute())
{
BYTE nLevel = pDlg->GetLevel();
BYTE nPara = pDlg->GetPara();
SwDoc* pSmryDoc = new SwDoc();
SfxObjectShellRef xDocSh( new SwDocShell( pSmryDoc, SFX_CREATE_MODE_STANDARD));
xDocSh->DoInitNew( 0 );
BOOL bImpress = FN_ABSTRACT_STARIMPRESS == nWhich;
pDoc->Summary( pSmryDoc, nLevel, nPara, bImpress );
if( bImpress )
{
WriterRef xWrt;
// mba: looks as if relative URLs don't make sense here
::GetRTFWriter( aEmptyStr, String(), xWrt );
SvMemoryStream *pStrm = new SvMemoryStream();
pStrm->SetBufferSize( 16348 );
SwWriter aWrt( *pStrm, *pSmryDoc );
ErrCode eErr = aWrt.Write( xWrt );
if( !ERRCODE_TOERROR( eErr ) )
{
uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
uno::Reference< frame::XDispatchProvider > xProv(
xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY );
if ( xProv.is() )
{
::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( "SendOutlineToImpress" );
uno::Reference< frame::XDispatchHelper > xHelper(
xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY );
if ( xHelper.is() )
{
pStrm->Seek( STREAM_SEEK_TO_END );
*pStrm << '\0';
pStrm->Seek( STREAM_SEEK_TO_BEGIN );
// Transfer ownership of stream to a lockbytes object
SvLockBytes aLockBytes( pStrm, TRUE );
SvLockBytesStat aStat;
if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE )
{
sal_uInt32 nLen = aStat.nSize;
ULONG nRead = 0;
uno::Sequence< sal_Int8 > aSeq( nLen );
aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead );
uno::Sequence< beans::PropertyValue > aArgs(1);
aArgs[0].Name = ::rtl::OUString::createFromAscii("RtfOutline");
aArgs[0].Value <<= aSeq;
xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs );
}
}
}
}
else
ErrorHandler::HandleError(ErrCode( eErr ));
}
else
{
// Neues Dokument erzeugen.
SfxViewFrame *pFrame = SfxViewFrame::LoadDocument( *xDocSh, 0 );
SwView *pCurrView = (SwView*) pFrame->GetViewShell();
// Dokumenttitel setzen
String aTmp( SW_RES(STR_ABSTRACT_TITLE) );
aTmp += GetTitle();
xDocSh->SetTitle( aTmp );
pCurrView->GetWrtShell().SetNewDoc();
pFrame->Show();
pSmryDoc->SetModified();
}
}
delete pDlg;
}
break;
case FN_OUTLINE_TO_CLIPBOARD:
case FN_OUTLINE_TO_IMPRESS:
{
WriterRef xWrt;
// mba: looks as if relative URLs don't make sense here
::GetRTFWriter( 'O', String(), xWrt );
SvMemoryStream *pStrm = new SvMemoryStream();
pStrm->SetBufferSize( 16348 );
SwWriter aWrt( *pStrm, *GetDoc() );
ErrCode eErr = aWrt.Write( xWrt );
if( !ERRCODE_TOERROR( eErr ) )
{
pStrm->Seek( STREAM_SEEK_TO_END );
*pStrm << '\0';
pStrm->Seek( STREAM_SEEK_TO_BEGIN );
if ( nWhich == FN_OUTLINE_TO_IMPRESS )
{
uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
uno::Reference< frame::XDispatchProvider > xProv(
xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY );
if ( xProv.is() )
{
::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( "SendOutlineToImpress" );
uno::Reference< frame::XDispatchHelper > xHelper(
xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY );
if ( xHelper.is() )
{
pStrm->Seek( STREAM_SEEK_TO_END );
*pStrm << '\0';
pStrm->Seek( STREAM_SEEK_TO_BEGIN );
// Transfer ownership of stream to a lockbytes object
SvLockBytes aLockBytes( pStrm, TRUE );
SvLockBytesStat aStat;
if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE )
{
sal_uInt32 nLen = aStat.nSize;
ULONG nRead = 0;
uno::Sequence< sal_Int8 > aSeq( nLen );
aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead );
uno::Sequence< beans::PropertyValue > aArgs(1);
aArgs[0].Name = ::rtl::OUString::createFromAscii("RtfOutline");
aArgs[0].Value <<= aSeq;
xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs );
}
}
}
}
else
{
TransferDataContainer* pClipCntnr =
new TransferDataContainer;
STAR_REFERENCE( datatransfer::XTransferable )
xRef( pClipCntnr );
pClipCntnr->CopyAnyData( FORMAT_RTF, (sal_Char*)
pStrm->GetData(), pStrm->GetEndOfData() );
pClipCntnr->CopyToClipboard(
GetView()? (Window*)&GetView()->GetEditWin() : 0 );
delete pStrm;
}
}
else
ErrorHandler::HandleError(ErrCode( eErr ));
}
break;
case SID_SPELLCHECKER_CHANGED:
//! FALSE, TRUE, TRUE is on the save side but a probably overdone
SW_MOD()->CheckSpellChanges(FALSE, TRUE, TRUE, FALSE );
break;
case SID_BROWSER_MODE:
case FN_PRINT_LAYOUT: //Fuer Web, genau umgekehrt zum BrowserMode
{
int eState = STATE_TOGGLE;
BOOL bSet = sal_True;
const SfxPoolItem* pAttr=NULL;
if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich , FALSE, &pAttr ))
{
bSet = ((SfxBoolItem*)pAttr)->GetValue();
if ( nWhich == FN_PRINT_LAYOUT )
bSet = !bSet;
eState = bSet ? STATE_ON : STATE_OFF;
}
if ( STATE_TOGGLE == eState )
bSet = !GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE);
ToggleBrowserMode(bSet, 0);
// OS: numerische Reihenfolge beachten!
static USHORT __READONLY_DATA aInva[] =
{
SID_NEWWINDOW,/*5620*/
SID_BROWSER_MODE, /*6313*/
SID_RULER_BORDERS, SID_RULER_PAGE_POS,
SID_ATTR_LONG_LRSPACE,
SID_HTML_MODE,
SID_RULER_PROTECT,
SID_AUTOSPELL_CHECK,
FN_RULER, /*20211*/
FN_VIEW_GRAPHIC, /*20213*/
FN_VIEW_BOUNDS, /**/
FN_VIEW_FIELDS, /*20215*/
FN_VLINEAL, /*20216*/
FN_VSCROLLBAR, /*20217*/
FN_HSCROLLBAR, /*20218*/
FN_VIEW_META_CHARS, /**/
FN_VIEW_MARKS, /**/
FN_VIEW_FIELDNAME, /**/
FN_VIEW_TABLEGRID, /*20227*/
FN_PRINT_LAYOUT, /*20237*/
FN_QRY_MERGE, /*20364*/
0
};
// the view must not exist!
SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst( this );
if( pTmpFrm )
pTmpFrm->GetBindings().Invalidate( aInva );
if ( !pAttr )
rReq.AppendItem( SfxBoolItem( nWhich, bSet ) );
rReq.Done();
}
break;
case SID_MAIL_EXPORT_FINISHED:
{
if(pWrtShell)
pWrtShell->StartAllAction();
//try to undo the removal of invisible content
pDoc->RestoreInvisibleContent();
if(pWrtShell)
pWrtShell->EndAllAction();
}
break;
case FN_NEW_HTML_DOC:
case FN_NEW_GLOBAL_DOC:
{
bDone = FALSE;
BOOL bCreateHtml = FN_NEW_HTML_DOC == nWhich;
BOOL bCreateByOutlineLevel = false; //#outline level,add by zhaojianwei
sal_Int32 nTemplateOutlineLevel = 0 ; //#outline level,add by zhaojianwei
String aFileName, aTemplateName;
if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich, FALSE, &pItem ) )
{
aFileName = ((const SfxStringItem*)pItem)->GetValue();
SFX_ITEMSET_ARG( pArgs, pTemplItem, SfxStringItem, SID_TEMPLATE_NAME, sal_False );
if ( pTemplItem )
aTemplateName = pTemplItem->GetValue();
}
bool bError = false;
if ( !aFileName.Len() )
{
FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE, 0 );
//set HelpIds
const sal_Int16 nControlIds[] = {
CommonFilePickerElementIds::PUSHBUTTON_OK,
CommonFilePickerElementIds::PUSHBUTTON_CANCEL,
CommonFilePickerElementIds::LISTBOX_FILTER,
CommonFilePickerElementIds::CONTROL_FILEVIEW,
CommonFilePickerElementIds::EDIT_FILEURL,
ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION,
ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
0
};
sal_Int32 nHelpIds[8];
sal_Int32 nStartHelpId =
bCreateHtml ?
HID_SEND_HTML_CTRL_PUSHBUTTON_OK : HID_SEND_MASTER_CTRL_PUSHBUTTON_OK ;
for(int nHelp = 0; nHelp < 7; nHelp++)
nHelpIds[nHelp] = nStartHelpId++;
nHelpIds[7] = 0;
aDlgHelper.SetControlHelpIds( nControlIds, nHelpIds );
uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
const SfxFilter* pFlt;
USHORT nStrId;
if( bCreateHtml )
{
// fuer HTML gibts es nur einen Filter!!
pFlt = SwIoSystem::GetFilterOfFormat(
String::CreateFromAscii("HTML"),
SwWebDocShell::Factory().GetFilterContainer() );
nStrId = STR_LOAD_HTML_DOC;
}
else
{
// Fuer Global-Dokumente bieten wir jetzt auch nur
// noch den aktuellen an.
pFlt = SwGlobalDocShell::Factory().GetFilterContainer()->
GetFilter4Extension( String::CreateFromAscii("odm") );
nStrId = STR_LOAD_GLOBAL_DOC;
}
if( pFlt )
{
uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
const String sWild = ((WildCard&)pFlt->GetWildcard()).GetWildCard();
xFltMgr->appendFilter( pFlt->GetUIName(), sWild );
try
{
xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ;
}
catch( const uno::Exception& )
{
bError = true;
}
}
if(!bError)
{
uno::Reference<XFilePickerControlAccess> xCtrlAcc(xFP, UNO_QUERY);
bool bOutline[MAXLEVEL] = {false};
const SwOutlineNodes& rOutlNds = pDoc->GetNodes().GetOutLineNds();
if( rOutlNds.Count() )
{
int nLevel;
for(USHORT n = 0; n < rOutlNds.Count(); ++n )
if( ( nLevel = rOutlNds[n]->GetTxtNode()->GetAttrOutlineLevel()) > 0 &&
! bOutline[nLevel-1] )
{
bOutline[nLevel-1] = true;
}
}
const USHORT nStyleCount = pDoc->GetTxtFmtColls()->Count();
Sequence<OUString> aListBoxEntries( MAXLEVEL + nStyleCount);
OUString* pEntries = aListBoxEntries.getArray();
sal_Int32 nIdx = 0 ;
OUString sOutline( SW_RESSTR(STR_FDLG_OUTLINE_LEVEL) );
for( USHORT i = 0; i < MAXLEVEL; ++i )
{
if( bOutline[i] )
pEntries[nIdx++] = sOutline + String::CreateFromInt32( i+1 );
}
OUString sStyle( SW_RESSTR(STR_FDLG_STYLE) );
for(USHORT i = 0; i < nStyleCount; ++i)
{
SwTxtFmtColl &rTxtColl =
*pDoc->GetTxtFmtColls()->GetObject( i );
if( !rTxtColl.IsDefault() && rTxtColl.IsAtDocNodeSet() )
{
pEntries[nIdx++] = sStyle + rTxtColl.GetName();
}
}
aListBoxEntries.realloc(nIdx);
sal_Int16 nSelect = 0;
try
{
Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries));
xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
ListboxControlActions::ADD_ITEMS , aTemplates );
Any aSelectPos(&nSelect, ::getCppuType(&nSelect));
xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
xCtrlAcc->setLabel( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
String(SW_RES( STR_FDLG_TEMPLATE_NAME )));
}
catch(Exception& )
{
DBG_ERROR("control acces failed");
}
xFP->setTitle( SW_RESSTR( nStrId ));
SvtPathOptions aPathOpt;
xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
if( ERRCODE_NONE == aDlgHelper.Execute())
{
aFileName = xFP->getFiles().getConstArray()[0];
Any aTemplateValue = xCtrlAcc->getValue(
ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
ListboxControlActions::GET_SELECTED_ITEM );
OUString sTmpl;
aTemplateValue >>= sTmpl;
sal_Int32 nColonPos = sTmpl.indexOf( sal_Unicode(':') );
OUString sPrefix = sTmpl.copy( 0L, nColonPos );
if( sPrefix.equalsAscii("Style"))
{
aTemplateName = sTmpl.copy( 7L ); //get string behind "Style: "
}
else if( sPrefix.equalsAscii("Outline"))
{
nTemplateOutlineLevel = ( sTmpl.copy( 15L )).toInt32(); //get string behind "Outline: Leve ";
bCreateByOutlineLevel = true;
}
if ( aFileName.Len() )
{
rReq.AppendItem( SfxStringItem( nWhich, aFileName ) );
if( aTemplateName.Len() )
rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aTemplateName ) );
}
}
}
}
if( aFileName.Len() )
{
if( PrepareClose( FALSE ) )
{
SwWait aWait( *this, TRUE );
if ( bCreateByOutlineLevel )
{
bDone = bCreateHtml
? pDoc->GenerateHTMLDoc( aFileName, nTemplateOutlineLevel )
: pDoc->GenerateGlobalDoc( aFileName, nTemplateOutlineLevel );
}
else
{
const SwTxtFmtColl* pSplitColl = 0;
if ( aTemplateName.Len() )
pSplitColl = pDoc->FindTxtFmtCollByName(aTemplateName);
bDone = bCreateHtml
? pDoc->GenerateHTMLDoc( aFileName, pSplitColl )
: pDoc->GenerateGlobalDoc( aFileName, pSplitColl );
}
if( bDone )
{
SfxStringItem aName( SID_FILE_NAME, aFileName );
SfxStringItem aReferer( SID_REFERER, aEmptyStr );
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while(pViewShell)
{
//search for the view that created the call
if(pViewShell->GetObjectShell() == this && pViewShell->GetDispatcher())
{
SfxFrameItem* pFrameItem = new SfxFrameItem( SID_DOCFRAME,
pViewShell->GetViewFrame() );
SfxDispatcher* pDispatch = pViewShell->GetDispatcher();
pDispatch->Execute(
SID_OPENDOC,
SFX_CALLMODE_ASYNCHRON,
&aName,
&aReferer,
pFrameItem, 0L );
delete pFrameItem;
break;
}
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
}
if( !bDone && !rReq.IsAPI() )
{
InfoBox( 0, SW_RESSTR( STR_CANTCREATE )).Execute();
}
}
}
rReq.SetReturnValue(SfxBoolItem( nWhich, bDone ));
if (bDone)
rReq.Done();
else
rReq.Ignore();
break;
case SID_ATTR_YEAR2000:
if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich , FALSE, &pItem ))
{
DBG_ASSERT(pItem->ISA(SfxUInt16Item), "falsches Item");
USHORT nYear2K = ((SfxUInt16Item*)pItem)->GetValue();
//ueber Views iterieren und den State an den FormShells setzen
SfxViewFrame* pVFrame = SfxViewFrame::GetFirst( this );
SfxViewShell* pViewShell = pVFrame ? pVFrame->GetViewShell() : 0;
SwView* pCurrView = dynamic_cast< SwView* >( pViewShell );
while(pCurrView)
{
FmFormShell* pFormShell = pCurrView->GetFormShell();
if(pFormShell)
pFormShell->SetY2KState(nYear2K);
pVFrame = SfxViewFrame::GetNext( *pVFrame, this );
pViewShell = pVFrame ? pVFrame->GetViewShell() : 0;
pCurrView = dynamic_cast<SwView*>( pViewShell );
}
pDoc->GetNumberFormatter(TRUE)->SetYear2000(nYear2K);
}
break;
default: DBG_ERROR("falscher Dispatcher");
}
}
/*--------------------------------------------------------------------
Beschreibung:
--------------------------------------------------------------------*/
long SwDocShell::DdeGetData( const String& rItem, const String& rMimeType,
uno::Any & rValue )
{
return pDoc->GetData( rItem, rMimeType, rValue );
}
/*--------------------------------------------------------------------
Beschreibung:
--------------------------------------------------------------------*/
long SwDocShell::DdeSetData( const String& rItem, const String& rMimeType,
const uno::Any & rValue )
{
return pDoc->SetData( rItem, rMimeType, rValue );
}
/*--------------------------------------------------------------------
Beschreibung:
--------------------------------------------------------------------*/
::sfx2::SvLinkSource* SwDocShell::DdeCreateLinkSource( const String& rItem )
{
return pDoc->CreateLinkSource( rItem );
}
void SwDocShell::ReconnectDdeLink(SfxObjectShell& rServer)
{
::sfx2::LinkManager& rLinkManager = pDoc->GetLinkManager();
rLinkManager.ReconnectDdeLink(rServer);
}
/*--------------------------------------------------------------------
Beschreibung:
--------------------------------------------------------------------*/
void SwDocShell::FillClass( SvGlobalName * pClassName,
sal_uInt32 * pClipFormat,
String * /*pAppName*/,
String * pLongUserName,
String * pUserName,
sal_Int32 nVersion,
sal_Bool bTemplate /* = sal_False */) const
{
if (nVersion == SOFFICE_FILEFORMAT_60)
{
*pClassName = SvGlobalName( SO3_SW_CLASSID_60 );
*pClipFormat = SOT_FORMATSTR_ID_STARWRITER_60;
*pLongUserName = SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE);
}
else if (nVersion == SOFFICE_FILEFORMAT_8)
{
*pClassName = SvGlobalName( SO3_SW_CLASSID_60 );
*pClipFormat = bTemplate ? SOT_FORMATSTR_ID_STARWRITER_8_TEMPLATE : SOT_FORMATSTR_ID_STARWRITER_8;
*pLongUserName = SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE);
}
*pUserName = SW_RESSTR(STR_HUMAN_SWDOC_NAME);
}
/*--------------------------------------------------------------------
Beschreibung:
--------------------------------------------------------------------*/
void SwDocShell::SetModified( BOOL bSet )
{
SfxObjectShell::SetModified( bSet );
if( IsEnableSetModified())
{
if (!pDoc->IsInCallModified() )
{
EnableSetModified( FALSE );
if( bSet )
{
BOOL bOld = pDoc->IsModified();
pDoc->SetModified();
if( !bOld )
pDoc->SetUndoNoResetModified();
}
else
pDoc->ResetModified();
EnableSetModified( TRUE );
}
UpdateChildWindows();
Broadcast(SfxSimpleHint(SFX_HINT_DOCCHANGED));
}
}
/*--------------------------------------------------------------------
Beschreibung:
--------------------------------------------------------------------*/
void SwDocShell::UpdateChildWindows()
{
// Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR)
if(!GetView())
return;
SfxViewFrame* pVFrame = GetView()->GetViewFrame();
SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->
GetChildWindow( SwFldDlgWrapper::GetChildWindowId() );
if( pWrp )
pWrp->ReInitDlg( this );
// RedlineDlg ggf neu initialisieren
SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->
GetChildWindow( SwRedlineAcceptChild::GetChildWindowId() );
if( pRed )
pRed->ReInitDlg( this );
}
/*--------------------------------------------------------------------
Beschreibung:
--------------------------------------------------------------------*/
// #i48748#
class SwReloadFromHtmlReader : public SwReader
{
public:
SwReloadFromHtmlReader( SfxMedium& _rTmpMedium,
const String& _rFilename,
SwDoc* _pDoc )
: SwReader( _rTmpMedium, _rFilename, _pDoc )
{
SetBaseURL( _rFilename );
}
};
void SwDocShell::ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView )
{
BOOL bModified = IsModified();
// MIB 23.6.97: Die HTTP-Header-Felder muessen geloescht werden,
// sonst gibt es welche aus Meta-Tags hinter doppelt und dreifach.
ClearHeaderAttributesForSourceViewHack();
// MIB 24.07.97: Das Dokument-Basic muss auch noch d'ran glauben ...
// Ein EnterBasicCall braucht man hier nicht, weil man nichts ruft und
// in HTML-Dokument kein Dok-Basic vorhanden sein kann, das noch nicht
// geladen wurde.
SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get();
//#59620# HasBasic() zeigt an, dass es schon einen BasicManager an der DocShell
// gibt. Der wurde im HTML-Import immer angelegt, wenn Macros im Quelltext
// vorhanden sind.
if( pHtmlOptions && pHtmlOptions->IsStarBasic() && HasBasic())
{
BasicManager *pBasicMan = GetBasicManager();
if( pBasicMan && (pBasicMan != SFX_APP()->GetBasicManager()) )
{
USHORT nLibCount = pBasicMan->GetLibCount();
while( nLibCount )
{
StarBASIC *pBasic = pBasicMan->GetLib( --nLibCount );
if( pBasic )
{
// Die IDE benachrichtigen
SfxUsrAnyItem aShellItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( GetModel() ) );
String aLibName( pBasic->GetName() );
SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
pSrcView->GetViewFrame()->GetDispatcher()->Execute(
SID_BASICIDE_LIBREMOVED,
SFX_CALLMODE_SYNCHRON,
&aShellItem, &aLibNameItem, 0L );
// Aus der Standard-Lib werden nur die Module geloescht
if( nLibCount )
pBasicMan->RemoveLib( nLibCount, TRUE );
else
pBasic->Clear();
}
}
ASSERT( pBasicMan->GetLibCount() <= 1,
"Loschen des Basics hat nicht geklappt" );
}
}
sal_Bool bWasBrowseMode = pDoc->get(IDocumentSettingAccess::BROWSE_MODE);
RemoveLink();
//jetzt muss auch das UNO-Model ueber das neue Doc informiert werden #51535#
uno::Reference<text::XTextDocument> xDoc(GetBaseModel(), uno::UNO_QUERY);
text::XTextDocument* pxDoc = xDoc.get();
((SwXTextDocument*)pxDoc)->InitNewDoc();
AddLink();
//#116402# update font list when new document is created
UpdateFontList();
pDoc->set(IDocumentSettingAccess::BROWSE_MODE, bWasBrowseMode);
pSrcView->SetPool(&GetPool());
const String& rMedname = GetMedium()->GetName();
// fix #51032#: Die HTML-Vorlage muss noch gesetzt werden
SetHTMLTemplate( *GetDoc() ); //Styles aus HTML.vor
SfxViewShell* pViewShell = GetView() ? (SfxViewShell*)GetView()
: SfxViewShell::Current();
SfxViewFrame* pViewFrm = pViewShell->GetViewFrame();
pViewFrm->GetDispatcher()->Execute( SID_VIEWSHELL0, SFX_CALLMODE_SYNCHRON );
SubInitNew();
SfxMedium aMed( rStreamName, STREAM_READ, FALSE );
// --> OD 2005-08-01 #i48748# - use class <SwReloadFromHtmlReader>, because
// the base URL has to be set to the filename of the document <rMedname>
// and not to the base URL of the temporary file <aMed> in order to get
// the URLs of the linked graphics correctly resolved.
SwReloadFromHtmlReader aReader( aMed, rMedname, pDoc );
// <--
aReader.Read( *ReadHTML );
const SwView* pCurrView = GetView();
//in print layout the first page(s) may have been formatted as a mix of browse
//and print layout
if(!bWasBrowseMode && pCurrView)
{
SwWrtShell& rWrtSh = pCurrView->GetWrtShell();
if( rWrtSh.GetLayout())
rWrtSh.CheckBrowseView( TRUE );
}
// MIB 23.6.97: Die HTTP-Header-Attribute wieder in die DokInfo
// uebernehmen. Die Base-URL ist hier egal, da TLX zum absolutieren die
// vom Dokument nimmt.
SetHeaderAttributesForSourceViewHack();
if(bModified && !IsReadOnly())
SetModified();
else
pDoc->ResetModified();
}
void SwDocShell::ToggleBrowserMode(BOOL bSet, SwView* _pView )
{
GetDoc()->set(IDocumentSettingAccess::BROWSE_MODE, bSet );
UpdateFontList();
SwView* pTempView = _pView ? _pView : (SwView*)GetView();
if( pTempView )
{
SfxBindings& rBind = pTempView->GetViewFrame()->GetBindings();
rBind.Invalidate(FN_SHADOWCURSOR);
rBind.Invalidate(SID_BROWSER_MODE);
rBind.Invalidate(FN_PRINT_LAYOUT);
if( !GetDoc()->getPrinter( false ) )
{
pTempView->SetPrinter( GetDoc()->getPrinter( false ),
SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP );
}
// --> FME 2005-03-16 #i44963# Good occasion to check if page sizes in
// page descriptions are still set to (LONG_MAX, LONG_MAX) (html import)
GetDoc()->CheckDefaultPageFmt();
// <--
// Currently there can be only one view (layout) if the document is viewed in Web layout
// So if there are more views we are in print layout and for toggling to Web layout all other views must be closed
SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this, FALSE);
do {
if( pTmpFrm != pTempView->GetViewFrame() )
{
pTmpFrm->DoClose();
pTmpFrm = SfxViewFrame::GetFirst(this, FALSE);
}
else
pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this, FALSE);
} while ( pTmpFrm );
const SwViewOption& rViewOptions = *pTempView->GetWrtShell().GetViewOptions();
// set view columns before toggling:
if ( bSet )
{
const USHORT nColumns = rViewOptions.GetViewLayoutColumns();
const bool bBookMode = rViewOptions.IsViewLayoutBookMode();
if ( 1 != nColumns || bBookMode )
{
((SwView*)GetView())->SetViewLayout( 1, false );
}
}
// Triggeres a formatting:
pTempView->GetWrtShell().CheckBrowseView( TRUE );
pTempView->CheckVisArea();
if( GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE) )
{
const SvxZoomType eType = (SvxZoomType)rViewOptions.GetZoomType();
if ( SVX_ZOOM_PERCENT != eType)
{
((SwView*)GetView())->SetZoom( eType );
}
}
pTempView->InvalidateBorder();
pTempView->SetNewWindowAllowed(!bSet);
}
}
ULONG SwDocShell::LoadStylesFromFile( const String& rURL,
SwgReaderOption& rOpt, BOOL bUnoCall )
{
ULONG nErr = 0;
// Create a URL from filename
INetURLObject aURLObj( rURL );
String sURL( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
SwRead pRead = 0;
SwReader* pReader = 0;
SwPaM* pPam = 0;
// Filter bestimmen:
String sFactory(String::CreateFromAscii(SwDocShell::Factory().GetShortName()));
SfxFilterMatcher aMatcher( sFactory );
//#b6445961# search for filter in WebDocShell, too
SfxMedium aMed( rURL, STREAM_STD_READ, FALSE );
const SfxFilter* pFlt = 0;
aMatcher.DetectFilter( aMed, &pFlt, FALSE, FALSE );
if(!pFlt)
{
String sWebFactory(String::CreateFromAscii(SwWebDocShell::Factory().GetShortName()));
SfxFilterMatcher aWebMatcher( sWebFactory );
aWebMatcher.DetectFilter( aMed, &pFlt, FALSE, FALSE );
}
if( aMed.IsStorage() )
{
DBG_ASSERT((pFlt ? pFlt->GetVersion() : 0) >= SOFFICE_FILEFORMAT_60, "which file version?");
pRead = ReadXML;
// the SW3IO - Reader need the pam/wrtshell, because only then he
// insert the styles!
if( bUnoCall )
{
SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfContent(), -1 );
pPam = new SwPaM( aIdx );
pReader = new SwReader( aMed, rURL, *pPam );
}
else
pReader = new SwReader( aMed, rURL, *pWrtShell->GetCrsr() );
}
else if( pFlt )
{
pReader = new SwReader( aMed, rURL, pDoc );
}
ASSERT( pRead, "no reader found" );
if( pRead )
{
pRead->GetReaderOpt().SetTxtFmts( rOpt.IsTxtFmts() );
pRead->GetReaderOpt().SetFrmFmts( rOpt.IsFrmFmts() );
pRead->GetReaderOpt().SetPageDescs( rOpt.IsPageDescs() );
pRead->GetReaderOpt().SetNumRules( rOpt.IsNumRules() );
pRead->GetReaderOpt().SetMerge( rOpt.IsMerge() );
if( bUnoCall )
{
UnoActionContext aAction( pDoc );
nErr = pReader->Read( *pRead );
}
else
{
pWrtShell->StartAllAction();
nErr = pReader->Read( *pRead );
pWrtShell->EndAllAction();
}
}
delete pPam;
delete pReader;
return nErr;
}
/*--------------------------------------------------------------------
Get a client for an embedded object if possible.
--------------------------------------------------------------------*/
SfxInPlaceClient* SwDocShell::GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef )
{
SfxInPlaceClient* pResult = NULL;
SwWrtShell* pShell = GetWrtShell();
if ( pShell )
{
pResult = pShell->GetView().FindIPClient( xObjRef.GetObject(), (Window*)&pShell->GetView().GetEditWin() );
if ( !pResult )
pResult = new SwOleClient( &pShell->GetView(), &pShell->GetView().GetEditWin(), xObjRef );
}
return pResult;
}
|