1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 28cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchHelper.hpp> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <hintids.hxx> 33cdf0e10cSrcweir #include <tools/urlobj.hxx> 34cdf0e10cSrcweir #include <unotools/tempfile.hxx> 35cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 36cdf0e10cSrcweir #include <vcl/msgbox.hxx> 37cdf0e10cSrcweir #include <svl/lckbitem.hxx> 38cdf0e10cSrcweir #include <svl/eitem.hxx> 39cdf0e10cSrcweir #include <svl/zforlist.hxx> 40cdf0e10cSrcweir #include <svl/zformat.hxx> 41cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 42cdf0e10cSrcweir #include <svtools/transfer.hxx> 43cdf0e10cSrcweir #include <sfx2/dialogs.hrc> 44cdf0e10cSrcweir #include <sfx2/dinfdlg.hxx> 45cdf0e10cSrcweir #include <sfx2/request.hxx> 46cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 47cdf0e10cSrcweir #include <sfx2/new.hxx> 48cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx> 49cdf0e10cSrcweir #include <sfx2/printer.hxx> 50cdf0e10cSrcweir #include <sfx2/evntconf.hxx> 51cdf0e10cSrcweir #include <svtools/sfxecode.hxx> 52cdf0e10cSrcweir #include <sfx2/docfile.hxx> 53cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 54cdf0e10cSrcweir #include <svx/svxids.hrc> 55cdf0e10cSrcweir #include <svx/drawitem.hxx> 56cdf0e10cSrcweir #include <editeng/svxacorr.hxx> 57cdf0e10cSrcweir #include <editeng/langitem.hxx> 58cdf0e10cSrcweir #include <svx/fmshell.hxx> 59cdf0e10cSrcweir 60cdf0e10cSrcweir #include <svtools/htmlcfg.hxx> 61cdf0e10cSrcweir #include <svx/ofaitem.hxx> 62cdf0e10cSrcweir #include <SwSmartTagMgr.hxx> 63cdf0e10cSrcweir #include <sfx2/app.hxx> 64cdf0e10cSrcweir #include <basic/sbstar.hxx> 65cdf0e10cSrcweir #include <basic/basmgr.hxx> 66cdf0e10cSrcweir #include <sot/storage.hxx> 67cdf0e10cSrcweir #include <sot/clsids.hxx> 68cdf0e10cSrcweir #include <swunodef.hxx> 69cdf0e10cSrcweir #include <fmtcol.hxx> 70cdf0e10cSrcweir #include <swevent.hxx> 71cdf0e10cSrcweir #include <view.hxx> // fuer die aktuelle Sicht 72cdf0e10cSrcweir #include <docsh.hxx> // Dokumenterzeugung 73cdf0e10cSrcweir #include <wrtsh.hxx> 74cdf0e10cSrcweir #include <fldbas.hxx> 75cdf0e10cSrcweir #include <viewopt.hxx> 76cdf0e10cSrcweir #include <globdoc.hxx> 77cdf0e10cSrcweir #include <fldwrap.hxx> 78cdf0e10cSrcweir #include <redlndlg.hxx> 79cdf0e10cSrcweir #include <docstyle.hxx> 80cdf0e10cSrcweir #include <doc.hxx> 81cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx> 82cdf0e10cSrcweir #include <pagedesc.hxx> 83cdf0e10cSrcweir #include <shellio.hxx> 84cdf0e10cSrcweir #include <pview.hxx> 85cdf0e10cSrcweir #include <srcview.hxx> 86cdf0e10cSrcweir #include <poolfmt.hxx> 87cdf0e10cSrcweir #include <usrpref.hxx> 88cdf0e10cSrcweir #include <wdocsh.hxx> 89cdf0e10cSrcweir #include <unotxdoc.hxx> 90cdf0e10cSrcweir #include <acmplwrd.hxx> 91cdf0e10cSrcweir #include <swmodule.hxx> 92cdf0e10cSrcweir #include <unobaseclass.hxx> 93cdf0e10cSrcweir #include <swwait.hxx> 94cdf0e10cSrcweir #include <swcli.hxx> 95cdf0e10cSrcweir 96cdf0e10cSrcweir #include <cmdid.h> 97cdf0e10cSrcweir #include <globals.h> 98cdf0e10cSrcweir #include <helpid.h> 99cdf0e10cSrcweir #include <app.hrc> 100cdf0e10cSrcweir #include <poolfmt.hrc> 101cdf0e10cSrcweir #include <globals.hrc> 102cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePicker.hpp> 103cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp> 104cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 105cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> 106cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> 107cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> 108cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" 109cdf0e10cSrcweir #ifdef FUTURE_VBA 110cdf0e10cSrcweir #include <com/sun/star/script/vba/XVBAEventProcessor.hpp> 111cdf0e10cSrcweir #include <com/sun/star/script/vba/VBAEventId.hpp> 112cdf0e10cSrcweir #endif 113cdf0e10cSrcweir #include <editeng/acorrcfg.hxx> 114cdf0e10cSrcweir #include <SwStyleNameMapper.hxx> 115cdf0e10cSrcweir 116cdf0e10cSrcweir #include <sfx2/fcontnr.hxx> 117cdf0e10cSrcweir 118cdf0e10cSrcweir #include "swabstdlg.hxx" 119cdf0e10cSrcweir #include "dialog.hrc" 120cdf0e10cSrcweir #include "swabstdlg.hxx" 121cdf0e10cSrcweir 122cdf0e10cSrcweir #include <ndtxt.hxx> //#outline level,add by zhaojianwei 123cdf0e10cSrcweir 124cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs; 125cdf0e10cSrcweir using namespace ::com::sun::star::lang; 126cdf0e10cSrcweir using namespace ::com::sun::star::uno; 127cdf0e10cSrcweir using namespace ::com::sun::star; 128cdf0e10cSrcweir using ::rtl::OUString; 129cdf0e10cSrcweir using namespace ::sfx2; 130cdf0e10cSrcweir extern sal_Bool FindPhyStyle( SwDoc& , const String& , SfxStyleFamily ); 131cdf0e10cSrcweir 132cdf0e10cSrcweir /*-------------------------------------------------------------------- 133cdf0e10cSrcweir Beschreibung: DocInfo kreieren (virtuell) 134cdf0e10cSrcweir --------------------------------------------------------------------*/ 135cdf0e10cSrcweir 136cdf0e10cSrcweir SfxDocumentInfoDialog* SwDocShell::CreateDocumentInfoDialog( 137cdf0e10cSrcweir Window *pParent, const SfxItemSet &rSet) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir SfxDocumentInfoDialog* pDlg = new SfxDocumentInfoDialog(pParent, rSet); 140cdf0e10cSrcweir //nur mit Statistik, wenn dieses Doc auch angezeigt wird, nicht 141cdf0e10cSrcweir //aus dem Doc-Manager 142cdf0e10cSrcweir SwDocShell* pDocSh = (SwDocShell*) SfxObjectShell::Current(); 143cdf0e10cSrcweir if( pDocSh == this ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir //Nicht fuer SourceView. 146cdf0e10cSrcweir SfxViewShell *pVSh = SfxViewShell::Current(); 147cdf0e10cSrcweir if ( pVSh && !pVSh->ISA(SwSrcView) ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 150cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 151cdf0e10cSrcweir pDlg->AddTabPage(TP_DOC_STAT, SW_RESSTR(STR_DOC_STAT),pFact->GetTabPageCreatorFunc( TP_DOC_STAT ),0); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir } 154cdf0e10cSrcweir return pDlg; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir // Disable "multiple layout" 158cdf0e10cSrcweir 159cdf0e10cSrcweir void SwDocShell::ToggleBrowserMode(sal_Bool bSet, SwView* _pView ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir GetDoc()->set(IDocumentSettingAccess::BROWSE_MODE, bSet ); 162cdf0e10cSrcweir UpdateFontList(); 163cdf0e10cSrcweir SwView* pTempView = _pView ? _pView : (SwView*)GetView(); 164cdf0e10cSrcweir if( pTempView ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir pTempView->GetViewFrame()->GetBindings().Invalidate(FN_SHADOWCURSOR); 167cdf0e10cSrcweir if( !GetDoc()->getPrinter( false ) ) 168cdf0e10cSrcweir pTempView->SetPrinter( GetDoc()->getPrinter( false ), SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP ); 169cdf0e10cSrcweir GetDoc()->CheckDefaultPageFmt(); 170cdf0e10cSrcweir SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this, sal_False); 171cdf0e10cSrcweir do { 172cdf0e10cSrcweir if( pTmpFrm != pTempView->GetViewFrame() ) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir pTmpFrm->DoClose(); 175cdf0e10cSrcweir pTmpFrm = SfxViewFrame::GetFirst(this, sal_False); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir else 178cdf0e10cSrcweir pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this, sal_False); 179cdf0e10cSrcweir 180cdf0e10cSrcweir } while ( pTmpFrm ); 181cdf0e10cSrcweir const SwViewOption& rViewOptions = *pTempView->GetWrtShell().GetViewOptions(); 182cdf0e10cSrcweir pTempView->GetWrtShell().CheckBrowseView( sal_True ); 183cdf0e10cSrcweir pTempView->CheckVisArea(); 184cdf0e10cSrcweir if( bSet ) 185cdf0e10cSrcweir { 186cdf0e10cSrcweir const SvxZoomType eType = (SvxZoomType)rViewOptions.GetZoomType(); 187cdf0e10cSrcweir if ( SVX_ZOOM_PERCENT != eType) 188cdf0e10cSrcweir ((SwView*)GetView())->SetZoom( eType ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir pTempView->InvalidateBorder(); 191cdf0e10cSrcweir pTempView->SetNewWindowAllowed(!bSet); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir } 194cdf0e10cSrcweir // End of disabled "multiple layout" 195cdf0e10cSrcweir 196cdf0e10cSrcweir /// update text fields on document properties changes 197cdf0e10cSrcweir void SwDocShell::DoFlushDocInfo() 198cdf0e10cSrcweir { 199cdf0e10cSrcweir if ( !pDoc ) return; 200cdf0e10cSrcweir 201cdf0e10cSrcweir bool bUnlockView(true); 202cdf0e10cSrcweir if ( pWrtShell ) { 203cdf0e10cSrcweir bUnlockView = !pWrtShell->IsViewLocked(); 204cdf0e10cSrcweir pWrtShell->LockView( sal_True ); // lock visible section 205cdf0e10cSrcweir pWrtShell->StartAllAction(); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir pDoc->DocInfoChgd(); 209cdf0e10cSrcweir 210cdf0e10cSrcweir if ( pWrtShell ) { 211cdf0e10cSrcweir pWrtShell->EndAllAction(); 212cdf0e10cSrcweir if ( bUnlockView ) { 213cdf0e10cSrcweir pWrtShell->LockView( sal_False ); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir } 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir #ifdef FUTURE_VBA 219cdf0e10cSrcweir void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XVBAEventProcessor >& xVbaEvents, const SfxHint& rHint ) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir using namespace com::sun::star::script::vba::VBAEventId; 222cdf0e10cSrcweir if ( rHint.ISA( SfxEventHint ) ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs; 225cdf0e10cSrcweir sal_uLong nEventId = ((SfxEventHint&)rHint).GetEventId(); 226cdf0e10cSrcweir switch( nEventId ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir case SFX_EVENT_CREATEDOC: 229cdf0e10cSrcweir xVbaEvents->processVbaEvent( DOCUMENT_NEW, aArgs ); 230cdf0e10cSrcweir break; 231cdf0e10cSrcweir case SFX_EVENT_OPENDOC: 232cdf0e10cSrcweir xVbaEvents->processVbaEvent( DOCUMENT_OPEN, aArgs ); 233cdf0e10cSrcweir break; 234cdf0e10cSrcweir } 235cdf0e10cSrcweir } 236cdf0e10cSrcweir } 237cdf0e10cSrcweir #endif 238cdf0e10cSrcweir 239cdf0e10cSrcweir /*-------------------------------------------------------------------- 240cdf0e10cSrcweir Beschreibung: Benachrichtigung bei geaenderter DocInfo 241cdf0e10cSrcweir --------------------------------------------------------------------*/ 242cdf0e10cSrcweir 243cdf0e10cSrcweir void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir if( !pDoc ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir //MA: Kommt bei der OLE-Registration vor! 248cdf0e10cSrcweir // ASSERT( !this, "DocShell ist nicht richtig initialisiert!" ); 249cdf0e10cSrcweir return ; 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir #ifdef FUTURE_VBA 253cdf0e10cSrcweir uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); 254cdf0e10cSrcweir if( xVbaEvents.is() ) 255cdf0e10cSrcweir lcl_processCompatibleSfxHint( xVbaEvents, rHint ); 256cdf0e10cSrcweir #endif 257cdf0e10cSrcweir 258cdf0e10cSrcweir sal_uInt16 nAction = 0; 259cdf0e10cSrcweir if( rHint.ISA(SfxSimpleHint) ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir // swithc for more actions 262cdf0e10cSrcweir switch( ((SfxSimpleHint&) rHint).GetId() ) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir case SFX_HINT_TITLECHANGED: 265cdf0e10cSrcweir if( GetMedium() ) 266cdf0e10cSrcweir nAction = 2; 267cdf0e10cSrcweir break; 268cdf0e10cSrcweir } 269cdf0e10cSrcweir } 270cdf0e10cSrcweir else if( rHint.ISA(SfxEventHint) && 271cdf0e10cSrcweir ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_LOADFINISHED ) 272cdf0e10cSrcweir { 273cdf0e10cSrcweir // --> OD 2004-12-03 #i38126# - own action id 274cdf0e10cSrcweir nAction = 3; 275cdf0e10cSrcweir // <-- 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir if( nAction ) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir sal_Bool bUnlockView = sal_True; //initializing prevents warning 281cdf0e10cSrcweir if( pWrtShell ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir bUnlockView = !pWrtShell->IsViewLocked(); 284cdf0e10cSrcweir pWrtShell->LockView( sal_True ); //lock visible section 285cdf0e10cSrcweir pWrtShell->StartAllAction(); 286cdf0e10cSrcweir } 287cdf0e10cSrcweir switch( nAction ) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir case 2: 290cdf0e10cSrcweir pDoc->GetSysFldType( RES_FILENAMEFLD )->UpdateFlds(); 291cdf0e10cSrcweir break; 292cdf0e10cSrcweir // --> OD 2004-12-03 #i38126# - own action for event LOADFINISHED 293cdf0e10cSrcweir // in order to avoid a modified document. 294cdf0e10cSrcweir // --> OD 2005-02-01 #i41679# - Also for the instance of <SwDoc> 295cdf0e10cSrcweir // it has to be assured, that it's not modified. 296cdf0e10cSrcweir // Perform the same as for action id 1, but disable <SetModified>. 297cdf0e10cSrcweir case 3: 298cdf0e10cSrcweir { 299cdf0e10cSrcweir const bool bResetModified = IsEnableSetModified(); 300cdf0e10cSrcweir if ( bResetModified ) 301cdf0e10cSrcweir EnableSetModified( sal_False ); 302cdf0e10cSrcweir // --> OD 2005-02-01 #i41679# 303cdf0e10cSrcweir const bool bIsDocModified = pDoc->IsModified(); 304cdf0e10cSrcweir // <-- 305cdf0e10cSrcweir 306cdf0e10cSrcweir pDoc->DocInfoChgd( ); 307cdf0e10cSrcweir 308cdf0e10cSrcweir // --> OD 2005-02-01 #i41679# 309cdf0e10cSrcweir if ( !bIsDocModified ) 310cdf0e10cSrcweir pDoc->ResetModified(); 311cdf0e10cSrcweir // <-- 312cdf0e10cSrcweir if ( bResetModified ) 313cdf0e10cSrcweir EnableSetModified( sal_True ); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir break; 316cdf0e10cSrcweir // <-- 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir if( pWrtShell ) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir pWrtShell->EndAllAction(); 322cdf0e10cSrcweir if( bUnlockView ) 323cdf0e10cSrcweir pWrtShell->LockView( sal_False ); 324cdf0e10cSrcweir } 325cdf0e10cSrcweir } 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir /*-------------------------------------------------------------------- 329cdf0e10cSrcweir Beschreibung: Benachrichtigung Doc schliessen 330cdf0e10cSrcweir --------------------------------------------------------------------*/ 331cdf0e10cSrcweir 332cdf0e10cSrcweir sal_uInt16 SwDocShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing ) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir sal_uInt16 nRet = SfxObjectShell::PrepareClose( bUI, bForBrowsing ); 335cdf0e10cSrcweir 336cdf0e10cSrcweir if( sal_True == nRet ) //Unbedingt auf sal_True abfragen! (RET_NEWTASK) 337cdf0e10cSrcweir EndListening( *this ); 338cdf0e10cSrcweir 339cdf0e10cSrcweir #ifdef FUTURE_VBA 340cdf0e10cSrcweir if( pDoc && IsInPrepareClose() ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); 343cdf0e10cSrcweir if( xVbaEvents.is() ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir using namespace com::sun::star::script::vba::VBAEventId; 346cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs; 347cdf0e10cSrcweir xVbaEvents->processVbaEvent( DOCUMENT_CLOSE, aArgs ); 348cdf0e10cSrcweir } 349cdf0e10cSrcweir } 350cdf0e10cSrcweir #endif 351cdf0e10cSrcweir return nRet; 352cdf0e10cSrcweir } 353cdf0e10cSrcweir 354cdf0e10cSrcweir /*-------------------------------------------------------------------- 355cdf0e10cSrcweir Beschreibung: Organizer 356cdf0e10cSrcweir --------------------------------------------------------------------*/ 357cdf0e10cSrcweir 358cdf0e10cSrcweir sal_Bool SwDocShell::Insert( SfxObjectShell &rSource, 359cdf0e10cSrcweir sal_uInt16 nSourceIdx1, // SourcePool: oberste Inhaltsebene (Vorlagen/Makros) 360cdf0e10cSrcweir sal_uInt16 nSourceIdx2, // Index in den Inhalt 361cdf0e10cSrcweir sal_uInt16 nSourceIdx3, // Index in die Inhaltsebene 362cdf0e10cSrcweir sal_uInt16 &rIdx1, // und das gleiche fuer den DestinationPool 363cdf0e10cSrcweir sal_uInt16 &rIdx2, // "" 364cdf0e10cSrcweir sal_uInt16 &rIdx3, // "" 365cdf0e10cSrcweir sal_uInt16 &rRemovedIdx ) // falls doppelte geloescht werden, Pos zurueck 366cdf0e10cSrcweir { 367cdf0e10cSrcweir // --> OD 2005-05-10 #i48949# - actions aren't undoable. Thus, allow no undo 368cdf0e10cSrcweir // actions 369cdf0e10cSrcweir // Note: The undo action stack is cleared at the end of this method. 370cdf0e10cSrcweir ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); 371cdf0e10cSrcweir // <-- 372cdf0e10cSrcweir 373cdf0e10cSrcweir sal_Bool bRet = sal_False; 374cdf0e10cSrcweir 375cdf0e10cSrcweir if (INDEX_IGNORE == rIdx1 && CONTENT_STYLE == nSourceIdx1) 376cdf0e10cSrcweir rIdx1 = CONTENT_STYLE; 377cdf0e10cSrcweir 378cdf0e10cSrcweir if (CONTENT_STYLE == nSourceIdx1 && CONTENT_STYLE == rIdx1) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir SfxStyleSheetBasePool* pHisPool = rSource.GetStyleSheetPool(); 381cdf0e10cSrcweir SwDocStyleSheetPool* pMyPool = 382cdf0e10cSrcweir (SwDocStyleSheetPool*)GetStyleSheetPool(); 383cdf0e10cSrcweir 384cdf0e10cSrcweir // wir koennen nicht in uns selbst hin und her moven 385cdf0e10cSrcweir if( pHisPool == pMyPool ) 386cdf0e10cSrcweir return sal_False; 387cdf0e10cSrcweir 388cdf0e10cSrcweir if( INDEX_IGNORE == rIdx2 ) 389cdf0e10cSrcweir rIdx2 = pMyPool->Count(); 390cdf0e10cSrcweir 391cdf0e10cSrcweir // erstmal auf die Such-Maske "positionieren" 392cdf0e10cSrcweir pHisPool->First(); 393cdf0e10cSrcweir SfxStyleSheetBase* pHisSheet = (*pHisPool)[nSourceIdx2]; 394cdf0e10cSrcweir 395cdf0e10cSrcweir // wenn so eine Vorlage schon existiert: loeschen! 396cdf0e10cSrcweir const String& rOldName = pHisSheet->GetName(); 397cdf0e10cSrcweir SfxStyleFamily eOldFamily( pHisSheet->GetFamily() ); 398cdf0e10cSrcweir 399cdf0e10cSrcweir // dflt. PageDesc und StandardZeichenvorlage nie loeschen !!! 400cdf0e10cSrcweir if( ( SFX_STYLE_FAMILY_PAGE == eOldFamily && 401cdf0e10cSrcweir const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetName() == 402cdf0e10cSrcweir rOldName ) || 403cdf0e10cSrcweir ( SFX_STYLE_FAMILY_CHAR == eOldFamily && 404cdf0e10cSrcweir rOldName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD - 405cdf0e10cSrcweir RES_POOLCOLL_TEXT_BEGIN ] )) 406cdf0e10cSrcweir return sal_False; 407cdf0e10cSrcweir 408cdf0e10cSrcweir SfxStyleFamily eMyOldFamily( pMyPool->GetSearchFamily() ); 409cdf0e10cSrcweir sal_uInt16 nMySrchMask = pMyPool->GetSearchMask(); 410cdf0e10cSrcweir 411cdf0e10cSrcweir SfxStyleSheetBase* pExist; 412cdf0e10cSrcweir if( ::FindPhyStyle( *pDoc, rOldName, eOldFamily ) ) 413cdf0e10cSrcweir { 414cdf0e10cSrcweir // Bug 20365: nur uebernehmen, wenn das gewuenscht ist! 415cdf0e10cSrcweir if( ERRCODE_BUTTON_OK != ErrorHandler::HandleError( 416cdf0e10cSrcweir *new MessageInfo( ERRCODE_SFXMSG_STYLEREPLACE, rOldName )) ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir return sal_False; 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir // Da Replace den aStyleSheet-Member selbst benoetigt, muss 422cdf0e10cSrcweir // das Ergebnis vom Find kopiert werden (s.u.)) 423cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > xExist( new SwDocStyleSheet( 424cdf0e10cSrcweir *(SwDocStyleSheet*)pMyPool->Find( rOldName, eOldFamily ) ) ); 425cdf0e10cSrcweir pMyPool->Replace( *pHisSheet, *xExist.get() ); 426cdf0e10cSrcweir 427cdf0e10cSrcweir // An der Reihenfolge der Vorlagen im Pool aendert sich nichts. 428cdf0e10cSrcweir rIdx2 = rIdx1 = INDEX_IGNORE; 429cdf0e10cSrcweir 430cdf0e10cSrcweir GetDoc()->SetModified(); 431cdf0e10cSrcweir 432cdf0e10cSrcweir return sal_True; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir pMyPool->SetSearchMask( eOldFamily, nMySrchMask ); 436cdf0e10cSrcweir 437cdf0e10cSrcweir // MIB 18.12.98: SwDocStyleSheetPool::Make liefert einen 438cdf0e10cSrcweir // Pointer auf SwDocStyleSheetPool::aStyleSheet zurueck. 439cdf0e10cSrcweir // Der gleiche Member von SwDocStyleSheetPool::Find benutzt. 440cdf0e10cSrcweir // Deshalb muss hier mit einer Kopie gearbeitet werden. 441cdf0e10cSrcweir // Vorsicht: SfxStyleSheetBase::SetFollow ruft seinerseits 442cdf0e10cSrcweir // ein SwDocStyleSheetPool::Find auf, do dass es nicht genuegt 443cdf0e10cSrcweir // die Find-Aufrufe in dieser Methode zu eleminieren. 444cdf0e10cSrcweir 445cdf0e10cSrcweir rtl::Reference< SwDocStyleSheet > xNewSheet( new SwDocStyleSheet( (SwDocStyleSheet&)pMyPool 446cdf0e10cSrcweir ->Make(rOldName, eOldFamily, pHisSheet->GetMask() ) ) ); 447cdf0e10cSrcweir if( SFX_STYLE_FAMILY_PAGE == eOldFamily && rSource.ISA(SwDocShell) ) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir // gesondert behandeln!! 450cdf0e10cSrcweir SwPageDesc* pDestDsc = (SwPageDesc*)xNewSheet->GetPageDesc(); 451cdf0e10cSrcweir SwPageDesc* pCpyDsc = (SwPageDesc*)((SwDocStyleSheet*)pHisSheet)->GetPageDesc(); 452cdf0e10cSrcweir pDoc->CopyPageDesc( *pCpyDsc, *pDestDsc ); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir else 455cdf0e10cSrcweir // die neue Vorlage mit den Attributen fuellen 456cdf0e10cSrcweir xNewSheet->SetItemSet( pHisSheet->GetItemSet() ); 457cdf0e10cSrcweir 458cdf0e10cSrcweir pMyPool->SetSearchMask( SFX_STYLE_FAMILY_ALL, nMySrchMask ); 459cdf0e10cSrcweir 460cdf0e10cSrcweir if( xNewSheet->IsUserDefined() || xNewSheet->IsUsed() ) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir // Benutzte und Benutzer-definierte Vorlagen werden angezeigt. 463cdf0e10cSrcweir // Dshalb muss hier der Index der neuen Vorlage im Pool 464cdf0e10cSrcweir // ermittelt werden. 465cdf0e10cSrcweir pExist = pMyPool->First(); 466cdf0e10cSrcweir sal_uInt16 nIdx = 0; 467cdf0e10cSrcweir while( pExist ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir if( pExist->GetName() == rOldName && 470cdf0e10cSrcweir eOldFamily == pExist->GetFamily() ) 471cdf0e10cSrcweir { 472cdf0e10cSrcweir rIdx2 = nIdx; 473cdf0e10cSrcweir break; 474cdf0e10cSrcweir } 475cdf0e10cSrcweir pExist = pMyPool->Next(); 476cdf0e10cSrcweir nIdx++; 477cdf0e10cSrcweir } 478cdf0e10cSrcweir } 479cdf0e10cSrcweir else 480cdf0e10cSrcweir { 481cdf0e10cSrcweir // Andere Vorlagen werden nicht angezeigt. 482cdf0e10cSrcweir rIdx1 = rIdx2 = INDEX_IGNORE; 483cdf0e10cSrcweir } 484cdf0e10cSrcweir 485cdf0e10cSrcweir /* pMyPool->Count(); //interne Liste neu fuellen lassen!!!!! 486cdf0e10cSrcweir 487cdf0e10cSrcweir // suchen, um die richige Insert-Position returnen zu koennen 488cdf0e10cSrcweir pMyPool->Find( rOldName, SFX_STYLE_FAMILY_ALL, nMySrchMask ); 489cdf0e10cSrcweir rIdx2 = pMyPool->GetFindPos();*/ 490cdf0e10cSrcweir 491cdf0e10cSrcweir // wer bekommt den Neuen als Parent? wer benutzt den Neuen als Follow? 492cdf0e10cSrcweir // (immer nur ueber die Instanziierten!!!) 493cdf0e10cSrcweir pMyPool->SetSearchMask( eOldFamily, nMySrchMask ); 494cdf0e10cSrcweir pMyPool->SetOrganizerMode( sal_True ); 495cdf0e10cSrcweir SfxStyleSheetBase* pTestSheet = pMyPool->First(); 496cdf0e10cSrcweir while (pTestSheet) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir if (pTestSheet->GetFamily() == eOldFamily && 499cdf0e10cSrcweir pTestSheet->HasParentSupport() && 500cdf0e10cSrcweir pTestSheet->GetParent() == rOldName) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir pTestSheet->SetParent(rOldName); // Verknuepfung neu aufbauen 503cdf0e10cSrcweir } 504cdf0e10cSrcweir 505cdf0e10cSrcweir if (pTestSheet->GetFamily() == eOldFamily && 506cdf0e10cSrcweir pTestSheet->HasFollowSupport() && 507cdf0e10cSrcweir pTestSheet->GetFollow() == rOldName) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir pTestSheet->SetFollow(rOldName); // Verknuepfung neu aufbauen 510cdf0e10cSrcweir } 511cdf0e10cSrcweir 512cdf0e10cSrcweir pTestSheet = pMyPool->Next(); 513cdf0e10cSrcweir } 514cdf0e10cSrcweir pMyPool->SetOrganizerMode( SFX_CREATE_MODE_ORGANIZER == GetCreateMode() ); 515cdf0e10cSrcweir 516cdf0e10cSrcweir // hat der Neue einen Parent? wenn ja, mit gleichem Namen bei uns suchen 517cdf0e10cSrcweir if (pHisSheet->HasParentSupport()) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir const String& rParentName = pHisSheet->GetParent(); 520cdf0e10cSrcweir if (0 != rParentName.Len()) 521cdf0e10cSrcweir { 522cdf0e10cSrcweir SfxStyleSheetBase* pParentOfNew = pMyPool->Find(rParentName, 523cdf0e10cSrcweir eOldFamily); 524cdf0e10cSrcweir if (pParentOfNew) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir xNewSheet->SetParent(rParentName); 527cdf0e10cSrcweir } 528cdf0e10cSrcweir pMyPool->SetSearchMask( eOldFamily, nMySrchMask ); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir } 531cdf0e10cSrcweir 532cdf0e10cSrcweir // hat der Neue einen Follow? wenn ja, mit gleichem Namen bei uns suchen 533cdf0e10cSrcweir if (pHisSheet->HasFollowSupport()) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir const String& rFollowName = pHisSheet->GetFollow(); 536cdf0e10cSrcweir if (0 != rFollowName.Len()) 537cdf0e10cSrcweir { 538cdf0e10cSrcweir SfxStyleSheetBase* pFollowOfNew = pMyPool->Find(rFollowName, 539cdf0e10cSrcweir eOldFamily); 540cdf0e10cSrcweir if (pFollowOfNew) 541cdf0e10cSrcweir { 542cdf0e10cSrcweir xNewSheet->SetFollow(rFollowName); 543cdf0e10cSrcweir } 544cdf0e10cSrcweir pMyPool->SetSearchMask( eOldFamily, nMySrchMask ); 545cdf0e10cSrcweir } 546cdf0e10cSrcweir } 547cdf0e10cSrcweir 548cdf0e10cSrcweir // Bug 27347: alte Einstellung wieder setzen 549cdf0e10cSrcweir pMyPool->SetSearchMask( eMyOldFamily, nMySrchMask ); 550cdf0e10cSrcweir 551cdf0e10cSrcweir // Model geaendert 552cdf0e10cSrcweir ASSERT(pDoc, "Doc fehlt"); 553cdf0e10cSrcweir GetDoc()->SetModified(); 554cdf0e10cSrcweir 555cdf0e10cSrcweir bRet = sal_True; 556cdf0e10cSrcweir } 557cdf0e10cSrcweir else 558cdf0e10cSrcweir bRet = SfxObjectShell::Insert( rSource, 559cdf0e10cSrcweir nSourceIdx1, 560cdf0e10cSrcweir nSourceIdx2, 561cdf0e10cSrcweir nSourceIdx3, 562cdf0e10cSrcweir rIdx1, 563cdf0e10cSrcweir rIdx2, 564cdf0e10cSrcweir rIdx3, 565cdf0e10cSrcweir rRemovedIdx); 566cdf0e10cSrcweir 567cdf0e10cSrcweir // --> OD 2005-05-10 #i48949# - actions aren't undoable and could have change 568cdf0e10cSrcweir // the document node array. Thus, clear the undo action stack. 569cdf0e10cSrcweir if (undoGuard.UndoWasEnabled()) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj(); 572cdf0e10cSrcweir } 573cdf0e10cSrcweir // <-- 574cdf0e10cSrcweir 575cdf0e10cSrcweir return bRet; 576cdf0e10cSrcweir } 577cdf0e10cSrcweir 578cdf0e10cSrcweir /*-------------------------------------------------------------------- 579cdf0e10cSrcweir Beschreibung: Vorlagen Remove 580cdf0e10cSrcweir --------------------------------------------------------------------*/ 581cdf0e10cSrcweir 582cdf0e10cSrcweir sal_Bool SwDocShell::Remove(sal_uInt16 nIdx1, // siehe Insert 583cdf0e10cSrcweir sal_uInt16 nIdx2, 584cdf0e10cSrcweir sal_uInt16 nIdx3) 585cdf0e10cSrcweir { 586cdf0e10cSrcweir sal_Bool bRet = sal_False; 587cdf0e10cSrcweir 588cdf0e10cSrcweir if (CONTENT_STYLE == nIdx1) 589cdf0e10cSrcweir { 590cdf0e10cSrcweir SwDocStyleSheetPool* pMyPool = (SwDocStyleSheetPool*)GetStyleSheetPool(); 591cdf0e10cSrcweir 592cdf0e10cSrcweir pMyPool->First(); // vorm Zugriff Pool aktualisieren!! 593cdf0e10cSrcweir SfxStyleSheetBase* pMySheet = (*pMyPool)[nIdx2]; 594cdf0e10cSrcweir 595cdf0e10cSrcweir String aName( pMySheet->GetName() ); 596cdf0e10cSrcweir SfxStyleFamily eFamily( pMySheet->GetFamily() ); 597cdf0e10cSrcweir 598cdf0e10cSrcweir // dflt. PageDesc und StandardZeichenvorlage nie loeschen !!! 599cdf0e10cSrcweir if( ( SFX_STYLE_FAMILY_PAGE == eFamily && 600cdf0e10cSrcweir const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetName() 601cdf0e10cSrcweir == aName ) || 602cdf0e10cSrcweir ( SFX_STYLE_FAMILY_CHAR == eFamily && 603cdf0e10cSrcweir aName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD - 604cdf0e10cSrcweir RES_POOLCOLL_TEXT_BEGIN ] )) 605cdf0e10cSrcweir return sal_False; 606cdf0e10cSrcweir 607cdf0e10cSrcweir // also loeschen 608cdf0e10cSrcweir pMyPool->Remove( pMySheet ); 609cdf0e10cSrcweir 610cdf0e10cSrcweir // jetzt noch die Parents/Follows aller Instanziierten korrigieren 611cdf0e10cSrcweir pMyPool->SetOrganizerMode( sal_True ); 612cdf0e10cSrcweir SfxStyleSheetBase* pTestSheet = pMyPool->First(); 613cdf0e10cSrcweir while (pTestSheet) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir if (pTestSheet->GetFamily() == eFamily && 616cdf0e10cSrcweir pTestSheet->HasParentSupport() && 617cdf0e10cSrcweir pTestSheet->GetParent() == aName) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir pTestSheet->SetParent( aEmptyStr ); // Verknuepfung aufloesen 620cdf0e10cSrcweir } 621cdf0e10cSrcweir 622cdf0e10cSrcweir if (pTestSheet->GetFamily() == eFamily && 623cdf0e10cSrcweir pTestSheet->HasFollowSupport() && 624cdf0e10cSrcweir pTestSheet->GetFollow() == aName) 625cdf0e10cSrcweir { 626cdf0e10cSrcweir pTestSheet->SetFollow( aEmptyStr ); // Verknuepfung aufloesen 627cdf0e10cSrcweir } 628cdf0e10cSrcweir 629cdf0e10cSrcweir pTestSheet = pMyPool->Next(); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir pMyPool->SetOrganizerMode( SFX_CREATE_MODE_ORGANIZER == GetCreateMode() ); 632cdf0e10cSrcweir 633cdf0e10cSrcweir bRet = sal_True; 634cdf0e10cSrcweir } 635cdf0e10cSrcweir else 636cdf0e10cSrcweir bRet = SfxObjectShell::Remove( nIdx1, 637cdf0e10cSrcweir nIdx2, 638cdf0e10cSrcweir nIdx3 ); 639cdf0e10cSrcweir 640cdf0e10cSrcweir 641cdf0e10cSrcweir // Model geaendert 642cdf0e10cSrcweir ASSERT(pDoc, "Doc fehlt"); 643cdf0e10cSrcweir GetDoc()->SetModified(); 644cdf0e10cSrcweir 645cdf0e10cSrcweir return bRet; 646cdf0e10cSrcweir } 647cdf0e10cSrcweir 648cdf0e10cSrcweir /*-------------------------------------------------------------------- 649cdf0e10cSrcweir Beschreibung: 650cdf0e10cSrcweir --------------------------------------------------------------------*/ 651cdf0e10cSrcweir 652cdf0e10cSrcweir void SwDocShell::Execute(SfxRequest& rReq) 653cdf0e10cSrcweir { 654cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 655cdf0e10cSrcweir const SfxPoolItem* pItem; 656cdf0e10cSrcweir sal_uInt16 nWhich = rReq.GetSlot(); 657cdf0e10cSrcweir sal_Bool bDone = sal_False; 658cdf0e10cSrcweir switch ( nWhich ) 659cdf0e10cSrcweir { 660cdf0e10cSrcweir case SID_AUTO_CORRECT_DLG: 661cdf0e10cSrcweir { 662cdf0e10cSrcweir SvxSwAutoFmtFlags* pAFlags = &SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags(); 663cdf0e10cSrcweir SwAutoCompleteWord& rACW = SwDoc::GetAutoCompleteWords(); 664cdf0e10cSrcweir 665cdf0e10cSrcweir sal_Bool bOldLocked = rACW.IsLockWordLstLocked(), 666cdf0e10cSrcweir bOldAutoCmpltCollectWords = pAFlags->bAutoCmpltCollectWords; 667cdf0e10cSrcweir 668cdf0e10cSrcweir rACW.SetLockWordLstLocked( sal_True ); 669cdf0e10cSrcweir 670cdf0e10cSrcweir SvStringsISortDtor aTmpLst; 671cdf0e10cSrcweir aTmpLst.Insert( &rACW.GetWordList() ); 672cdf0e10cSrcweir pAFlags->pAutoCmpltList = &aTmpLst; 673cdf0e10cSrcweir 674cdf0e10cSrcweir SfxApplication* pApp = SFX_APP(); 675cdf0e10cSrcweir SfxRequest aAppReq(SID_AUTO_CORRECT_DLG, SFX_CALLMODE_SYNCHRON, pApp->GetPool()); 676cdf0e10cSrcweir SfxBoolItem aSwOptions( SID_AUTO_CORRECT_DLG, sal_True ); 677cdf0e10cSrcweir aAppReq.AppendItem(aSwOptions); 678cdf0e10cSrcweir 679cdf0e10cSrcweir // SMARTTAGS 680cdf0e10cSrcweir pAFlags->pSmartTagMgr = &SwSmartTagMgr::Get(); 681cdf0e10cSrcweir 682cdf0e10cSrcweir //pApp->ExecuteSlot(aAppReq); 683cdf0e10cSrcweir 684cdf0e10cSrcweir SfxItemSet aSet( pApp->GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG, SID_OPEN_SMARTTAGOPTIONS, SID_OPEN_SMARTTAGOPTIONS, 0 ); 685cdf0e10cSrcweir aSet.Put( aSwOptions ); 686cdf0e10cSrcweir 687cdf0e10cSrcweir const SfxPoolItem* pOpenSmartTagOptionsItem = 0; 688cdf0e10cSrcweir if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_OPEN_SMARTTAGOPTIONS, sal_False, &pOpenSmartTagOptionsItem ) ) 689cdf0e10cSrcweir aSet.Put( *static_cast<const SfxBoolItem*>(pOpenSmartTagOptionsItem) ); 690cdf0e10cSrcweir 691cdf0e10cSrcweir SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 692cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL ); 693cdf0e10cSrcweir pDlg->Execute(); 694cdf0e10cSrcweir delete pDlg; 695cdf0e10cSrcweir 696cdf0e10cSrcweir rACW.SetLockWordLstLocked( bOldLocked ); 697cdf0e10cSrcweir 698cdf0e10cSrcweir SwEditShell::SetAutoFmtFlags( pAFlags ); 699cdf0e10cSrcweir rACW.SetMinWordLen( pAFlags->nAutoCmpltWordLen ); 700cdf0e10cSrcweir rACW.SetMaxCount( pAFlags->nAutoCmpltListLen ); 701cdf0e10cSrcweir if( pAFlags->pAutoCmpltList ) // any changes? 702cdf0e10cSrcweir { 703cdf0e10cSrcweir rACW.CheckChangedList( aTmpLst ); 704cdf0e10cSrcweir // clear the temp WordList pointer 705cdf0e10cSrcweir pAFlags->pAutoCmpltList = 0; 706cdf0e10cSrcweir } 707cdf0e10cSrcweir // remove all pointer we never delete the strings 708cdf0e10cSrcweir aTmpLst.Remove( (sal_uInt16)0, aTmpLst.Count() ); 709cdf0e10cSrcweir 710cdf0e10cSrcweir if( !bOldAutoCmpltCollectWords && bOldAutoCmpltCollectWords != 711cdf0e10cSrcweir pAFlags->bAutoCmpltCollectWords ) 712cdf0e10cSrcweir { 713cdf0e10cSrcweir // call on all Docs the idle formatter to start 714cdf0e10cSrcweir // the collection of Words 715cdf0e10cSrcweir TypeId aType = TYPE(SwDocShell); 716cdf0e10cSrcweir for( SwDocShell *pDocSh = (SwDocShell*)SfxObjectShell::GetFirst(&aType); 717cdf0e10cSrcweir pDocSh; 718cdf0e10cSrcweir pDocSh = (SwDocShell*)SfxObjectShell::GetNext( *pDocSh, &aType ) ) 719cdf0e10cSrcweir { 720cdf0e10cSrcweir SwDoc* pTmp = pDocSh->GetDoc(); 721cdf0e10cSrcweir if ( pTmp->GetCurrentViewShell() ) //swmod 071108//swmod 071225 722cdf0e10cSrcweir pTmp->InvalidateAutoCompleteFlag(); 723cdf0e10cSrcweir } 724cdf0e10cSrcweir } 725cdf0e10cSrcweir } 726cdf0e10cSrcweir break; 727cdf0e10cSrcweir 728cdf0e10cSrcweir case SID_PRINTPREVIEW: 729cdf0e10cSrcweir { 730cdf0e10cSrcweir sal_Bool bSet = sal_False, bFound = sal_False, bOnly = sal_True; 731cdf0e10cSrcweir SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this); 732cdf0e10cSrcweir SfxViewShell* pViewShell = SfxViewShell::Current(); 733cdf0e10cSrcweir SwView* pCurrView = dynamic_cast< SwView *> ( pViewShell ); 734cdf0e10cSrcweir sal_Bool bCurrent = IS_TYPE( SwPagePreView, pViewShell ); 735cdf0e10cSrcweir 736cdf0e10cSrcweir while( pTmpFrm ) // search PreView 737cdf0e10cSrcweir { 738cdf0e10cSrcweir if( IS_TYPE( SwView, pTmpFrm->GetViewShell()) ) 739cdf0e10cSrcweir bOnly = sal_False; 740cdf0e10cSrcweir else if( IS_TYPE( SwPagePreView, pTmpFrm->GetViewShell())) 741cdf0e10cSrcweir { 742cdf0e10cSrcweir pTmpFrm->GetFrame().Appear(); 743cdf0e10cSrcweir bFound = sal_True; 744cdf0e10cSrcweir } 745cdf0e10cSrcweir if( bFound && !bOnly ) 746cdf0e10cSrcweir break; 747cdf0e10cSrcweir pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, this); 748cdf0e10cSrcweir } 749cdf0e10cSrcweir 750cdf0e10cSrcweir if( pArgs && SFX_ITEM_SET == 751cdf0e10cSrcweir pArgs->GetItemState( SID_PRINTPREVIEW, sal_False, &pItem )) 752cdf0e10cSrcweir bSet = ((SfxBoolItem*)pItem)->GetValue(); 753cdf0e10cSrcweir else 754cdf0e10cSrcweir bSet = !bCurrent; 755cdf0e10cSrcweir 756cdf0e10cSrcweir sal_uInt16 nSlotId = 0; 757cdf0e10cSrcweir if( bSet && !bFound ) // Keine gefunden, daher neue Preview anlegen 758cdf0e10cSrcweir nSlotId = SID_VIEWSHELL1; 759cdf0e10cSrcweir else if( bFound && !bSet ) 760cdf0e10cSrcweir nSlotId = bOnly ? SID_VIEWSHELL0 : SID_VIEWSHELL1; 761cdf0e10cSrcweir 762cdf0e10cSrcweir if( nSlotId ) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir //JP 23.8.2001: Bug 91360 - PagePreView in the WebDocShell 765cdf0e10cSrcweir // is found under Id ViewShell2. 766cdf0e10cSrcweir if( ISA(SwWebDocShell) && SID_VIEWSHELL1 == nSlotId ) 767cdf0e10cSrcweir nSlotId = SID_VIEWSHELL2; 768cdf0e10cSrcweir 769cdf0e10cSrcweir if( pCurrView && pCurrView->GetDocShell() == this ) 770cdf0e10cSrcweir pTmpFrm = pCurrView->GetViewFrame(); 771cdf0e10cSrcweir else 772cdf0e10cSrcweir pTmpFrm = SfxViewFrame::GetFirst( this ); 773cdf0e10cSrcweir 774cdf0e10cSrcweir pTmpFrm->GetDispatcher()->Execute( nSlotId, 0, 0, SFX_CALLMODE_ASYNCHRON ); 775cdf0e10cSrcweir } 776cdf0e10cSrcweir 777cdf0e10cSrcweir rReq.SetReturnValue(SfxBoolItem(SID_PRINTPREVIEW, bSet )); 778cdf0e10cSrcweir } 779cdf0e10cSrcweir break; 780cdf0e10cSrcweir case SID_TEMPLATE_LOAD: 781cdf0e10cSrcweir { 782cdf0e10cSrcweir String aFileName; 783cdf0e10cSrcweir static sal_Bool bText = sal_True; 784cdf0e10cSrcweir static sal_Bool bFrame = sal_False; 785cdf0e10cSrcweir static sal_Bool bPage = sal_False; 786cdf0e10cSrcweir static sal_Bool bNum = sal_False; 787cdf0e10cSrcweir static sal_Bool bMerge = sal_False; 788cdf0e10cSrcweir sal_uInt16 nRet = USHRT_MAX; 789cdf0e10cSrcweir 790cdf0e10cSrcweir sal_uInt16 nFlags = bFrame ? SFX_LOAD_FRAME_STYLES : 0; 791cdf0e10cSrcweir if(bPage) 792cdf0e10cSrcweir nFlags|= SFX_LOAD_PAGE_STYLES; 793cdf0e10cSrcweir if(bNum) 794cdf0e10cSrcweir nFlags|= SFX_LOAD_NUM_STYLES; 795cdf0e10cSrcweir if(!nFlags || bText) 796cdf0e10cSrcweir nFlags|= SFX_LOAD_TEXT_STYLES; 797cdf0e10cSrcweir if(bMerge) 798cdf0e10cSrcweir nFlags|= SFX_MERGE_STYLES; 799cdf0e10cSrcweir 800cdf0e10cSrcweir if ( pArgs ) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pTemplateItem, SfxStringItem, SID_TEMPLATE_NAME, sal_False ); 803cdf0e10cSrcweir if ( pTemplateItem ) 804cdf0e10cSrcweir { 805cdf0e10cSrcweir aFileName = pTemplateItem->GetValue(); 806cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pFlagsItem, SfxInt32Item, SID_TEMPLATE_LOAD, sal_False ); 807cdf0e10cSrcweir if ( pFlagsItem ) 808cdf0e10cSrcweir nFlags = (sal_uInt16) pFlagsItem->GetValue(); 809cdf0e10cSrcweir } 810cdf0e10cSrcweir } 811cdf0e10cSrcweir 812cdf0e10cSrcweir if ( !aFileName.Len() ) 813cdf0e10cSrcweir { 814cdf0e10cSrcweir SvtPathOptions aPathOpt; 815cdf0e10cSrcweir SfxNewFileDialog* pNewFileDlg = 816cdf0e10cSrcweir new SfxNewFileDialog(&GetView()->GetViewFrame()->GetWindow(), SFXWB_LOAD_TEMPLATE); 817cdf0e10cSrcweir pNewFileDlg->SetTemplateFlags(nFlags); 818cdf0e10cSrcweir 819cdf0e10cSrcweir nRet = pNewFileDlg->Execute(); 820cdf0e10cSrcweir if(RET_TEMPLATE_LOAD == nRet) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 ); 823cdf0e10cSrcweir uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker(); 824cdf0e10cSrcweir 825cdf0e10cSrcweir xFP->setDisplayDirectory( aPathOpt.GetWorkPath() ); 826cdf0e10cSrcweir 827cdf0e10cSrcweir SfxObjectFactory &rFact = GetFactory(); 828cdf0e10cSrcweir SfxFilterMatcher aMatcher( String::CreateFromAscii(rFact.GetShortName()) ); 829cdf0e10cSrcweir SfxFilterMatcherIter aIter( &aMatcher ); 830cdf0e10cSrcweir uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); 831cdf0e10cSrcweir const SfxFilter* pFlt = aIter.First(); 832cdf0e10cSrcweir while( pFlt ) 833cdf0e10cSrcweir { 834cdf0e10cSrcweir // --> OD #i117339# 835cdf0e10cSrcweir // if( pFlt && pFlt->IsAllowedAsTemplate() ) 836cdf0e10cSrcweir if( pFlt && pFlt->IsAllowedAsTemplate() && 837cdf0e10cSrcweir ( pFlt->GetUserData().EqualsAscii("CXML") || 838cdf0e10cSrcweir pFlt->GetUserData().EqualsAscii("CXMLV") ) ) 839cdf0e10cSrcweir { 840cdf0e10cSrcweir const String sWild = ((WildCard&)pFlt->GetWildcard()).GetWildCard(); 841cdf0e10cSrcweir xFltMgr->appendFilter( pFlt->GetUIName(), sWild ); 842cdf0e10cSrcweir } 843cdf0e10cSrcweir pFlt = aIter.Next(); 844cdf0e10cSrcweir } 845cdf0e10cSrcweir sal_Bool bWeb = 0 != dynamic_cast< SwWebDocShell *>( this ); 846cdf0e10cSrcweir const SfxFilter *pOwnFlt = 847cdf0e10cSrcweir SwDocShell::Factory().GetFilterContainer()-> 848cdf0e10cSrcweir GetFilter4FilterName(String::CreateFromAscii("writer8")); 849cdf0e10cSrcweir 850cdf0e10cSrcweir //#b6439685# make sure the default file format is also available 851cdf0e10cSrcweir if(bWeb) 852cdf0e10cSrcweir { 853cdf0e10cSrcweir const String sWild = ((WildCard&)pOwnFlt->GetWildcard()).GetWildCard(); 854cdf0e10cSrcweir xFltMgr->appendFilter( pOwnFlt->GetUIName(), sWild ); 855cdf0e10cSrcweir } 856cdf0e10cSrcweir 857cdf0e10cSrcweir bool bError = false; 858cdf0e10cSrcweir //#b6439685# catch expception if wrong filter is selected - should not happen anymore 859cdf0e10cSrcweir try 860cdf0e10cSrcweir { 861cdf0e10cSrcweir xFltMgr->setCurrentFilter( pOwnFlt->GetUIName() ); 862cdf0e10cSrcweir } 863cdf0e10cSrcweir catch( const uno::Exception& ) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir bError = true; 866cdf0e10cSrcweir } 867cdf0e10cSrcweir 868cdf0e10cSrcweir if( !bError && ERRCODE_NONE == aDlgHelper.Execute() ) 869cdf0e10cSrcweir { 870cdf0e10cSrcweir aFileName = xFP->getFiles().getConstArray()[0]; 871cdf0e10cSrcweir } 872cdf0e10cSrcweir } 873cdf0e10cSrcweir else if( RET_OK == nRet) 874cdf0e10cSrcweir { 875cdf0e10cSrcweir aFileName = pNewFileDlg->GetTemplateFileName(); 876cdf0e10cSrcweir } 877cdf0e10cSrcweir 878cdf0e10cSrcweir nFlags = pNewFileDlg->GetTemplateFlags(); 879cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) ); 880cdf0e10cSrcweir rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, (long) nFlags ) ); 881cdf0e10cSrcweir delete pNewFileDlg; 882cdf0e10cSrcweir } 883cdf0e10cSrcweir 884cdf0e10cSrcweir if( aFileName.Len() ) 885cdf0e10cSrcweir { 886cdf0e10cSrcweir SwgReaderOption aOpt; 887cdf0e10cSrcweir aOpt.SetTxtFmts( bText = (0 != (nFlags&SFX_LOAD_TEXT_STYLES) )); 888cdf0e10cSrcweir aOpt.SetFrmFmts( bFrame = (0 != (nFlags&SFX_LOAD_FRAME_STYLES))); 889cdf0e10cSrcweir aOpt.SetPageDescs( bPage = (0 != (nFlags&SFX_LOAD_PAGE_STYLES ))); 890cdf0e10cSrcweir aOpt.SetNumRules( bNum = (0 != (nFlags&SFX_LOAD_NUM_STYLES ))); 891cdf0e10cSrcweir //different meaning between SFX_MERGE_STYLES and aOpt.SetMerge! 892cdf0e10cSrcweir bMerge = 0 != (nFlags&SFX_MERGE_STYLES); 893cdf0e10cSrcweir aOpt.SetMerge( !bMerge ); 894cdf0e10cSrcweir 895cdf0e10cSrcweir SetError( LoadStylesFromFile( aFileName, aOpt, sal_False ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) )); 896cdf0e10cSrcweir if ( !GetError() ) 897cdf0e10cSrcweir rReq.Done(); 898cdf0e10cSrcweir } 899cdf0e10cSrcweir } 900cdf0e10cSrcweir break; 901cdf0e10cSrcweir case SID_SOURCEVIEW: 902cdf0e10cSrcweir { 903cdf0e10cSrcweir SfxViewShell* pViewShell = GetView() 904cdf0e10cSrcweir ? (SfxViewShell*)GetView() 905cdf0e10cSrcweir : SfxViewShell::Current(); 906cdf0e10cSrcweir SfxViewFrame* pViewFrm = pViewShell->GetViewFrame(); 907cdf0e10cSrcweir SwSrcView* pSrcView = dynamic_cast< SwSrcView *>( pViewShell ); 908cdf0e10cSrcweir if(!pSrcView) 909cdf0e10cSrcweir { 910cdf0e10cSrcweir // 3 possible state: 911cdf0e10cSrcweir // 1 - file unsaved -> save as HTML 912cdf0e10cSrcweir // 2 - file modified and HTML filter active -> save 913cdf0e10cSrcweir // 3 - file saved in non-HTML -> QueryBox to save as HTML 914cdf0e10cSrcweir const SfxFilter* pHtmlFlt = 915cdf0e10cSrcweir SwIoSystem::GetFilterOfFormat( 916cdf0e10cSrcweir String::CreateFromAscii("HTML"), 917cdf0e10cSrcweir SwWebDocShell::Factory().GetFilterContainer() ); 918cdf0e10cSrcweir sal_Bool bLocalHasName = HasName(); 919cdf0e10cSrcweir if(bLocalHasName) 920cdf0e10cSrcweir { 921cdf0e10cSrcweir //check for filter type 922cdf0e10cSrcweir const SfxFilter* pFlt = GetMedium()->GetFilter(); 923cdf0e10cSrcweir if(!pFlt || pFlt->GetUserData() != pHtmlFlt->GetUserData()) 924cdf0e10cSrcweir { 925cdf0e10cSrcweir QueryBox aQuery(&pViewFrm->GetWindow(), SW_RES(MSG_SAVEAS_HTML_QUERY)); 926cdf0e10cSrcweir if(RET_YES == aQuery.Execute()) 927cdf0e10cSrcweir bLocalHasName = sal_False; 928cdf0e10cSrcweir else 929cdf0e10cSrcweir break; 930cdf0e10cSrcweir } 931cdf0e10cSrcweir } 932cdf0e10cSrcweir if(!bLocalHasName) 933cdf0e10cSrcweir { 934cdf0e10cSrcweir FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION, 0 ); 935cdf0e10cSrcweir aDlgHelper.AddFilter( pHtmlFlt->GetFilterName(), pHtmlFlt->GetDefaultExtension() ); 936cdf0e10cSrcweir aDlgHelper.SetCurrentFilter( pHtmlFlt->GetFilterName() ); 937cdf0e10cSrcweir if( ERRCODE_NONE != aDlgHelper.Execute()) 938cdf0e10cSrcweir { 939cdf0e10cSrcweir break; 940cdf0e10cSrcweir } 941cdf0e10cSrcweir String sPath = aDlgHelper.GetPath(); 942cdf0e10cSrcweir SfxStringItem aName(SID_FILE_NAME, sPath); 943cdf0e10cSrcweir SfxStringItem aFilter(SID_FILTER_NAME, pHtmlFlt->GetName()); 944cdf0e10cSrcweir const SfxBoolItem* pBool = (const SfxBoolItem*) 945cdf0e10cSrcweir pViewFrm->GetDispatcher()->Execute( 946cdf0e10cSrcweir SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON, &aName, &aFilter, 0L ); 947cdf0e10cSrcweir if(!pBool || !pBool->GetValue()) 948cdf0e10cSrcweir break; 949cdf0e10cSrcweir } 950cdf0e10cSrcweir } 951cdf0e10cSrcweir #ifdef DBG_UTIL 952cdf0e10cSrcweir { 953cdf0e10cSrcweir sal_Bool bWeb = 0 != dynamic_cast<SwWebDocShell*>(this); 954cdf0e10cSrcweir DBG_ASSERT(bWeb == sal_True, "SourceView nur in der WebDocShell"); 955cdf0e10cSrcweir } 956cdf0e10cSrcweir #endif 957cdf0e10cSrcweir // die SourceView ist fuer die SwWebDocShell die 1 958cdf0e10cSrcweir sal_uInt16 nSlot = SID_VIEWSHELL1; 959cdf0e10cSrcweir sal_Bool bSetModified = sal_False; 960cdf0e10cSrcweir SfxPrinter* pSavePrinter = 0; 961cdf0e10cSrcweir if( 0 != pSrcView) 962cdf0e10cSrcweir { 963cdf0e10cSrcweir SfxPrinter* pTemp = GetDoc()->getPrinter( false ); 964cdf0e10cSrcweir if(pTemp) 965cdf0e10cSrcweir pSavePrinter = new SfxPrinter(*pTemp); 966cdf0e10cSrcweir bSetModified = IsModified() || pSrcView->IsModified(); 967cdf0e10cSrcweir if(pSrcView->IsModified()||pSrcView->HasSourceSaved()) 968cdf0e10cSrcweir { 969cdf0e10cSrcweir utl::TempFile aTempFile; 970cdf0e10cSrcweir aTempFile.EnableKillingFile(); 971cdf0e10cSrcweir pSrcView->SaveContent(aTempFile.GetURL()); 972cdf0e10cSrcweir bDone = sal_True; 973cdf0e10cSrcweir SvxMacro aMac(aEmptyStr, aEmptyStr, STARBASIC); 974cdf0e10cSrcweir SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ), aMac, this); 975cdf0e10cSrcweir SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ), aMac, this); 976cdf0e10cSrcweir SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), aMac, this); 977cdf0e10cSrcweir SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ), aMac, this); 978cdf0e10cSrcweir ReloadFromHtml(aTempFile.GetURL(), pSrcView); 979cdf0e10cSrcweir nSlot = 0; 980cdf0e10cSrcweir } 981cdf0e10cSrcweir else 982cdf0e10cSrcweir { 983cdf0e10cSrcweir nSlot = SID_VIEWSHELL0; 984cdf0e10cSrcweir } 985cdf0e10cSrcweir } 986cdf0e10cSrcweir /* OS 10.04.97 14.20: Im Web-Writer gibt es keinen Unterschied zwischen 987cdf0e10cSrcweir Export in den SourceMode und dem Speichern des Docs 988cdf0e10cSrcweir else if(IsModified()) 989cdf0e10cSrcweir { 990cdf0e10cSrcweir sal_uInt16 nRet = QueryBox( SFX_APPWINDOW ,SW_RES(MSG_SAVE_HTML_QUERY)).Execute(); 991cdf0e10cSrcweir if(RET_YES == nRet) 992cdf0e10cSrcweir { 993cdf0e10cSrcweir S F X _DISPATCHER().Execute(SID_SAVEDOC, 994cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON); 995cdf0e10cSrcweir // der ReturnValue von SID_SAVEDOC ist etwas schwer verstaendlich 996cdf0e10cSrcweir if(IsModified()) 997cdf0e10cSrcweir nSlot = 0; 998cdf0e10cSrcweir } 999cdf0e10cSrcweir else if( RET_CANCEL == nRet ) 1000cdf0e10cSrcweir { 1001cdf0e10cSrcweir nSlot = 0; 1002cdf0e10cSrcweir } 1003cdf0e10cSrcweir }*/ 1004cdf0e10cSrcweir if(nSlot) 1005cdf0e10cSrcweir pViewFrm->GetDispatcher()->Execute(nSlot, SFX_CALLMODE_SYNCHRON); 1006cdf0e10cSrcweir if(bSetModified) 1007cdf0e10cSrcweir GetDoc()->SetModified(); 1008cdf0e10cSrcweir if(pSavePrinter) 1009cdf0e10cSrcweir { 1010cdf0e10cSrcweir GetDoc()->setPrinter( pSavePrinter, true, true); 1011cdf0e10cSrcweir //pSavePrinter darf nicht wieder geloescht werden 1012cdf0e10cSrcweir } 1013cdf0e10cSrcweir pViewFrm->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, nSlot == SID_VIEWSHELL2)); 1014cdf0e10cSrcweir pViewFrm->GetBindings().Invalidate( SID_NEWWINDOW ); 1015cdf0e10cSrcweir pViewFrm->GetBindings().Invalidate( SID_BROWSER_MODE ); 1016cdf0e10cSrcweir pViewFrm->GetBindings().Invalidate( FN_PRINT_LAYOUT ); 1017cdf0e10cSrcweir } 1018cdf0e10cSrcweir break; 1019cdf0e10cSrcweir case SID_GET_COLORTABLE: 1020cdf0e10cSrcweir { 1021cdf0e10cSrcweir SvxColorTableItem* pColItem = (SvxColorTableItem*)GetItem(SID_COLOR_TABLE); 1022cdf0e10cSrcweir XColorTable* pTable = pColItem->GetColorTable(); 1023cdf0e10cSrcweir rReq.SetReturnValue(OfaPtrItem(SID_GET_COLORTABLE, pTable)); 1024cdf0e10cSrcweir } 1025cdf0e10cSrcweir break; 1026cdf0e10cSrcweir case FN_ABSTRACT_STARIMPRESS: 1027cdf0e10cSrcweir case FN_ABSTRACT_NEWDOC: 1028cdf0e10cSrcweir { 1029cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 1030cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 1031cdf0e10cSrcweir 1032cdf0e10cSrcweir AbstractSwInsertAbstractDlg* pDlg = pFact->CreateSwInsertAbstractDlg(0, DLG_INSERT_ABSTRACT ); 1033cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 1034cdf0e10cSrcweir if(RET_OK == pDlg->Execute()) 1035cdf0e10cSrcweir { 1036cdf0e10cSrcweir sal_uInt8 nLevel = pDlg->GetLevel(); 1037cdf0e10cSrcweir sal_uInt8 nPara = pDlg->GetPara(); 1038cdf0e10cSrcweir SwDoc* pSmryDoc = new SwDoc(); 1039cdf0e10cSrcweir SfxObjectShellLock xDocSh( new SwDocShell( pSmryDoc, SFX_CREATE_MODE_STANDARD)); 1040cdf0e10cSrcweir xDocSh->DoInitNew( 0 ); 1041cdf0e10cSrcweir 1042cdf0e10cSrcweir sal_Bool bImpress = FN_ABSTRACT_STARIMPRESS == nWhich; 1043cdf0e10cSrcweir pDoc->Summary( pSmryDoc, nLevel, nPara, bImpress ); 1044cdf0e10cSrcweir if( bImpress ) 1045cdf0e10cSrcweir { 1046cdf0e10cSrcweir WriterRef xWrt; 1047cdf0e10cSrcweir // mba: looks as if relative URLs don't make sense here 1048cdf0e10cSrcweir ::GetRTFWriter( aEmptyStr, String(), xWrt ); 1049cdf0e10cSrcweir SvMemoryStream *pStrm = new SvMemoryStream(); 1050cdf0e10cSrcweir pStrm->SetBufferSize( 16348 ); 1051cdf0e10cSrcweir SwWriter aWrt( *pStrm, *pSmryDoc ); 1052cdf0e10cSrcweir ErrCode eErr = aWrt.Write( xWrt ); 1053cdf0e10cSrcweir if( !ERRCODE_TOERROR( eErr ) ) 1054cdf0e10cSrcweir { 1055cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); 1056cdf0e10cSrcweir uno::Reference< frame::XDispatchProvider > xProv( 1057cdf0e10cSrcweir xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY ); 1058cdf0e10cSrcweir if ( xProv.is() ) 1059cdf0e10cSrcweir { 1060cdf0e10cSrcweir ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( "SendOutlineToImpress" ); 1061cdf0e10cSrcweir uno::Reference< frame::XDispatchHelper > xHelper( 1062cdf0e10cSrcweir xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY ); 1063cdf0e10cSrcweir if ( xHelper.is() ) 1064cdf0e10cSrcweir { 1065cdf0e10cSrcweir pStrm->Seek( STREAM_SEEK_TO_END ); 1066cdf0e10cSrcweir *pStrm << '\0'; 1067cdf0e10cSrcweir pStrm->Seek( STREAM_SEEK_TO_BEGIN ); 1068cdf0e10cSrcweir 1069cdf0e10cSrcweir // Transfer ownership of stream to a lockbytes object 1070cdf0e10cSrcweir SvLockBytes aLockBytes( pStrm, sal_True ); 1071cdf0e10cSrcweir SvLockBytesStat aStat; 1072cdf0e10cSrcweir if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE ) 1073cdf0e10cSrcweir { 1074cdf0e10cSrcweir sal_uInt32 nLen = aStat.nSize; 1075cdf0e10cSrcweir sal_uLong nRead = 0; 1076cdf0e10cSrcweir uno::Sequence< sal_Int8 > aSeq( nLen ); 1077cdf0e10cSrcweir aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead ); 1078cdf0e10cSrcweir 1079cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aArgs(1); 1080cdf0e10cSrcweir aArgs[0].Name = ::rtl::OUString::createFromAscii("RtfOutline"); 1081cdf0e10cSrcweir aArgs[0].Value <<= aSeq; 1082cdf0e10cSrcweir xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs ); 1083cdf0e10cSrcweir } 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir } 1086cdf0e10cSrcweir } 1087cdf0e10cSrcweir else 1088cdf0e10cSrcweir ErrorHandler::HandleError(ErrCode( eErr )); 1089cdf0e10cSrcweir } 1090cdf0e10cSrcweir else 1091cdf0e10cSrcweir { 1092cdf0e10cSrcweir // Neues Dokument erzeugen. 1093cdf0e10cSrcweir SfxViewFrame *pFrame = SfxViewFrame::LoadDocument( *xDocSh, 0 ); 1094cdf0e10cSrcweir SwView *pCurrView = (SwView*) pFrame->GetViewShell(); 1095cdf0e10cSrcweir 1096cdf0e10cSrcweir // Dokumenttitel setzen 1097cdf0e10cSrcweir String aTmp( SW_RES(STR_ABSTRACT_TITLE) ); 1098cdf0e10cSrcweir aTmp += GetTitle(); 1099cdf0e10cSrcweir xDocSh->SetTitle( aTmp ); 1100cdf0e10cSrcweir pCurrView->GetWrtShell().SetNewDoc(); 1101cdf0e10cSrcweir pFrame->Show(); 1102cdf0e10cSrcweir pSmryDoc->SetModified(); 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir 1105cdf0e10cSrcweir } 1106cdf0e10cSrcweir delete pDlg; 1107cdf0e10cSrcweir } 1108cdf0e10cSrcweir break; 1109cdf0e10cSrcweir case FN_OUTLINE_TO_CLIPBOARD: 1110cdf0e10cSrcweir case FN_OUTLINE_TO_IMPRESS: 1111cdf0e10cSrcweir { 1112cdf0e10cSrcweir sal_Bool bEnable = IsEnableSetModified(); 1113cdf0e10cSrcweir EnableSetModified( sal_False ); 1114cdf0e10cSrcweir WriterRef xWrt; 1115cdf0e10cSrcweir // mba: looks as if relative URLs don't make sense here 1116cdf0e10cSrcweir ::GetRTFWriter( 'O', String(), xWrt ); 1117cdf0e10cSrcweir SvMemoryStream *pStrm = new SvMemoryStream(); 1118cdf0e10cSrcweir pStrm->SetBufferSize( 16348 ); 1119cdf0e10cSrcweir SwWriter aWrt( *pStrm, *GetDoc() ); 1120cdf0e10cSrcweir ErrCode eErr = aWrt.Write( xWrt ); 1121cdf0e10cSrcweir EnableSetModified( bEnable ); 1122cdf0e10cSrcweir if( !ERRCODE_TOERROR( eErr ) ) 1123cdf0e10cSrcweir { 1124cdf0e10cSrcweir pStrm->Seek( STREAM_SEEK_TO_END ); 1125cdf0e10cSrcweir *pStrm << '\0'; 1126cdf0e10cSrcweir pStrm->Seek( STREAM_SEEK_TO_BEGIN ); 1127cdf0e10cSrcweir if ( nWhich == FN_OUTLINE_TO_IMPRESS ) 1128cdf0e10cSrcweir { 1129cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory(); 1130cdf0e10cSrcweir uno::Reference< frame::XDispatchProvider > xProv( 1131cdf0e10cSrcweir xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ModuleDispatcher")), UNO_QUERY ); 1132cdf0e10cSrcweir if ( xProv.is() ) 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir ::rtl::OUString aCmd = ::rtl::OUString::createFromAscii( "SendOutlineToImpress" ); 1135cdf0e10cSrcweir uno::Reference< frame::XDispatchHelper > xHelper( 1136cdf0e10cSrcweir xORB->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")), UNO_QUERY ); 1137cdf0e10cSrcweir if ( xHelper.is() ) 1138cdf0e10cSrcweir { 1139cdf0e10cSrcweir pStrm->Seek( STREAM_SEEK_TO_END ); 1140cdf0e10cSrcweir *pStrm << '\0'; 1141cdf0e10cSrcweir pStrm->Seek( STREAM_SEEK_TO_BEGIN ); 1142cdf0e10cSrcweir 1143cdf0e10cSrcweir // Transfer ownership of stream to a lockbytes object 1144cdf0e10cSrcweir SvLockBytes aLockBytes( pStrm, sal_True ); 1145cdf0e10cSrcweir SvLockBytesStat aStat; 1146cdf0e10cSrcweir if ( aLockBytes.Stat( &aStat, SVSTATFLAG_DEFAULT ) == ERRCODE_NONE ) 1147cdf0e10cSrcweir { 1148cdf0e10cSrcweir sal_uInt32 nLen = aStat.nSize; 1149cdf0e10cSrcweir sal_uLong nRead = 0; 1150cdf0e10cSrcweir uno::Sequence< sal_Int8 > aSeq( nLen ); 1151cdf0e10cSrcweir aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead ); 1152cdf0e10cSrcweir 1153cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aArgs(1); 1154cdf0e10cSrcweir aArgs[0].Name = ::rtl::OUString::createFromAscii("RtfOutline"); 1155cdf0e10cSrcweir aArgs[0].Value <<= aSeq; 1156cdf0e10cSrcweir xHelper->executeDispatch( xProv, aCmd, ::rtl::OUString(), 0, aArgs ); 1157cdf0e10cSrcweir } 1158cdf0e10cSrcweir } 1159cdf0e10cSrcweir } 1160cdf0e10cSrcweir } 1161cdf0e10cSrcweir else 1162cdf0e10cSrcweir { 1163cdf0e10cSrcweir TransferDataContainer* pClipCntnr = 1164cdf0e10cSrcweir new TransferDataContainer; 1165cdf0e10cSrcweir STAR_REFERENCE( datatransfer::XTransferable ) 1166cdf0e10cSrcweir xRef( pClipCntnr ); 1167cdf0e10cSrcweir 1168cdf0e10cSrcweir pClipCntnr->CopyAnyData( FORMAT_RTF, (sal_Char*) 1169cdf0e10cSrcweir pStrm->GetData(), pStrm->GetEndOfData() ); 1170cdf0e10cSrcweir pClipCntnr->CopyToClipboard( 1171cdf0e10cSrcweir GetView()? (Window*)&GetView()->GetEditWin() : 0 ); 1172cdf0e10cSrcweir delete pStrm; 1173cdf0e10cSrcweir } 1174cdf0e10cSrcweir } 1175cdf0e10cSrcweir else 1176cdf0e10cSrcweir ErrorHandler::HandleError(ErrCode( eErr )); 1177cdf0e10cSrcweir } 1178cdf0e10cSrcweir break; 1179cdf0e10cSrcweir case SID_SPELLCHECKER_CHANGED: 1180cdf0e10cSrcweir //! sal_False, sal_True, sal_True is on the save side but a probably overdone 1181cdf0e10cSrcweir SW_MOD()->CheckSpellChanges(sal_False, sal_True, sal_True, sal_False ); 1182cdf0e10cSrcweir break; 1183cdf0e10cSrcweir 1184cdf0e10cSrcweir case SID_MAIL_PREPAREEXPORT: 1185cdf0e10cSrcweir { 1186cdf0e10cSrcweir //pWrtShell is not set in page preview 1187cdf0e10cSrcweir if(pWrtShell) 1188cdf0e10cSrcweir pWrtShell->StartAllAction(); 1189cdf0e10cSrcweir pDoc->UpdateFlds( NULL, false ); 1190cdf0e10cSrcweir pDoc->EmbedAllLinks(); 1191cdf0e10cSrcweir pDoc->RemoveInvisibleContent(); 1192cdf0e10cSrcweir if(pWrtShell) 1193cdf0e10cSrcweir pWrtShell->EndAllAction(); 1194cdf0e10cSrcweir } 1195cdf0e10cSrcweir break; 1196cdf0e10cSrcweir 1197cdf0e10cSrcweir case SID_MAIL_EXPORT_FINISHED: 1198cdf0e10cSrcweir { 1199cdf0e10cSrcweir if(pWrtShell) 1200cdf0e10cSrcweir pWrtShell->StartAllAction(); 1201cdf0e10cSrcweir //try to undo the removal of invisible content 1202cdf0e10cSrcweir pDoc->RestoreInvisibleContent(); 1203cdf0e10cSrcweir if(pWrtShell) 1204cdf0e10cSrcweir pWrtShell->EndAllAction(); 1205cdf0e10cSrcweir } 1206cdf0e10cSrcweir break; 1207cdf0e10cSrcweir case FN_NEW_HTML_DOC: 1208cdf0e10cSrcweir case FN_NEW_GLOBAL_DOC: 1209cdf0e10cSrcweir { 1210cdf0e10cSrcweir bDone = sal_False; 1211cdf0e10cSrcweir sal_Bool bCreateHtml = FN_NEW_HTML_DOC == nWhich; 1212cdf0e10cSrcweir 1213cdf0e10cSrcweir sal_Bool bCreateByOutlineLevel = false; //#outline level,add by zhaojianwei 1214cdf0e10cSrcweir sal_Int32 nTemplateOutlineLevel = 0 ; //#outline level,add by zhaojianwei 1215cdf0e10cSrcweir 1216cdf0e10cSrcweir String aFileName, aTemplateName; 1217cdf0e10cSrcweir if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich, sal_False, &pItem ) ) 1218cdf0e10cSrcweir { 1219cdf0e10cSrcweir aFileName = ((const SfxStringItem*)pItem)->GetValue(); 1220cdf0e10cSrcweir SFX_ITEMSET_ARG( pArgs, pTemplItem, SfxStringItem, SID_TEMPLATE_NAME, sal_False ); 1221cdf0e10cSrcweir if ( pTemplItem ) 1222cdf0e10cSrcweir aTemplateName = pTemplItem->GetValue(); 1223cdf0e10cSrcweir } 1224cdf0e10cSrcweir bool bError = false; 1225cdf0e10cSrcweir if ( !aFileName.Len() ) 1226cdf0e10cSrcweir { 1227cdf0e10cSrcweir FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE, 0 ); 1228cdf0e10cSrcweir 1229cdf0e10cSrcweir const sal_Int16 nControlIds[] = { 1230cdf0e10cSrcweir CommonFilePickerElementIds::PUSHBUTTON_OK, 1231cdf0e10cSrcweir CommonFilePickerElementIds::PUSHBUTTON_CANCEL, 1232cdf0e10cSrcweir CommonFilePickerElementIds::LISTBOX_FILTER, 1233cdf0e10cSrcweir CommonFilePickerElementIds::CONTROL_FILEVIEW, 1234cdf0e10cSrcweir CommonFilePickerElementIds::EDIT_FILEURL, 1235cdf0e10cSrcweir ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 1236cdf0e10cSrcweir ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, 1237cdf0e10cSrcweir 0 1238cdf0e10cSrcweir }; 1239cdf0e10cSrcweir 1240cdf0e10cSrcweir const char* aHTMLHelpIds[] = 1241cdf0e10cSrcweir { 1242cdf0e10cSrcweir HID_SEND_HTML_CTRL_PUSHBUTTON_OK, 1243cdf0e10cSrcweir HID_SEND_HTML_CTRL_PUSHBUTTON_CANCEL, 1244cdf0e10cSrcweir HID_SEND_HTML_CTRL_LISTBOX_FILTER, 1245cdf0e10cSrcweir HID_SEND_HTML_CTRL_CONTROL_FILEVIEW, 1246cdf0e10cSrcweir HID_SEND_HTML_CTRL_EDIT_FILEURL, 1247cdf0e10cSrcweir HID_SEND_HTML_CTRL_CHECKBOX_AUTOEXTENSION, 1248cdf0e10cSrcweir HID_SEND_HTML_CTRL_LISTBOX_TEMPLATE, 1249cdf0e10cSrcweir "" 1250cdf0e10cSrcweir }; 1251cdf0e10cSrcweir 1252cdf0e10cSrcweir const char* aMasterHelpIds[] = 1253cdf0e10cSrcweir { 1254cdf0e10cSrcweir HID_SEND_MASTER_CTRL_PUSHBUTTON_OK, 1255cdf0e10cSrcweir HID_SEND_MASTER_CTRL_PUSHBUTTON_CANCEL, 1256cdf0e10cSrcweir HID_SEND_MASTER_CTRL_LISTBOX_FILTER, 1257cdf0e10cSrcweir HID_SEND_MASTER_CTRL_CONTROL_FILEVIEW, 1258cdf0e10cSrcweir HID_SEND_MASTER_CTRL_EDIT_FILEURL, 1259cdf0e10cSrcweir HID_SEND_MASTER_CTRL_CHECKBOX_AUTOEXTENSION, 1260cdf0e10cSrcweir HID_SEND_MASTER_CTRL_LISTBOX_TEMPLATE, 1261cdf0e10cSrcweir "" 1262cdf0e10cSrcweir }; 1263cdf0e10cSrcweir 1264cdf0e10cSrcweir const char** pHelpIds = bCreateHtml ? aHTMLHelpIds : aMasterHelpIds; 1265cdf0e10cSrcweir aDlgHelper.SetControlHelpIds( nControlIds, pHelpIds ); 1266cdf0e10cSrcweir uno::Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker(); 1267cdf0e10cSrcweir 1268cdf0e10cSrcweir const SfxFilter* pFlt; 1269cdf0e10cSrcweir sal_uInt16 nStrId; 1270cdf0e10cSrcweir 1271cdf0e10cSrcweir if( bCreateHtml ) 1272cdf0e10cSrcweir { 1273cdf0e10cSrcweir // fuer HTML gibts es nur einen Filter!! 1274cdf0e10cSrcweir pFlt = SwIoSystem::GetFilterOfFormat( 1275cdf0e10cSrcweir String::CreateFromAscii("HTML"), 1276cdf0e10cSrcweir SwWebDocShell::Factory().GetFilterContainer() ); 1277cdf0e10cSrcweir nStrId = STR_LOAD_HTML_DOC; 1278cdf0e10cSrcweir } 1279cdf0e10cSrcweir else 1280cdf0e10cSrcweir { 1281cdf0e10cSrcweir // Fuer Global-Dokumente bieten wir jetzt auch nur 1282cdf0e10cSrcweir // noch den aktuellen an. 1283cdf0e10cSrcweir pFlt = SwGlobalDocShell::Factory().GetFilterContainer()-> 1284cdf0e10cSrcweir GetFilter4Extension( String::CreateFromAscii("odm") ); 1285cdf0e10cSrcweir nStrId = STR_LOAD_GLOBAL_DOC; 1286cdf0e10cSrcweir } 1287cdf0e10cSrcweir 1288cdf0e10cSrcweir if( pFlt ) 1289cdf0e10cSrcweir { 1290cdf0e10cSrcweir uno::Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY); 1291cdf0e10cSrcweir const String sWild = ((WildCard&)pFlt->GetWildcard()).GetWildCard(); 1292cdf0e10cSrcweir xFltMgr->appendFilter( pFlt->GetUIName(), sWild ); 1293cdf0e10cSrcweir try 1294cdf0e10cSrcweir { 1295cdf0e10cSrcweir xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ; 1296cdf0e10cSrcweir } 1297cdf0e10cSrcweir catch( const uno::Exception& ) 1298cdf0e10cSrcweir { 1299cdf0e10cSrcweir bError = true; 1300cdf0e10cSrcweir } 1301cdf0e10cSrcweir } 1302cdf0e10cSrcweir if(!bError) 1303cdf0e10cSrcweir { 1304cdf0e10cSrcweir uno::Reference<XFilePickerControlAccess> xCtrlAcc(xFP, UNO_QUERY); 1305cdf0e10cSrcweir 1306cdf0e10cSrcweir //#removed by zhaojianwei 1307cdf0e10cSrcweir 1308cdf0e10cSrcweir // const sal_uInt16 nCount = pDoc->GetTxtFmtColls()->Count(); 1309cdf0e10cSrcweir // Sequence<OUString> aListBoxEntries(nCount); 1310cdf0e10cSrcweir // OUString* pEntries = aListBoxEntries.getArray(); 1311cdf0e10cSrcweir // sal_Int32 nIdx = 0; 1312cdf0e10cSrcweir // sal_Int16 nSelect = 0; 1313cdf0e10cSrcweir // OUString sStartTemplate; 1314cdf0e10cSrcweir // SwTxtFmtColl *pFnd = 0, *pAny = 0; 1315cdf0e10cSrcweir // for(sal_uInt16 i = 0; i < nCount; ++i) 1316cdf0e10cSrcweir // { 1317cdf0e10cSrcweir // SwTxtFmtColl &rTxtColl = 1318cdf0e10cSrcweir // *pDoc->GetTxtFmtColls()->GetObject( i ); 1319cdf0e10cSrcweir // if( !rTxtColl.IsDefault() && rTxtColl.IsAtDocNodeSet() ) 1320cdf0e10cSrcweir // { 1321cdf0e10cSrcweir // //if( MAXLEVEL >= rTxtColl.GetOutlineLevel() && ( !pFnd || //#outline level,zhaojianwei 1322cdf0e10cSrcweir //if( rTxtColl.IsAssignedToListLevelOfOutlineStyle() && ( !pFnd || //<-end,zhaojianwei 1323cdf0e10cSrcweir // pFnd->GetAssignedOutlineStyleLevel() > rTxtColl.GetAssignedOutlineStyleLevel() )) 1324cdf0e10cSrcweir // { 1325cdf0e10cSrcweir // nSelect = (sal_Int16)nIdx; 1326cdf0e10cSrcweir // pFnd = &rTxtColl; 1327cdf0e10cSrcweir // sStartTemplate = rTxtColl.GetName(); 1328cdf0e10cSrcweir // } 1329cdf0e10cSrcweir // else if( !pAny ) 1330cdf0e10cSrcweir // pAny = &rTxtColl; 1331cdf0e10cSrcweir // //pEntries[nIdx++] = rTxtColl.GetName(); //#outline level,remove by zhaojianwei 1332cdf0e10cSrcweir // pEntries[nIdx++] = sStyles + rTxtColl.GetName(); //#outline level,add by zhaojianwei 1333cdf0e10cSrcweir // } 1334cdf0e10cSrcweir // } 1335cdf0e10cSrcweir // if(!sStartTemplate.getLength() && pAny) 1336cdf0e10cSrcweir // sStartTemplate = pAny->GetName(); 1337cdf0e10cSrcweir // aListBoxEntries.realloc(nIdx); 1338cdf0e10cSrcweir //<-end,zhaojianwei 1339cdf0e10cSrcweir 1340cdf0e10cSrcweir 1341cdf0e10cSrcweir //#outline level,add by zhaojianwei 1342cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////// 1343cdf0e10cSrcweir 1344cdf0e10cSrcweir bool bOutline[MAXLEVEL] = {false}; 1345cdf0e10cSrcweir const SwOutlineNodes& rOutlNds = pDoc->GetNodes().GetOutLineNds(); 1346cdf0e10cSrcweir if( rOutlNds.Count() ) 1347cdf0e10cSrcweir { 1348cdf0e10cSrcweir int nLevel; 1349cdf0e10cSrcweir for(sal_uInt16 n = 0; n < rOutlNds.Count(); ++n ) 1350cdf0e10cSrcweir if( ( nLevel = rOutlNds[n]->GetTxtNode()->GetAttrOutlineLevel()) > 0 && 1351cdf0e10cSrcweir ! bOutline[nLevel-1] ) 1352cdf0e10cSrcweir { 1353cdf0e10cSrcweir bOutline[nLevel-1] = true; 1354cdf0e10cSrcweir } 1355cdf0e10cSrcweir } 1356cdf0e10cSrcweir 1357cdf0e10cSrcweir const sal_uInt16 nStyleCount = pDoc->GetTxtFmtColls()->Count(); 1358cdf0e10cSrcweir Sequence<OUString> aListBoxEntries( MAXLEVEL + nStyleCount); 1359cdf0e10cSrcweir OUString* pEntries = aListBoxEntries.getArray(); 1360cdf0e10cSrcweir sal_Int32 nIdx = 0 ; 1361cdf0e10cSrcweir 1362cdf0e10cSrcweir OUString sOutline( SW_RESSTR(STR_FDLG_OUTLINE_LEVEL) ); 1363cdf0e10cSrcweir for( sal_uInt16 i = 0; i < MAXLEVEL; ++i ) 1364cdf0e10cSrcweir { 1365cdf0e10cSrcweir if( bOutline[i] ) 1366cdf0e10cSrcweir pEntries[nIdx++] = sOutline + String::CreateFromInt32( i+1 ); 1367cdf0e10cSrcweir } 1368cdf0e10cSrcweir 1369cdf0e10cSrcweir OUString sStyle( SW_RESSTR(STR_FDLG_STYLE) ); 1370cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nStyleCount; ++i) 1371cdf0e10cSrcweir { 1372cdf0e10cSrcweir SwTxtFmtColl &rTxtColl = 1373cdf0e10cSrcweir *pDoc->GetTxtFmtColls()->GetObject( i ); 1374cdf0e10cSrcweir if( !rTxtColl.IsDefault() && rTxtColl.IsAtDocNodeSet() ) 1375cdf0e10cSrcweir { 1376cdf0e10cSrcweir pEntries[nIdx++] = sStyle + rTxtColl.GetName(); 1377cdf0e10cSrcweir } 1378cdf0e10cSrcweir } 1379cdf0e10cSrcweir 1380cdf0e10cSrcweir aListBoxEntries.realloc(nIdx); 1381cdf0e10cSrcweir sal_Int16 nSelect = 0; 1382cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////// 1383cdf0e10cSrcweir //<-end,zhaojianwei 1384cdf0e10cSrcweir 1385cdf0e10cSrcweir try 1386cdf0e10cSrcweir { 1387cdf0e10cSrcweir Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries)); 1388cdf0e10cSrcweir 1389cdf0e10cSrcweir xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, 1390cdf0e10cSrcweir ListboxControlActions::ADD_ITEMS , aTemplates ); 1391cdf0e10cSrcweir Any aSelectPos(&nSelect, ::getCppuType(&nSelect)); 1392cdf0e10cSrcweir xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, 1393cdf0e10cSrcweir ListboxControlActions::SET_SELECT_ITEM, aSelectPos ); 1394cdf0e10cSrcweir xCtrlAcc->setLabel( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, 1395cdf0e10cSrcweir String(SW_RES( STR_FDLG_TEMPLATE_NAME ))); 1396cdf0e10cSrcweir } 1397cdf0e10cSrcweir catch(Exception& ) 1398cdf0e10cSrcweir { 1399cdf0e10cSrcweir DBG_ERROR("control acces failed"); 1400cdf0e10cSrcweir } 1401cdf0e10cSrcweir 1402cdf0e10cSrcweir xFP->setTitle( SW_RESSTR( nStrId )); 1403cdf0e10cSrcweir SvtPathOptions aPathOpt; 1404cdf0e10cSrcweir xFP->setDisplayDirectory( aPathOpt.GetWorkPath() ); 1405cdf0e10cSrcweir if( ERRCODE_NONE == aDlgHelper.Execute()) 1406cdf0e10cSrcweir { 1407cdf0e10cSrcweir aFileName = xFP->getFiles().getConstArray()[0]; 1408cdf0e10cSrcweir Any aTemplateValue = xCtrlAcc->getValue( 1409cdf0e10cSrcweir ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, 1410cdf0e10cSrcweir ListboxControlActions::GET_SELECTED_ITEM ); 1411cdf0e10cSrcweir OUString sTmpl; 1412cdf0e10cSrcweir aTemplateValue >>= sTmpl; 1413cdf0e10cSrcweir //aTemplateName = sTmpl; //#outline level,removed by zhaojianwei 1414cdf0e10cSrcweir //#outline level,add by zhaojianwei 1415cdf0e10cSrcweir 1416cdf0e10cSrcweir sal_Int32 nColonPos = sTmpl.indexOf( sal_Unicode(':') ); 1417cdf0e10cSrcweir OUString sPrefix = sTmpl.copy( 0L, nColonPos ); 1418cdf0e10cSrcweir if( sPrefix.equalsAscii("Style")) 1419cdf0e10cSrcweir { 1420cdf0e10cSrcweir aTemplateName = sTmpl.copy( 7L ); //get string behind "Style: " 1421cdf0e10cSrcweir } 1422cdf0e10cSrcweir else if( sPrefix.equalsAscii("Outline")) 1423cdf0e10cSrcweir { 1424cdf0e10cSrcweir nTemplateOutlineLevel = ( sTmpl.copy( 15L )).toInt32(); //get string behind "Outline: Leve "; 1425cdf0e10cSrcweir bCreateByOutlineLevel = true; 1426cdf0e10cSrcweir } 1427cdf0e10cSrcweir //<-end,zhaojianwei 1428cdf0e10cSrcweir 1429cdf0e10cSrcweir if ( aFileName.Len() ) 1430cdf0e10cSrcweir { 1431cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( nWhich, aFileName ) ); 1432cdf0e10cSrcweir if( aTemplateName.Len() ) 1433cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aTemplateName ) ); 1434cdf0e10cSrcweir } 1435cdf0e10cSrcweir } 1436cdf0e10cSrcweir } 1437cdf0e10cSrcweir } 1438cdf0e10cSrcweir 1439cdf0e10cSrcweir //const SwTxtFmtColl* pSplitColl = 0; //#outline level,removed by zhaojianwei 1440cdf0e10cSrcweir // if ( aTemplateName.Len() ) 1441cdf0e10cSrcweir // pSplitColl = pDoc->FindTxtFmtCollByName(aTemplateName); 1442cdf0e10cSrcweir //<-end,zhaojianwei 1443cdf0e10cSrcweir if( aFileName.Len() ) 1444cdf0e10cSrcweir { 1445cdf0e10cSrcweir if( PrepareClose( sal_False ) ) 1446cdf0e10cSrcweir { 1447cdf0e10cSrcweir SwWait aWait( *this, sal_True ); 1448cdf0e10cSrcweir 1449cdf0e10cSrcweir //bDone = bCreateHtml //#outline level,removed by zhaojianwei 1450cdf0e10cSrcweir // ? pDoc->GenerateHTMLDoc( aFileName, pSplitColl ) 1451cdf0e10cSrcweir // : pDoc->GenerateGlobalDoc( aFileName, pSplitColl ); 1452cdf0e10cSrcweir if ( bCreateByOutlineLevel ) //add by zhaojianwei 1453cdf0e10cSrcweir { 1454cdf0e10cSrcweir bDone = bCreateHtml //#outline level,removed by zhaojianwei 1455cdf0e10cSrcweir ? pDoc->GenerateHTMLDoc( aFileName, nTemplateOutlineLevel ) 1456cdf0e10cSrcweir : pDoc->GenerateGlobalDoc( aFileName, nTemplateOutlineLevel ); 1457cdf0e10cSrcweir } 1458cdf0e10cSrcweir else 1459cdf0e10cSrcweir { 1460cdf0e10cSrcweir const SwTxtFmtColl* pSplitColl = 0; 1461cdf0e10cSrcweir if ( aTemplateName.Len() ) 1462cdf0e10cSrcweir pSplitColl = pDoc->FindTxtFmtCollByName(aTemplateName); 1463cdf0e10cSrcweir bDone = bCreateHtml //#outline level,removed by zhaojianwei 1464cdf0e10cSrcweir ? pDoc->GenerateHTMLDoc( aFileName, pSplitColl ) 1465cdf0e10cSrcweir : pDoc->GenerateGlobalDoc( aFileName, pSplitColl ); 1466cdf0e10cSrcweir } 1467cdf0e10cSrcweir //<-end,zhaojianwei 1468cdf0e10cSrcweir if( bDone ) 1469cdf0e10cSrcweir { 1470cdf0e10cSrcweir SfxStringItem aName( SID_FILE_NAME, aFileName ); 1471cdf0e10cSrcweir SfxStringItem aReferer( SID_REFERER, aEmptyStr ); 1472cdf0e10cSrcweir SfxViewShell* pViewShell = SfxViewShell::GetFirst(); 1473cdf0e10cSrcweir while(pViewShell) 1474cdf0e10cSrcweir { 1475cdf0e10cSrcweir //search for the view that created the call 1476cdf0e10cSrcweir if(pViewShell->GetObjectShell() == this && pViewShell->GetDispatcher()) 1477cdf0e10cSrcweir { 1478cdf0e10cSrcweir SfxFrameItem* pFrameItem = new SfxFrameItem( SID_DOCFRAME, 1479cdf0e10cSrcweir pViewShell->GetViewFrame() ); 1480cdf0e10cSrcweir SfxDispatcher* pDispatch = pViewShell->GetDispatcher(); 1481cdf0e10cSrcweir pDispatch->Execute( 1482cdf0e10cSrcweir SID_OPENDOC, 1483cdf0e10cSrcweir SFX_CALLMODE_ASYNCHRON, 1484cdf0e10cSrcweir &aName, 1485cdf0e10cSrcweir &aReferer, 1486cdf0e10cSrcweir pFrameItem, 0L ); 1487cdf0e10cSrcweir 1488cdf0e10cSrcweir delete pFrameItem; 1489cdf0e10cSrcweir break; 1490cdf0e10cSrcweir } 1491cdf0e10cSrcweir pViewShell = SfxViewShell::GetNext(*pViewShell); 1492cdf0e10cSrcweir } 1493cdf0e10cSrcweir } 1494cdf0e10cSrcweir } 1495cdf0e10cSrcweir if( !bDone && !rReq.IsAPI() ) 1496cdf0e10cSrcweir { 1497cdf0e10cSrcweir InfoBox( 0, SW_RESSTR( STR_CANTCREATE )).Execute(); 1498cdf0e10cSrcweir } 1499cdf0e10cSrcweir } 1500cdf0e10cSrcweir } 1501cdf0e10cSrcweir rReq.SetReturnValue(SfxBoolItem( nWhich, bDone )); 1502cdf0e10cSrcweir if (bDone) 1503cdf0e10cSrcweir rReq.Done(); 1504cdf0e10cSrcweir else 1505cdf0e10cSrcweir rReq.Ignore(); 1506cdf0e10cSrcweir break; 1507cdf0e10cSrcweir 1508cdf0e10cSrcweir case SID_ATTR_YEAR2000: 1509cdf0e10cSrcweir if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nWhich , sal_False, &pItem )) 1510cdf0e10cSrcweir { 1511cdf0e10cSrcweir DBG_ASSERT(pItem->ISA(SfxUInt16Item), "falsches Item"); 1512cdf0e10cSrcweir sal_uInt16 nYear2K = ((SfxUInt16Item*)pItem)->GetValue(); 1513cdf0e10cSrcweir //ueber Views iterieren und den State an den FormShells setzen 1514cdf0e10cSrcweir 1515cdf0e10cSrcweir SfxViewFrame* pVFrame = SfxViewFrame::GetFirst( this ); 1516cdf0e10cSrcweir SfxViewShell* pViewShell = pVFrame ? pVFrame->GetViewShell() : 0; 1517cdf0e10cSrcweir SwView* pCurrView = dynamic_cast< SwView* >( pViewShell ); 1518cdf0e10cSrcweir while(pCurrView) 1519cdf0e10cSrcweir { 1520cdf0e10cSrcweir FmFormShell* pFormShell = pCurrView->GetFormShell(); 1521cdf0e10cSrcweir if(pFormShell) 1522cdf0e10cSrcweir pFormShell->SetY2KState(nYear2K); 1523cdf0e10cSrcweir pVFrame = SfxViewFrame::GetNext( *pVFrame, this ); 1524cdf0e10cSrcweir pViewShell = pVFrame ? pVFrame->GetViewShell() : 0; 1525cdf0e10cSrcweir pCurrView = dynamic_cast<SwView*>( pViewShell ); 1526cdf0e10cSrcweir } 1527cdf0e10cSrcweir pDoc->GetNumberFormatter(sal_True)->SetYear2000(nYear2K); 1528cdf0e10cSrcweir } 1529cdf0e10cSrcweir break; 1530cdf0e10cSrcweir 1531cdf0e10cSrcweir default: DBG_ERROR("falscher Dispatcher"); 1532cdf0e10cSrcweir } 1533cdf0e10cSrcweir } 1534cdf0e10cSrcweir 1535cdf0e10cSrcweir 1536cdf0e10cSrcweir /*-------------------------------------------------------------------- 1537cdf0e10cSrcweir Beschreibung: 1538cdf0e10cSrcweir --------------------------------------------------------------------*/ 1539cdf0e10cSrcweir 1540cdf0e10cSrcweir long SwDocShell::DdeGetData( const String& rItem, const String& rMimeType, 1541cdf0e10cSrcweir uno::Any & rValue ) 1542cdf0e10cSrcweir { 1543cdf0e10cSrcweir return pDoc->GetData( rItem, rMimeType, rValue ); 1544cdf0e10cSrcweir } 1545cdf0e10cSrcweir 1546cdf0e10cSrcweir 1547cdf0e10cSrcweir /*-------------------------------------------------------------------- 1548cdf0e10cSrcweir Beschreibung: 1549cdf0e10cSrcweir --------------------------------------------------------------------*/ 1550cdf0e10cSrcweir 1551cdf0e10cSrcweir long SwDocShell::DdeSetData( const String& rItem, const String& rMimeType, 1552cdf0e10cSrcweir const uno::Any & rValue ) 1553cdf0e10cSrcweir { 1554cdf0e10cSrcweir return pDoc->SetData( rItem, rMimeType, rValue ); 1555cdf0e10cSrcweir } 1556cdf0e10cSrcweir 1557cdf0e10cSrcweir 1558cdf0e10cSrcweir /*-------------------------------------------------------------------- 1559cdf0e10cSrcweir Beschreibung: 1560cdf0e10cSrcweir --------------------------------------------------------------------*/ 1561cdf0e10cSrcweir 1562cdf0e10cSrcweir ::sfx2::SvLinkSource* SwDocShell::DdeCreateLinkSource( const String& rItem ) 1563cdf0e10cSrcweir { 1564cdf0e10cSrcweir return pDoc->CreateLinkSource( rItem ); 1565cdf0e10cSrcweir } 1566cdf0e10cSrcweir 1567cdf0e10cSrcweir /*-------------------------------------------------------------------- 1568cdf0e10cSrcweir Beschreibung: 1569cdf0e10cSrcweir --------------------------------------------------------------------*/ 1570cdf0e10cSrcweir 1571cdf0e10cSrcweir void SwDocShell::FillClass( SvGlobalName * pClassName, 1572cdf0e10cSrcweir sal_uInt32 * pClipFormat, 1573cdf0e10cSrcweir String * /*pAppName*/, 1574cdf0e10cSrcweir String * pLongUserName, 1575cdf0e10cSrcweir String * pUserName, 1576cdf0e10cSrcweir sal_Int32 nVersion, 1577cdf0e10cSrcweir sal_Bool bTemplate /* = sal_False */) const 1578cdf0e10cSrcweir { 1579cdf0e10cSrcweir if (nVersion == SOFFICE_FILEFORMAT_60) 1580cdf0e10cSrcweir { 1581cdf0e10cSrcweir *pClassName = SvGlobalName( SO3_SW_CLASSID_60 ); 1582cdf0e10cSrcweir *pClipFormat = SOT_FORMATSTR_ID_STARWRITER_60; 1583cdf0e10cSrcweir *pLongUserName = SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE); 1584cdf0e10cSrcweir } 1585cdf0e10cSrcweir else if (nVersion == SOFFICE_FILEFORMAT_8) 1586cdf0e10cSrcweir { 1587cdf0e10cSrcweir *pClassName = SvGlobalName( SO3_SW_CLASSID_60 ); 1588cdf0e10cSrcweir *pClipFormat = bTemplate ? SOT_FORMATSTR_ID_STARWRITER_8_TEMPLATE : SOT_FORMATSTR_ID_STARWRITER_8; 1589cdf0e10cSrcweir *pLongUserName = SW_RESSTR(STR_WRITER_DOCUMENT_FULLTYPE); 1590cdf0e10cSrcweir } 1591cdf0e10cSrcweir 1592cdf0e10cSrcweir *pUserName = SW_RESSTR(STR_HUMAN_SWDOC_NAME); 1593cdf0e10cSrcweir } 1594cdf0e10cSrcweir 1595cdf0e10cSrcweir 1596cdf0e10cSrcweir /*-------------------------------------------------------------------- 1597cdf0e10cSrcweir Beschreibung: 1598cdf0e10cSrcweir --------------------------------------------------------------------*/ 1599cdf0e10cSrcweir 1600cdf0e10cSrcweir void SwDocShell::SetModified( sal_Bool bSet ) 1601cdf0e10cSrcweir { 1602cdf0e10cSrcweir SfxObjectShell::SetModified( bSet ); 1603cdf0e10cSrcweir if( IsEnableSetModified()) 1604cdf0e10cSrcweir { 1605cdf0e10cSrcweir if (!pDoc->IsInCallModified() ) 1606cdf0e10cSrcweir { 1607cdf0e10cSrcweir EnableSetModified( sal_False ); 1608cdf0e10cSrcweir if( bSet ) 1609cdf0e10cSrcweir { 1610cdf0e10cSrcweir sal_Bool bOld = pDoc->IsModified(); 1611cdf0e10cSrcweir pDoc->SetModified(); 1612cdf0e10cSrcweir if( !bOld ) 1613cdf0e10cSrcweir { 1614cdf0e10cSrcweir pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified(); 1615cdf0e10cSrcweir } 1616cdf0e10cSrcweir } 1617cdf0e10cSrcweir else 1618cdf0e10cSrcweir pDoc->ResetModified(); 1619cdf0e10cSrcweir 1620cdf0e10cSrcweir EnableSetModified( sal_True ); 1621cdf0e10cSrcweir } 1622cdf0e10cSrcweir 1623cdf0e10cSrcweir UpdateChildWindows(); 1624cdf0e10cSrcweir Broadcast(SfxSimpleHint(SFX_HINT_DOCCHANGED)); 1625cdf0e10cSrcweir } 1626cdf0e10cSrcweir } 1627cdf0e10cSrcweir 1628cdf0e10cSrcweir /*-------------------------------------------------------------------- 1629cdf0e10cSrcweir Beschreibung: 1630cdf0e10cSrcweir --------------------------------------------------------------------*/ 1631cdf0e10cSrcweir 1632cdf0e10cSrcweir void SwDocShell::UpdateChildWindows() 1633cdf0e10cSrcweir { 1634cdf0e10cSrcweir // Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR) 1635cdf0e10cSrcweir if(!GetView()) 1636cdf0e10cSrcweir return; 1637cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView()->GetViewFrame(); 1638cdf0e10cSrcweir SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame-> 1639cdf0e10cSrcweir GetChildWindow( SwFldDlgWrapper::GetChildWindowId() ); 1640cdf0e10cSrcweir if( pWrp ) 1641cdf0e10cSrcweir pWrp->ReInitDlg( this ); 1642cdf0e10cSrcweir 1643cdf0e10cSrcweir // RedlineDlg ggf neu initialisieren 1644cdf0e10cSrcweir SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame-> 1645cdf0e10cSrcweir GetChildWindow( SwRedlineAcceptChild::GetChildWindowId() ); 1646cdf0e10cSrcweir if( pRed ) 1647cdf0e10cSrcweir pRed->ReInitDlg( this ); 1648cdf0e10cSrcweir } 1649cdf0e10cSrcweir 1650cdf0e10cSrcweir /*-------------------------------------------------------------------- 1651cdf0e10cSrcweir Beschreibung: 1652cdf0e10cSrcweir --------------------------------------------------------------------*/ 1653cdf0e10cSrcweir // --> OD 2005-08-02 #i48748# 1654cdf0e10cSrcweir class SwReloadFromHtmlReader : public SwReader 1655cdf0e10cSrcweir { 1656cdf0e10cSrcweir public: 1657cdf0e10cSrcweir SwReloadFromHtmlReader( SfxMedium& _rTmpMedium, 1658cdf0e10cSrcweir const String& _rFilename, 1659cdf0e10cSrcweir SwDoc* _pDoc ) 1660cdf0e10cSrcweir : SwReader( _rTmpMedium, _rFilename, _pDoc ) 1661cdf0e10cSrcweir { 1662cdf0e10cSrcweir SetBaseURL( _rFilename ); 1663cdf0e10cSrcweir } 1664cdf0e10cSrcweir }; 1665cdf0e10cSrcweir // <-- 1666cdf0e10cSrcweir void SwDocShell::ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView ) 1667cdf0e10cSrcweir { 1668cdf0e10cSrcweir sal_Bool bModified = IsModified(); 1669cdf0e10cSrcweir 1670cdf0e10cSrcweir // MIB 23.6.97: Die HTTP-Header-Felder muessen geloescht werden, 1671cdf0e10cSrcweir // sonst gibt es welche aus Meta-Tags hinter doppelt und dreifach. 1672cdf0e10cSrcweir ClearHeaderAttributesForSourceViewHack(); 1673cdf0e10cSrcweir 1674cdf0e10cSrcweir // MIB 24.07.97: Das Dokument-Basic muss auch noch d'ran glauben ... 1675cdf0e10cSrcweir SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get(); 1676cdf0e10cSrcweir //#59620# HasBasic() zeigt an, dass es schon einen BasicManager an der DocShell 1677cdf0e10cSrcweir // gibt. Der wurde im HTML-Import immer angelegt, wenn Macros im Quelltext 1678cdf0e10cSrcweir // vorhanden sind. 1679cdf0e10cSrcweir if( pHtmlOptions && pHtmlOptions->IsStarBasic() && HasBasic()) 1680cdf0e10cSrcweir { 1681cdf0e10cSrcweir BasicManager *pBasicMan = GetBasicManager(); 1682cdf0e10cSrcweir if( pBasicMan && (pBasicMan != SFX_APP()->GetBasicManager()) ) 1683cdf0e10cSrcweir { 1684cdf0e10cSrcweir sal_uInt16 nLibCount = pBasicMan->GetLibCount(); 1685cdf0e10cSrcweir while( nLibCount ) 1686cdf0e10cSrcweir { 1687cdf0e10cSrcweir StarBASIC *pBasic = pBasicMan->GetLib( --nLibCount ); 1688cdf0e10cSrcweir if( pBasic ) 1689cdf0e10cSrcweir { 1690cdf0e10cSrcweir // Die IDE benachrichtigen 1691cdf0e10cSrcweir SfxUsrAnyItem aShellItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( GetModel() ) ); 1692cdf0e10cSrcweir String aLibName( pBasic->GetName() ); 1693cdf0e10cSrcweir SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName ); 1694cdf0e10cSrcweir pSrcView->GetViewFrame()->GetDispatcher()->Execute( 1695cdf0e10cSrcweir SID_BASICIDE_LIBREMOVED, 1696cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON, 1697cdf0e10cSrcweir &aShellItem, &aLibNameItem, 0L ); 1698cdf0e10cSrcweir 1699cdf0e10cSrcweir // Aus der Standard-Lib werden nur die Module geloescht 1700cdf0e10cSrcweir if( nLibCount ) 1701cdf0e10cSrcweir pBasicMan->RemoveLib( nLibCount, sal_True ); 1702cdf0e10cSrcweir else 1703cdf0e10cSrcweir pBasic->Clear(); 1704cdf0e10cSrcweir } 1705cdf0e10cSrcweir } 1706cdf0e10cSrcweir 1707cdf0e10cSrcweir ASSERT( pBasicMan->GetLibCount() <= 1, 1708cdf0e10cSrcweir "Loschen des Basics hat nicht geklappt" ); 1709cdf0e10cSrcweir } 1710cdf0e10cSrcweir } 1711cdf0e10cSrcweir sal_Bool bWasBrowseMode = pDoc->get(IDocumentSettingAccess::BROWSE_MODE); 1712cdf0e10cSrcweir RemoveLink(); 1713cdf0e10cSrcweir 1714cdf0e10cSrcweir //jetzt muss auch das UNO-Model ueber das neue Doc informiert werden #51535# 1715cdf0e10cSrcweir uno::Reference<text::XTextDocument> xDoc(GetBaseModel(), uno::UNO_QUERY); 1716cdf0e10cSrcweir text::XTextDocument* pxDoc = xDoc.get(); 1717cdf0e10cSrcweir ((SwXTextDocument*)pxDoc)->InitNewDoc(); 1718cdf0e10cSrcweir 1719cdf0e10cSrcweir AddLink(); 1720cdf0e10cSrcweir //#116402# update font list when new document is created 1721cdf0e10cSrcweir UpdateFontList(); 1722cdf0e10cSrcweir pDoc->set(IDocumentSettingAccess::BROWSE_MODE, bWasBrowseMode); 1723cdf0e10cSrcweir pSrcView->SetPool(&GetPool()); 1724cdf0e10cSrcweir 1725cdf0e10cSrcweir 1726cdf0e10cSrcweir const String& rMedname = GetMedium()->GetName(); 1727cdf0e10cSrcweir 1728cdf0e10cSrcweir // fix #51032#: Die HTML-Vorlage muss noch gesetzt werden 1729cdf0e10cSrcweir SetHTMLTemplate( *GetDoc() ); //Styles aus HTML.vor 1730cdf0e10cSrcweir 1731cdf0e10cSrcweir SfxViewShell* pViewShell = GetView() ? (SfxViewShell*)GetView() 1732cdf0e10cSrcweir : SfxViewShell::Current(); 1733cdf0e10cSrcweir SfxViewFrame* pViewFrm = pViewShell->GetViewFrame(); 1734cdf0e10cSrcweir pViewFrm->GetDispatcher()->Execute( SID_VIEWSHELL0, SFX_CALLMODE_SYNCHRON ); 1735cdf0e10cSrcweir 1736cdf0e10cSrcweir SubInitNew(); 1737cdf0e10cSrcweir 1738cdf0e10cSrcweir SfxMedium aMed( rStreamName, STREAM_READ, sal_False ); 1739cdf0e10cSrcweir // --> OD 2005-08-01 #i48748# - use class <SwReloadFromHtmlReader>, because 1740cdf0e10cSrcweir // the base URL has to be set to the filename of the document <rMedname> 1741cdf0e10cSrcweir // and not to the base URL of the temporary file <aMed> in order to get 1742cdf0e10cSrcweir // the URLs of the linked graphics correctly resolved. 1743cdf0e10cSrcweir SwReloadFromHtmlReader aReader( aMed, rMedname, pDoc ); 1744cdf0e10cSrcweir // <-- 1745cdf0e10cSrcweir aReader.Read( *ReadHTML ); 1746cdf0e10cSrcweir 1747cdf0e10cSrcweir const SwView* pCurrView = GetView(); 1748cdf0e10cSrcweir //in print layout the first page(s) may have been formatted as a mix of browse 1749cdf0e10cSrcweir //and print layout 1750cdf0e10cSrcweir if(!bWasBrowseMode && pCurrView) 1751cdf0e10cSrcweir { 1752cdf0e10cSrcweir SwWrtShell& rWrtSh = pCurrView->GetWrtShell(); 1753cdf0e10cSrcweir if( rWrtSh.GetLayout()) 1754cdf0e10cSrcweir rWrtSh.CheckBrowseView( sal_True ); 1755cdf0e10cSrcweir } 1756cdf0e10cSrcweir 1757cdf0e10cSrcweir 1758cdf0e10cSrcweir // MIB 23.6.97: Die HTTP-Header-Attribute wieder in die DokInfo 1759cdf0e10cSrcweir // uebernehmen. Die Base-URL ist hier egal, da TLX zum absolutieren die 1760cdf0e10cSrcweir // vom Dokument nimmt. 1761cdf0e10cSrcweir SetHeaderAttributesForSourceViewHack(); 1762cdf0e10cSrcweir 1763cdf0e10cSrcweir if(bModified && !IsReadOnly()) 1764cdf0e10cSrcweir SetModified(); 1765cdf0e10cSrcweir else 1766cdf0e10cSrcweir pDoc->ResetModified(); 1767cdf0e10cSrcweir } 1768cdf0e10cSrcweir 1769cdf0e10cSrcweir sal_uLong SwDocShell::LoadStylesFromFile( const String& rURL, 1770cdf0e10cSrcweir SwgReaderOption& rOpt, sal_Bool bUnoCall ) 1771cdf0e10cSrcweir { 1772cdf0e10cSrcweir sal_uLong nErr = 0; 1773cdf0e10cSrcweir 1774cdf0e10cSrcweir // Create a URL from filename 1775cdf0e10cSrcweir INetURLObject aURLObj( rURL ); 1776cdf0e10cSrcweir String sURL( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) ); 1777cdf0e10cSrcweir 1778cdf0e10cSrcweir // Filter bestimmen: 1779cdf0e10cSrcweir // const SfxFilter* pFlt = SwIoSystem::GetFileFilter( rURL, aEmptyStr ); 1780cdf0e10cSrcweir String sFactory(String::CreateFromAscii(SwDocShell::Factory().GetShortName())); 1781cdf0e10cSrcweir SfxFilterMatcher aMatcher( sFactory ); 1782cdf0e10cSrcweir 1783cdf0e10cSrcweir //#b6445961# search for filter in WebDocShell, too 1784cdf0e10cSrcweir SfxMedium aMed( rURL, STREAM_STD_READ, sal_False ); 1785cdf0e10cSrcweir const SfxFilter* pFlt = 0; 1786cdf0e10cSrcweir aMatcher.DetectFilter( aMed, &pFlt, sal_False, sal_False ); 1787cdf0e10cSrcweir if(!pFlt) 1788cdf0e10cSrcweir { 1789cdf0e10cSrcweir String sWebFactory(String::CreateFromAscii(SwWebDocShell::Factory().GetShortName())); 1790cdf0e10cSrcweir SfxFilterMatcher aWebMatcher( sWebFactory ); 1791cdf0e10cSrcweir aWebMatcher.DetectFilter( aMed, &pFlt, sal_False, sal_False ); 1792cdf0e10cSrcweir } 1793cdf0e10cSrcweir // --> OD #i117339# - trigger import only for own formats 1794cdf0e10cSrcweir // if( aMed.IsStorage() ) 1795cdf0e10cSrcweir bool bImport( false ); 1796cdf0e10cSrcweir { 1797cdf0e10cSrcweir if ( aMed.IsStorage() ) 1798cdf0e10cSrcweir { 1799cdf0e10cSrcweir // As <SfxMedium.GetFilter().IsOwnFormat() resp. IsOwnTemplateFormat() 1800cdf0e10cSrcweir // does not work correct (e.g., MS Word 2007 XML Template), 1801cdf0e10cSrcweir // use workaround provided by MAV. 1802cdf0e10cSrcweir uno::Reference< embed::XStorage > xStorage = aMed.GetStorage(); 1803cdf0e10cSrcweir if ( xStorage.is() ) 1804cdf0e10cSrcweir { 1805cdf0e10cSrcweir // use <try-catch> on retrieving <MediaType> in order to check, 1806cdf0e10cSrcweir // if the storage is one of our own ones. 1807cdf0e10cSrcweir try 1808cdf0e10cSrcweir { 1809cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY_THROW ); 1810cdf0e10cSrcweir const ::rtl::OUString aMediaTypePropName( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ); 1811cdf0e10cSrcweir xProps->getPropertyValue( aMediaTypePropName ); 1812cdf0e10cSrcweir bImport = true; 1813cdf0e10cSrcweir } 1814cdf0e10cSrcweir catch( const uno::Exception& ) 1815cdf0e10cSrcweir { 1816cdf0e10cSrcweir bImport = false; 1817cdf0e10cSrcweir } 1818cdf0e10cSrcweir } 1819cdf0e10cSrcweir } 1820cdf0e10cSrcweir } 1821cdf0e10cSrcweir if ( bImport ) 1822cdf0e10cSrcweir // <-- 1823cdf0e10cSrcweir { 1824cdf0e10cSrcweir DBG_ASSERT((pFlt ? pFlt->GetVersion() : 0) >= SOFFICE_FILEFORMAT_60, "which file version?"); 1825cdf0e10cSrcweir SwRead pRead = ReadXML; 1826cdf0e10cSrcweir SwReader* pReader = 0; 1827cdf0e10cSrcweir SwPaM* pPam = 0; 1828cdf0e10cSrcweir // the SW3IO - Reader need the pam/wrtshell, because only then he 1829cdf0e10cSrcweir // insert the styles! 1830cdf0e10cSrcweir if( bUnoCall ) 1831cdf0e10cSrcweir { 1832cdf0e10cSrcweir SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfContent(), -1 ); 1833cdf0e10cSrcweir pPam = new SwPaM( aIdx ); 1834cdf0e10cSrcweir pReader = new SwReader( aMed, rURL, *pPam ); 1835cdf0e10cSrcweir } 1836cdf0e10cSrcweir else 1837cdf0e10cSrcweir { 1838cdf0e10cSrcweir pReader = new SwReader( aMed, rURL, *pWrtShell->GetCrsr() ); 1839cdf0e10cSrcweir } 1840cdf0e10cSrcweir 1841cdf0e10cSrcweir pRead->GetReaderOpt().SetTxtFmts( rOpt.IsTxtFmts() ); 1842cdf0e10cSrcweir pRead->GetReaderOpt().SetFrmFmts( rOpt.IsFrmFmts() ); 1843cdf0e10cSrcweir pRead->GetReaderOpt().SetPageDescs( rOpt.IsPageDescs() ); 1844cdf0e10cSrcweir pRead->GetReaderOpt().SetNumRules( rOpt.IsNumRules() ); 1845cdf0e10cSrcweir pRead->GetReaderOpt().SetMerge( rOpt.IsMerge() ); 1846cdf0e10cSrcweir 1847cdf0e10cSrcweir if( bUnoCall ) 1848cdf0e10cSrcweir { 1849cdf0e10cSrcweir UnoActionContext aAction( pDoc ); 1850cdf0e10cSrcweir nErr = pReader->Read( *pRead ); 1851cdf0e10cSrcweir } 1852cdf0e10cSrcweir else 1853cdf0e10cSrcweir { 1854cdf0e10cSrcweir pWrtShell->StartAllAction(); 1855cdf0e10cSrcweir nErr = pReader->Read( *pRead ); 1856cdf0e10cSrcweir pWrtShell->EndAllAction(); 1857cdf0e10cSrcweir } 1858cdf0e10cSrcweir delete pPam; 1859cdf0e10cSrcweir delete pReader; 1860cdf0e10cSrcweir } 1861cdf0e10cSrcweir 1862cdf0e10cSrcweir return nErr; 1863cdf0e10cSrcweir } 1864cdf0e10cSrcweir 1865cdf0e10cSrcweir /*-------------------------------------------------------------------- 1866cdf0e10cSrcweir Get a client for an embedded object if possible. 1867cdf0e10cSrcweir --------------------------------------------------------------------*/ 1868cdf0e10cSrcweir SfxInPlaceClient* SwDocShell::GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef ) 1869cdf0e10cSrcweir { 1870cdf0e10cSrcweir SfxInPlaceClient* pResult = NULL; 1871cdf0e10cSrcweir 1872cdf0e10cSrcweir SwWrtShell* pShell = GetWrtShell(); 1873cdf0e10cSrcweir if ( pShell ) 1874cdf0e10cSrcweir { 1875cdf0e10cSrcweir pResult = pShell->GetView().FindIPClient( xObjRef.GetObject(), (Window*)&pShell->GetView().GetEditWin() ); 1876cdf0e10cSrcweir if ( !pResult ) 1877cdf0e10cSrcweir pResult = new SwOleClient( &pShell->GetView(), &pShell->GetView().GetEditWin(), xObjRef ); 1878cdf0e10cSrcweir } 1879cdf0e10cSrcweir 1880cdf0e10cSrcweir return pResult; 1881cdf0e10cSrcweir } 1882cdf0e10cSrcweir 1883