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