update dev300-m58
[ooovba.git] / sw / source / ui / app / docsh2.cxx
blob8cd955aa192952808907462428c152adc374fbb1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docsh2.cxx,v $
10 * $Revision: 1.103.144.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifndef _COM_SUN_STAR_LANG_XMultiServiceFactory_HPP_
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #endif
37 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
38 #include <comphelper/processfactory.hxx>
39 #endif
40 #include <com/sun/star/frame/XDispatchHelper.hpp>
43 #include <hintids.hxx>
44 #include <tools/urlobj.hxx>
45 #include <unotools/tempfile.hxx>
46 #ifndef _WRKWIN_HXX //autogen
47 #include <vcl/wrkwin.hxx>
48 #endif
49 #ifndef _MSGBOX_HXX //autogen
50 #include <vcl/msgbox.hxx>
51 #endif
52 #include <svtools/lckbitem.hxx>
53 #include <svtools/eitem.hxx>
55 #include <svtools/macitem.hxx>
57 #include <svtools/zforlist.hxx>
58 #include <svtools/zformat.hxx>
59 #include <svtools/pathoptions.hxx>
60 #include <svtools/transfer.hxx>
61 #ifndef _SFXSIDS_HRC //autogen
62 #include <sfx2/dialogs.hrc>
63 #endif
64 #include <sfx2/dinfdlg.hxx>
65 #include <sfx2/request.hxx>
66 #include <sfx2/dispatch.hxx>
67 #include <sfx2/new.hxx>
68 #include <sfx2/filedlghelper.hxx>
69 #include <sfx2/printer.hxx>
70 #include <sfx2/evntconf.hxx>
71 #include <svtools/sfxecode.hxx>
72 #include <sfx2/docfile.hxx>
73 #include <sfx2/docfilt.hxx>
74 #ifndef _SVX_SVXIDS_HRC //autogen
75 #include <svx/svxids.hrc>
76 #endif
77 #include <svx/drawitem.hxx>
78 #include <svx/svxacorr.hxx>
79 #include <svx/langitem.hxx>
80 #include <svx/fmshell.hxx>
82 #include <svx/htmlcfg.hxx>
83 #include <svx/ofaitem.hxx>
84 #include <SwSmartTagMgr.hxx>
85 #include <sfx2/app.hxx>
86 #include <basic/sbstar.hxx>
87 #include <basic/basmgr.hxx>
88 #include <sot/storage.hxx>
89 #include <sot/clsids.hxx>
90 #include <swunodef.hxx>
91 #include <fmtcol.hxx>
92 #include <swevent.hxx>
93 #ifndef _VIEW_HXX
94 #include <view.hxx> // fuer die aktuelle Sicht
95 #endif
96 #ifndef _DOCSH_HXX
97 #include <docsh.hxx> // Dokumenterzeugung
98 #endif
99 #include <wrtsh.hxx>
100 #include <fldbas.hxx>
101 #include <viewopt.hxx>
102 #ifndef _GLOBDOC_HXX
103 #include <globdoc.hxx>
104 #endif
105 #include <fldwrap.hxx>
106 #ifndef _REDLNDLG_HXX
107 #include <redlndlg.hxx>
108 #endif
109 #include <docstyle.hxx>
110 #include <doc.hxx>
111 #include <pagedesc.hxx>
112 #include <shellio.hxx>
113 #ifndef _PVIEW_HXX
114 #include <pview.hxx>
115 #endif
116 #ifndef _SRCVIEW_HXX
117 #include <srcview.hxx>
118 #endif
119 #include <poolfmt.hxx>
120 #include <usrpref.hxx>
121 #ifndef _WDOCSH_HXX
122 #include <wdocsh.hxx>
123 #endif
124 #include <unotxdoc.hxx>
125 #include <acmplwrd.hxx>
126 #include <swmodule.hxx>
127 #include <unoobj.hxx>
128 #include <swwait.hxx>
129 #include <swcli.hxx>
131 #ifndef _CMDID_H
132 #include <cmdid.h>
133 #endif
134 #include <globals.h>
135 #ifndef _HELPID_H
136 #include <helpid.h>
137 #endif
138 #ifndef _APP_HRC
139 #include <app.hrc>
140 #endif
141 #ifndef _POOLFMT_HRC
142 #include <poolfmt.hrc>
143 #endif
144 #ifndef _GLOBALS_HRC
145 #include <globals.hrc>
146 #endif
147 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
148 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
149 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
150 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
151 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
152 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
153 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
155 #include <svx/acorrcfg.hxx>
156 #include <SwStyleNameMapper.hxx>
158 #include <sfx2/fcontnr.hxx>
160 #include "swabstdlg.hxx"
161 #include "dialog.hrc"
162 #include "swabstdlg.hxx"
164 #include <ndtxt.hxx> //#outline level,add by zhaojianwei
166 using namespace ::com::sun::star::ui::dialogs;
167 using namespace ::com::sun::star::lang;
168 using namespace ::com::sun::star::uno;
169 using namespace ::com::sun::star;
170 using ::rtl::OUString;
171 using namespace ::sfx2;
173 extern BOOL FindPhyStyle( SwDoc& , const String& , SfxStyleFamily );
175 /*--------------------------------------------------------------------
176 Beschreibung: DocInfo kreieren (virtuell)
177 --------------------------------------------------------------------*/
179 SfxDocumentInfoDialog* SwDocShell::CreateDocumentInfoDialog(
180 Window *pParent, const SfxItemSet &rSet)
182 SfxDocumentInfoDialog* pDlg = new SfxDocumentInfoDialog(pParent, rSet);
183 // const SfxDocumentInfoItem& rItem = (const SfxDocumentInfoItem&)rSet.Get(SID_DOCINFO);
184 // if(rItem.IsOwnFormat())
185 //nur mit Statistik, wenn dieses Doc auch angezeigt wird, nicht
186 //aus dem Doc-Manager
187 SwDocShell* pDocSh = (SwDocShell*) SfxObjectShell::Current();
188 if( pDocSh == this )
190 //Nicht fuer SourceView.
191 SfxViewShell *pVSh = SfxViewShell::Current();
192 if ( pVSh && !pVSh->ISA(SwSrcView) )
194 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
195 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
196 pDlg->AddTabPage(TP_DOC_STAT, SW_RESSTR(STR_DOC_STAT),pFact->GetTabPageCreatorFunc( TP_DOC_STAT ),0);
199 return pDlg;
203 /// update text fields on document properties changes
204 void SwDocShell::DoFlushDocInfo()
206 if ( !pDoc ) return;
208 bool bUnlockView(true);
209 if ( pWrtShell ) {
210 bUnlockView = !pWrtShell->IsViewLocked();
211 pWrtShell->LockView( TRUE ); // lock visible section
212 pWrtShell->StartAllAction();
215 pDoc->DocInfoChgd();
217 if ( pWrtShell ) {
218 pWrtShell->EndAllAction();
219 if ( bUnlockView ) {
220 pWrtShell->LockView( FALSE );
226 /*--------------------------------------------------------------------
227 Beschreibung: Benachrichtigung bei geaenderter DocInfo
228 --------------------------------------------------------------------*/
230 void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
232 if( !pDoc )
234 //MA: Kommt bei der OLE-Registration vor!
235 // ASSERT( !this, "DocShell ist nicht richtig initialisiert!" );
236 return ;
239 USHORT nAction = 0;
240 if( rHint.ISA(SfxSimpleHint) )
242 // swithc for more actions
243 switch( ((SfxSimpleHint&) rHint).GetId() )
245 case SFX_HINT_TITLECHANGED:
246 if( GetMedium() )
247 nAction = 2;
248 break;
251 else if( rHint.ISA(SfxEventHint) &&
252 ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_LOADFINISHED )
254 // --> OD 2004-12-03 #i38126# - own action id
255 nAction = 3;
256 // <--
259 if( nAction )
261 BOOL bUnlockView = sal_True; //initializing prevents warning
262 if( pWrtShell )
264 bUnlockView = !pWrtShell->IsViewLocked();
265 pWrtShell->LockView( TRUE ); //lock visible section
266 pWrtShell->StartAllAction();
268 switch( nAction )
270 case 2:
271 pDoc->GetSysFldType( RES_FILENAMEFLD )->UpdateFlds();
272 break;
273 // --> OD 2004-12-03 #i38126# - own action for event LOADFINISHED
274 // in order to avoid a modified document.
275 // --> OD 2005-02-01 #i41679# - Also for the instance of <SwDoc>
276 // it has to be assured, that it's not modified.
277 // Perform the same as for action id 1, but disable <SetModified>.
278 case 3:
280 const bool bResetModified = IsEnableSetModified();
281 if ( bResetModified )
282 EnableSetModified( FALSE );
283 // --> OD 2005-02-01 #i41679#
284 const bool bIsDocModified = pDoc->IsModified();
285 // <--
287 pDoc->DocInfoChgd( );
289 // --> OD 2005-02-01 #i41679#
290 if ( !bIsDocModified )
291 pDoc->ResetModified();
292 // <--
293 if ( bResetModified )
294 EnableSetModified( TRUE );
296 break;
297 // <--
300 if( pWrtShell )
302 pWrtShell->EndAllAction();
303 if( bUnlockView )
304 pWrtShell->LockView( FALSE );
309 /*--------------------------------------------------------------------
310 Beschreibung: Benachrichtigung Doc schliessen
311 --------------------------------------------------------------------*/
313 USHORT SwDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing )
315 USHORT nRet = SfxObjectShell::PrepareClose( bUI, bForBrowsing );
317 if( TRUE == nRet ) //Unbedingt auf TRUE abfragen! (RET_NEWTASK)
318 EndListening( *this );
320 return nRet;
323 /*--------------------------------------------------------------------
324 Beschreibung: Organizer
325 --------------------------------------------------------------------*/
327 BOOL SwDocShell::Insert( SfxObjectShell &rSource,
328 USHORT nSourceIdx1, // SourcePool: oberste Inhaltsebene (Vorlagen/Makros)
329 USHORT nSourceIdx2, // Index in den Inhalt
330 USHORT nSourceIdx3, // Index in die Inhaltsebene
331 USHORT &rIdx1, // und das gleiche fuer den DestinationPool
332 USHORT &rIdx2, // ""
333 USHORT &rIdx3, // ""
334 USHORT &rRemovedIdx ) // falls doppelte geloescht werden, Pos zurueck
336 // --> OD 2005-05-10 #i48949# - actions aren't undoable. Thus, allow no undo
337 // actions
338 // Note: The undo action stack is cleared at the end of this method.
339 bool bDoesUndo( GetDoc()->DoesUndo() );
340 GetDoc()->DoUndo( sal_False );
341 // <--
343 BOOL bRet = FALSE;
345 if (INDEX_IGNORE == rIdx1 && CONTENT_STYLE == nSourceIdx1)
346 rIdx1 = CONTENT_STYLE;
348 if (CONTENT_STYLE == nSourceIdx1 && CONTENT_STYLE == rIdx1)
350 SfxStyleSheetBasePool* pHisPool = rSource.GetStyleSheetPool();
351 SwDocStyleSheetPool* pMyPool =
352 (SwDocStyleSheetPool*)GetStyleSheetPool();
354 // wir koennen nicht in uns selbst hin und her moven
355 if( pHisPool == pMyPool )
356 return FALSE;
358 if( INDEX_IGNORE == rIdx2 )
359 rIdx2 = pMyPool->Count();
361 // erstmal auf die Such-Maske "positionieren"
362 pHisPool->First();
363 SfxStyleSheetBase* pHisSheet = (*pHisPool)[nSourceIdx2];
365 // wenn so eine Vorlage schon existiert: loeschen!
366 const String& rOldName = pHisSheet->GetName();
367 SfxStyleFamily eOldFamily( pHisSheet->GetFamily() );
369 // dflt. PageDesc und StandardZeichenvorlage nie loeschen !!!
370 if( ( SFX_STYLE_FAMILY_PAGE == eOldFamily &&
371 const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetName() ==
372 rOldName ) ||
373 ( SFX_STYLE_FAMILY_CHAR == eOldFamily &&
374 rOldName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
375 RES_POOLCOLL_TEXT_BEGIN ] ))
376 return FALSE;
378 SfxStyleFamily eMyOldFamily( pMyPool->GetSearchFamily() );
379 USHORT nMySrchMask = pMyPool->GetSearchMask();
381 SfxStyleSheetBase* pExist;
382 if( ::FindPhyStyle( *pDoc, rOldName, eOldFamily ) )
384 // Bug 20365: nur uebernehmen, wenn das gewuenscht ist!
385 if( ERRCODE_BUTTON_OK != ErrorHandler::HandleError(
386 *new MessageInfo( ERRCODE_SFXMSG_STYLEREPLACE, rOldName )) )
388 return FALSE;
391 // Da Replace den aStyleSheet-Member selbst benoetigt, muss
392 // das Ergebnis vom Find kopiert werden (s.u.))
393 rtl::Reference< SwDocStyleSheet > xExist( new SwDocStyleSheet(
394 *(SwDocStyleSheet*)pMyPool->Find( rOldName, eOldFamily ) ) );
395 pMyPool->Replace( *pHisSheet, *xExist.get() );
397 // An der Reihenfolge der Vorlagen im Pool aendert sich nichts.
398 rIdx2 = rIdx1 = INDEX_IGNORE;
400 GetDoc()->SetModified();
402 return TRUE;
405 pMyPool->SetSearchMask( eOldFamily, nMySrchMask );
407 // MIB 18.12.98: SwDocStyleSheetPool::Make liefert einen
408 // Pointer auf SwDocStyleSheetPool::aStyleSheet zurueck.
409 // Der gleiche Member von SwDocStyleSheetPool::Find benutzt.
410 // Deshalb muss hier mit einer Kopie gearbeitet werden.
411 // Vorsicht: SfxStyleSheetBase::SetFollow ruft seinerseits
412 // ein SwDocStyleSheetPool::Find auf, do dass es nicht genuegt
413 // die Find-Aufrufe in dieser Methode zu eleminieren.
415 rtl::Reference< SwDocStyleSheet > xNewSheet( new SwDocStyleSheet( (SwDocStyleSheet&)pMyPool
416 ->Make(rOldName, eOldFamily, pHisSheet->GetMask() ) ) );
417 if( SFX_STYLE_FAMILY_PAGE == eOldFamily && rSource.ISA(SwDocShell) )
419 // gesondert behandeln!!
420 SwPageDesc* pDestDsc = (SwPageDesc*)xNewSheet->GetPageDesc();
421 SwPageDesc* pCpyDsc = (SwPageDesc*)((SwDocStyleSheet*)pHisSheet)->GetPageDesc();
422 pDoc->CopyPageDesc( *pCpyDsc, *pDestDsc );
424 else
425 // die neue Vorlage mit den Attributen fuellen
426 xNewSheet->SetItemSet( pHisSheet->GetItemSet() );
428 pMyPool->SetSearchMask( SFX_STYLE_FAMILY_ALL, nMySrchMask );
430 if( xNewSheet->IsUserDefined() || xNewSheet->IsUsed() )
432 // Benutzte und Benutzer-definierte Vorlagen werden angezeigt.
433 // Dshalb muss hier der Index der neuen Vorlage im Pool
434 // ermittelt werden.
435 pExist = pMyPool->First();
436 USHORT nIdx = 0;
437 while( pExist )
439 if( pExist->GetName() == rOldName &&
440 eOldFamily == pExist->GetFamily() )
442 rIdx2 = nIdx;
443 break;
445 pExist = pMyPool->Next();
446 nIdx++;
449 else
451 // Andere Vorlagen werden nicht angezeigt.
452 rIdx1 = rIdx2 = INDEX_IGNORE;
455 /* pMyPool->Count(); //interne Liste neu fuellen lassen!!!!!
457 // suchen, um die richige Insert-Position returnen zu koennen
458 pMyPool->Find( rOldName, SFX_STYLE_FAMILY_ALL, nMySrchMask );
459 rIdx2 = pMyPool->GetFindPos();*/
461 // wer bekommt den Neuen als Parent? wer benutzt den Neuen als Follow?
462 // (immer nur ueber die Instanziierten!!!)
463 pMyPool->SetSearchMask( eOldFamily, nMySrchMask );
464 pMyPool->SetOrganizerMode( TRUE );
465 SfxStyleSheetBase* pTestSheet = pMyPool->First();
466 while (pTestSheet)
468 if (pTestSheet->GetFamily() == eOldFamily &&
469 pTestSheet->HasParentSupport() &&
470 pTestSheet->GetParent() == rOldName)
472 pTestSheet->SetParent(rOldName); // Verknuepfung neu aufbauen
475 if (pTestSheet->GetFamily() == eOldFamily &&
476 pTestSheet->HasFollowSupport() &&
477 pTestSheet->GetFollow() == rOldName)
479 pTestSheet->SetFollow(rOldName); // Verknuepfung neu aufbauen
482 pTestSheet = pMyPool->Next();
484 pMyPool->SetOrganizerMode( SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
486 // hat der Neue einen Parent? wenn ja, mit gleichem Namen bei uns suchen
487 if (pHisSheet->HasParentSupport())
489 const String& rParentName = pHisSheet->GetParent();
490 if (0 != rParentName.Len())
492 SfxStyleSheetBase* pParentOfNew = pMyPool->Find(rParentName,
493 eOldFamily);
494 if (pParentOfNew)
496 xNewSheet->SetParent(rParentName);
498 pMyPool->SetSearchMask( eOldFamily, nMySrchMask );
502 // hat der Neue einen Follow? wenn ja, mit gleichem Namen bei uns suchen
503 if (pHisSheet->HasFollowSupport())
505 const String& rFollowName = pHisSheet->GetFollow();
506 if (0 != rFollowName.Len())
508 SfxStyleSheetBase* pFollowOfNew = pMyPool->Find(rFollowName,
509 eOldFamily);
510 if (pFollowOfNew)
512 xNewSheet->SetFollow(rFollowName);
514 pMyPool->SetSearchMask( eOldFamily, nMySrchMask );
518 // Bug 27347: alte Einstellung wieder setzen
519 pMyPool->SetSearchMask( eMyOldFamily, nMySrchMask );
521 // Model geaendert
522 ASSERT(pDoc, "Doc fehlt");
523 GetDoc()->SetModified();
525 bRet = TRUE;
527 else
528 bRet = SfxObjectShell::Insert( rSource,
529 nSourceIdx1,
530 nSourceIdx2,
531 nSourceIdx3,
532 rIdx1,
533 rIdx2,
534 rIdx3,
535 rRemovedIdx);
537 // --> OD 2005-05-10 #i48949# - actions aren't undoable and could have change
538 // the document node array. Thus, clear the undo action stack.
539 if ( bDoesUndo )
541 GetDoc()->DelAllUndoObj();
543 GetDoc()->DoUndo( bDoesUndo );
544 // <--
546 return bRet;
549 /*--------------------------------------------------------------------
550 Beschreibung: Vorlagen Remove
551 --------------------------------------------------------------------*/
553 BOOL SwDocShell::Remove(USHORT nIdx1, // siehe Insert
554 USHORT nIdx2,
555 USHORT nIdx3)
557 BOOL bRet = FALSE;
559 if (CONTENT_STYLE == nIdx1)
561 SwDocStyleSheetPool* pMyPool = (SwDocStyleSheetPool*)GetStyleSheetPool();
563 pMyPool->First(); // vorm Zugriff Pool aktualisieren!!
564 SfxStyleSheetBase* pMySheet = (*pMyPool)[nIdx2];
566 String aName( pMySheet->GetName() );
567 SfxStyleFamily eFamily( pMySheet->GetFamily() );
569 // dflt. PageDesc und StandardZeichenvorlage nie loeschen !!!
570 if( ( SFX_STYLE_FAMILY_PAGE == eFamily &&
571 const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetName()
572 == aName ) ||
573 ( SFX_STYLE_FAMILY_CHAR == eFamily &&
574 aName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
575 RES_POOLCOLL_TEXT_BEGIN ] ))
576 return FALSE;
578 // also loeschen
579 pMyPool->Remove( pMySheet );
581 // jetzt noch die Parents/Follows aller Instanziierten korrigieren
582 pMyPool->SetOrganizerMode( TRUE );
583 SfxStyleSheetBase* pTestSheet = pMyPool->First();
584 while (pTestSheet)
586 if (pTestSheet->GetFamily() == eFamily &&
587 pTestSheet->HasParentSupport() &&
588 pTestSheet->GetParent() == aName)
590 pTestSheet->SetParent( aEmptyStr ); // Verknuepfung aufloesen
593 if (pTestSheet->GetFamily() == eFamily &&
594 pTestSheet->HasFollowSupport() &&
595 pTestSheet->GetFollow() == aName)
597 pTestSheet->SetFollow( aEmptyStr ); // Verknuepfung aufloesen
600 pTestSheet = pMyPool->Next();
602 pMyPool->SetOrganizerMode( SFX_CREATE_MODE_ORGANIZER == GetCreateMode() );
604 bRet = TRUE;
606 else
607 bRet = SfxObjectShell::Remove( nIdx1,
608 nIdx2,
609 nIdx3 );
612 // Model geaendert
613 ASSERT(pDoc, "Doc fehlt");
614 GetDoc()->SetModified();
616 return bRet;
619 /*--------------------------------------------------------------------
620 Beschreibung:
621 --------------------------------------------------------------------*/
623 void SwDocShell::Execute(SfxRequest& rReq)
625 const SfxItemSet* pArgs = rReq.GetArgs();
626 const SfxPoolItem* pItem;
627 USHORT nWhich = rReq.GetSlot();
628 BOOL bDone = FALSE;
629 switch ( nWhich )
631 case SID_AUTO_CORRECT_DLG:
633 SvxSwAutoFmtFlags* pAFlags = &SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags();
634 SwAutoCompleteWord& rACW = SwDoc::GetAutoCompleteWords();
636 BOOL bOldLocked = rACW.IsLockWordLstLocked(),
637 bOldAutoCmpltCollectWords = pAFlags->bAutoCmpltCollectWords;
639 rACW.SetLockWordLstLocked( TRUE );
641 SvStringsISortDtor aTmpLst;
642 aTmpLst.Insert( &rACW.GetWordList() );
643 pAFlags->pAutoCmpltList = &aTmpLst;
645 SfxApplication* pApp = SFX_APP();
646 SfxRequest aAppReq(SID_AUTO_CORRECT_DLG, SFX_CALLMODE_SYNCHRON, pApp->GetPool());
647 SfxBoolItem aSwOptions( SID_AUTO_CORRECT_DLG, TRUE );
648 aAppReq.AppendItem(aSwOptions);
650 // SMARTTAGS
651 pAFlags->pSmartTagMgr = &SwSmartTagMgr::Get();
653 //pApp->ExecuteSlot(aAppReq);
655 SfxItemSet aSet( pApp->GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG, SID_OPEN_SMARTTAGOPTIONS, SID_OPEN_SMARTTAGOPTIONS, 0 );
656 aSet.Put( aSwOptions );
658 const SfxPoolItem* pOpenSmartTagOptionsItem = 0;
659 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_OPEN_SMARTTAGOPTIONS, FALSE, &pOpenSmartTagOptionsItem ) )
660 aSet.Put( *static_cast<const SfxBoolItem*>(pOpenSmartTagOptionsItem) );
662 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
663 SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL );
664 pDlg->Execute();
665 delete pDlg;
667 rACW.SetLockWordLstLocked( bOldLocked );
669 SwEditShell::SetAutoFmtFlags( pAFlags );
670 rACW.SetMinWordLen( pAFlags->nAutoCmpltWordLen );
671 rACW.SetMaxCount( pAFlags->nAutoCmpltListLen );
672 if( pAFlags->pAutoCmpltList ) // any changes?
674 rACW.CheckChangedList( aTmpLst );
675 // clear the temp WordList pointer
676 pAFlags->pAutoCmpltList = 0;
678 // remove all pointer we never delete the strings
679 aTmpLst.Remove( (USHORT)0, aTmpLst.Count() );
681 if( !bOldAutoCmpltCollectWords && bOldAutoCmpltCollectWords !=
682 pAFlags->bAutoCmpltCollectWords )
684 // call on all Docs the idle formatter to start
685 // the collection of Words
686 TypeId aType = TYPE(SwDocShell);
687 for( SwDocShell *pDocSh = (SwDocShell*)SfxObjectShell::GetFirst(&aType);
688 pDocSh;
689 pDocSh = (SwDocShell*)SfxObjectShell::GetNext( *pDocSh, &aType ) )
691 SwDoc* pTmp = pDocSh->GetDoc();
692 if ( pTmp->GetRootFrm() )
693 pTmp->InvalidateAutoCompleteFlag();
697 break;
699 case SID_PRINTPREVIEW:
701 BOOL bSet = FALSE, bFound = FALSE, bOnly = TRUE;
702 SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this);
703 SfxViewShell* pViewShell = SfxViewShell::Current();
704 SwView* pCurrView = dynamic_cast< SwView *> ( pViewShell );
705 BOOL bCurrent = IS_TYPE( SwPagePreView, pViewShell );
707 while( pTmpFrm ) // search PreView
709 if( IS_TYPE( SwView, pTmpFrm->GetViewShell()) )
710 bOnly = FALSE;
711 else if( IS_TYPE( SwPagePreView, pTmpFrm->GetViewShell()))
713 pTmpFrm->GetFrame()->Appear();
714 bFound = TRUE;
716 if( bFound && !bOnly )
717 break;
718 pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this);
721 if( pArgs && SFX_ITEM_SET ==
722 pArgs->GetItemState( SID_PRINTPREVIEW, FALSE, &pItem ))
723 bSet = ((SfxBoolItem*)pItem)->GetValue();
724 else
725 bSet = !bCurrent;
727 USHORT nSlotId = 0;
728 if( bSet && !bFound ) // Keine gefunden, daher neue Preview anlegen
730 //Keine neue anlegen fuer BrowseView!
731 if( !GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE) )
732 nSlotId = SID_VIEWSHELL1;
734 else if( bFound && !bSet )
735 nSlotId = bOnly ? SID_VIEWSHELL0 : SID_VIEWSHELL1;
737 if( nSlotId )
739 //JP 23.8.2001: Bug 91360 - PagePreView in the WebDocShell
740 // is found under Id ViewShell2.
741 if( ISA(SwWebDocShell) && SID_VIEWSHELL1 == nSlotId )
742 nSlotId = SID_VIEWSHELL2;
744 if( pCurrView && pCurrView->GetDocShell() == this )
745 pTmpFrm = pCurrView->GetViewFrame();
746 else
747 pTmpFrm = SfxViewFrame::GetFirst( this );
749 pTmpFrm->GetDispatcher()->Execute( nSlotId, 0, 0, SFX_CALLMODE_ASYNCHRON );
752 rReq.SetReturnValue(SfxBoolItem(SID_PRINTPREVIEW, bSet ));
754 break;
755 case SID_TEMPLATE_LOAD:
757 String aFileName;
758 static BOOL bText = TRUE;
759 static BOOL bFrame = FALSE;
760 static BOOL bPage = FALSE;
761 static BOOL bNum = FALSE;
762 static BOOL bMerge = FALSE;
763 USHORT nRet = USHRT_MAX;
765 USHORT nFlags = bFrame ? SFX_LOAD_FRAME_STYLES : 0;
766 if(bPage)
767 nFlags|= SFX_LOAD_PAGE_STYLES;
768 if(bNum)
769 nFlags|= SFX_LOAD_NUM_STYLES;
770 if(!nFlags || bText)
771 nFlags|= SFX_LOAD_TEXT_STYLES;
772 if(bMerge)
773 nFlags|= SFX_MERGE_STYLES;
775 if ( pArgs )
777 SFX_REQUEST_ARG( rReq, pTemplateItem, SfxStringItem, SID_TEMPLATE_NAME, FALSE );
778 if ( pTemplateItem )
780 aFileName = pTemplateItem->GetValue();
781 SFX_REQUEST_ARG( rReq, pFlagsItem, SfxInt32Item, SID_TEMPLATE_LOAD, FALSE );
782 if ( pFlagsItem )
783 nFlags = (USHORT) pFlagsItem->GetValue();
787 if ( !aFileName.Len() )
789 SvtPathOptions aPathOpt;
790 SfxNewFileDialog* pNewFileDlg =
791 new SfxNewFileDialog(&GetView()->GetViewFrame()->GetWindow(), SFXWB_LOAD_TEMPLATE);
792 pNewFileDlg->SetTemplateFlags(nFlags);
794 nRet = pNewFileDlg->Execute();
795 if(RET_TEMPLATE_LOAD == nRet)
797 FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
798 uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
800 xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
802 SfxObjectFactory &rFact = GetFactory();
803 SfxFilterMatcher aMatcher( String::CreateFromAscii(rFact.GetShortName()) );
804 SfxFilterMatcherIter aIter( &aMatcher );
805 uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
806 const SfxFilter* pFlt = aIter.First();
807 while( pFlt )
809 if( pFlt && pFlt->IsAllowedAsTemplate() )
811 const String sWild = ((WildCard&)pFlt->GetWildcard()).GetWildCard();
812 xFltMgr->appendFilter( pFlt->GetUIName(), sWild );
814 pFlt = aIter.Next();
816 BOOL bWeb = 0 != dynamic_cast< SwWebDocShell *>( this );
817 const SfxFilter *pOwnFlt =
818 SwDocShell::Factory().GetFilterContainer()->
819 GetFilter4FilterName(String::CreateFromAscii("writer8"));
821 //#b6439685# make sure the default file format is also available
822 if(bWeb)
824 const String sWild = ((WildCard&)pOwnFlt->GetWildcard()).GetWildCard();
825 xFltMgr->appendFilter( pOwnFlt->GetUIName(), sWild );
828 bool bError = false;
829 //#b6439685# catch expception if wrong filter is selected - should not happen anymore
832 xFltMgr->setCurrentFilter( pOwnFlt->GetUIName() );
834 catch( const uno::Exception& )
836 bError = true;
839 if( !bError && ERRCODE_NONE == aDlgHelper.Execute() )
841 aFileName = xFP->getFiles().getConstArray()[0];
844 else if( RET_OK == nRet)
846 aFileName = pNewFileDlg->GetTemplateFileName();
849 nFlags = pNewFileDlg->GetTemplateFlags();
850 rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) );
851 rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, (long) nFlags ) );
852 delete pNewFileDlg;
855 if( aFileName.Len() )
857 SwgReaderOption aOpt;
858 aOpt.SetTxtFmts( bText = (0 != (nFlags&SFX_LOAD_TEXT_STYLES) ));
859 aOpt.SetFrmFmts( bFrame = (0 != (nFlags&SFX_LOAD_FRAME_STYLES)));
860 aOpt.SetPageDescs( bPage = (0 != (nFlags&SFX_LOAD_PAGE_STYLES )));
861 aOpt.SetNumRules( bNum = (0 != (nFlags&SFX_LOAD_NUM_STYLES )));
862 //different meaning between SFX_MERGE_STYLES and aOpt.SetMerge!
863 bMerge = 0 != (nFlags&SFX_MERGE_STYLES);
864 aOpt.SetMerge( !bMerge );
866 SetError( LoadStylesFromFile( aFileName, aOpt, FALSE ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
867 if ( !GetError() )
868 rReq.Done();
871 break;
872 case SID_SOURCEVIEW:
874 SfxViewShell* pViewShell = GetView()
875 ? (SfxViewShell*)GetView()
876 : SfxViewShell::Current();
877 SfxViewFrame* pViewFrm = pViewShell->GetViewFrame();
878 SwSrcView* pSrcView = dynamic_cast< SwSrcView *>( pViewShell );
879 if(!pSrcView)
881 // 3 possible state:
882 // 1 - file unsaved -> save as HTML
883 // 2 - file modified and HTML filter active -> save
884 // 3 - file saved in non-HTML -> QueryBox to save as HTML
885 const SfxFilter* pHtmlFlt =
886 SwIoSystem::GetFilterOfFormat(
887 String::CreateFromAscii("HTML"),
888 SwWebDocShell::Factory().GetFilterContainer() );
889 BOOL bLocalHasName = HasName();
890 if(bLocalHasName)
892 //check for filter type
893 const SfxFilter* pFlt = GetMedium()->GetFilter();
894 if(!pFlt || pFlt->GetUserData() != pHtmlFlt->GetUserData())
896 QueryBox aQuery(&pViewFrm->GetWindow(), SW_RES(MSG_SAVEAS_HTML_QUERY));
897 if(RET_YES == aQuery.Execute())
898 bLocalHasName = FALSE;
899 else
900 break;
903 if(!bLocalHasName)
905 FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION, 0 );
906 aDlgHelper.AddFilter( pHtmlFlt->GetFilterName(), pHtmlFlt->GetDefaultExtension() );
907 aDlgHelper.SetCurrentFilter( pHtmlFlt->GetFilterName() );
908 if( ERRCODE_NONE != aDlgHelper.Execute())
910 break;
912 String sPath = aDlgHelper.GetPath();
913 SfxStringItem aName(SID_FILE_NAME, sPath);
914 SfxStringItem aFilter(SID_FILTER_NAME, pHtmlFlt->GetName());
915 const SfxBoolItem* pBool = (const SfxBoolItem*)
916 pViewFrm->GetDispatcher()->Execute(
917 SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON, &aName, &aFilter, 0L );
918 if(!pBool || !pBool->GetValue())
919 break;
922 #ifdef DBG_UTIL
924 BOOL bWeb = 0 != dynamic_cast<SwWebDocShell*>(this);
925 DBG_ASSERT(bWeb == TRUE, "SourceView nur in der WebDocShell");
927 #endif
928 // die SourceView ist fuer die SwWebDocShell die 1
929 USHORT nSlot = SID_VIEWSHELL1;
930 BOOL bSetModified = FALSE;
931 SfxPrinter* pSavePrinter = 0;
932 if( 0 != pSrcView)
934 SfxPrinter* pTemp = GetDoc()->getPrinter( false );
935 if(pTemp)
936 pSavePrinter = new SfxPrinter(*pTemp);
937 bSetModified = IsModified() || pSrcView->IsModified();
938 if(pSrcView->IsModified()||pSrcView->HasSourceSaved())
940 utl::TempFile aTempFile;
941 aTempFile.EnableKillingFile();
942 pSrcView->SaveContent(aTempFile.GetURL());
943 bDone = TRUE;
944 SfxEventConfiguration* pEvent = SFX_APP()->GetEventConfig();
945 SvxMacro aMac(aEmptyStr, aEmptyStr, STARBASIC);
946 pEvent->ConfigureEvent(SFX_EVENT_OPENDOC, aMac, this);
947 pEvent->ConfigureEvent(SFX_EVENT_CLOSEDOC, aMac, this);
948 pEvent->ConfigureEvent(SFX_EVENT_ACTIVATEDOC, aMac, this);
949 pEvent->ConfigureEvent(SFX_EVENT_DEACTIVATEDOC, aMac, this);
950 ReloadFromHtml(aTempFile.GetURL(), pSrcView);
951 nSlot = 0;
953 else
955 nSlot = SID_VIEWSHELL0;
958 /* OS 10.04.97 14.20: Im Web-Writer gibt es keinen Unterschied zwischen
959 Export in den SourceMode und dem Speichern des Docs
960 else if(IsModified())
962 USHORT nRet = QueryBox( SFX_APPWINDOW ,SW_RES(MSG_SAVE_HTML_QUERY)).Execute();
963 if(RET_YES == nRet)
965 S F X _DISPATCHER().Execute(SID_SAVEDOC,
966 SFX_CALLMODE_SYNCHRON);
967 // der ReturnValue von SID_SAVEDOC ist etwas schwer verstaendlich
968 if(IsModified())
969 nSlot = 0;
971 else if( RET_CANCEL == nRet )
973 nSlot = 0;
976 if(nSlot)
977 pViewFrm->GetDispatcher()->Execute(nSlot, SFX_CALLMODE_SYNCHRON);
978 if(bSetModified)
979 GetDoc()->SetModified();
980 if(pSavePrinter)
982 GetDoc()->setPrinter( pSavePrinter, true, true);
983 //pSavePrinter darf nicht wieder geloescht werden
985 pViewFrm->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, nSlot == SID_VIEWSHELL2));
987 break;
988 case SID_GET_COLORTABLE:
990 SvxColorTableItem* pColItem = (SvxColorTableItem*)GetItem(SID_COLOR_TABLE);
991 XColorTable* pTable = pColItem->GetColorTable();
992 rReq.SetReturnValue(OfaPtrItem(SID_GET_COLORTABLE, pTable));
994 break;
995 case FN_ABSTRACT_STARIMPRESS:
996 case FN_ABSTRACT_NEWDOC:
998 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
999 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
1001 AbstractSwInsertAbstractDlg* pDlg = pFact->CreateSwInsertAbstractDlg(0, DLG_INSERT_ABSTRACT );
1002 DBG_ASSERT(pDlg, "Dialogdiet fail!");
1003 if(RET_OK == pDlg->Execute())
1005 BYTE nLevel = pDlg->GetLevel();
1006 BYTE nPara = pDlg->GetPara();
1007 SwDoc* pSmryDoc = new SwDoc();
1008 SfxObjectShellRef xDocSh( new SwDocShell( pSmryDoc, SFX_CREATE_MODE_STANDARD));
1009 xDocSh->DoInitNew( 0 );
1011 BOOL bImpress = FN_ABSTRACT_STARIMPRESS == nWhich;
1012 pDoc->Summary( pSmryDoc, nLevel, nPara, bImpress );
1013 if( bImpress )
1015 WriterRef xWrt;
1016 // mba: looks as if relative URLs don't make sense here
1017 ::GetRTFWriter( aEmptyStr, String(), xWrt );
1018 SvMemoryStream *pStrm = new SvMemoryStream();
1019 pStrm->SetBufferSize( 16348 );
1020 SwWriter aWrt( *pStrm, *pSmryDoc );
1021 ErrCode eErr = aWrt.Write( xWrt );
1022 if( !ERRCODE_TOERROR( eErr ) )
1024 uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
1025 uno::Reference< frame::XDispatchProvider > xProv(
1026 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY );
1027 if ( xProv.is() )
1029 ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( "SendOutlineToImpress" );
1030 uno::Reference< frame::XDispatchHelper > xHelper(
1031 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY );
1032 if ( xHelper.is() )
1034 pStrm->Seek( STREAM_SEEK_TO_END );
1035 *pStrm << '\0';
1036 pStrm->Seek( STREAM_SEEK_TO_BEGIN );
1038 // Transfer ownership of stream to a lockbytes object
1039 SvLockBytes aLockBytes( pStrm, TRUE );
1040 SvLockBytesStat aStat;
1041 if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE )
1043 sal_uInt32 nLen = aStat.nSize;
1044 ULONG nRead = 0;
1045 uno::Sequence< sal_Int8 > aSeq( nLen );
1046 aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead );
1048 uno::Sequence< beans::PropertyValue > aArgs(1);
1049 aArgs[0].Name = ::rtl::OUString::createFromAscii("RtfOutline");
1050 aArgs[0].Value <<= aSeq;
1051 xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs );
1056 else
1057 ErrorHandler::HandleError(ErrCode( eErr ));
1059 else
1061 // Neues Dokument erzeugen.
1062 SfxViewFrame *pFrame = SfxViewFrame::CreateViewFrame( *xDocSh, 0 );
1063 SwView *pCurrView = (SwView*) pFrame->GetViewShell();
1065 // Dokumenttitel setzen
1066 String aTmp( SW_RES(STR_ABSTRACT_TITLE) );
1067 aTmp += GetTitle();
1068 xDocSh->SetTitle( aTmp );
1069 pCurrView->GetWrtShell().SetNewDoc();
1070 pFrame->Show();
1071 pSmryDoc->SetModified();
1075 delete pDlg;
1077 break;
1078 case FN_OUTLINE_TO_CLIPBOARD:
1079 case FN_OUTLINE_TO_IMPRESS:
1081 WriterRef xWrt;
1082 // mba: looks as if relative URLs don't make sense here
1083 ::GetRTFWriter( 'O', String(), xWrt );
1084 SvMemoryStream *pStrm = new SvMemoryStream();
1085 pStrm->SetBufferSize( 16348 );
1086 SwWriter aWrt( *pStrm, *GetDoc() );
1087 ErrCode eErr = aWrt.Write( xWrt );
1088 if( !ERRCODE_TOERROR( eErr ) )
1090 pStrm->Seek( STREAM_SEEK_TO_END );
1091 *pStrm << '\0';
1092 pStrm->Seek( STREAM_SEEK_TO_BEGIN );
1093 if ( nWhich == FN_OUTLINE_TO_IMPRESS )
1095 uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
1096 uno::Reference< frame::XDispatchProvider > xProv(
1097 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY );
1098 if ( xProv.is() )
1100 ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( "SendOutlineToImpress" );
1101 uno::Reference< frame::XDispatchHelper > xHelper(
1102 xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY );
1103 if ( xHelper.is() )
1105 pStrm->Seek( STREAM_SEEK_TO_END );
1106 *pStrm << '\0';
1107 pStrm->Seek( STREAM_SEEK_TO_BEGIN );
1109 // Transfer ownership of stream to a lockbytes object
1110 SvLockBytes aLockBytes( pStrm, TRUE );
1111 SvLockBytesStat aStat;
1112 if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE )
1114 sal_uInt32 nLen = aStat.nSize;
1115 ULONG nRead = 0;
1116 uno::Sequence< sal_Int8 > aSeq( nLen );
1117 aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead );
1119 uno::Sequence< beans::PropertyValue > aArgs(1);
1120 aArgs[0].Name = ::rtl::OUString::createFromAscii("RtfOutline");
1121 aArgs[0].Value <<= aSeq;
1122 xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs );
1127 else
1129 TransferDataContainer* pClipCntnr =
1130 new TransferDataContainer;
1131 STAR_REFERENCE( datatransfer::XTransferable )
1132 xRef( pClipCntnr );
1134 pClipCntnr->CopyAnyData( FORMAT_RTF, (sal_Char*)
1135 pStrm->GetData(), pStrm->GetSize() );
1136 pClipCntnr->CopyToClipboard(
1137 GetView()? (Window*)&GetView()->GetEditWin() : 0 );
1138 delete pStrm;
1141 else
1142 ErrorHandler::HandleError(ErrCode( eErr ));
1144 break;
1145 case SID_SPELLCHECKER_CHANGED:
1146 //! FALSE, TRUE, TRUE is on the save side but a probably overdone
1147 SW_MOD()->CheckSpellChanges(FALSE, TRUE, TRUE, FALSE );
1148 break;
1150 case SID_BROWSER_MODE:
1151 case FN_PRINT_LAYOUT: //Fuer Web, genau umgekehrt zum BrowserMode
1153 int eState = STATE_TOGGLE;
1154 BOOL bSet = sal_True;
1155 const SfxPoolItem* pAttr=NULL;
1156 if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich , FALSE, &pAttr ))
1158 bSet = ((SfxBoolItem*)pAttr)->GetValue();
1159 if ( nWhich == FN_PRINT_LAYOUT )
1160 bSet = !bSet;
1161 eState = bSet ? STATE_ON : STATE_OFF;
1164 if ( STATE_TOGGLE == eState )
1165 bSet = !GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE);
1167 ToggleBrowserMode(bSet, 0);
1169 // OS: numerische Reihenfolge beachten!
1170 static USHORT __READONLY_DATA aInva[] =
1172 SID_NEWWINDOW,/*5620*/
1173 SID_BROWSER_MODE, /*6313*/
1174 SID_RULER_BORDERS, SID_RULER_PAGE_POS,
1175 SID_ATTR_LONG_LRSPACE,
1176 SID_HTML_MODE,
1177 SID_RULER_PROTECT,
1178 SID_AUTOSPELL_CHECK,
1179 FN_RULER, /*20211*/
1180 FN_VIEW_GRAPHIC, /*20213*/
1181 FN_VIEW_BOUNDS, /**/
1182 FN_VIEW_FIELDS, /*20215*/
1183 FN_VLINEAL, /*20216*/
1184 FN_VSCROLLBAR, /*20217*/
1185 FN_HSCROLLBAR, /*20218*/
1186 FN_VIEW_META_CHARS, /**/
1187 FN_VIEW_MARKS, /**/
1188 FN_VIEW_FIELDNAME, /**/
1189 FN_VIEW_TABLEGRID, /*20227*/
1190 FN_PRINT_LAYOUT, /*20237*/
1191 FN_QRY_MERGE, /*20364*/
1194 // the view must not exist!
1195 SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst( this );
1196 if( pTmpFrm )
1197 pTmpFrm->GetBindings().Invalidate( aInva );
1198 if ( !pAttr )
1199 rReq.AppendItem( SfxBoolItem( nWhich, bSet ) );
1200 rReq.Done();
1202 break;
1204 case SID_MAIL_PREPAREEXPORT:
1206 //pWrtShell is not set in page preview
1207 if(pWrtShell)
1208 pWrtShell->StartAllAction();
1209 pDoc->UpdateFlds( NULL, false );
1210 pDoc->EmbedAllLinks();
1211 pDoc->RemoveInvisibleContent();
1212 if(pWrtShell)
1213 pWrtShell->EndAllAction();
1215 break;
1216 case SID_MAIL_EXPORT_FINISHED:
1218 if(pWrtShell)
1219 pWrtShell->StartAllAction();
1220 //try to undo the removal of invisible content
1221 pDoc->RestoreInvisibleContent();
1222 if(pWrtShell)
1223 pWrtShell->EndAllAction();
1225 break;
1226 case FN_NEW_HTML_DOC:
1227 case FN_NEW_GLOBAL_DOC:
1229 bDone = FALSE;
1230 BOOL bCreateHtml = FN_NEW_HTML_DOC == nWhich;
1232 BOOL bCreateByOutlineLevel = false; //#outline level,add by zhaojianwei
1233 sal_Int32 nTemplateOutlineLevel = 0 ; //#outline level,add by zhaojianwei
1235 String aFileName, aTemplateName;
1236 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich, FALSE, &pItem ) )
1238 aFileName = ((const SfxStringItem*)pItem)->GetValue();
1239 SFX_ITEMSET_ARG( pArgs, pTemplItem, SfxStringItem, SID_TEMPLATE_NAME, sal_False );
1240 if ( pTemplItem )
1241 aTemplateName = pTemplItem->GetValue();
1243 bool bError = false;
1244 if ( !aFileName.Len() )
1246 FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE, 0 );
1247 //set HelpIds
1248 const sal_Int16 nControlIds[] = {
1249 CommonFilePickerElementIds::PUSHBUTTON_OK,
1250 CommonFilePickerElementIds::PUSHBUTTON_CANCEL,
1251 CommonFilePickerElementIds::LISTBOX_FILTER,
1252 CommonFilePickerElementIds::CONTROL_FILEVIEW,
1253 CommonFilePickerElementIds::EDIT_FILEURL,
1254 ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION,
1255 ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1258 sal_Int32 nHelpIds[8];
1259 sal_Int32 nStartHelpId =
1260 bCreateHtml ?
1261 HID_SEND_HTML_CTRL_PUSHBUTTON_OK : HID_SEND_MASTER_CTRL_PUSHBUTTON_OK ;
1262 for(int nHelp = 0; nHelp < 7; nHelp++)
1263 nHelpIds[nHelp] = nStartHelpId++;
1264 nHelpIds[7] = 0;
1266 aDlgHelper.SetControlHelpIds( nControlIds, nHelpIds );
1267 // aDlgHelper.SetDialogHelpId( bCreateHtml ? HID_SEND_HTML_DIALOG : HID_SEND_MASTER_DIALOG );
1269 uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
1271 const SfxFilter* pFlt;
1272 USHORT nStrId;
1274 if( bCreateHtml )
1276 // fuer HTML gibts es nur einen Filter!!
1277 pFlt = SwIoSystem::GetFilterOfFormat(
1278 String::CreateFromAscii("HTML"),
1279 SwWebDocShell::Factory().GetFilterContainer() );
1280 nStrId = STR_LOAD_HTML_DOC;
1282 else
1284 // Fuer Global-Dokumente bieten wir jetzt auch nur
1285 // noch den aktuellen an.
1286 pFlt = SwGlobalDocShell::Factory().GetFilterContainer()->
1287 GetFilter4Extension( String::CreateFromAscii("odm") );
1288 nStrId = STR_LOAD_GLOBAL_DOC;
1291 if( pFlt )
1293 uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
1294 const String sWild = ((WildCard&)pFlt->GetWildcard()).GetWildCard();
1295 xFltMgr->appendFilter( pFlt->GetUIName(), sWild );
1298 xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ;
1300 catch( const uno::Exception& )
1302 bError = true;
1305 if(!bError)
1307 uno::Reference<XFilePickerControlAccess> xCtrlAcc(xFP, UNO_QUERY);
1309 //#removed by zhaojianwei
1311 // const USHORT nCount = pDoc->GetTxtFmtColls()->Count();
1312 // Sequence<OUString> aListBoxEntries(nCount);
1313 // OUString* pEntries = aListBoxEntries.getArray();
1314 // sal_Int32 nIdx = 0;
1315 // sal_Int16 nSelect = 0;
1316 // OUString sStartTemplate;
1317 // SwTxtFmtColl *pFnd = 0, *pAny = 0;
1318 // for(USHORT i = 0; i < nCount; ++i)
1319 // {
1320 // SwTxtFmtColl &rTxtColl =
1321 // *pDoc->GetTxtFmtColls()->GetObject( i );
1322 // if( !rTxtColl.IsDefault() && rTxtColl.IsAtDocNodeSet() )
1323 // {
1324 // //if( MAXLEVEL >= rTxtColl.GetOutlineLevel() && ( !pFnd || //#outline level,zhaojianwei
1325 //if( rTxtColl.IsAssignedToListLevelOfOutlineStyle() && ( !pFnd || //<-end,zhaojianwei
1326 // pFnd->GetAssignedOutlineStyleLevel() > rTxtColl.GetAssignedOutlineStyleLevel() ))
1327 // {
1328 // nSelect = (sal_Int16)nIdx;
1329 // pFnd = &rTxtColl;
1330 // sStartTemplate = rTxtColl.GetName();
1331 // }
1332 // else if( !pAny )
1333 // pAny = &rTxtColl;
1334 // //pEntries[nIdx++] = rTxtColl.GetName(); //#outline level,remove by zhaojianwei
1335 // pEntries[nIdx++] = sStyles + rTxtColl.GetName(); //#outline level,add by zhaojianwei
1336 // }
1337 // }
1338 // if(!sStartTemplate.getLength() && pAny)
1339 // sStartTemplate = pAny->GetName();
1340 // aListBoxEntries.realloc(nIdx);
1341 //<-end,zhaojianwei
1344 //#outline level,add by zhaojianwei
1345 /////////////////////////////////////////////////////////////////////
1347 bool bOutline[MAXLEVEL] = {false};
1348 const SwOutlineNodes& rOutlNds = pDoc->GetNodes().GetOutLineNds();
1349 if( rOutlNds.Count() )
1351 int nLevel;
1352 for(USHORT n = 0; n < rOutlNds.Count(); ++n )
1353 if( ( nLevel = rOutlNds[n]->GetTxtNode()->GetAttrOutlineLevel()) > 0 &&
1354 ! bOutline[nLevel-1] )
1356 bOutline[nLevel-1] = true;
1360 const USHORT nStyleCount = pDoc->GetTxtFmtColls()->Count();
1361 Sequence<OUString> aListBoxEntries( MAXLEVEL + nStyleCount);
1362 OUString* pEntries = aListBoxEntries.getArray();
1363 sal_Int32 nIdx = 0 ;
1365 OUString sOutline( SW_RESSTR(STR_FDLG_OUTLINE_LEVEL) );
1366 for( USHORT i = 0; i < MAXLEVEL; ++i )
1368 if( bOutline[i] )
1369 pEntries[nIdx++] = sOutline + String::CreateFromInt32( i+1 );
1372 OUString sStyle( SW_RESSTR(STR_FDLG_STYLE) );
1373 for(USHORT i = 0; i < nStyleCount; ++i)
1375 SwTxtFmtColl &rTxtColl =
1376 *pDoc->GetTxtFmtColls()->GetObject( i );
1377 if( !rTxtColl.IsDefault() && rTxtColl.IsAtDocNodeSet() )
1379 pEntries[nIdx++] = sStyle + rTxtColl.GetName();
1383 aListBoxEntries.realloc(nIdx);
1384 sal_Int16 nSelect = 0;
1385 /////////////////////////////////////////////////////////////////////
1386 //<-end,zhaojianwei
1390 Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries));
1392 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1393 ListboxControlActions::ADD_ITEMS , aTemplates );
1394 Any aSelectPos(&nSelect, ::getCppuType(&nSelect));
1395 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1396 ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
1397 xCtrlAcc->setLabel( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1398 String(SW_RES( STR_FDLG_TEMPLATE_NAME )));
1400 catch(Exception& )
1402 DBG_ERROR("control acces failed");
1405 xFP->setTitle( SW_RESSTR( nStrId ));
1406 SvtPathOptions aPathOpt;
1407 xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
1408 if( ERRCODE_NONE == aDlgHelper.Execute())
1410 aFileName = xFP->getFiles().getConstArray()[0];
1411 Any aTemplateValue = xCtrlAcc->getValue(
1412 ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1413 ListboxControlActions::GET_SELECTED_ITEM );
1414 OUString sTmpl;
1415 aTemplateValue >>= sTmpl;
1416 //aTemplateName = sTmpl; //#outline level,removed by zhaojianwei
1417 //#outline level,add by zhaojianwei
1419 sal_Int32 nColonPos = sTmpl.indexOf( sal_Unicode(':') );
1420 OUString sPrefix = sTmpl.copy( 0L, nColonPos );
1421 if( sPrefix.equalsAscii("Style"))
1423 aTemplateName = sTmpl.copy( 7L ); //get string behind "Style: "
1425 else if( sPrefix.equalsAscii("Outline"))
1427 nTemplateOutlineLevel = ( sTmpl.copy( 15L )).toInt32(); //get string behind "Outline: Leve ";
1428 bCreateByOutlineLevel = true;
1430 //<-end,zhaojianwei
1432 if ( aFileName.Len() )
1434 rReq.AppendItem( SfxStringItem( nWhich, aFileName ) );
1435 if( aTemplateName.Len() )
1436 rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aTemplateName ) );
1442 //const SwTxtFmtColl* pSplitColl = 0; //#outline level,removed by zhaojianwei
1443 // if ( aTemplateName.Len() )
1444 // pSplitColl = pDoc->FindTxtFmtCollByName(aTemplateName);
1445 //<-end,zhaojianwei
1446 if( aFileName.Len() )
1448 if( PrepareClose( FALSE ) )
1450 SwWait aWait( *this, TRUE );
1452 //bDone = bCreateHtml //#outline level,removed by zhaojianwei
1453 // ? pDoc->GenerateHTMLDoc( aFileName, pSplitColl )
1454 // : pDoc->GenerateGlobalDoc( aFileName, pSplitColl );
1455 if ( bCreateByOutlineLevel ) //add by zhaojianwei
1457 bDone = bCreateHtml //#outline level,removed by zhaojianwei
1458 ? pDoc->GenerateHTMLDoc( aFileName, nTemplateOutlineLevel )
1459 : pDoc->GenerateGlobalDoc( aFileName, nTemplateOutlineLevel );
1461 else
1463 const SwTxtFmtColl* pSplitColl = 0;
1464 if ( aTemplateName.Len() )
1465 pSplitColl = pDoc->FindTxtFmtCollByName(aTemplateName);
1466 bDone = bCreateHtml //#outline level,removed by zhaojianwei
1467 ? pDoc->GenerateHTMLDoc( aFileName, pSplitColl )
1468 : pDoc->GenerateGlobalDoc( aFileName, pSplitColl );
1470 //<-end,zhaojianwei
1471 if( bDone )
1473 SfxStringItem aName( SID_FILE_NAME, aFileName );
1474 SfxStringItem aReferer( SID_REFERER, aEmptyStr );
1475 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1476 while(pViewShell)
1478 //search for the view that created the call
1479 if(pViewShell->GetObjectShell() == this && pViewShell->GetDispatcher())
1481 SfxFrameItem* pFrameItem = new SfxFrameItem( SID_DOCFRAME,
1482 pViewShell->GetViewFrame() );
1483 SfxDispatcher* pDispatch = pViewShell->GetDispatcher();
1484 pDispatch->Execute(
1485 SID_OPENDOC,
1486 SFX_CALLMODE_ASYNCHRON,
1487 &aName,
1488 &aReferer,
1489 pFrameItem, 0L );
1491 delete pFrameItem;
1492 break;
1494 pViewShell = SfxViewShell::GetNext(*pViewShell);
1498 if( !bDone && !rReq.IsAPI() )
1500 InfoBox( 0, SW_RESSTR( STR_CANTCREATE )).Execute();
1504 rReq.SetReturnValue(SfxBoolItem( nWhich, bDone ));
1505 if (bDone)
1506 rReq.Done();
1507 else
1508 rReq.Ignore();
1509 break;
1511 case SID_ATTR_YEAR2000:
1512 if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich , FALSE, &pItem ))
1514 DBG_ASSERT(pItem->ISA(SfxUInt16Item), "falsches Item");
1515 USHORT nYear2K = ((SfxUInt16Item*)pItem)->GetValue();
1516 //ueber Views iterieren und den State an den FormShells setzen
1518 SfxViewFrame* pVFrame = SfxViewFrame::GetFirst( this );
1519 SfxViewShell* pViewShell = pVFrame ? pVFrame->GetViewShell() : 0;
1520 SwView* pCurrView = dynamic_cast< SwView* >( pViewShell );
1521 while(pCurrView)
1523 FmFormShell* pFormShell = pCurrView->GetFormShell();
1524 if(pFormShell)
1525 pFormShell->SetY2KState(nYear2K);
1526 pVFrame = SfxViewFrame::GetNext( *pVFrame, this );
1527 pViewShell = pVFrame ? pVFrame->GetViewShell() : 0;
1528 pCurrView = dynamic_cast<SwView*>( pViewShell );
1530 pDoc->GetNumberFormatter(TRUE)->SetYear2000(nYear2K);
1532 break;
1534 default: DBG_ERROR("falscher Dispatcher");
1539 /*--------------------------------------------------------------------
1540 Beschreibung:
1541 --------------------------------------------------------------------*/
1543 long SwDocShell::DdeGetData( const String& rItem, const String& rMimeType,
1544 uno::Any & rValue )
1546 return pDoc->GetData( rItem, rMimeType, rValue );
1550 /*--------------------------------------------------------------------
1551 Beschreibung:
1552 --------------------------------------------------------------------*/
1554 long SwDocShell::DdeSetData( const String& rItem, const String& rMimeType,
1555 const uno::Any & rValue )
1557 return pDoc->SetData( rItem, rMimeType, rValue );
1561 /*--------------------------------------------------------------------
1562 Beschreibung:
1563 --------------------------------------------------------------------*/
1565 ::sfx2::SvLinkSource* SwDocShell::DdeCreateLinkSource( const String& rItem )
1567 return pDoc->CreateLinkSource( rItem );
1570 /*--------------------------------------------------------------------
1571 Beschreibung:
1572 --------------------------------------------------------------------*/
1574 void SwDocShell::FillClass( SvGlobalName * pClassName,
1575 sal_uInt32 * pClipFormat,
1576 String * /*pAppName*/,
1577 String * pLongUserName,
1578 String * pUserName,
1579 sal_Int32 nVersion,
1580 sal_Bool bTemplate /* = sal_False */) const
1582 if (nVersion == SOFFICE_FILEFORMAT_60)
1584 *pClassName = SvGlobalName( SO3_SW_CLASSID_60 );
1585 *pClipFormat = SOT_FORMATSTR_ID_STARWRITER_60;
1586 *pLongUserName = SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE);
1588 else if (nVersion == SOFFICE_FILEFORMAT_8)
1590 *pClassName = SvGlobalName( SO3_SW_CLASSID_60 );
1591 *pClipFormat = bTemplate ? SOT_FORMATSTR_ID_STARWRITER_8_TEMPLATE : SOT_FORMATSTR_ID_STARWRITER_8;
1592 *pLongUserName = SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE);
1595 *pUserName = SW_RESSTR(STR_HUMAN_SWDOC_NAME);
1599 /*--------------------------------------------------------------------
1600 Beschreibung:
1601 --------------------------------------------------------------------*/
1603 void SwDocShell::SetModified( BOOL bSet )
1605 SfxObjectShell::SetModified( bSet );
1606 if( IsEnableSetModified())
1608 if (!pDoc->IsInCallModified() )
1610 EnableSetModified( FALSE );
1611 if( bSet )
1613 BOOL bOld = pDoc->IsModified();
1614 pDoc->SetModified();
1615 if( !bOld )
1616 pDoc->SetUndoNoResetModified();
1618 else
1619 pDoc->ResetModified();
1621 EnableSetModified( TRUE );
1624 UpdateChildWindows();
1625 Broadcast(SfxSimpleHint(SFX_HINT_DOCCHANGED));
1629 /*--------------------------------------------------------------------
1630 Beschreibung:
1631 --------------------------------------------------------------------*/
1633 void SwDocShell::UpdateChildWindows()
1635 // Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR)
1636 if(!GetView())
1637 return;
1638 SfxViewFrame* pVFrame = GetView()->GetViewFrame();
1639 SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->
1640 GetChildWindow( SwFldDlgWrapper::GetChildWindowId() );
1641 if( pWrp )
1642 pWrp->ReInitDlg( this );
1644 // RedlineDlg ggf neu initialisieren
1645 SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->
1646 GetChildWindow( SwRedlineAcceptChild::GetChildWindowId() );
1647 if( pRed )
1648 pRed->ReInitDlg( this );
1651 /*--------------------------------------------------------------------
1652 Beschreibung:
1653 --------------------------------------------------------------------*/
1654 // --> OD 2005-08-02 #i48748#
1655 class SwReloadFromHtmlReader : public SwReader
1657 public:
1658 SwReloadFromHtmlReader( SfxMedium& _rTmpMedium,
1659 const String& _rFilename,
1660 SwDoc* _pDoc )
1661 : SwReader( _rTmpMedium, _rFilename, _pDoc )
1663 SetBaseURL( _rFilename );
1666 // <--
1667 void SwDocShell::ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView )
1669 BOOL bModified = IsModified();
1671 // MIB 23.6.97: Die HTTP-Header-Felder muessen geloescht werden,
1672 // sonst gibt es welche aus Meta-Tags hinter doppelt und dreifach.
1673 ClearHeaderAttributesForSourceViewHack();
1675 // MIB 24.07.97: Das Dokument-Basic muss auch noch d'ran glauben ...
1676 // Ein EnterBasicCall braucht man hier nicht, weil man nichts ruft und
1677 // in HTML-Dokument kein Dok-Basic vorhanden sein kann, das noch nicht
1678 // geladen wurde.
1679 SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get();
1680 //#59620# HasBasic() zeigt an, dass es schon einen BasicManager an der DocShell
1681 // gibt. Der wurde im HTML-Import immer angelegt, wenn Macros im Quelltext
1682 // vorhanden sind.
1683 if( pHtmlOptions && pHtmlOptions->IsStarBasic() && HasBasic())
1685 BasicManager *pBasicMan = GetBasicManager();
1686 if( pBasicMan && (pBasicMan != SFX_APP()->GetBasicManager()) )
1688 USHORT nLibCount = pBasicMan->GetLibCount();
1689 while( nLibCount )
1691 StarBASIC *pBasic = pBasicMan->GetLib( --nLibCount );
1692 if( pBasic )
1694 // Die IDE benachrichtigen
1695 SfxUsrAnyItem aShellItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( GetModel() ) );
1696 String aLibName( pBasic->GetName() );
1697 SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
1698 pSrcView->GetViewFrame()->GetDispatcher()->Execute(
1699 SID_BASICIDE_LIBREMOVED,
1700 SFX_CALLMODE_SYNCHRON,
1701 &aShellItem, &aLibNameItem, 0L );
1703 // Aus der Standard-Lib werden nur die Module geloescht
1704 if( nLibCount )
1705 pBasicMan->RemoveLib( nLibCount, TRUE );
1706 else
1707 pBasic->Clear();
1711 ASSERT( pBasicMan->GetLibCount() <= 1,
1712 "Loschen des Basics hat nicht geklappt" );
1715 sal_Bool bWasBrowseMode = pDoc->get(IDocumentSettingAccess::BROWSE_MODE);
1716 RemoveLink();
1718 //jetzt muss auch das UNO-Model ueber das neue Doc informiert werden #51535#
1719 uno::Reference<text::XTextDocument> xDoc(GetBaseModel(), uno::UNO_QUERY);
1720 text::XTextDocument* pxDoc = xDoc.get();
1721 ((SwXTextDocument*)pxDoc)->InitNewDoc();
1723 AddLink();
1724 //#116402# update font list when new document is created
1725 UpdateFontList();
1726 pDoc->set(IDocumentSettingAccess::BROWSE_MODE, bWasBrowseMode);
1727 pSrcView->SetPool(&GetPool());
1730 const String& rMedname = GetMedium()->GetName();
1732 // fix #51032#: Die HTML-Vorlage muss noch gesetzt werden
1733 SetHTMLTemplate( *GetDoc() ); //Styles aus HTML.vor
1735 SfxViewShell* pViewShell = GetView() ? (SfxViewShell*)GetView()
1736 : SfxViewShell::Current();
1737 SfxViewFrame* pViewFrm = pViewShell->GetViewFrame();
1738 pViewFrm->GetDispatcher()->Execute( SID_VIEWSHELL0, SFX_CALLMODE_SYNCHRON );
1740 SubInitNew();
1742 SfxMedium aMed( rStreamName, STREAM_READ, FALSE );
1743 // --> OD 2005-08-01 #i48748# - use class <SwReloadFromHtmlReader>, because
1744 // the base URL has to be set to the filename of the document <rMedname>
1745 // and not to the base URL of the temporary file <aMed> in order to get
1746 // the URLs of the linked graphics correctly resolved.
1747 SwReloadFromHtmlReader aReader( aMed, rMedname, pDoc );
1748 // <--
1749 aReader.Read( *ReadHTML );
1751 const SwView* pCurrView = GetView();
1752 //in print layout the first page(s) may have been formatted as a mix of browse
1753 //and print layout
1754 if(!bWasBrowseMode && pCurrView)
1756 SwWrtShell& rWrtSh = pCurrView->GetWrtShell();
1757 if( rWrtSh.GetLayout())
1758 rWrtSh.CheckBrowseView( TRUE );
1762 // MIB 23.6.97: Die HTTP-Header-Attribute wieder in die DokInfo
1763 // uebernehmen. Die Base-URL ist hier egal, da TLX zum absolutieren die
1764 // vom Dokument nimmt.
1765 SetHeaderAttributesForSourceViewHack();
1767 if(bModified && !IsReadOnly())
1768 SetModified();
1769 else
1770 pDoc->ResetModified();
1773 /* -----------------------------14.12.99 16:52--------------------------------
1775 ---------------------------------------------------------------------------*/
1776 void SwDocShell::ToggleBrowserMode(BOOL bSet, SwView* _pView )
1778 GetDoc()->set(IDocumentSettingAccess::BROWSE_MODE, bSet );
1779 UpdateFontList();
1780 SwView* pTempView = _pView ? _pView : (SwView*)GetView();
1781 if( pTempView )
1783 pTempView->GetViewFrame()->GetBindings().Invalidate(FN_SHADOWCURSOR);
1785 if( !GetDoc()->getPrinter( false ) )
1787 pTempView->SetPrinter( GetDoc()->getPrinter( false ),
1788 SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP );
1791 // --> FME 2005-03-16 #i44963# Good occasion to check if page sizes in
1792 // page descriptions are still set to (LONG_MAX, LONG_MAX) (html import)
1793 GetDoc()->CheckDefaultPageFmt();
1794 // <--
1796 //Wenn wir die BrowseView einschalten, darf es nur diese eine
1797 //Sicht auf das Dokument geben, alle anderen werden geschlossen.
1798 SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this, 0, FALSE);
1799 do {
1800 if( pTmpFrm != pTempView->GetViewFrame() )
1802 pTmpFrm->DoClose();
1803 pTmpFrm = SfxViewFrame::GetFirst(this, 0, FALSE);
1805 else
1806 pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this, 0, FALSE);
1808 } while ( pTmpFrm );
1810 const SwViewOption& rViewOptions = *pTempView->GetWrtShell().GetViewOptions();
1812 // set view columns before toggling:
1813 if ( bSet )
1815 const USHORT nColumns = rViewOptions.GetViewLayoutColumns();
1816 const bool bBookMode = rViewOptions.IsViewLayoutBookMode();
1817 if ( 1 != nColumns || bBookMode )
1819 ((SwView*)GetView())->SetViewLayout( 1, false );
1823 // Triggeres a formatting:
1824 pTempView->GetWrtShell().CheckBrowseView( TRUE );
1825 pTempView->CheckVisArea();
1827 if( GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE) )
1829 const SvxZoomType eType = (SvxZoomType)rViewOptions.GetZoomType();
1831 if ( SVX_ZOOM_PERCENT != eType)
1833 ((SwView*)GetView())->SetZoom( eType );
1836 pTempView->InvalidateBorder();
1837 pTempView->SetNewWindowAllowed(!bSet);
1841 ULONG SwDocShell::LoadStylesFromFile( const String& rURL,
1842 SwgReaderOption& rOpt, BOOL bUnoCall )
1844 ULONG nErr = 0;
1846 // Create a URL from filename
1847 INetURLObject aURLObj( rURL );
1848 String sURL( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
1850 SwRead pRead = 0;
1851 SwReader* pReader = 0;
1852 SwPaM* pPam = 0;
1854 // Filter bestimmen:
1855 // const SfxFilter* pFlt = SwIoSystem::GetFileFilter( rURL, aEmptyStr );
1856 String sFactory(String::CreateFromAscii(SwDocShell::Factory().GetShortName()));
1857 SfxFilterMatcher aMatcher( sFactory );
1859 //#b6445961# search for filter in WebDocShell, too
1860 SfxMedium aMed( rURL, STREAM_STD_READ, FALSE );
1861 const SfxFilter* pFlt = 0;
1862 aMatcher.DetectFilter( aMed, &pFlt, FALSE, FALSE );
1863 if(!pFlt)
1865 String sWebFactory(String::CreateFromAscii(SwWebDocShell::Factory().GetShortName()));
1866 SfxFilterMatcher aWebMatcher( sWebFactory );
1867 aWebMatcher.DetectFilter( aMed, &pFlt, FALSE, FALSE );
1869 if( aMed.IsStorage() )
1871 DBG_ASSERT((pFlt ? pFlt->GetVersion() : 0) >= SOFFICE_FILEFORMAT_60, "which file version?");
1872 pRead = ReadXML;
1873 // the SW3IO - Reader need the pam/wrtshell, because only then he
1874 // insert the styles!
1875 if( bUnoCall )
1877 SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfContent(), -1 );
1878 pPam = new SwPaM( aIdx );
1879 pReader = new SwReader( aMed, rURL, *pPam );
1881 else
1882 pReader = new SwReader( aMed, rURL, *pWrtShell->GetCrsr() );
1884 else if( pFlt )
1886 // if( pFlt->GetUserData().EqualsAscii( FILTER_SWG ) ||
1887 // pFlt->GetUserData().EqualsAscii( FILTER_SWGV ))
1888 // pRead = ReadSwg;
1889 pReader = new SwReader( aMed, rURL, pDoc );
1892 ASSERT( pRead, "no reader found" );
1893 if( pRead )
1895 pRead->GetReaderOpt().SetTxtFmts( rOpt.IsTxtFmts() );
1896 pRead->GetReaderOpt().SetFrmFmts( rOpt.IsFrmFmts() );
1897 pRead->GetReaderOpt().SetPageDescs( rOpt.IsPageDescs() );
1898 pRead->GetReaderOpt().SetNumRules( rOpt.IsNumRules() );
1899 pRead->GetReaderOpt().SetMerge( rOpt.IsMerge() );
1901 if( bUnoCall )
1903 UnoActionContext aAction( pDoc );
1904 nErr = pReader->Read( *pRead );
1906 else
1908 pWrtShell->StartAllAction();
1909 nErr = pReader->Read( *pRead );
1910 pWrtShell->EndAllAction();
1913 delete pPam;
1914 delete pReader;
1915 return nErr;
1918 /*--------------------------------------------------------------------
1919 Get a client for an embedded object if possible.
1920 --------------------------------------------------------------------*/
1921 SfxInPlaceClient* SwDocShell::GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef )
1923 SfxInPlaceClient* pResult = NULL;
1925 SwWrtShell* pShell = GetWrtShell();
1926 if ( pShell )
1928 pResult = pShell->GetView().FindIPClient( xObjRef.GetObject(), (Window*)&pShell->GetView().GetEditWin() );
1929 if ( !pResult )
1930 pResult = new SwOleClient( &pShell->GetView(), &pShell->GetView().GetEditWin(), xObjRef );
1933 return pResult;