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