1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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>
37 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
38 #include <comphelper/processfactory.hxx>
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>
49 #ifndef _MSGBOX_HXX //autogen
50 #include <vcl/msgbox.hxx>
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>
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>
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>
92 #include <swevent.hxx>
94 #include <view.hxx> // fuer die aktuelle Sicht
97 #include <docsh.hxx> // Dokumenterzeugung
100 #include <fldbas.hxx>
101 #include <viewopt.hxx>
103 #include <globdoc.hxx>
105 #include <fldwrap.hxx>
106 #ifndef _REDLNDLG_HXX
107 #include <redlndlg.hxx>
109 #include <docstyle.hxx>
111 #include <pagedesc.hxx>
112 #include <shellio.hxx>
117 #include <srcview.hxx>
119 #include <poolfmt.hxx>
120 #include <usrpref.hxx>
122 #include <wdocsh.hxx>
124 #include <unotxdoc.hxx>
125 #include <acmplwrd.hxx>
126 #include <swmodule.hxx>
127 #include <unoobj.hxx>
128 #include <swwait.hxx>
142 #include <poolfmt.hrc>
145 #include <globals.hrc>
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();
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);
203 /// update text fields on document properties changes
204 void SwDocShell::DoFlushDocInfo()
208 bool bUnlockView(true);
210 bUnlockView
= !pWrtShell
->IsViewLocked();
211 pWrtShell
->LockView( TRUE
); // lock visible section
212 pWrtShell
->StartAllAction();
218 pWrtShell
->EndAllAction();
220 pWrtShell
->LockView( FALSE
);
226 /*--------------------------------------------------------------------
227 Beschreibung: Benachrichtigung bei geaenderter DocInfo
228 --------------------------------------------------------------------*/
230 void SwDocShell::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
234 //MA: Kommt bei der OLE-Registration vor!
235 // ASSERT( !this, "DocShell ist nicht richtig initialisiert!" );
240 if( rHint
.ISA(SfxSimpleHint
) )
242 // swithc for more actions
243 switch( ((SfxSimpleHint
&) rHint
).GetId() )
245 case SFX_HINT_TITLECHANGED
:
251 else if( rHint
.ISA(SfxEventHint
) &&
252 ((SfxEventHint
&) rHint
).GetEventId() == SFX_EVENT_LOADFINISHED
)
254 // --> OD 2004-12-03 #i38126# - own action id
261 BOOL bUnlockView
= sal_True
; //initializing prevents warning
264 bUnlockView
= !pWrtShell
->IsViewLocked();
265 pWrtShell
->LockView( TRUE
); //lock visible section
266 pWrtShell
->StartAllAction();
271 pDoc
->GetSysFldType( RES_FILENAMEFLD
)->UpdateFlds();
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>.
280 const bool bResetModified
= IsEnableSetModified();
281 if ( bResetModified
)
282 EnableSetModified( FALSE
);
283 // --> OD 2005-02-01 #i41679#
284 const bool bIsDocModified
= pDoc
->IsModified();
287 pDoc
->DocInfoChgd( );
289 // --> OD 2005-02-01 #i41679#
290 if ( !bIsDocModified
)
291 pDoc
->ResetModified();
293 if ( bResetModified
)
294 EnableSetModified( TRUE
);
302 pWrtShell
->EndAllAction();
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 );
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
334 USHORT
&rRemovedIdx
) // falls doppelte geloescht werden, Pos zurueck
336 // --> OD 2005-05-10 #i48949# - actions aren't undoable. Thus, allow no undo
338 // Note: The undo action stack is cleared at the end of this method.
339 bool bDoesUndo( GetDoc()->DoesUndo() );
340 GetDoc()->DoUndo( sal_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
)
358 if( INDEX_IGNORE
== rIdx2
)
359 rIdx2
= pMyPool
->Count();
361 // erstmal auf die Such-Maske "positionieren"
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() ==
373 ( SFX_STYLE_FAMILY_CHAR
== eOldFamily
&&
374 rOldName
== *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD
-
375 RES_POOLCOLL_TEXT_BEGIN
] ))
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
)) )
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();
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
);
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
435 pExist
= pMyPool
->First();
439 if( pExist
->GetName() == rOldName
&&
440 eOldFamily
== pExist
->GetFamily() )
445 pExist
= pMyPool
->Next();
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();
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
,
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
,
512 xNewSheet
->SetFollow(rFollowName
);
514 pMyPool
->SetSearchMask( eOldFamily
, nMySrchMask
);
518 // Bug 27347: alte Einstellung wieder setzen
519 pMyPool
->SetSearchMask( eMyOldFamily
, nMySrchMask
);
522 ASSERT(pDoc
, "Doc fehlt");
523 GetDoc()->SetModified();
528 bRet
= SfxObjectShell::Insert( rSource
,
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.
541 GetDoc()->DelAllUndoObj();
543 GetDoc()->DoUndo( bDoesUndo
);
549 /*--------------------------------------------------------------------
550 Beschreibung: Vorlagen Remove
551 --------------------------------------------------------------------*/
553 BOOL
SwDocShell::Remove(USHORT nIdx1
, // siehe Insert
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()
573 ( SFX_STYLE_FAMILY_CHAR
== eFamily
&&
574 aName
== *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD
-
575 RES_POOLCOLL_TEXT_BEGIN
] ))
579 pMyPool
->Remove( pMySheet
);
581 // jetzt noch die Parents/Follows aller Instanziierten korrigieren
582 pMyPool
->SetOrganizerMode( TRUE
);
583 SfxStyleSheetBase
* pTestSheet
= pMyPool
->First();
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() );
607 bRet
= SfxObjectShell::Remove( nIdx1
,
613 ASSERT(pDoc
, "Doc fehlt");
614 GetDoc()->SetModified();
619 /*--------------------------------------------------------------------
621 --------------------------------------------------------------------*/
623 void SwDocShell::Execute(SfxRequest
& rReq
)
625 const SfxItemSet
* pArgs
= rReq
.GetArgs();
626 const SfxPoolItem
* pItem
;
627 USHORT nWhich
= rReq
.GetSlot();
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
);
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
);
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
);
689 pDocSh
= (SwDocShell
*)SfxObjectShell::GetNext( *pDocSh
, &aType
) )
691 SwDoc
* pTmp
= pDocSh
->GetDoc();
692 if ( pTmp
->GetRootFrm() )
693 pTmp
->InvalidateAutoCompleteFlag();
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()) )
711 else if( IS_TYPE( SwPagePreView
, pTmpFrm
->GetViewShell()))
713 pTmpFrm
->GetFrame()->Appear();
716 if( bFound
&& !bOnly
)
718 pTmpFrm
= pTmpFrm
->GetNext(*pTmpFrm
, this);
721 if( pArgs
&& SFX_ITEM_SET
==
722 pArgs
->GetItemState( SID_PRINTPREVIEW
, FALSE
, &pItem
))
723 bSet
= ((SfxBoolItem
*)pItem
)->GetValue();
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
;
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();
747 pTmpFrm
= SfxViewFrame::GetFirst( this );
749 pTmpFrm
->GetDispatcher()->Execute( nSlotId
, 0, 0, SFX_CALLMODE_ASYNCHRON
);
752 rReq
.SetReturnValue(SfxBoolItem(SID_PRINTPREVIEW
, bSet
));
755 case SID_TEMPLATE_LOAD
:
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;
767 nFlags
|= SFX_LOAD_PAGE_STYLES
;
769 nFlags
|= SFX_LOAD_NUM_STYLES
;
771 nFlags
|= SFX_LOAD_TEXT_STYLES
;
773 nFlags
|= SFX_MERGE_STYLES
;
777 SFX_REQUEST_ARG( rReq
, pTemplateItem
, SfxStringItem
, SID_TEMPLATE_NAME
, FALSE
);
780 aFileName
= pTemplateItem
->GetValue();
781 SFX_REQUEST_ARG( rReq
, pFlagsItem
, SfxInt32Item
, SID_TEMPLATE_LOAD
, FALSE
);
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();
809 if( pFlt
&& pFlt
->IsAllowedAsTemplate() )
811 const String sWild
= ((WildCard
&)pFlt
->GetWildcard()).GetWildCard();
812 xFltMgr
->appendFilter( pFlt
->GetUIName(), sWild
);
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
824 const String sWild
= ((WildCard
&)pOwnFlt
->GetWildcard()).GetWildCard();
825 xFltMgr
->appendFilter( pOwnFlt
->GetUIName(), sWild
);
829 //#b6439685# catch expception if wrong filter is selected - should not happen anymore
832 xFltMgr
->setCurrentFilter( pOwnFlt
->GetUIName() );
834 catch( const uno::Exception
& )
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
) );
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
) ));
874 SfxViewShell
* pViewShell
= GetView()
875 ? (SfxViewShell
*)GetView()
876 : SfxViewShell::Current();
877 SfxViewFrame
* pViewFrm
= pViewShell
->GetViewFrame();
878 SwSrcView
* pSrcView
= dynamic_cast< SwSrcView
*>( pViewShell
);
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();
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
;
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())
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())
924 BOOL bWeb
= 0 != dynamic_cast<SwWebDocShell
*>(this);
925 DBG_ASSERT(bWeb
== TRUE
, "SourceView nur in der WebDocShell");
928 // die SourceView ist fuer die SwWebDocShell die 1
929 USHORT nSlot
= SID_VIEWSHELL1
;
930 BOOL bSetModified
= FALSE
;
931 SfxPrinter
* pSavePrinter
= 0;
934 SfxPrinter
* pTemp
= GetDoc()->getPrinter( false );
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());
944 SfxEventConfiguration
* pEvent
= SFX_APP()->GetEventConfig();
945 SvxMacro
aMac(aEmptyStr
, aEmptyStr
, STARBASIC
);
946 pEvent
->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC
), aMac
, this);
947 pEvent
->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC
), aMac
, this);
948 pEvent
->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC
), aMac
, this);
949 pEvent
->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC
), aMac
, this);
950 ReloadFromHtml(aTempFile
.GetURL(), pSrcView
);
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();
965 S F X _DISPATCHER().Execute(SID_SAVEDOC,
966 SFX_CALLMODE_SYNCHRON);
967 // der ReturnValue von SID_SAVEDOC ist etwas schwer verstaendlich
971 else if( RET_CANCEL == nRet )
977 pViewFrm
->GetDispatcher()->Execute(nSlot
, SFX_CALLMODE_SYNCHRON
);
979 GetDoc()->SetModified();
982 GetDoc()->setPrinter( pSavePrinter
, true, true);
983 //pSavePrinter darf nicht wieder geloescht werden
985 pViewFrm
->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW
, nSlot
== SID_VIEWSHELL2
));
986 pViewFrm
->GetBindings().Invalidate( SID_BROWSER_MODE
);
987 pViewFrm
->GetBindings().Invalidate( FN_PRINT_LAYOUT
);
990 case SID_GET_COLORTABLE
:
992 SvxColorTableItem
* pColItem
= (SvxColorTableItem
*)GetItem(SID_COLOR_TABLE
);
993 XColorTable
* pTable
= pColItem
->GetColorTable();
994 rReq
.SetReturnValue(OfaPtrItem(SID_GET_COLORTABLE
, pTable
));
997 case FN_ABSTRACT_STARIMPRESS
:
998 case FN_ABSTRACT_NEWDOC
:
1000 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
1001 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
1003 AbstractSwInsertAbstractDlg
* pDlg
= pFact
->CreateSwInsertAbstractDlg(0, DLG_INSERT_ABSTRACT
);
1004 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
1005 if(RET_OK
== pDlg
->Execute())
1007 BYTE nLevel
= pDlg
->GetLevel();
1008 BYTE nPara
= pDlg
->GetPara();
1009 SwDoc
* pSmryDoc
= new SwDoc();
1010 SfxObjectShellRef
xDocSh( new SwDocShell( pSmryDoc
, SFX_CREATE_MODE_STANDARD
));
1011 xDocSh
->DoInitNew( 0 );
1013 BOOL bImpress
= FN_ABSTRACT_STARIMPRESS
== nWhich
;
1014 pDoc
->Summary( pSmryDoc
, nLevel
, nPara
, bImpress
);
1018 // mba: looks as if relative URLs don't make sense here
1019 ::GetRTFWriter( aEmptyStr
, String(), xWrt
);
1020 SvMemoryStream
*pStrm
= new SvMemoryStream();
1021 pStrm
->SetBufferSize( 16348 );
1022 SwWriter
aWrt( *pStrm
, *pSmryDoc
);
1023 ErrCode eErr
= aWrt
.Write( xWrt
);
1024 if( !ERRCODE_TOERROR( eErr
) )
1026 uno::Reference
< lang::XMultiServiceFactory
> xORB
= ::comphelper::getProcessServiceFactory();
1027 uno::Reference
< frame::XDispatchProvider
> xProv(
1028 xORB
->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY
);
1031 ::rtl::OUString aCmd
= ::rtl::OUString::createFromAscii( "SendOutlineToImpress" );
1032 uno::Reference
< frame::XDispatchHelper
> xHelper(
1033 xORB
->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY
);
1036 pStrm
->Seek( STREAM_SEEK_TO_END
);
1038 pStrm
->Seek( STREAM_SEEK_TO_BEGIN
);
1040 // Transfer ownership of stream to a lockbytes object
1041 SvLockBytes
aLockBytes( pStrm
, TRUE
);
1042 SvLockBytesStat aStat
;
1043 if ( aLockBytes
.Stat( &aStat
, SVSTATFLAG_DEFAULT
) == ERRCODE_NONE
)
1045 sal_uInt32 nLen
= aStat
.nSize
;
1047 uno::Sequence
< sal_Int8
> aSeq( nLen
);
1048 aLockBytes
.ReadAt( 0, aSeq
.getArray(), nLen
, &nRead
);
1050 uno::Sequence
< beans::PropertyValue
> aArgs(1);
1051 aArgs
[0].Name
= ::rtl::OUString::createFromAscii("RtfOutline");
1052 aArgs
[0].Value
<<= aSeq
;
1053 xHelper
->executeDispatch( xProv
, aCmd
, ::rtl::OUString(), 0, aArgs
);
1059 ErrorHandler::HandleError(ErrCode( eErr
));
1063 // Neues Dokument erzeugen.
1064 SfxViewFrame
*pFrame
= SfxViewFrame::CreateViewFrame( *xDocSh
, 0 );
1065 SwView
*pCurrView
= (SwView
*) pFrame
->GetViewShell();
1067 // Dokumenttitel setzen
1068 String
aTmp( SW_RES(STR_ABSTRACT_TITLE
) );
1070 xDocSh
->SetTitle( aTmp
);
1071 pCurrView
->GetWrtShell().SetNewDoc();
1073 pSmryDoc
->SetModified();
1080 case FN_OUTLINE_TO_CLIPBOARD
:
1081 case FN_OUTLINE_TO_IMPRESS
:
1084 // mba: looks as if relative URLs don't make sense here
1085 ::GetRTFWriter( 'O', String(), xWrt
);
1086 SvMemoryStream
*pStrm
= new SvMemoryStream();
1087 pStrm
->SetBufferSize( 16348 );
1088 SwWriter
aWrt( *pStrm
, *GetDoc() );
1089 ErrCode eErr
= aWrt
.Write( xWrt
);
1090 if( !ERRCODE_TOERROR( eErr
) )
1092 pStrm
->Seek( STREAM_SEEK_TO_END
);
1094 pStrm
->Seek( STREAM_SEEK_TO_BEGIN
);
1095 if ( nWhich
== FN_OUTLINE_TO_IMPRESS
)
1097 uno::Reference
< lang::XMultiServiceFactory
> xORB
= ::comphelper::getProcessServiceFactory();
1098 uno::Reference
< frame::XDispatchProvider
> xProv(
1099 xORB
->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY
);
1102 ::rtl::OUString aCmd
= ::rtl::OUString::createFromAscii( "SendOutlineToImpress" );
1103 uno::Reference
< frame::XDispatchHelper
> xHelper(
1104 xORB
->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY
);
1107 pStrm
->Seek( STREAM_SEEK_TO_END
);
1109 pStrm
->Seek( STREAM_SEEK_TO_BEGIN
);
1111 // Transfer ownership of stream to a lockbytes object
1112 SvLockBytes
aLockBytes( pStrm
, TRUE
);
1113 SvLockBytesStat aStat
;
1114 if ( aLockBytes
.Stat( &aStat
, SVSTATFLAG_DEFAULT
) == ERRCODE_NONE
)
1116 sal_uInt32 nLen
= aStat
.nSize
;
1118 uno::Sequence
< sal_Int8
> aSeq( nLen
);
1119 aLockBytes
.ReadAt( 0, aSeq
.getArray(), nLen
, &nRead
);
1121 uno::Sequence
< beans::PropertyValue
> aArgs(1);
1122 aArgs
[0].Name
= ::rtl::OUString::createFromAscii("RtfOutline");
1123 aArgs
[0].Value
<<= aSeq
;
1124 xHelper
->executeDispatch( xProv
, aCmd
, ::rtl::OUString(), 0, aArgs
);
1131 TransferDataContainer
* pClipCntnr
=
1132 new TransferDataContainer
;
1133 STAR_REFERENCE( datatransfer::XTransferable
)
1136 pClipCntnr
->CopyAnyData( FORMAT_RTF
, (sal_Char
*)
1137 pStrm
->GetData(), pStrm
->GetSize() );
1138 pClipCntnr
->CopyToClipboard(
1139 GetView()? (Window
*)&GetView()->GetEditWin() : 0 );
1144 ErrorHandler::HandleError(ErrCode( eErr
));
1147 case SID_SPELLCHECKER_CHANGED
:
1148 //! FALSE, TRUE, TRUE is on the save side but a probably overdone
1149 SW_MOD()->CheckSpellChanges(FALSE
, TRUE
, TRUE
, FALSE
);
1152 case SID_BROWSER_MODE
:
1153 case FN_PRINT_LAYOUT
: //Fuer Web, genau umgekehrt zum BrowserMode
1155 int eState
= STATE_TOGGLE
;
1156 BOOL bSet
= sal_True
;
1157 const SfxPoolItem
* pAttr
=NULL
;
1158 if ( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( nWhich
, FALSE
, &pAttr
))
1160 bSet
= ((SfxBoolItem
*)pAttr
)->GetValue();
1161 if ( nWhich
== FN_PRINT_LAYOUT
)
1163 eState
= bSet
? STATE_ON
: STATE_OFF
;
1166 if ( STATE_TOGGLE
== eState
)
1167 bSet
= !GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE
);
1169 ToggleBrowserMode(bSet
, 0);
1171 // OS: numerische Reihenfolge beachten!
1172 static USHORT __READONLY_DATA aInva
[] =
1174 SID_NEWWINDOW
,/*5620*/
1175 SID_BROWSER_MODE
, /*6313*/
1176 SID_RULER_BORDERS
, SID_RULER_PAGE_POS
,
1177 SID_ATTR_LONG_LRSPACE
,
1180 SID_AUTOSPELL_CHECK
,
1182 FN_VIEW_GRAPHIC
, /*20213*/
1183 FN_VIEW_BOUNDS
, /**/
1184 FN_VIEW_FIELDS
, /*20215*/
1185 FN_VLINEAL
, /*20216*/
1186 FN_VSCROLLBAR
, /*20217*/
1187 FN_HSCROLLBAR
, /*20218*/
1188 FN_VIEW_META_CHARS
, /**/
1190 FN_VIEW_FIELDNAME
, /**/
1191 FN_VIEW_TABLEGRID
, /*20227*/
1192 FN_PRINT_LAYOUT
, /*20237*/
1193 FN_QRY_MERGE
, /*20364*/
1196 // the view must not exist!
1197 SfxViewFrame
*pTmpFrm
= SfxViewFrame::GetFirst( this );
1199 pTmpFrm
->GetBindings().Invalidate( aInva
);
1201 rReq
.AppendItem( SfxBoolItem( nWhich
, bSet
) );
1206 case SID_MAIL_PREPAREEXPORT
:
1208 //pWrtShell is not set in page preview
1210 pWrtShell
->StartAllAction();
1211 pDoc
->UpdateFlds( NULL
, false );
1212 pDoc
->EmbedAllLinks();
1213 pDoc
->RemoveInvisibleContent();
1215 pWrtShell
->EndAllAction();
1218 case SID_MAIL_EXPORT_FINISHED
:
1221 pWrtShell
->StartAllAction();
1222 //try to undo the removal of invisible content
1223 pDoc
->RestoreInvisibleContent();
1225 pWrtShell
->EndAllAction();
1228 case FN_NEW_HTML_DOC
:
1229 case FN_NEW_GLOBAL_DOC
:
1232 BOOL bCreateHtml
= FN_NEW_HTML_DOC
== nWhich
;
1234 BOOL bCreateByOutlineLevel
= false; //#outline level,add by zhaojianwei
1235 sal_Int32 nTemplateOutlineLevel
= 0 ; //#outline level,add by zhaojianwei
1237 String aFileName
, aTemplateName
;
1238 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( nWhich
, FALSE
, &pItem
) )
1240 aFileName
= ((const SfxStringItem
*)pItem
)->GetValue();
1241 SFX_ITEMSET_ARG( pArgs
, pTemplItem
, SfxStringItem
, SID_TEMPLATE_NAME
, sal_False
);
1243 aTemplateName
= pTemplItem
->GetValue();
1245 bool bError
= false;
1246 if ( !aFileName
.Len() )
1248 FileDialogHelper
aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE
, 0 );
1250 const sal_Int16 nControlIds
[] = {
1251 CommonFilePickerElementIds::PUSHBUTTON_OK
,
1252 CommonFilePickerElementIds::PUSHBUTTON_CANCEL
,
1253 CommonFilePickerElementIds::LISTBOX_FILTER
,
1254 CommonFilePickerElementIds::CONTROL_FILEVIEW
,
1255 CommonFilePickerElementIds::EDIT_FILEURL
,
1256 ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
,
1257 ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
,
1260 sal_Int32 nHelpIds
[8];
1261 sal_Int32 nStartHelpId
=
1263 HID_SEND_HTML_CTRL_PUSHBUTTON_OK
: HID_SEND_MASTER_CTRL_PUSHBUTTON_OK
;
1264 for(int nHelp
= 0; nHelp
< 7; nHelp
++)
1265 nHelpIds
[nHelp
] = nStartHelpId
++;
1268 aDlgHelper
.SetControlHelpIds( nControlIds
, nHelpIds
);
1269 // aDlgHelper.SetDialogHelpId( bCreateHtml ? HID_SEND_HTML_DIALOG : HID_SEND_MASTER_DIALOG );
1271 uno::Reference
< XFilePicker
> xFP
= aDlgHelper
.GetFilePicker();
1273 const SfxFilter
* pFlt
;
1278 // fuer HTML gibts es nur einen Filter!!
1279 pFlt
= SwIoSystem::GetFilterOfFormat(
1280 String::CreateFromAscii("HTML"),
1281 SwWebDocShell::Factory().GetFilterContainer() );
1282 nStrId
= STR_LOAD_HTML_DOC
;
1286 // Fuer Global-Dokumente bieten wir jetzt auch nur
1287 // noch den aktuellen an.
1288 pFlt
= SwGlobalDocShell::Factory().GetFilterContainer()->
1289 GetFilter4Extension( String::CreateFromAscii("odm") );
1290 nStrId
= STR_LOAD_GLOBAL_DOC
;
1295 uno::Reference
<XFilterManager
> xFltMgr(xFP
, UNO_QUERY
);
1296 const String sWild
= ((WildCard
&)pFlt
->GetWildcard()).GetWildCard();
1297 xFltMgr
->appendFilter( pFlt
->GetUIName(), sWild
);
1300 xFltMgr
->setCurrentFilter( pFlt
->GetUIName() ) ;
1302 catch( const uno::Exception
& )
1309 uno::Reference
<XFilePickerControlAccess
> xCtrlAcc(xFP
, UNO_QUERY
);
1311 //#removed by zhaojianwei
1313 // const USHORT nCount = pDoc->GetTxtFmtColls()->Count();
1314 // Sequence<OUString> aListBoxEntries(nCount);
1315 // OUString* pEntries = aListBoxEntries.getArray();
1316 // sal_Int32 nIdx = 0;
1317 // sal_Int16 nSelect = 0;
1318 // OUString sStartTemplate;
1319 // SwTxtFmtColl *pFnd = 0, *pAny = 0;
1320 // for(USHORT i = 0; i < nCount; ++i)
1322 // SwTxtFmtColl &rTxtColl =
1323 // *pDoc->GetTxtFmtColls()->GetObject( i );
1324 // if( !rTxtColl.IsDefault() && rTxtColl.IsAtDocNodeSet() )
1326 // //if( MAXLEVEL >= rTxtColl.GetOutlineLevel() && ( !pFnd || //#outline level,zhaojianwei
1327 //if( rTxtColl.IsAssignedToListLevelOfOutlineStyle() && ( !pFnd || //<-end,zhaojianwei
1328 // pFnd->GetAssignedOutlineStyleLevel() > rTxtColl.GetAssignedOutlineStyleLevel() ))
1330 // nSelect = (sal_Int16)nIdx;
1331 // pFnd = &rTxtColl;
1332 // sStartTemplate = rTxtColl.GetName();
1335 // pAny = &rTxtColl;
1336 // //pEntries[nIdx++] = rTxtColl.GetName(); //#outline level,remove by zhaojianwei
1337 // pEntries[nIdx++] = sStyles + rTxtColl.GetName(); //#outline level,add by zhaojianwei
1340 // if(!sStartTemplate.getLength() && pAny)
1341 // sStartTemplate = pAny->GetName();
1342 // aListBoxEntries.realloc(nIdx);
1346 //#outline level,add by zhaojianwei
1347 /////////////////////////////////////////////////////////////////////
1349 bool bOutline
[MAXLEVEL
] = {false};
1350 const SwOutlineNodes
& rOutlNds
= pDoc
->GetNodes().GetOutLineNds();
1351 if( rOutlNds
.Count() )
1354 for(USHORT n
= 0; n
< rOutlNds
.Count(); ++n
)
1355 if( ( nLevel
= rOutlNds
[n
]->GetTxtNode()->GetAttrOutlineLevel()) > 0 &&
1356 ! bOutline
[nLevel
-1] )
1358 bOutline
[nLevel
-1] = true;
1362 const USHORT nStyleCount
= pDoc
->GetTxtFmtColls()->Count();
1363 Sequence
<OUString
> aListBoxEntries( MAXLEVEL
+ nStyleCount
);
1364 OUString
* pEntries
= aListBoxEntries
.getArray();
1365 sal_Int32 nIdx
= 0 ;
1367 OUString
sOutline( SW_RESSTR(STR_FDLG_OUTLINE_LEVEL
) );
1368 for( USHORT i
= 0; i
< MAXLEVEL
; ++i
)
1371 pEntries
[nIdx
++] = sOutline
+ String::CreateFromInt32( i
+1 );
1374 OUString
sStyle( SW_RESSTR(STR_FDLG_STYLE
) );
1375 for(USHORT i
= 0; i
< nStyleCount
; ++i
)
1377 SwTxtFmtColl
&rTxtColl
=
1378 *pDoc
->GetTxtFmtColls()->GetObject( i
);
1379 if( !rTxtColl
.IsDefault() && rTxtColl
.IsAtDocNodeSet() )
1381 pEntries
[nIdx
++] = sStyle
+ rTxtColl
.GetName();
1385 aListBoxEntries
.realloc(nIdx
);
1386 sal_Int16 nSelect
= 0;
1387 /////////////////////////////////////////////////////////////////////
1392 Any
aTemplates(&aListBoxEntries
, ::getCppuType(&aListBoxEntries
));
1394 xCtrlAcc
->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
,
1395 ListboxControlActions::ADD_ITEMS
, aTemplates
);
1396 Any
aSelectPos(&nSelect
, ::getCppuType(&nSelect
));
1397 xCtrlAcc
->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
,
1398 ListboxControlActions::SET_SELECT_ITEM
, aSelectPos
);
1399 xCtrlAcc
->setLabel( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
,
1400 String(SW_RES( STR_FDLG_TEMPLATE_NAME
)));
1404 DBG_ERROR("control acces failed");
1407 xFP
->setTitle( SW_RESSTR( nStrId
));
1408 SvtPathOptions aPathOpt
;
1409 xFP
->setDisplayDirectory( aPathOpt
.GetWorkPath() );
1410 if( ERRCODE_NONE
== aDlgHelper
.Execute())
1412 aFileName
= xFP
->getFiles().getConstArray()[0];
1413 Any aTemplateValue
= xCtrlAcc
->getValue(
1414 ExtendedFilePickerElementIds::LISTBOX_TEMPLATE
,
1415 ListboxControlActions::GET_SELECTED_ITEM
);
1417 aTemplateValue
>>= sTmpl
;
1418 //aTemplateName = sTmpl; //#outline level,removed by zhaojianwei
1419 //#outline level,add by zhaojianwei
1421 sal_Int32 nColonPos
= sTmpl
.indexOf( sal_Unicode(':') );
1422 OUString sPrefix
= sTmpl
.copy( 0L, nColonPos
);
1423 if( sPrefix
.equalsAscii("Style"))
1425 aTemplateName
= sTmpl
.copy( 7L ); //get string behind "Style: "
1427 else if( sPrefix
.equalsAscii("Outline"))
1429 nTemplateOutlineLevel
= ( sTmpl
.copy( 15L )).toInt32(); //get string behind "Outline: Leve ";
1430 bCreateByOutlineLevel
= true;
1434 if ( aFileName
.Len() )
1436 rReq
.AppendItem( SfxStringItem( nWhich
, aFileName
) );
1437 if( aTemplateName
.Len() )
1438 rReq
.AppendItem( SfxStringItem( SID_TEMPLATE_NAME
, aTemplateName
) );
1444 //const SwTxtFmtColl* pSplitColl = 0; //#outline level,removed by zhaojianwei
1445 // if ( aTemplateName.Len() )
1446 // pSplitColl = pDoc->FindTxtFmtCollByName(aTemplateName);
1448 if( aFileName
.Len() )
1450 if( PrepareClose( FALSE
) )
1452 SwWait
aWait( *this, TRUE
);
1454 //bDone = bCreateHtml //#outline level,removed by zhaojianwei
1455 // ? pDoc->GenerateHTMLDoc( aFileName, pSplitColl )
1456 // : pDoc->GenerateGlobalDoc( aFileName, pSplitColl );
1457 if ( bCreateByOutlineLevel
) //add by zhaojianwei
1459 bDone
= bCreateHtml
//#outline level,removed by zhaojianwei
1460 ? pDoc
->GenerateHTMLDoc( aFileName
, nTemplateOutlineLevel
)
1461 : pDoc
->GenerateGlobalDoc( aFileName
, nTemplateOutlineLevel
);
1465 const SwTxtFmtColl
* pSplitColl
= 0;
1466 if ( aTemplateName
.Len() )
1467 pSplitColl
= pDoc
->FindTxtFmtCollByName(aTemplateName
);
1468 bDone
= bCreateHtml
//#outline level,removed by zhaojianwei
1469 ? pDoc
->GenerateHTMLDoc( aFileName
, pSplitColl
)
1470 : pDoc
->GenerateGlobalDoc( aFileName
, pSplitColl
);
1475 SfxStringItem
aName( SID_FILE_NAME
, aFileName
);
1476 SfxStringItem
aReferer( SID_REFERER
, aEmptyStr
);
1477 SfxViewShell
* pViewShell
= SfxViewShell::GetFirst();
1480 //search for the view that created the call
1481 if(pViewShell
->GetObjectShell() == this && pViewShell
->GetDispatcher())
1483 SfxFrameItem
* pFrameItem
= new SfxFrameItem( SID_DOCFRAME
,
1484 pViewShell
->GetViewFrame() );
1485 SfxDispatcher
* pDispatch
= pViewShell
->GetDispatcher();
1488 SFX_CALLMODE_ASYNCHRON
,
1496 pViewShell
= SfxViewShell::GetNext(*pViewShell
);
1500 if( !bDone
&& !rReq
.IsAPI() )
1502 InfoBox( 0, SW_RESSTR( STR_CANTCREATE
)).Execute();
1506 rReq
.SetReturnValue(SfxBoolItem( nWhich
, bDone
));
1513 case SID_ATTR_YEAR2000
:
1514 if ( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( nWhich
, FALSE
, &pItem
))
1516 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "falsches Item");
1517 USHORT nYear2K
= ((SfxUInt16Item
*)pItem
)->GetValue();
1518 //ueber Views iterieren und den State an den FormShells setzen
1520 SfxViewFrame
* pVFrame
= SfxViewFrame::GetFirst( this );
1521 SfxViewShell
* pViewShell
= pVFrame
? pVFrame
->GetViewShell() : 0;
1522 SwView
* pCurrView
= dynamic_cast< SwView
* >( pViewShell
);
1525 FmFormShell
* pFormShell
= pCurrView
->GetFormShell();
1527 pFormShell
->SetY2KState(nYear2K
);
1528 pVFrame
= SfxViewFrame::GetNext( *pVFrame
, this );
1529 pViewShell
= pVFrame
? pVFrame
->GetViewShell() : 0;
1530 pCurrView
= dynamic_cast<SwView
*>( pViewShell
);
1532 pDoc
->GetNumberFormatter(TRUE
)->SetYear2000(nYear2K
);
1536 default: DBG_ERROR("falscher Dispatcher");
1541 /*--------------------------------------------------------------------
1543 --------------------------------------------------------------------*/
1545 long SwDocShell::DdeGetData( const String
& rItem
, const String
& rMimeType
,
1548 return pDoc
->GetData( rItem
, rMimeType
, rValue
);
1552 /*--------------------------------------------------------------------
1554 --------------------------------------------------------------------*/
1556 long SwDocShell::DdeSetData( const String
& rItem
, const String
& rMimeType
,
1557 const uno::Any
& rValue
)
1559 return pDoc
->SetData( rItem
, rMimeType
, rValue
);
1563 /*--------------------------------------------------------------------
1565 --------------------------------------------------------------------*/
1567 ::sfx2::SvLinkSource
* SwDocShell::DdeCreateLinkSource( const String
& rItem
)
1569 return pDoc
->CreateLinkSource( rItem
);
1572 /*--------------------------------------------------------------------
1574 --------------------------------------------------------------------*/
1576 void SwDocShell::FillClass( SvGlobalName
* pClassName
,
1577 sal_uInt32
* pClipFormat
,
1578 String
* /*pAppName*/,
1579 String
* pLongUserName
,
1582 sal_Bool bTemplate
/* = sal_False */) const
1584 if (nVersion
== SOFFICE_FILEFORMAT_60
)
1586 *pClassName
= SvGlobalName( SO3_SW_CLASSID_60
);
1587 *pClipFormat
= SOT_FORMATSTR_ID_STARWRITER_60
;
1588 *pLongUserName
= SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE
);
1590 else if (nVersion
== SOFFICE_FILEFORMAT_8
)
1592 *pClassName
= SvGlobalName( SO3_SW_CLASSID_60
);
1593 *pClipFormat
= bTemplate
? SOT_FORMATSTR_ID_STARWRITER_8_TEMPLATE
: SOT_FORMATSTR_ID_STARWRITER_8
;
1594 *pLongUserName
= SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE
);
1597 *pUserName
= SW_RESSTR(STR_HUMAN_SWDOC_NAME
);
1601 /*--------------------------------------------------------------------
1603 --------------------------------------------------------------------*/
1605 void SwDocShell::SetModified( BOOL bSet
)
1607 SfxObjectShell::SetModified( bSet
);
1608 if( IsEnableSetModified())
1610 if (!pDoc
->IsInCallModified() )
1612 EnableSetModified( FALSE
);
1615 BOOL bOld
= pDoc
->IsModified();
1616 pDoc
->SetModified();
1618 pDoc
->SetUndoNoResetModified();
1621 pDoc
->ResetModified();
1623 EnableSetModified( TRUE
);
1626 UpdateChildWindows();
1627 Broadcast(SfxSimpleHint(SFX_HINT_DOCCHANGED
));
1631 /*--------------------------------------------------------------------
1633 --------------------------------------------------------------------*/
1635 void SwDocShell::UpdateChildWindows()
1637 // Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR)
1640 SfxViewFrame
* pVFrame
= GetView()->GetViewFrame();
1641 SwFldDlgWrapper
*pWrp
= (SwFldDlgWrapper
*)pVFrame
->
1642 GetChildWindow( SwFldDlgWrapper::GetChildWindowId() );
1644 pWrp
->ReInitDlg( this );
1646 // RedlineDlg ggf neu initialisieren
1647 SwRedlineAcceptChild
*pRed
= (SwRedlineAcceptChild
*)pVFrame
->
1648 GetChildWindow( SwRedlineAcceptChild::GetChildWindowId() );
1650 pRed
->ReInitDlg( this );
1653 /*--------------------------------------------------------------------
1655 --------------------------------------------------------------------*/
1656 // --> OD 2005-08-02 #i48748#
1657 class SwReloadFromHtmlReader
: public SwReader
1660 SwReloadFromHtmlReader( SfxMedium
& _rTmpMedium
,
1661 const String
& _rFilename
,
1663 : SwReader( _rTmpMedium
, _rFilename
, _pDoc
)
1665 SetBaseURL( _rFilename
);
1669 void SwDocShell::ReloadFromHtml( const String
& rStreamName
, SwSrcView
* pSrcView
)
1671 BOOL bModified
= IsModified();
1673 // MIB 23.6.97: Die HTTP-Header-Felder muessen geloescht werden,
1674 // sonst gibt es welche aus Meta-Tags hinter doppelt und dreifach.
1675 ClearHeaderAttributesForSourceViewHack();
1677 // MIB 24.07.97: Das Dokument-Basic muss auch noch d'ran glauben ...
1678 // Ein EnterBasicCall braucht man hier nicht, weil man nichts ruft und
1679 // in HTML-Dokument kein Dok-Basic vorhanden sein kann, das noch nicht
1681 SvxHtmlOptions
* pHtmlOptions
= SvxHtmlOptions::Get();
1682 //#59620# HasBasic() zeigt an, dass es schon einen BasicManager an der DocShell
1683 // gibt. Der wurde im HTML-Import immer angelegt, wenn Macros im Quelltext
1685 if( pHtmlOptions
&& pHtmlOptions
->IsStarBasic() && HasBasic())
1687 BasicManager
*pBasicMan
= GetBasicManager();
1688 if( pBasicMan
&& (pBasicMan
!= SFX_APP()->GetBasicManager()) )
1690 USHORT nLibCount
= pBasicMan
->GetLibCount();
1693 StarBASIC
*pBasic
= pBasicMan
->GetLib( --nLibCount
);
1696 // Die IDE benachrichtigen
1697 SfxUsrAnyItem
aShellItem( SID_BASICIDE_ARG_DOCUMENT_MODEL
, makeAny( GetModel() ) );
1698 String
aLibName( pBasic
->GetName() );
1699 SfxStringItem
aLibNameItem( SID_BASICIDE_ARG_LIBNAME
, aLibName
);
1700 pSrcView
->GetViewFrame()->GetDispatcher()->Execute(
1701 SID_BASICIDE_LIBREMOVED
,
1702 SFX_CALLMODE_SYNCHRON
,
1703 &aShellItem
, &aLibNameItem
, 0L );
1705 // Aus der Standard-Lib werden nur die Module geloescht
1707 pBasicMan
->RemoveLib( nLibCount
, TRUE
);
1713 ASSERT( pBasicMan
->GetLibCount() <= 1,
1714 "Loschen des Basics hat nicht geklappt" );
1717 sal_Bool bWasBrowseMode
= pDoc
->get(IDocumentSettingAccess::BROWSE_MODE
);
1720 //jetzt muss auch das UNO-Model ueber das neue Doc informiert werden #51535#
1721 uno::Reference
<text::XTextDocument
> xDoc(GetBaseModel(), uno::UNO_QUERY
);
1722 text::XTextDocument
* pxDoc
= xDoc
.get();
1723 ((SwXTextDocument
*)pxDoc
)->InitNewDoc();
1726 //#116402# update font list when new document is created
1728 pDoc
->set(IDocumentSettingAccess::BROWSE_MODE
, bWasBrowseMode
);
1729 pSrcView
->SetPool(&GetPool());
1732 const String
& rMedname
= GetMedium()->GetName();
1734 // fix #51032#: Die HTML-Vorlage muss noch gesetzt werden
1735 SetHTMLTemplate( *GetDoc() ); //Styles aus HTML.vor
1737 SfxViewShell
* pViewShell
= GetView() ? (SfxViewShell
*)GetView()
1738 : SfxViewShell::Current();
1739 SfxViewFrame
* pViewFrm
= pViewShell
->GetViewFrame();
1740 pViewFrm
->GetDispatcher()->Execute( SID_VIEWSHELL0
, SFX_CALLMODE_SYNCHRON
);
1744 SfxMedium
aMed( rStreamName
, STREAM_READ
, FALSE
);
1745 // --> OD 2005-08-01 #i48748# - use class <SwReloadFromHtmlReader>, because
1746 // the base URL has to be set to the filename of the document <rMedname>
1747 // and not to the base URL of the temporary file <aMed> in order to get
1748 // the URLs of the linked graphics correctly resolved.
1749 SwReloadFromHtmlReader
aReader( aMed
, rMedname
, pDoc
);
1751 aReader
.Read( *ReadHTML
);
1753 const SwView
* pCurrView
= GetView();
1754 //in print layout the first page(s) may have been formatted as a mix of browse
1756 if(!bWasBrowseMode
&& pCurrView
)
1758 SwWrtShell
& rWrtSh
= pCurrView
->GetWrtShell();
1759 if( rWrtSh
.GetLayout())
1760 rWrtSh
.CheckBrowseView( TRUE
);
1764 // MIB 23.6.97: Die HTTP-Header-Attribute wieder in die DokInfo
1765 // uebernehmen. Die Base-URL ist hier egal, da TLX zum absolutieren die
1766 // vom Dokument nimmt.
1767 SetHeaderAttributesForSourceViewHack();
1769 if(bModified
&& !IsReadOnly())
1772 pDoc
->ResetModified();
1775 /* -----------------------------14.12.99 16:52--------------------------------
1777 ---------------------------------------------------------------------------*/
1778 void SwDocShell::ToggleBrowserMode(BOOL bSet
, SwView
* _pView
)
1780 GetDoc()->set(IDocumentSettingAccess::BROWSE_MODE
, bSet
);
1782 SwView
* pTempView
= _pView
? _pView
: (SwView
*)GetView();
1785 SfxBindings
& rBind
= pTempView
->GetViewFrame()->GetBindings();
1786 rBind
.Invalidate(FN_SHADOWCURSOR
);
1787 rBind
.Invalidate(SID_BROWSER_MODE
);
1788 rBind
.Invalidate(FN_PRINT_LAYOUT
);
1790 if( !GetDoc()->getPrinter( false ) )
1792 pTempView
->SetPrinter( GetDoc()->getPrinter( false ),
1793 SFX_PRINTER_PRINTER
| SFX_PRINTER_JOBSETUP
);
1796 // --> FME 2005-03-16 #i44963# Good occasion to check if page sizes in
1797 // page descriptions are still set to (LONG_MAX, LONG_MAX) (html import)
1798 GetDoc()->CheckDefaultPageFmt();
1801 // Currently there can be only one view (layout) if the document is viewed in Web layout
1802 // So if there are more views we are in print layout and for toggling to Web layout all other views must be closed
1803 SfxViewFrame
*pTmpFrm
= SfxViewFrame::GetFirst(this, 0, FALSE
);
1805 if( pTmpFrm
!= pTempView
->GetViewFrame() )
1808 pTmpFrm
= SfxViewFrame::GetFirst(this, 0, FALSE
);
1811 pTmpFrm
= pTmpFrm
->GetNext(*pTmpFrm
, this, 0, FALSE
);
1813 } while ( pTmpFrm
);
1815 const SwViewOption
& rViewOptions
= *pTempView
->GetWrtShell().GetViewOptions();
1817 // set view columns before toggling:
1820 const USHORT nColumns
= rViewOptions
.GetViewLayoutColumns();
1821 const bool bBookMode
= rViewOptions
.IsViewLayoutBookMode();
1822 if ( 1 != nColumns
|| bBookMode
)
1824 ((SwView
*)GetView())->SetViewLayout( 1, false );
1828 // Triggeres a formatting:
1829 pTempView
->GetWrtShell().CheckBrowseView( TRUE
);
1830 pTempView
->CheckVisArea();
1832 if( GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE
) )
1834 const SvxZoomType eType
= (SvxZoomType
)rViewOptions
.GetZoomType();
1836 if ( SVX_ZOOM_PERCENT
!= eType
)
1838 ((SwView
*)GetView())->SetZoom( eType
);
1841 pTempView
->InvalidateBorder();
1842 pTempView
->SetNewWindowAllowed(!bSet
);
1846 ULONG
SwDocShell::LoadStylesFromFile( const String
& rURL
,
1847 SwgReaderOption
& rOpt
, BOOL bUnoCall
)
1851 // Create a URL from filename
1852 INetURLObject
aURLObj( rURL
);
1853 String
sURL( aURLObj
.GetMainURL( INetURLObject::NO_DECODE
) );
1856 SwReader
* pReader
= 0;
1859 // Filter bestimmen:
1860 // const SfxFilter* pFlt = SwIoSystem::GetFileFilter( rURL, aEmptyStr );
1861 String
sFactory(String::CreateFromAscii(SwDocShell::Factory().GetShortName()));
1862 SfxFilterMatcher
aMatcher( sFactory
);
1864 //#b6445961# search for filter in WebDocShell, too
1865 SfxMedium
aMed( rURL
, STREAM_STD_READ
, FALSE
);
1866 const SfxFilter
* pFlt
= 0;
1867 aMatcher
.DetectFilter( aMed
, &pFlt
, FALSE
, FALSE
);
1870 String
sWebFactory(String::CreateFromAscii(SwWebDocShell::Factory().GetShortName()));
1871 SfxFilterMatcher
aWebMatcher( sWebFactory
);
1872 aWebMatcher
.DetectFilter( aMed
, &pFlt
, FALSE
, FALSE
);
1874 if( aMed
.IsStorage() )
1876 DBG_ASSERT((pFlt
? pFlt
->GetVersion() : 0) >= SOFFICE_FILEFORMAT_60
, "which file version?");
1878 // the SW3IO - Reader need the pam/wrtshell, because only then he
1879 // insert the styles!
1882 SwNodeIndex
aIdx( pDoc
->GetNodes().GetEndOfContent(), -1 );
1883 pPam
= new SwPaM( aIdx
);
1884 pReader
= new SwReader( aMed
, rURL
, *pPam
);
1887 pReader
= new SwReader( aMed
, rURL
, *pWrtShell
->GetCrsr() );
1891 // if( pFlt->GetUserData().EqualsAscii( FILTER_SWG ) ||
1892 // pFlt->GetUserData().EqualsAscii( FILTER_SWGV ))
1894 pReader
= new SwReader( aMed
, rURL
, pDoc
);
1897 ASSERT( pRead
, "no reader found" );
1900 pRead
->GetReaderOpt().SetTxtFmts( rOpt
.IsTxtFmts() );
1901 pRead
->GetReaderOpt().SetFrmFmts( rOpt
.IsFrmFmts() );
1902 pRead
->GetReaderOpt().SetPageDescs( rOpt
.IsPageDescs() );
1903 pRead
->GetReaderOpt().SetNumRules( rOpt
.IsNumRules() );
1904 pRead
->GetReaderOpt().SetMerge( rOpt
.IsMerge() );
1908 UnoActionContext
aAction( pDoc
);
1909 nErr
= pReader
->Read( *pRead
);
1913 pWrtShell
->StartAllAction();
1914 nErr
= pReader
->Read( *pRead
);
1915 pWrtShell
->EndAllAction();
1923 /*--------------------------------------------------------------------
1924 Get a client for an embedded object if possible.
1925 --------------------------------------------------------------------*/
1926 SfxInPlaceClient
* SwDocShell::GetIPClient( const ::svt::EmbeddedObjectRef
& xObjRef
)
1928 SfxInPlaceClient
* pResult
= NULL
;
1930 SwWrtShell
* pShell
= GetWrtShell();
1933 pResult
= pShell
->GetView().FindIPClient( xObjRef
.GetObject(), (Window
*)&pShell
->GetView().GetEditWin() );
1935 pResult
= new SwOleClient( &pShell
->GetView(), &pShell
->GetView().GetEditWin(), xObjRef
);