merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / uiview / view2.cxx
bloba5eba2d5ca75a165c942b33e01ecb70858d8a11e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: view2.cxx,v $
10 * $Revision: 1.90 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <com/sun/star/util/SearchOptions.hpp>
34 #include <com/sun/star/util/SearchFlags.hpp>
35 #include <com/sun/star/i18n/TransliterationModules.hpp>
37 // #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
38 // #include <com/sun/star/lang/Locale.hpp>
39 // #endif
40 // #ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_
41 // #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
42 // #endif
43 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
44 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
45 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
48 #define _SVSTDARR_STRINGSSORTDTOR
49 #include <svtools/svstdarr.hxx>
50 #include <svtools/aeitem.hxx>
52 // #ifndef _FILTER_HXX
53 // #include <svtools/filter.hxx>
54 // #endif
55 #include <SwStyleNameMapper.hxx>
56 #include <docary.hxx>
57 #include <hintids.hxx>
58 #include <SwRewriter.hxx>
59 #include <undobj.hxx>
60 #include <swundo.hxx>
61 #include <caption.hxx>
62 #include <svtools/PasswordHelper.hxx>
63 #include <svtools/urihelper.hxx>
64 #include <svtools/miscopt.hxx>
65 #include <sfx2/passwd.hxx>
66 #include <sfx2/sfxdlg.hxx>
67 #include <sfx2/filedlghelper.hxx>
68 #include <sfx2/sfxhelp.hxx>
69 #include <svx/langitem.hxx>
70 #include <svx/viewlayoutitem.hxx>
71 #include <svx/zoomslideritem.hxx>
72 #include <svx/linkwarn.hxx>
73 #include <svx/htmlmode.hxx>
74 #ifndef _APP_HXX //autogen
75 #include <vcl/svapp.hxx>
76 #endif
77 #ifndef _WRKWIN_HXX //autogen
78 #include <vcl/wrkwin.hxx>
79 #endif
80 #include <sfx2/app.hxx>
81 #include <sfx2/request.hxx>
82 #include <sfx2/bindings.hxx>
83 #include <svx/lrspitem.hxx>
84 #include <svx/impgrf.hxx>
85 #include <svtools/txtcmp.hxx>
86 #include "svx/unolingu.hxx"
87 #include <vcl/msgbox.hxx>
88 #include <svx/tstpitem.hxx>
89 #include <sfx2/event.hxx>
90 #include <sfx2/docfile.hxx>
91 #include <sfx2/docfilt.hxx>
92 #include <sfx2/fcontnr.hxx>
93 #include <svx/sizeitem.hxx>
94 #include <sfx2/dispatch.hxx>
95 #include <sfx2/topfrm.hxx>
96 #include <svtools/whiter.hxx>
97 #include <svtools/ptitem.hxx>
98 #include <svx/linkmgr.hxx>
99 #ifndef __RSC //autogen
100 #include <tools/errinf.hxx>
101 #endif
102 #include <tools/urlobj.hxx>
103 #include <svx/svdview.hxx>
104 #include <swtypes.hxx>
105 #include <swwait.hxx>
106 #include <redlndlg.hxx>
107 #include <view.hxx>
108 #include <uivwimp.hxx>
109 #include <docsh.hxx>
110 #include <doc.hxx>
111 #include <wrtsh.hxx>
112 #include <viewopt.hxx>
113 #include <basesh.hxx>
114 #include <swmodule.hxx>
115 #include <uitool.hxx>
116 #include <shellio.hxx>
117 #include <fmtinfmt.hxx>
118 #include <mdiexp.hxx>
119 #include <drawbase.hxx>
120 #include <frmmgr.hxx>
121 #include <pagedesc.hxx>
122 #include <section.hxx>
123 #include <usrpref.hxx>
124 #include <IMark.hxx>
125 #include <navipi.hxx>
126 #include <tox.hxx>
127 #include <workctrl.hxx>
128 #include <scroll.hxx>
129 #include <edtwin.hxx>
130 #include <wview.hxx>
131 #include <textsh.hxx>
132 #include <tabsh.hxx>
133 #include <listsh.hxx>
134 #include <cmdid.h>
135 #include <comcore.hrc>
136 #include <poolfmt.hrc>
137 #include <statstr.hrc>
138 #include <swerror.h>
139 #include <globals.hrc>
140 #include <shells.hrc>
141 #include <web.hrc>
142 #include <view.hrc>
143 #include <app.hrc>
144 #include <fmtclds.hxx>
145 #include <helpid.h>
146 #include <svtools/templdlg.hxx>
147 #include <dbconfig.hxx>
148 #include <dbmgr.hxx>
150 #include <PostItMgr.hxx>
151 #include <postit.hxx>
153 // #ifndef _FRMMGR_HXX
154 // #include <frmmgr.hxx>
155 // #endif
157 #include <ndtxt.hxx> //#outline level,added by zhaojianwei
159 #include <comphelper/processfactory.hxx>
161 #include <svx/svxdlg.hxx>
162 #include <svx/dialogs.hrc>
163 #include "swabstdlg.hxx"
164 #include "globals.hrc"
165 #include <envelp.hrc>
166 #include <fmthdft.hxx>
167 #include <svx/ofaitem.hxx>
168 #include <unomid.h>
170 const char __FAR_DATA sStatusDelim[] = " : ";
171 const char __FAR_DATA sStatusComma[] = " , ";//#outlinelevel, define a Variable for "," add by zhaojianwei
173 using ::rtl::OUString;
174 using namespace sfx2;
175 using namespace ::com::sun::star;
176 using namespace ::com::sun::star::i18n;
177 using namespace ::com::sun::star::util;
178 using namespace ::com::sun::star::uno;
179 using namespace ::com::sun::star::lang;
180 using namespace ::com::sun::star::scanner;
181 using namespace ::com::sun::star::i18n;
182 using namespace ::com::sun::star::beans;
183 using namespace ::com::sun::star::container;
184 using namespace ::com::sun::star::ui::dialogs;
187 static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, USHORT nWhichId )
189 if (nWhichId == RES_CHRATR_LANGUAGE ||
190 nWhichId == RES_CHRATR_CJK_LANGUAGE ||
191 nWhichId == RES_CHRATR_CTL_LANGUAGE)
193 rWrtSh.StartAction();
194 rWrtSh.LockView( TRUE );
195 rWrtSh.Push();
197 // prepare to apply new language to all text in document
198 rWrtSh.SelAll();
199 rWrtSh.ExtendedSelectAll();
201 // set language attribute to default for all text
202 SvUShortsSort aAttribs;
203 aAttribs.Insert( nWhichId );
204 rWrtSh.ResetAttr( &aAttribs );
206 rWrtSh.Pop( FALSE );
207 rWrtSh.LockView( FALSE );
208 rWrtSh.EndAction();
212 /*---------------------------------------------------------------------------
213 Beschreibung: String fuer die Seitenanzeige in der Statusbar basteln.
214 ----------------------------------------------------------------------------*/
216 String SwView::GetPageStr( USHORT nPg, USHORT nLogPg,
217 const String& rDisplay )
219 String aStr( aPageStr );
220 if( rDisplay.Len() )
221 aStr += rDisplay;
222 else
223 aStr += String::CreateFromInt32(nLogPg);
225 if( nLogPg && nLogPg != nPg )
227 aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" "));
228 aStr += String::CreateFromInt32(nPg);
230 aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / "));
231 aStr += String::CreateFromInt32( GetWrtShell().GetPageCnt() );
233 return aStr;
237 int SwView::InsertGraphic( const String &rPath, const String &rFilter,
238 BOOL bLink, GraphicFilter *pFlt,
239 Graphic* pPreviewGrf, BOOL bRule )
241 SwWait aWait( *GetDocShell(), TRUE );
243 Graphic aGrf;
244 int nRes = GRFILTER_OK;
245 if ( pPreviewGrf )
246 aGrf = *pPreviewGrf;
247 else
249 if( !pFlt )
250 pFlt = ::GetGrfFilter();
251 nRes = ::LoadGraphic( rPath, rFilter, aGrf, pFlt /*, nFilter*/ );
254 if( GRFILTER_OK == nRes )
256 SwFlyFrmAttrMgr aFrmMgr( TRUE, GetWrtShellPtr(), FRMMGR_TYPE_GRF );
258 SwWrtShell &rSh = GetWrtShell();
259 rSh.StartAction();
260 if( bLink )
262 SwDocShell* pDocSh = GetDocShell();
263 INetURLObject aTemp(
264 pDocSh->HasName() ?
265 pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) :
266 rtl::OUString());
268 String sURL = URIHelper::SmartRel2Abs(
269 aTemp, rPath, URIHelper::GetMaybeFileHdl() );
271 rSh.Insert( sURL,
272 rFilter, aGrf, &aFrmMgr, bRule );
274 else
275 rSh.Insert( aEmptyStr, aEmptyStr, aGrf, &aFrmMgr );
276 // nach dem EndAction ist es zu spaet, weil die Shell dann schon zerstoert sein kann
277 rSh.EndAction();
279 return nRes;
283 BOOL SwView::InsertGraphicDlg( SfxRequest& rReq )
285 #ifndef ENABLE_PROP_WITHOUTLINK
286 #define ENABLE_PROP_WITHOUTLINK 0x08
287 #endif
289 BOOL bReturn = FALSE;
290 SwDocShell* pDocShell = GetDocShell();
291 USHORT nHtmlMode = ::GetHtmlMode(pDocShell);
292 // im HTML-Mode nur verknuepft einfuegen
293 FileDialogHelper* pFileDlg = new FileDialogHelper( SFXWB_GRAPHIC | SFXWB_SHOWSTYLES );
294 pFileDlg->SetTitle(SW_RESSTR(STR_INSERT_GRAPHIC ));
295 pFileDlg->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC );
296 uno::Reference < XFilePicker > xFP = pFileDlg->GetFilePicker();
297 uno::Reference < XFilePickerControlAccess > xCtrlAcc(xFP, UNO_QUERY);
298 if(nHtmlMode & HTMLMODE_ON)
300 sal_Bool bTrue = sal_True;
301 Any aVal(&bTrue, ::getBooleanCppuType());
302 xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aVal);
303 xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False);
306 SvStringsSortDtor aFormats;
307 SwDoc* pDoc = pDocShell->GetDoc();
308 const USHORT nArrLen = pDoc->GetFrmFmts()->Count();
309 USHORT i;
310 for( i = 0; i < nArrLen; i++ )
312 SwFrmFmt* pFmt = (*pDoc->GetFrmFmts())[ i ];
313 if(pFmt->IsDefault() || pFmt->IsAuto())
314 continue;
315 String *pFormat = new String(pFmt->GetName());
316 aFormats.Insert(pFormat);
319 // pool formats
321 const SvStringsDtor& rFrmPoolArr = SwStyleNameMapper::GetFrmFmtUINameArray();
322 for( i = 0; i < rFrmPoolArr.Count(); i++ )
324 String *pFormat = new String(*rFrmPoolArr[i]);
325 if (!aFormats.Insert(pFormat))
326 delete pFormat;
329 Sequence<OUString> aListBoxEntries(aFormats.Count());
330 OUString* pEntries = aListBoxEntries.getArray();
331 sal_Int16 nSelect = 0;
332 String sGraphicFormat = SW_RESSTR(STR_POOLFRM_GRAPHIC);
333 for(i = 0; i < aFormats.Count(); ++i)
335 pEntries[i] = *aFormats[i];
336 if(pEntries[i].equals(sGraphicFormat))
337 nSelect = i;
341 Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries));
343 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
344 ListboxControlActions::ADD_ITEMS , aTemplates );
346 Any aSelectPos(&nSelect, ::getCppuType(&nSelect));
347 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
348 ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
350 catch(Exception& )
352 DBG_ERROR("control acces failed");
355 SFX_REQUEST_ARG( rReq, pName, SfxStringItem, SID_INSERT_GRAPHIC , sal_False );
356 BOOL bShowError = !pName;
357 if( pName || ERRCODE_NONE == pFileDlg->Execute() )
360 String aFileName, aFilterName;
361 if ( pName )
363 aFileName = pName->GetValue();
364 SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, FN_PARAM_FILTER , sal_False );
365 if ( pFilter )
366 aFilterName = pFilter->GetValue();
368 else
370 aFileName = pFileDlg->GetPath();
371 aFilterName = pFileDlg->GetCurrentFilter();
372 rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) );
373 rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) );
375 sal_Bool bAsLink = sal_False;
376 if(nHtmlMode & HTMLMODE_ON)
377 bAsLink = sal_True;
378 else
382 Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
383 DBG_ASSERT(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
384 bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True;
385 Any aTemplateValue = xCtrlAcc->getValue(
386 ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
387 ListboxControlActions::GET_SELECTED_ITEM );
388 OUString sTmpl;
389 aTemplateValue >>= sTmpl;
390 rReq.AppendItem( SfxStringItem( FN_PARAM_2, sTmpl) );
392 catch(Exception& )
394 DBG_ERROR("control acces failed");
397 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
400 SFX_REQUEST_ARG( rReq, pAsLink, SfxBoolItem, FN_PARAM_1 , sal_False );
401 SFX_REQUEST_ARG( rReq, pStyle, SfxStringItem, FN_PARAM_2 , sal_False );
403 sal_Bool bAsLink = sal_False;
404 if( nHtmlMode & HTMLMODE_ON )
405 bAsLink = sal_True;
406 else
408 if ( rReq.GetArgs() )
410 if ( pAsLink )
411 bAsLink = pAsLink->GetValue();
412 if ( pStyle && pStyle->GetValue().Len() )
413 sGraphicFormat = pStyle->GetValue();
415 else
417 Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
418 DBG_ASSERT(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
419 bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True;
420 Any aTemplateValue = xCtrlAcc->getValue(
421 ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
422 ListboxControlActions::GET_SELECTED_ITEM );
423 OUString sTmpl;
424 aTemplateValue >>= sTmpl;
425 if( sTmpl.getLength() )
426 sGraphicFormat = sTmpl;
427 rReq.AppendItem( SfxStringItem( FN_PARAM_2, sGraphicFormat ) );
428 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
431 // really store as link only?
432 if( bAsLink && SvtMiscOptions().ShowLinkWarningDialog() )
434 SvxLinkWarningDialog aWarnDlg(GetWindow(),pFileDlg->GetPath());
435 if( aWarnDlg.Execute() != RET_OK )
436 bAsLink=sal_False; // don't store as link
440 SwWrtShell& rSh = GetWrtShell();
441 rSh.LockPaint();
442 rSh.StartAction();
444 /// #111827#
445 SwRewriter aRewriter;
446 aRewriter.AddRule(UNDO_ARG1, String(SW_RES(STR_GRAPHIC_DEFNAME)));
448 rSh.StartUndo(UNDO_INSERT, &aRewriter);
450 int nError = InsertGraphic( aFileName, aFilterName, bAsLink, ::GetGrfFilter() );
452 // Format ist ungleich Current Filter, jetzt mit auto. detection
453 if( nError == GRFILTER_FORMATERROR )
454 nError = InsertGraphic( aFileName, aEmptyStr, bAsLink, ::GetGrfFilter() );
455 if ( rSh.IsFrmSelected() )
457 SwFrmFmt* pFmt = pDoc->FindFrmFmtByName( sGraphicFormat );
458 if(!pFmt)
459 pFmt = pDoc->MakeFrmFmt(sGraphicFormat,
460 pDocShell->GetDoc()->GetDfltFrmFmt(),
461 TRUE, FALSE);
462 rSh.SetFrmFmt( pFmt );
465 RESOURCE_TYPE nResId = 0;
466 switch( nError )
468 case GRFILTER_OPENERROR:
469 nResId = STR_GRFILTER_OPENERROR;
470 break;
471 case GRFILTER_IOERROR:
472 nResId = STR_GRFILTER_IOERROR;
473 break;
474 case GRFILTER_FORMATERROR:
475 nResId = STR_GRFILTER_FORMATERROR;
476 break;
477 case GRFILTER_VERSIONERROR:
478 nResId = STR_GRFILTER_VERSIONERROR;
479 break;
480 case GRFILTER_FILTERERROR:
481 nResId = STR_GRFILTER_FILTERERROR;
482 break;
483 case GRFILTER_TOOBIG:
484 nResId = STR_GRFILTER_TOOBIG;
485 break;
488 rSh.EndAction();
489 rSh.UnlockPaint();
490 if( nResId )
492 if( bShowError )
494 InfoBox aInfoBox( GetWindow(), SW_RESSTR( nResId ));
495 aInfoBox.Execute();
497 rReq.Ignore();
499 else
501 // set the specific graphic attrbutes to the graphic
502 bReturn = TRUE;
503 AutoCaption( GRAPHIC_CAP );
504 rReq.Done();
507 rSh.EndUndo(UNDO_INSERT); // wegen moegl. Shellwechsel
510 delete pFileDlg;
512 return bReturn;
516 void __EXPORT SwView::Execute(SfxRequest &rReq)
518 USHORT nSlot = rReq.GetSlot();
519 const SfxItemSet* pArgs = rReq.GetArgs();
520 const SfxPoolItem* pItem;
521 BOOL bIgnore = FALSE;
522 switch( nSlot )
524 case SID_CREATE_SW_DRAWVIEW:
525 // --> OD 2005-08-08 #i52858# - method name changed
526 pWrtShell->getIDocumentDrawModelAccess()->GetOrCreateDrawModel();
527 // <--
528 break;
530 case FN_LINE_NUMBERING_DLG:
532 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
533 DBG_ASSERT(pFact, "Dialogdiet fail!");
534 VclAbstractDialog* pDlg = pFact->CreateVclSwViewDialog( DLG_LINE_NUMBERING, *this);
535 DBG_ASSERT(pDlg, "Dialogdiet fail!");
536 pDlg->Execute();
537 delete pDlg;
538 break;
540 case FN_EDIT_LINK_DLG:
541 EditLinkDlg();
542 break;
543 case FN_REFRESH_VIEW:
544 GetEditWin().Invalidate();
545 break;
546 case FN_PAGEUP:
547 case FN_PAGEUP_SEL:
548 case FN_PAGEDOWN:
549 case FN_PAGEDOWN_SEL:
551 Rectangle aVis( GetVisArea() );
552 SwEditWin& rTmpWin = GetEditWin();
553 if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot )
554 PageUpCrsr(FN_PAGEUP_SEL == nSlot);
555 else
556 PageDownCrsr(FN_PAGEDOWN_SEL == nSlot);
558 rReq.SetReturnValue(SfxBoolItem(nSlot,
559 aVis != GetVisArea()));
560 //#i42732# - notify the edit window that from now on we do not use the input language
561 rTmpWin.SetUseInputLanguage( sal_False );
563 break;
564 case FN_REDLINE_ON:
566 if( pArgs &&
567 SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem ))
569 IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess();
570 Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
571 if( aPasswd.getLength() )
573 DBG_ASSERT( !((const SfxBoolItem*)pItem)->GetValue(), "SwView::Execute(): password set an redlining off doesn't match!" );
574 // xmlsec05: new password dialog
575 Window* pParent;
576 const SfxPoolItem* pParentItem;
577 if( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_PARENTWINDOW, FALSE, &pParentItem ) )
578 pParent = ( Window* ) ( ( const OfaPtrItem* ) pParentItem )->GetValue();
579 else
580 pParent = &GetViewFrame()->GetWindow();
581 SfxPasswordDialog aPasswdDlg( pParent );
582 //#i69751# the result of Execute() can be ignored
583 aPasswdDlg.Execute();
584 String sNewPasswd( aPasswdDlg.GetPassword() );
585 Sequence <sal_Int8> aNewPasswd = pIDRA->GetRedlinePassword();
586 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
587 if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
588 pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
589 else
590 { // xmlsec05: message box for wrong password
591 break;
595 USHORT nOn = ((const SfxBoolItem*)pItem)->GetValue() ? nsRedlineMode_t::REDLINE_ON : 0;
596 USHORT nMode = pWrtShell->GetRedlineMode();
597 pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
600 break;
601 case FN_REDLINE_PROTECT :
603 IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess();
604 Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
605 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem )
606 && ((SfxBoolItem*)pItem)->GetValue() == ( aPasswd.getLength() != 0 ) )
607 break;
609 // xmlsec05: new password dialog
610 // message box for wrong password
611 Window* pParent;
612 const SfxPoolItem* pParentItem;
613 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_PARENTWINDOW, FALSE, &pParentItem ) )
614 pParent = ( Window* ) ( ( const OfaPtrItem* ) pParentItem )->GetValue();
615 else
616 pParent = &GetViewFrame()->GetWindow();
617 SfxPasswordDialog aPasswdDlg( pParent );
618 if(!aPasswd.getLength())
619 aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
620 if (aPasswdDlg.Execute())
622 USHORT nOn = nsRedlineMode_t::REDLINE_ON;
623 String sNewPasswd( aPasswdDlg.GetPassword() );
624 Sequence <sal_Int8> aNewPasswd =
625 pIDRA->GetRedlinePassword();
626 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
627 if(!aPasswd.getLength())
629 pIDRA->SetRedlinePassword(aNewPasswd);
631 else if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
633 pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
634 nOn = 0;
636 USHORT nMode = pIDRA->GetRedlineMode();
637 pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
638 rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, ((nMode&nsRedlineMode_t::REDLINE_ON)==0) ) );
640 else
641 bIgnore = TRUE;
643 break;
644 case FN_REDLINE_SHOW:
646 if( pArgs &&
647 SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem))
649 USHORT nMode = ( ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)
650 & pWrtShell->GetRedlineMode() ) | nsRedlineMode_t::REDLINE_SHOW_INSERT;
651 if( ((const SfxBoolItem*)pItem)->GetValue() )
652 nMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
654 pWrtShell->SetRedlineModeAndCheckInsMode( nMode );
656 break;
657 case FN_MAILMERGE_SENDMAIL_CHILDWINDOW:
658 case FN_REDLINE_ACCEPT:
659 GetViewFrame()->ToggleChildWindow(nSlot);
660 break;
661 case FN_REDLINE_ACCEPT_DIRECT:
662 case FN_REDLINE_REJECT_DIRECT:
664 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE );
665 Point aCrsrPos = pWrtShell->GetCrsrDocPos( sal_True );
666 if( pWrtShell->GetContentAtPos( aCrsrPos, aCntntAtPos ) )
668 USHORT nCount = pWrtShell->GetRedlineCount();
669 for( USHORT nRedline = 0; nRedline < nCount; ++nRedline )
671 const SwRedline& rRedline = pWrtShell->GetRedline( nRedline );
672 if( *aCntntAtPos.aFnd.pRedl == rRedline )
674 if( FN_REDLINE_ACCEPT_DIRECT == nSlot )
675 pWrtShell->AcceptRedline( nRedline );
676 else
677 pWrtShell->RejectRedline( nRedline );
678 break;
683 break;
684 case SID_DOCUMENT_COMPARE:
685 case SID_DOCUMENT_MERGE:
687 String sFileName, sFilterName;
688 INT16 nVersion = 0;
689 bool bHasFileName = false;
690 pViewImpl->SetParam( 0 );
692 if( pArgs )
694 if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILE_NAME, FALSE, &pItem ))
695 sFileName = ((const SfxStringItem*)pItem)->GetValue();
696 bHasFileName = ( sFileName.Len() > 0 );
698 if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILTER_NAME, FALSE, &pItem ))
699 sFilterName = ((const SfxStringItem*)pItem)->GetValue();
701 if( SFX_ITEM_SET == pArgs->GetItemState( SID_VERSION, FALSE, &pItem ))
703 nVersion = ((const SfxInt16Item *)pItem)->GetValue();
704 pViewImpl->SetParam( nVersion );
708 pViewImpl->InitRequest( rReq );
709 long nFound = InsertDoc( nSlot, sFileName, sFilterName, nVersion );
711 if ( bHasFileName )
713 rReq.SetReturnValue( SfxInt32Item( nSlot, nFound ));
715 if (nFound > 0) // Redline-Browser anzeigen
717 SfxViewFrame* pVFrame = GetViewFrame();
718 pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
720 // RedlineDlg neu initialisieren
721 USHORT nId = SwRedlineAcceptChild::GetChildWindowId();
722 SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)
723 pVFrame->GetChildWindow(nId);
724 if (pRed)
725 pRed->ReInitDlg(GetDocShell());
728 else
729 bIgnore = TRUE;
731 break;
732 case FN_SYNC_LABELS:
733 case FN_MAILMERGE_CHILDWINDOW:
734 GetViewFrame()->ShowChildWindow(nSlot, TRUE);
735 break;
736 case FN_ESCAPE:
738 if ( pWrtShell->HasDrawView() && pWrtShell->GetDrawView()->IsDragObj() )
740 pWrtShell->BreakDrag();
741 pWrtShell->EnterSelFrmMode();
743 else if ( pWrtShell->IsDrawCreate() )
745 GetDrawFuncPtr()->BreakCreate();
746 AttrChangedNotify(pWrtShell); // ggf Shellwechsel...
748 else if ( pWrtShell->HasSelection() || IsDrawMode() )
750 SdrView *pSdrView = pWrtShell->HasDrawView() ? pWrtShell->GetDrawView() : 0;
751 if(pSdrView && pSdrView->AreObjectsMarked() &&
752 pSdrView->GetHdlList().GetFocusHdl())
754 ((SdrHdlList&)pSdrView->GetHdlList()).ResetFocusHdl();
756 else
758 if(pSdrView)
760 LeaveDrawCreate();
761 Point aPt(LONG_MIN, LONG_MIN);
762 //go out of the frame
763 pWrtShell->SelectObj(aPt, SW_LEAVE_FRAME);
764 SfxBindings& rBind = GetViewFrame()->GetBindings();
765 rBind.Invalidate( SID_ATTR_SIZE );
767 pWrtShell->EnterStdMode();
768 AttrChangedNotify(pWrtShell); // ggf Shellwechsel...
771 else if ( GetEditWin().GetApplyTemplate() )
773 GetEditWin().SetApplyTemplate(SwApplyTemplate());
775 else if( ((SfxObjectShell*)GetDocShell())->IsInPlaceActive() )
777 Escape();
779 else if ( GetEditWin().IsChainMode() )
781 GetEditWin().SetChainMode( FALSE );
783 else if( pWrtShell->GetFlyFrmFmt() )
785 const SwFrmFmt* pFmt = pWrtShell->GetFlyFrmFmt();
786 if(pWrtShell->GotoFly( pFmt->GetName(), FLYCNTTYPE_FRM ))
788 pWrtShell->HideCrsr();
789 pWrtShell->EnterSelFrmMode();
792 else
794 SfxBoolItem aItem( SID_WIN_FULLSCREEN, FALSE );
795 GetViewFrame()->GetDispatcher()->Execute( SID_WIN_FULLSCREEN, SFX_CALLMODE_RECORD, &aItem, 0L );
796 bIgnore = TRUE;
799 break;
800 case SID_ATTR_BORDER_INNER:
801 case SID_ATTR_BORDER_OUTER:
802 case SID_ATTR_BORDER_SHADOW:
803 if(pArgs)
804 pWrtShell->SetAttr(*pArgs);
805 break;
807 case SID_ATTR_PAGE:
808 case SID_ATTR_PAGE_SIZE:
809 case SID_ATTR_PAGE_MAXSIZE:
810 case SID_ATTR_PAGE_PAPERBIN:
811 case SID_ATTR_PAGE_EXT1:
812 case FN_PARAM_FTN_INFO:
814 if(pArgs)
816 const USHORT nCurIdx = pWrtShell->GetCurPageDesc();
817 SwPageDesc aPageDesc( pWrtShell->GetPageDesc( nCurIdx ) );
818 ::ItemSetToPageDesc( *pArgs, aPageDesc );
819 // Den Descriptor der Core veraendern.
820 pWrtShell->ChgPageDesc( nCurIdx, aPageDesc );
823 break;
824 case FN_NAVIGATION_PI_GOTO_PAGE:
826 SfxViewFrame* pVFrame = GetViewFrame();
827 SfxChildWindow* pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
828 if(!pCh)
830 pVFrame->ToggleChildWindow( SID_NAVIGATOR );
831 pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
834 ((SwNavigationPI*) pCh->GetContextWindow(SW_MOD()))->GotoPage();
836 break;
837 case FN_EDIT_CURRENT_TOX:
839 GetViewFrame()->GetDispatcher()->Execute(
840 FN_INSERT_MULTI_TOX, SFX_CALLMODE_ASYNCHRON);
842 break;
843 case FN_UPDATE_CUR_TOX:
845 const SwTOXBase* pBase = pWrtShell->GetCurTOX();
846 if(pBase)
848 pWrtShell->StartAction();
849 if(TOX_INDEX == pBase->GetType())
850 pWrtShell->ApplyAutoMark();
851 pWrtShell->UpdateTableOf( *pBase );
852 pWrtShell->EndAction();
855 break;
856 case FN_UPDATE_TOX:
858 pWrtShell->StartAction();
859 pWrtShell->EnterStdMode();
860 BOOL bOldCrsrInReadOnly = pWrtShell->IsReadOnlyAvailable();
861 pWrtShell->SetReadOnlyAvailable( TRUE );
863 for( USHORT i = 0; i < 2; ++i )
865 USHORT nCount = pWrtShell->GetTOXCount();
866 if( 1 == nCount )
867 ++i;
869 while( pWrtShell->GotoPrevTOXBase() )
870 ; // aufs erste Verzeichnis springen
872 // falls wir nicht mehr in einem stehen, dann zum naechsten
873 // springen.
874 const SwTOXBase* pBase = pWrtShell->GetCurTOX();
875 if( !pBase )
877 pWrtShell->GotoNextTOXBase();
878 pBase = pWrtShell->GetCurTOX();
881 BOOL bAutoMarkApplied = FALSE;
882 while( pBase )
884 if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied)
886 pWrtShell->ApplyAutoMark();
887 bAutoMarkApplied = TRUE;
889 // JP 15.07.96: das pBase wird nur fuer die Schnittstelle
890 // benoetigt. Muss mal umgetstellt werden!!!
891 pWrtShell->UpdateTableOf( *pBase );
893 if( pWrtShell->GotoNextTOXBase() )
894 pBase = pWrtShell->GetCurTOX();
895 else
896 pBase = 0;
899 pWrtShell->SetReadOnlyAvailable( bOldCrsrInReadOnly );
900 pWrtShell->EndAction();
902 break;
903 case SID_ATTR_BRUSH:
905 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_BACKGROUND, FALSE, &pItem))
907 const USHORT nCurIdx = pWrtShell->GetCurPageDesc();
908 SwPageDesc aDesc( pWrtShell->GetPageDesc( nCurIdx ));
909 SwFrmFmt& rMaster = aDesc.GetMaster();
910 rMaster.SetFmtAttr(*pItem);
911 pWrtShell->ChgPageDesc( nCurIdx, aDesc);
914 break;
915 case SID_CLEARHISTORY:
917 pWrtShell->DelAllUndoObj();
919 break;
920 case SID_UNDO:
922 pShell->ExecuteSlot(rReq);
924 break;
925 case FN_INSERT_CTRL:
926 case FN_INSERT_OBJ_CTRL:
928 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem))
930 USHORT nValue = ((SfxUInt16Item*)pItem)->GetValue();
931 switch ( nSlot )
933 case FN_INSERT_CTRL:
935 BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
936 if(bWeb)
937 SwView::nWebInsertCtrlState = nValue;
938 else
939 SwView::nInsertCtrlState = nValue;
941 break;
942 case FN_INSERT_OBJ_CTRL: SwView::nInsertObjectCtrlState = nValue ;break;
946 GetViewFrame()->GetBindings().Invalidate( nSlot );
948 break;
949 #if defined WIN || defined WNT || defined UNX
950 case SID_TWAIN_SELECT:
951 case SID_TWAIN_TRANSFER:
952 GetViewImpl()->ExecuteScan( rReq );
953 break;
954 #endif
956 case SID_ATTR_DEFTABSTOP:
958 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_DEFTABSTOP, FALSE, &pItem))
960 SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
961 USHORT nTab = ((const SfxUInt16Item*)pItem)->GetValue();
962 MakeDefTabs( nTab, aDefTabs );
963 pWrtShell->SetDefault( aDefTabs );
966 break;
967 case SID_ATTR_LANGUAGE :
968 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_LANGUAGE, FALSE, &pItem))
970 SvxLanguageItem aLang(((SvxLanguageItem*)pItem)->GetLanguage(), RES_CHRATR_LANGUAGE);
971 pWrtShell->SetDefault( aLang );
972 lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_LANGUAGE );
974 break;
975 case SID_ATTR_CHAR_CTL_LANGUAGE:
976 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CTL_LANGUAGE, FALSE, &pItem))
978 pWrtShell->SetDefault( *pItem );
979 lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_CTL_LANGUAGE );
981 break;
982 case SID_ATTR_CHAR_CJK_LANGUAGE:
983 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CJK_LANGUAGE, FALSE, &pItem))
985 pWrtShell->SetDefault( *pItem );
986 lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_CJK_LANGUAGE );
988 break;
989 case FN_SCROLL_NEXT_PREV:
990 if(pArgs && pArgs->GetItemState(FN_SCROLL_NEXT_PREV, FALSE, &pItem))
992 // call the handlers of PageUp/DownButtons, only
993 bool* pbNext = new bool ( ((const SfxBoolItem*)pItem)->GetValue() );
994 // #i75416# move the execution of the search to an asynchronously called static link
995 Application::PostUserEvent( STATIC_LINK(this, SwView, MoveNavigationHdl), pbNext );
997 break;
998 case SID_JUMPTOMARK:
999 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_JUMPTOMARK, FALSE, &pItem))
1000 JumpToSwMark( (( const SfxStringItem*)pItem)->GetValue() );
1001 break;
1002 case SID_GALLERY :
1003 GetViewFrame()->ChildWindowExecute(rReq);//ToggleChildWindow(SID_GALLERY);
1004 break;
1005 case SID_AVMEDIA_PLAYER :
1006 GetViewFrame()->ChildWindowExecute(rReq);//ToggleChildWindow(SID_AVMEDIA_PLAYER);
1007 break;
1008 case SID_VIEW_DATA_SOURCE_BROWSER:
1010 SfxViewFrame* pVFrame = GetViewFrame();
1011 pVFrame->ChildWindowExecute(rReq);
1012 if(pVFrame->HasChildWindow(SID_BROWSER))
1014 const SwDBData& rData = GetWrtShell().GetDBDesc();
1015 SW_MOD()->ShowDBObj(*this, rData, FALSE);
1018 break;
1019 case FN_INSERT_FIELD_DATA_ONLY :
1021 BOOL bShow = FALSE;
1022 if( pArgs &&
1023 SFX_ITEM_SET == pArgs->GetItemState(nSlot, FALSE, &pItem ))
1024 bShow = ((const SfxBoolItem*)pItem)->GetValue();
1025 //GetViewFrame()->ShowChildWindow(nSlot, bShow && bInMailMerge);
1026 if((bShow && bInMailMerge) != GetViewFrame()->HasChildWindow(nSlot))
1027 GetViewFrame()->ToggleChildWindow(nSlot);
1028 //if fields have been succesfully inserted call the "real"
1029 //mail merge dialog
1030 SwWrtShell &rSh = GetWrtShell();
1031 if(bInMailMerge && rSh.IsAnyDatabaseFieldInDoc())
1033 SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr();
1034 if (pNewDBMgr)
1036 SwDBData aData;
1037 aData = rSh.GetDBData();
1038 rSh.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer
1039 // das Mischen von DB-Feldern notwendig.
1040 AttrChangedNotify( &rSh );
1041 pNewDBMgr->SetMergeType( DBMGR_MERGE );
1043 Sequence<PropertyValue> aProperties(3);
1044 PropertyValue* pValues = aProperties.getArray();
1045 pValues[0].Name = C2U("DataSourceName");
1046 pValues[1].Name = C2U("Command");
1047 pValues[2].Name = C2U("CommandType");
1048 pValues[0].Value <<= aData.sDataSource;
1049 pValues[1].Value <<= aData.sCommand;
1050 pValues[2].Value <<= aData.nCommandType;
1051 pNewDBMgr->ExecuteFormLetter(rSh, aProperties, TRUE);
1054 bInMailMerge &= bShow;
1055 GetViewFrame()->GetBindings().Invalidate(FN_INSERT_FIELD);
1057 break;
1058 case FN_QRY_MERGE:
1060 BOOL bUseCurrentDocument = TRUE;
1061 BOOL bQuery = !pArgs||SFX_ITEM_SET != pArgs->GetItemState(nSlot);
1062 if(bQuery)
1064 SfxViewFrame* pTmpFrame = GetViewFrame();
1065 SfxHelp::OpenHelpAgent( pTmpFrame->GetFrame(), HID_MAIL_MERGE_SELECT );
1066 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1067 DBG_ASSERT(pFact, "Dialogdiet fail!");
1068 AbstractMailMergeCreateFromDlg* pDlg = pFact->CreateMailMergeCreateFromDlg( DLG_MERGE_CREATE,
1069 &pTmpFrame->GetWindow());
1070 DBG_ASSERT(pDlg, "Dialogdiet fail!");
1071 if(RET_OK == pDlg->Execute())
1072 bUseCurrentDocument = pDlg->IsThisDocument();
1073 else
1074 break;
1076 GenerateFormLetter(bUseCurrentDocument);
1078 break;
1079 case SID_RECHECK_DOCUMENT:
1081 SwDocShell* pDocShell = GetDocShell();
1082 SwDoc* pDoc = pDocShell->GetDoc();
1083 uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() );
1084 if( xGCIterator.is() )
1086 xGCIterator->resetIgnoreRules();
1088 // reset ignore lists
1089 pDoc->SpellItAgainSam( sal_True, sal_False, sal_False );
1090 // clear ignore dictionary
1091 uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY );
1092 if( xDictionary.is() )
1093 xDictionary->clear();
1094 // put cursor to the start of the document
1095 pWrtShell->SttDoc();
1097 // no break; - but call spell/grammar dialog
1098 case FN_SPELL_GRAMMAR_DIALOG:
1100 SfxViewFrame* pViewFrame = GetViewFrame();
1101 if (rReq.GetArgs() != NULL)
1102 pViewFrame->SetChildWindow (FN_SPELL_GRAMMAR_DIALOG,
1103 ((const SfxBoolItem&) (rReq.GetArgs()->
1104 Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue());
1105 else
1106 pViewFrame->ToggleChildWindow(FN_SPELL_GRAMMAR_DIALOG);
1108 pViewFrame->GetBindings().Invalidate(FN_SPELL_GRAMMAR_DIALOG);
1109 rReq.Ignore ();
1111 break;
1112 case SID_ALIGN_ANY_LEFT :
1113 case SID_ALIGN_ANY_HCENTER :
1114 case SID_ALIGN_ANY_RIGHT :
1115 case SID_ALIGN_ANY_JUSTIFIED:
1116 case SID_ALIGN_ANY_TOP :
1117 case SID_ALIGN_ANY_VCENTER :
1118 case SID_ALIGN_ANY_BOTTOM :
1119 case SID_ALIGN_ANY_HDEFAULT :
1120 case SID_ALIGN_ANY_VDEFAULT :
1122 USHORT nAlias = 0;
1123 if( nSelectionType & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_TXT) )
1125 switch( nSlot )
1127 case SID_ALIGN_ANY_LEFT : nAlias = SID_ATTR_PARA_ADJUST_LEFT; break;
1128 case SID_ALIGN_ANY_HCENTER : nAlias = SID_ATTR_PARA_ADJUST_CENTER; break;
1129 case SID_ALIGN_ANY_RIGHT : nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break;
1130 case SID_ALIGN_ANY_JUSTIFIED: nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break;
1131 case SID_ALIGN_ANY_TOP : nAlias = FN_TABLE_VERT_NONE; break;
1132 case SID_ALIGN_ANY_VCENTER : nAlias = FN_TABLE_VERT_CENTER; break;
1133 case SID_ALIGN_ANY_BOTTOM : nAlias = FN_TABLE_VERT_BOTTOM; break;
1136 else
1138 switch( nSlot )
1140 case SID_ALIGN_ANY_LEFT : nAlias = SID_OBJECT_ALIGN_LEFT ; break;
1141 case SID_ALIGN_ANY_HCENTER : nAlias = SID_OBJECT_ALIGN_CENTER ; break;
1142 case SID_ALIGN_ANY_RIGHT : nAlias = SID_OBJECT_ALIGN_RIGHT ; break;
1143 case SID_ALIGN_ANY_TOP : nAlias = SID_OBJECT_ALIGN_UP ; break;
1144 case SID_ALIGN_ANY_VCENTER : nAlias = SID_OBJECT_ALIGN_MIDDLE ; break;
1145 case SID_ALIGN_ANY_BOTTOM : nAlias = SID_OBJECT_ALIGN_DOWN ; break;
1148 //special handling for the draw shell
1149 if(nAlias && (nSelectionType & (nsSelectionType::SEL_DRW)))
1151 SfxAllEnumItem aEnumItem(SID_OBJECT_ALIGN, nAlias - SID_OBJECT_ALIGN_LEFT);
1152 GetViewFrame()->GetDispatcher()->Execute(
1153 SID_OBJECT_ALIGN, SFX_CALLMODE_ASYNCHRON, &aEnumItem, 0L);
1155 else if(nAlias)
1156 //these slots are either re-mapped to text or object alignment
1157 GetViewFrame()->GetDispatcher()->Execute(
1158 nAlias, SFX_CALLMODE_ASYNCHRON);
1160 break;
1161 case SID_RESTORE_EDITING_VIEW:
1163 //#i33307# restore editing position
1164 Point aCrsrPos;
1165 bool bSelectObj;
1166 if(pViewImpl->GetRestorePosition(aCrsrPos, bSelectObj))
1168 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1169 if( bSelectObj )
1171 pWrtShell->SelectObj( aCrsrPos );
1172 pWrtShell->EnterSelFrmMode( &aCrsrPos );
1176 break;
1177 case SID_INSERT_GRAPHIC:
1179 rReq.SetReturnValue(SfxBoolItem(nSlot, InsertGraphicDlg( rReq )));
1181 break;
1184 default:
1185 ASSERT(!this, falscher Dispatcher);
1186 return;
1188 if(!bIgnore)
1189 rReq.Done();
1192 /*--------------------------------------------------------------------
1193 Beschreibung: SeitenNr-Feld invalidieren
1194 --------------------------------------------------------------------*/
1196 void SwView::UpdatePageNums(USHORT nPhyNum, USHORT nVirtNum, const String& rPgStr)
1198 String sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr ));
1199 const SfxStringItem aTmp( FN_STAT_PAGE, sTemp );
1200 SfxBindings &rBnd = GetViewFrame()->GetBindings();
1201 rBnd.SetState( aTmp );
1202 rBnd.Update( FN_STAT_PAGE );
1205 /*--------------------------------------------------------------------
1206 Beschreibung: Status der Stauszeile
1207 --------------------------------------------------------------------*/
1210 void SwView::StateStatusLine(SfxItemSet &rSet)
1212 SwWrtShell& rShell = GetWrtShell();
1214 SfxWhichIter aIter( rSet );
1215 USHORT nWhich = aIter.FirstWhich();
1216 ASSERT( nWhich, "leeres Set");
1218 while( nWhich )
1220 switch( nWhich )
1222 case FN_STAT_PAGE:
1224 //JP 07.01.00: is a nice feature - show the selektion of DrawObjects
1225 if( rShell.IsObjSelected()
1226 //??? || rShell.IsFrmSelected()
1229 String sDisplay( rShell.GetDrawView()->GetMarkedObjectList().
1230 GetDescriptionOfMarkedObjects() );
1231 rSet.Put( SfxStringItem( FN_STAT_PAGE, sDisplay ));
1233 else
1234 */ {
1235 // Anzahl der Seiten, log. SeitenNr. SeitenNr ermitteln
1236 USHORT nPage, nLogPage;
1237 String sDisplay;
1238 rShell.GetPageNumber( -1, rShell.IsCrsrVisible(), nPage, nLogPage, sDisplay );
1239 rSet.Put( SfxStringItem( FN_STAT_PAGE,
1240 GetPageStr( nPage, nLogPage, sDisplay) ));
1242 USHORT nCnt = GetWrtShell().GetPageCnt();
1243 if (nPageCnt != nCnt) // Basic benachrichtigen
1245 nPageCnt = nCnt;
1246 SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), FALSE);
1249 break;
1250 case FN_STAT_TEMPLATE:
1252 rSet.Put(SfxStringItem( FN_STAT_TEMPLATE,
1253 rShell.GetCurPageStyle(FALSE)));
1256 break;
1257 case SID_ATTR_ZOOM:
1259 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1261 const SwViewOption* pVOpt = rShell.GetViewOptions();
1262 SvxZoomType eZoom = (SvxZoomType) pVOpt->GetZoomType();
1263 SvxZoomItem aZoom(eZoom, pVOpt->GetZoom());
1264 if(pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE))
1266 aZoom.SetValueSet(
1267 SVX_ZOOM_ENABLE_50|
1268 SVX_ZOOM_ENABLE_75|
1269 SVX_ZOOM_ENABLE_100|
1270 SVX_ZOOM_ENABLE_150|
1271 SVX_ZOOM_ENABLE_200);
1273 rSet.Put( aZoom );
1275 else
1276 rSet.DisableItem( SID_ATTR_ZOOM );
1278 break;
1279 case SID_ATTR_VIEWLAYOUT:
1281 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1283 const SwViewOption* pVOpt = rShell.GetViewOptions();
1284 const USHORT nColumns = pVOpt->GetViewLayoutColumns();
1285 const bool bBookMode = pVOpt->IsViewLayoutBookMode();
1286 SvxViewLayoutItem aViewLayout(nColumns, bBookMode);
1287 rSet.Put( aViewLayout );
1289 else
1290 rSet.DisableItem( SID_ATTR_VIEWLAYOUT );
1292 break;
1293 case SID_ATTR_ZOOMSLIDER:
1295 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1297 const SwViewOption* pVOpt = rShell.GetViewOptions();
1298 const USHORT nCurrentZoom = pVOpt->GetZoom();
1299 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
1300 aZoomSliderItem.AddSnappingPoint( 100 );
1302 if ( !pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
1304 const USHORT nColumns = pVOpt->GetViewLayoutColumns();
1305 const bool bAutomaticViewLayout = 0 == nColumns;
1306 const SwPostItMgr* pMgr = GetPostItMgr();
1308 // snapping points:
1309 // automatic mode: 1 Page, 2 Pages, 100%
1310 // n Columns mode: n Pages, 100%
1311 // n Columns book mode: nPages without gaps, 100%
1312 const SwRect aPageRect( pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) );
1313 const SwRect aRootRect( pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) ); // width of columns
1314 Size aPageSize( aPageRect.SSize() );
1315 aPageSize.Width() += pMgr->HasNotes() && pMgr->ShowNotes() ?
1316 pMgr->GetSidebarWidth() + pMgr->GetSidebarBorderWidth() :
1319 Size aRootSize( aRootRect.SSize() );
1321 const MapMode aTmpMap( MAP_TWIP );
1322 const Size& rEditSize = GetEditWin().GetOutputSizePixel();
1323 const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
1325 const long nOf = DOCUMENTBORDER * 2L;
1326 long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
1327 nTmpWidth += nOf;
1328 aPageSize.Height() += nOf;
1329 long nFac = aWindowSize.Width() * 100 / nTmpWidth;
1331 long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
1332 nFac = Min( nFac, nVisPercent );
1334 aZoomSliderItem.AddSnappingPoint( nFac );
1336 if ( bAutomaticViewLayout )
1338 nTmpWidth += aPageSize.Width() + GAPBETWEENPAGES;
1339 nFac = aWindowSize.Width() * 100 / nTmpWidth;
1340 nFac = Min( nFac, nVisPercent );
1341 aZoomSliderItem.AddSnappingPoint( nFac );
1345 rSet.Put( aZoomSliderItem );
1347 else
1348 rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
1350 break;
1351 case SID_ATTR_POSITION:
1352 case SID_ATTR_SIZE:
1354 if( !rShell.IsFrmSelected() && !rShell.IsObjSelected() )
1355 SwBaseShell::_SetFrmMode( FLY_DRAG_END );
1356 else
1358 FlyMode eFrameMode = SwBaseShell::GetFrmMode();
1359 if ( eFrameMode == FLY_DRAG_START || eFrameMode == FLY_DRAG )
1361 if ( nWhich == SID_ATTR_POSITION )
1362 rSet.Put( SfxPointItem( SID_ATTR_POSITION,
1363 rShell.GetAnchorObjDiff()));
1364 else
1365 rSet.Put( SvxSizeItem( SID_ATTR_SIZE,
1366 rShell.GetObjSize()));
1370 break;
1371 case SID_TABLE_CELL:
1373 if( rShell.IsFrmSelected() || rShell.IsObjSelected() )
1375 // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem.
1376 // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot
1377 // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied
1378 // in SID_ATTR_SIZE).
1380 else
1382 String sStr;
1383 if( rShell.IsCrsrInTbl() )
1385 // table name + cell coordinate
1386 sStr = rShell.GetTableFmt()->GetName();
1387 sStr += ':';
1388 sStr += rShell.GetBoxNms();
1390 else
1392 const SwSection* pCurrSect = rShell.GetCurrSection();
1393 if( pCurrSect )
1395 switch( pCurrSect->GetType() )
1397 case TOX_HEADER_SECTION:
1398 case TOX_CONTENT_SECTION:
1400 const SwTOXBase* pTOX = pWrtShell->GetCurTOX();
1401 if( pTOX )
1402 sStr = pTOX->GetTOXName();
1403 else
1405 ASSERT( !this,
1406 "was ist das fuer ein Verzeichnis?" );
1407 sStr = pCurrSect->GetName();
1410 break;
1411 default:
1412 sStr = pCurrSect->GetName();
1413 break;
1418 //#outline level, removed by zhaojianwei
1419 //const SwNumRule* pNumRule = rShell.GetCurNumRule();
1420 //if (pNumRule) // Cursor in Numerierung
1422 // BYTE nNumLevel = rShell.GetNumLevel();
1423 // if( IsShowNum(nNumLevel) && MAXLEVEL >
1424 // ( nNumLevel = GetRealLevel( nNumLevel )) )
1425 // {
1426 // if( sStr.Len() )
1427 // sStr.AppendAscii(sStatusDelim);
1428 // sStr += SW_RESSTR(STR_NUM_LEVEL);
1429 // sStr += String::CreateFromInt32( nNumLevel + 1 );
1430 // if(!pNumRule->IsAutoRule())
1431 // {
1432 // SfxItemSet aSet(GetPool(),
1433 // RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
1434 // rShell.GetCurAttr(aSet);
1435 // /* const SfxPoolItem* pItem; */
1436 // if(SFX_ITEM_AVAILABLE <=
1437 // aSet.GetItemState(RES_PARATR_NUMRULE, TRUE
1438 // /*, &pItem */ ))
1439 // {
1440 // const String& rNumStyle =
1441 // ((const SfxStringItem &)
1442 // aSet.Get(RES_PARATR_NUMRULE)).GetValue();
1443 // /* #i5116# GetItemState does not necessarily
1444 // change pItem */
1445 // // ((const SfxStringItem*)pItem)->GetValue();
1446 // if(rNumStyle.Len())
1447 // {
1448 // sStr.AppendAscii(sStatusDelim);
1449 // sStr += rNumStyle;
1450 // }
1451 // }
1452 // }
1453 // }
1454 //}//<-removed end ,zhaojianwei
1456 //-->#outline level,added by zhaojianwei
1457 const SwNumRule* pNumRule = rShell.GetCurNumRule();
1458 const bool bOutlineNum = pNumRule ? pNumRule->IsOutlineRule() : 0;
1459 //((SwTxtFmtColl*)rShell.GetCrsr()->GetNode()->GetTxtNode()->GetFmtColl())->IsAssignedToListLevelOfOutlineStyle();
1461 if (pNumRule && !bOutlineNum ) // Cursor in Numerierung
1463 BYTE nNumLevel = rShell.GetNumLevel();
1464 // --> OD 2008-04-02 #refactorlists#
1465 // if( IsShowNum(nNumLevel) && MAXLEVEL >
1466 // ( nNumLevel = GetRealLevel( nNumLevel )) )
1467 if ( nNumLevel < MAXLEVEL )
1468 // <--
1470 if(!pNumRule->IsAutoRule())
1472 SfxItemSet aSet(GetPool(),
1473 RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
1474 rShell.GetCurAttr(aSet);
1475 /* const SfxPoolItem* pItem; */
1476 if(SFX_ITEM_AVAILABLE <=
1477 aSet.GetItemState(RES_PARATR_NUMRULE, TRUE
1478 /*, &pItem */ ))
1480 const String& rNumStyle =
1481 ((const SfxStringItem &)
1482 aSet.Get(RES_PARATR_NUMRULE)).GetValue();
1483 /* #i5116# GetItemState does not necessarily
1484 change pItem */
1485 // ((const SfxStringItem*)pItem)->GetValue();
1486 if(rNumStyle.Len())
1488 if( sStr.Len() )
1489 sStr.AppendAscii(sStatusDelim);
1490 sStr += rNumStyle;
1494 if( sStr.Len() )
1495 sStr.AppendAscii(sStatusDelim);
1496 sStr += SW_RESSTR(STR_NUM_LEVEL);
1497 sStr += String::CreateFromInt32( nNumLevel + 1 );
1501 const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel();
1502 if( nOutlineLevel != 0 )
1504 if( sStr.Len() )
1505 sStr.AppendAscii(sStatusComma);
1506 if( bOutlineNum )
1508 sStr += SW_RESSTR(STR_OUTLINE_NUMBERING);
1509 sStr.AppendAscii(sStatusDelim);
1510 sStr += SW_RESSTR(STR_NUM_LEVEL);
1512 else
1513 sStr += SW_RESSTR(STR_NUM_OUTLINE);
1514 sStr += String::CreateFromInt32( nOutlineLevel);
1516 //<-end ,zhaojianwei
1518 if( rShell.HasReadonlySel() )
1520 if( sStr.Len() )
1521 sStr.InsertAscii( sStatusDelim, 0 );
1522 sStr.Insert( SW_RESSTR( STR_READONLY_SEL ), 0 );
1524 if( sStr.Len() )
1525 rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr ));
1527 break;
1528 case FN_STAT_SELMODE:
1530 if(rShell.IsStdMode())
1531 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
1532 else if(rShell.IsAddMode())
1533 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 2));
1534 else if(rShell.IsBlockMode())
1535 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 3));
1536 else
1537 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 1));
1538 break;
1540 case SID_ATTR_INSERT:
1541 if( rShell.IsRedlineOn() )
1542 rSet.DisableItem( nWhich );
1543 else
1545 rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode()));
1547 break;
1549 nWhich = aIter.NextWhich();
1553 /*--------------------------------------------------------------------
1554 Beschreibung: Execute fuer die Stauszeile
1555 --------------------------------------------------------------------*/
1558 void SwView::ExecuteStatusLine(SfxRequest &rReq)
1560 SwWrtShell &rSh = GetWrtShell();
1561 const SfxItemSet* pArgs = rReq.GetArgs();
1562 const SfxPoolItem* pItem=NULL;
1563 BOOL bUp = FALSE;
1564 USHORT nWhich = rReq.GetSlot();
1565 switch( nWhich )
1567 case FN_STAT_PAGE:
1569 GetViewFrame()->GetDispatcher()->Execute( SID_NAVIGATOR,
1570 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
1572 break;
1574 case FN_STAT_BOOKMARK:
1575 if ( pArgs )
1577 if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, TRUE, &pItem))
1579 const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess();
1580 const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1581 if(nIdx < pMarkAccess->getBookmarksCount())
1583 const IDocumentMarkAccess::const_iterator_t ppBookmark = rSh.getIDocumentMarkAccess()->getBookmarksBegin() + nIdx;
1584 rSh.EnterStdMode();
1585 rSh.GotoMark( ppBookmark->get() );
1587 else
1588 OSL_ENSURE(false,
1589 "SwView::ExecuteStatusLine(..)"
1590 " - Ignoring out of range bookmark index");
1593 break;
1595 case FN_STAT_TEMPLATE:
1597 GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG,
1598 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
1600 break;
1601 case SID_ATTR_ZOOM:
1603 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1605 const SfxItemSet *pSet = 0;
1606 AbstractSvxZoomDialog *pDlg = 0;
1607 if ( pArgs )
1608 pSet = pArgs;
1609 else
1611 const SwViewOption& rViewOptions = *rSh.GetViewOptions();
1612 SfxItemSet aCoreSet(pShell->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM, SID_ATTR_VIEWLAYOUT, SID_ATTR_VIEWLAYOUT, 0 );
1613 SvxZoomItem aZoom( (SvxZoomType)rViewOptions.GetZoomType(), rViewOptions.GetZoom() );
1615 const bool bBrowseMode = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
1616 if( bBrowseMode )
1618 aZoom.SetValueSet(
1619 SVX_ZOOM_ENABLE_50|
1620 SVX_ZOOM_ENABLE_75|
1621 SVX_ZOOM_ENABLE_100|
1622 SVX_ZOOM_ENABLE_150|
1623 SVX_ZOOM_ENABLE_200);
1625 aCoreSet.Put( aZoom );
1627 // PAGES01
1628 if ( !bBrowseMode )
1630 const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() );
1631 aCoreSet.Put( aViewLayout );
1634 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1635 if(pFact)
1637 pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet, RID_SVXDLG_ZOOM);
1638 DBG_ASSERT(pDlg, "Dialogdiet fail!");
1641 pDlg->SetLimits( MINZOOM, MAXZOOM );
1643 if( pDlg->Execute() != RET_CANCEL )
1644 pSet = pDlg->GetOutputItemSet();
1647 // PAGES01
1648 const SfxPoolItem* pViewLayoutItem = 0;
1649 if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_VIEWLAYOUT, TRUE, &pViewLayoutItem))
1651 const USHORT nColumns = ((const SvxViewLayoutItem *)pViewLayoutItem)->GetValue();
1652 const bool bBookMode = ((const SvxViewLayoutItem *)pViewLayoutItem)->IsBookMode();
1653 SetViewLayout( nColumns, bBookMode );
1656 if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_ZOOM, TRUE, &pItem))
1658 enum SvxZoomType eType = ((const SvxZoomItem *)pItem)->GetType();
1659 SetZoom( eType, ((const SvxZoomItem *)pItem)->GetValue() );
1661 bUp = TRUE;
1662 if ( pItem )
1663 rReq.AppendItem( *pItem );
1664 rReq.Done();
1666 delete pDlg;
1669 break;
1671 case SID_ATTR_VIEWLAYOUT:
1673 if ( pArgs && !rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
1674 ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1676 // PAGES01
1677 if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_VIEWLAYOUT, TRUE, &pItem ))
1679 const USHORT nColumns = ((const SvxViewLayoutItem *)pItem)->GetValue();
1680 const bool bBookMode = (0 == nColumns || 0 != (nColumns % 2)) ?
1681 false :
1682 ((const SvxViewLayoutItem *)pItem)->IsBookMode();
1684 SetViewLayout( nColumns, bBookMode );
1687 bUp = TRUE;
1688 rReq.Done();
1690 InvalidateRulerPos();
1693 break;
1695 case SID_ATTR_ZOOMSLIDER:
1697 if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1699 // PAGES01
1700 if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, TRUE, &pItem ))
1702 const USHORT nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
1703 SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom );
1706 bUp = TRUE;
1707 rReq.Done();
1710 break;
1712 case SID_ATTR_SIZE:
1714 ULONG nId = FN_INSERT_FIELD;
1715 if( rSh.IsCrsrInTbl() )
1716 nId = FN_FORMAT_TABLE_DLG;
1717 else if( rSh.GetCurTOX() )
1718 nId = FN_INSERT_MULTI_TOX;
1719 else if( rSh.GetCurrSection() )
1720 nId = FN_EDIT_REGION;
1721 else
1723 const SwNumRule* pNumRule = rSh.GetCurNumRule();
1724 if( pNumRule ) // Cursor in Numerierung
1726 if( pNumRule->IsAutoRule() )
1727 nId = FN_NUMBER_BULLETS;
1728 else
1730 // Dialog vom Gestalter starten ;-)
1731 nId = 0;
1734 else if( rSh.IsFrmSelected() )
1735 nId = FN_FORMAT_FRAME_DLG;
1736 else if( rSh.IsObjSelected() )
1737 nId = SID_ATTR_TRANSFORM;
1739 if( nId )
1740 GetViewFrame()->GetDispatcher()->Execute(
1741 static_cast< USHORT >( nId ), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
1743 break;
1745 case FN_STAT_SELMODE:
1747 if ( pArgs )
1749 if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, TRUE, &pItem))
1751 switch ( ((const SfxUInt16Item *)pItem)->GetValue() )
1753 case 0: rSh.EnterStdMode(); break;
1754 case 1: rSh.EnterExtMode(); break;
1755 case 2: rSh.EnterAddMode(); break;
1756 case 3: rSh.EnterBlockMode(); break;
1760 else
1763 if( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
1764 rSh.ToggleExtMode();
1765 else if ( rSh.IsExtMode() )
1767 rSh.ToggleExtMode();
1768 rSh.ToggleAddMode();
1770 else if ( rSh.IsAddMode() )
1772 rSh.ToggleAddMode();
1773 rSh.ToggleBlockMode();
1775 else
1776 rSh.ToggleBlockMode();
1778 bUp = TRUE;
1779 break;
1781 case FN_SET_ADD_MODE:
1782 rSh.ToggleAddMode();
1783 nWhich = FN_STAT_SELMODE;
1784 bUp = TRUE;
1785 break;
1786 case FN_SET_BLOCK_MODE:
1787 rSh.ToggleBlockMode();
1788 nWhich = FN_STAT_SELMODE;
1789 bUp = TRUE;
1790 break;
1791 case FN_SET_EXT_MODE:
1792 rSh.ToggleExtMode();
1793 nWhich = FN_STAT_SELMODE;
1794 bUp = TRUE;
1795 break;
1796 case SID_ATTR_INSERT:
1797 SwPostItMgr* pMgr = GetPostItMgr();
1798 if (pMgr && pMgr->GetActivePostIt())
1799 pMgr->GetActivePostIt()->ToggleInsMode();
1800 else
1801 rSh.ToggleInsMode();
1802 bUp = TRUE;
1803 break;
1806 if ( bUp )
1808 SfxBindings &rBnd = GetViewFrame()->GetBindings();
1809 rBnd.Invalidate(nWhich);
1810 rBnd.Update(nWhich);
1817 void SwView::InsFrmMode(USHORT nCols)
1819 if ( pWrtShell->HasWholeTabSelection() )
1821 SwFlyFrmAttrMgr aMgr( TRUE, pWrtShell, FRMMGR_TYPE_TEXT );
1823 const SwFrmFmt &rPageFmt =
1824 pWrtShell->GetPageDesc(pWrtShell->GetCurPageDesc()).GetMaster();
1825 SwTwips lWidth = rPageFmt.GetFrmSize().GetWidth();
1826 const SvxLRSpaceItem &rLR = rPageFmt.GetLRSpace();
1827 lWidth -= rLR.GetLeft() + rLR.GetRight();
1828 aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height()));
1829 if(nCols > 1)
1831 SwFmtCol aCol;
1832 aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
1833 aMgr.SetCol( aCol );
1835 aMgr.InsertFlyFrm();
1837 else
1838 GetEditWin().InsFrm(nCols);
1841 /*--------------------------------------------------------------------
1842 Beschreibung: Links bearbeiten
1843 --------------------------------------------------------------------*/
1845 void SwView::EditLinkDlg()
1847 BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
1848 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1849 SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb );
1850 if ( pDlg )
1852 pDlg->Execute();
1853 delete pDlg;
1856 SwLinkDlg* pDlg = new SwLinkDlg(GetFrameWindow());
1857 pDlg->SetShell(&GetWrtShell());
1858 pDlg->Execute();
1860 DELETEZ(pDlg);
1864 BOOL SwView::JumpToSwMark( const String& rMark )
1866 BOOL bRet = FALSE;
1867 if( rMark.Len() )
1869 // wir wollen den Bookmark aber am oberen Rand haben
1870 BOOL bSaveCC = IsCrsrAtCenter();
1871 BOOL bSaveCT = IsCrsrAtTop();
1872 SetCrsrAtTop( TRUE );
1874 //JP 27.04.98: Bug 49786
1875 // Damit in FrameSet auch gescrollt werden kann, muss die
1876 // entsprechende Shell auch das Focus-Flag gesetzt haben!
1877 BOOL bHasShFocus = pWrtShell->HasShFcs();
1878 if( !bHasShFocus )
1879 pWrtShell->ShGetFcs( FALSE );
1881 const SwFmtINetFmt* pINet;
1882 String sCmp, sMark( INetURLObject::decode( rMark, INET_HEX_ESCAPE,
1883 INetURLObject::DECODE_WITH_CHARSET,
1884 RTL_TEXTENCODING_UTF8 ));
1886 xub_StrLen nLastPos, nPos = sMark.Search( cMarkSeperator );
1887 if( STRING_NOTFOUND != nPos )
1888 while( STRING_NOTFOUND != ( nLastPos =
1889 sMark.Search( cMarkSeperator, nPos + 1 )) )
1890 nPos = nLastPos;
1892 IDocumentMarkAccess::const_iterator_t ppMark;
1893 IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
1894 if( STRING_NOTFOUND != nPos &&
1895 ( sCmp = sMark.Copy( nPos + 1 ) ).EraseAllChars().Len() )
1897 String sName( sMark.Copy( 0, nPos ) );
1898 sCmp.ToLowerAscii();
1899 FlyCntType eFlyType = FLYCNTTYPE_ALL;
1901 if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToRegion ) )
1903 pWrtShell->EnterStdMode();
1904 bRet = pWrtShell->GotoRegion( sName );
1906 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOutline ) )
1908 pWrtShell->EnterStdMode();
1909 bRet = pWrtShell->GotoOutline( sName );
1911 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToFrame ) )
1912 eFlyType = FLYCNTTYPE_FRM;
1913 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToGraphic ) )
1914 eFlyType = FLYCNTTYPE_GRF;
1915 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOLE ) )
1916 eFlyType = FLYCNTTYPE_OLE;
1917 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToTable ) )
1919 pWrtShell->EnterStdMode();
1920 bRet = pWrtShell->GotoTable( sName );
1922 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToText ) )
1924 // Normale Textsuche
1925 pWrtShell->EnterStdMode();
1927 SearchOptions aSearchOpt(
1928 SearchAlgorithms_ABSOLUTE, 0,
1929 sName, rtl::OUString(),
1930 SvxCreateLocale( LANGUAGE_SYSTEM ),
1931 0,0,0,
1932 TransliterationModules_IGNORE_CASE );
1934 //todo/mba: assuming that notes shouldn't be searched
1935 BOOL bSearchInNotes = FALSE;
1936 if( pWrtShell->SearchPattern( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END ))
1938 pWrtShell->EnterStdMode(); // Selektion wieder aufheben
1939 bRet = TRUE;
1942 else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) )
1943 pWrtShell->GotoMark( ppMark->get(), FALSE, TRUE ), bRet = TRUE;
1944 else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) ))
1945 bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
1947 // fuer alle Arten von Flys
1948 if( FLYCNTTYPE_ALL != eFlyType && pWrtShell->GotoFly( sName, eFlyType ))
1950 bRet = TRUE;
1951 if( FLYCNTTYPE_FRM == eFlyType )
1953 // TextFrames: Cursor in den Frame setzen
1954 pWrtShell->UnSelectFrm();
1955 pWrtShell->LeaveSelFrmMode();
1957 else
1959 pWrtShell->HideCrsr();
1960 pWrtShell->EnterSelFrmMode();
1964 else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)))
1965 pWrtShell->GotoMark( ppMark->get(), FALSE, TRUE ), bRet = TRUE;
1966 else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) ))
1967 bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
1969 // #b6330459# make selection visible later
1970 if ( aVisArea.IsEmpty() )
1971 bMakeSelectionVisible = sal_True;
1973 // ViewStatus wieder zurueck setzen
1974 SetCrsrAtTop( bSaveCT, bSaveCC );
1976 if( !bHasShFocus )
1977 pWrtShell->ShLooseFcs();
1979 return bRet;
1982 // #i67305, #1367991: Undo after insert from file:
1983 // Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled
1984 // Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains
1985 // page styles with active header/footer => disabled for those documents
1987 sal_uInt16 lcl_PageDescWithHeader( const SwDoc& rDoc )
1989 sal_uInt16 nRet = 0;
1990 sal_uInt16 nCnt = rDoc.GetPageDescCnt();
1991 for( sal_uInt16 i = 0; i < nCnt; ++i )
1993 const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i );
1994 const SwFrmFmt& rMaster = rPageDesc.GetMaster();
1995 const SfxPoolItem* pItem;
1996 if( ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_HEADER, FALSE, &pItem ) &&
1997 ((SwFmtHeader*)pItem)->IsActive() ) ||
1998 ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_FOOTER, FALSE, &pItem ) &&
1999 ((SwFmtFooter*)pItem)->IsActive()) )
2000 ++nRet;
2002 return nRet; // number of page styles with active header/footer
2005 /*--------------------------------------------------------------------
2006 Beschreibung: Links bearbeiten
2007 --------------------------------------------------------------------*/
2009 void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem )
2011 pViewImpl->InitRequest( rRequest );
2012 pViewImpl->SetParam( pItem ? 1 : 0 );
2013 USHORT nSlot = rRequest.GetSlot();
2015 if ( !pItem )
2017 String sEmpty;
2018 InsertDoc( nSlot, sEmpty, sEmpty );
2020 else
2022 String sFile, sFilter;
2023 sFile = ( (const SfxStringItem *)pItem )->GetValue();
2024 if ( SFX_ITEM_SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, TRUE, &pItem ) )
2025 sFilter = ( (const SfxStringItem *)pItem )->GetValue();
2027 bool bHasFileName = ( sFile.Len() > 0 );
2028 long nFound = InsertDoc( nSlot, sFile, sFilter );
2030 if ( bHasFileName )
2032 rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2033 rRequest.Done();
2038 long SwView::InsertDoc( USHORT nSlotId, const String& rFileName, const String& rFilterName, INT16 nVersion )
2040 SfxMedium* pMed = 0;
2041 SwDocShell* pDocSh = GetDocShell();
2043 if( rFileName.Len() )
2045 SfxObjectFactory& rFact = pDocSh->GetFactory();
2046 const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
2047 if ( !pFilter )
2049 pMed = new SfxMedium(rFileName, STREAM_READ, TRUE, 0, 0 );
2050 SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
2051 pMed->UseInteractionHandler( TRUE );
2052 ErrCode nErr = aMatcher.GuessFilter( *pMed, &pFilter, FALSE );
2053 if ( nErr )
2054 DELETEZ(pMed);
2055 else
2056 pMed->SetFilter( pFilter );
2058 else
2059 pMed = new SfxMedium(rFileName, STREAM_READ, TRUE, pFilter, 0);
2061 else
2063 String sFactory = String::CreateFromAscii( pDocSh->GetFactory().GetShortName() );
2064 pViewImpl->StartDocumentInserter( sFactory, LINK( this, SwView, DialogClosedHdl ) );
2065 return -1;
2068 if( !pMed )
2069 return -1;
2071 return InsertMedium( nSlotId, pMed, nVersion );
2074 long SwView::InsertMedium( USHORT nSlotId, SfxMedium* pMedium, INT16 nVersion )
2076 BOOL bInsert = FALSE, bCompare = FALSE, bMerge = FALSE;
2077 long nFound = 0;
2078 SwDocShell* pDocSh = GetDocShell();
2080 switch( nSlotId )
2082 case SID_DOCUMENT_MERGE: bMerge = TRUE; break;
2083 case SID_DOCUMENT_COMPARE: bCompare = TRUE; break;
2084 case SID_INSERTDOC: bInsert = TRUE; break;
2086 default:
2087 ASSERT( !this, "Unbekannte SlotId!" );
2088 bInsert = TRUE;
2089 nSlotId = SID_INSERTDOC;
2090 break;
2093 if( bInsert )
2095 uno::Reference< frame::XDispatchRecorder > xRecorder =
2096 GetViewFrame()->GetBindings().GetRecorder();
2097 if ( xRecorder.is() )
2099 SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC);
2100 aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL()));
2101 if(pMedium->GetFilter())
2102 aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName()));
2103 aRequest.Done();
2106 SfxObjectShellRef aRef( pDocSh );
2108 sal_uInt32 nError = SfxObjectShell::HandleFilter( pMedium, pDocSh );
2109 // #i16722# aborted?
2110 if(nError != ERRCODE_NONE)
2112 delete pMedium;
2113 return -1;
2115 pDocSh->RegisterTransfer( *pMedium );
2116 pMedium->DownLoad(); // ggfs. den DownLoad anstossen
2117 if( aRef.Is() && 1 < aRef->GetRefCount() ) // noch gueltige Ref?
2119 SwReader* pRdr;
2120 Reader *pRead = pDocSh->StartConvertFrom( *pMedium, &pRdr, pWrtShell );
2121 if( pRead ||
2122 (pMedium->GetFilter()->GetFilterFlags() & SFX_FILTER_STARONEFILTER) != 0 )
2124 sal_uInt16 nUndoCheck = 0;
2125 SwDoc *pDoc = pDocSh->GetDoc();
2126 if( pRead && pDocSh->GetDoc() )
2127 nUndoCheck = lcl_PageDescWithHeader( *pDoc );
2128 ULONG nErrno;
2129 { //Scope for SwWait-Object, to be able to execute slots
2130 //outside this scope.
2131 SwWait aWait( *GetDocShell(), TRUE );
2132 pWrtShell->StartAllAction();
2133 if ( pWrtShell->HasSelection() )
2134 pWrtShell->DelRight(); // Selektionen loeschen
2135 if( pRead )
2137 nErrno = pRdr->Read( *pRead ); // und Dokument einfuegen
2138 delete pRdr;
2140 else
2142 sal_Bool bUndo = pDoc->DoesUndo();
2143 pDoc->DoUndo( sal_False );
2144 nErrno = pDocSh->InsertFrom( *pMedium ) ? 0 : ERR_SWG_READ_ERROR;
2145 pDoc->DoUndo( bUndo );
2150 // ggfs. alle Verzeichnisse updaten:
2151 if( pWrtShell->IsUpdateTOX() )
2153 SfxRequest aReq( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
2154 Execute( aReq );
2155 pWrtShell->SetUpdateTOX( FALSE ); // wieder zurueck setzen
2158 if( pDoc )
2159 { // Disable Undo for .sdw (136991) or
2160 // if the number of page styles with header/footer has changed (#i67305)
2161 if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) )
2162 pDoc->DelAllUndoObj();
2165 pWrtShell->EndAllAction();
2166 if( nErrno )
2168 ErrorHandler::HandleError( nErrno );
2169 nFound = IsError( nErrno ) ? -1 : 0;
2171 else
2172 nFound = 0;
2176 else
2178 SfxObjectShellRef xDocSh;
2180 extern int lcl_FindDocShell( SfxObjectShellRef& xDocSh,
2181 const String& rFileName, const String& rPasswd,
2182 String& rFilter, INT16 nVersion,
2183 SwDocShell* pDestSh );
2185 String sFltNm;
2186 int nRet = lcl_FindDocShell( xDocSh, pMedium->GetName(), aEmptyStr,
2187 sFltNm, nVersion, pDocSh );
2188 if( nRet )
2190 SwWait aWait( *GetDocShell(), TRUE );
2191 pWrtShell->StartAllAction();
2193 pWrtShell->EnterStdMode(); // Selektionen loeschen
2195 if( bCompare )
2196 nFound = pWrtShell->CompareDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
2197 else
2198 nFound = pWrtShell->MergeDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
2200 pWrtShell->EndAllAction();
2202 if (!bCompare && !nFound)
2204 Window* pWin = &GetEditWin();
2205 InfoBox(pWin, SW_RES(MSG_NO_MERGE_ENTRY)).Execute();
2208 if( 2 == nRet && xDocSh.Is() )
2209 xDocSh->DoClose();
2212 delete pMedium;
2213 return nFound;
2215 /* -----------------05.02.2003 12:06-----------------
2217 * --------------------------------------------------*/
2218 void SwView::EnableMailMerge(BOOL bEnable )
2220 bInMailMerge = bEnable;
2221 SfxBindings& rBind = GetViewFrame()->GetBindings();
2222 rBind.Invalidate(FN_INSERT_FIELD_DATA_ONLY);
2223 rBind.Update(FN_INSERT_FIELD_DATA_ONLY);
2227 namespace
2229 sal_Bool lcl_NeedAdditionalDataSource( const uno::Reference< XNameAccess >& _rDatasourceContext )
2231 Sequence < OUString > aNames = _rDatasourceContext->getElementNames();
2233 return ( !aNames.getLength()
2234 || ( ( 1 == aNames.getLength() )
2235 && aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
2241 /* -----------------27.11.2002 12:12-----------------
2243 * --------------------------------------------------*/
2245 class SwMergeSourceWarningBox_Impl : public ModalDialog
2247 FixedInfo aMessageFI;
2248 OKButton aOK;
2249 CancelButton aCancel;
2251 FixedImage aWarnImage;
2252 public:
2253 SwMergeSourceWarningBox_Impl( Window* pParent ) :
2254 ModalDialog( pParent, SW_RES( DLG_MERGE_SOURCE_UNAVAILABLE ) ),
2255 aMessageFI( this, SW_RES( ST_MERGE_SOURCE_UNAVAILABLE ) ),
2256 aOK( this, SW_RES( PB_MERGE_OK ) ),
2257 aCancel( this, SW_RES( PB_MERGE_CANCEL ) ),
2258 aWarnImage( this, SW_RES( IMG_MERGE ) )
2260 FreeResource();
2261 SetText( Application::GetDisplayName() );
2262 const Image& rImg = WarningBox::GetStandardImage();
2263 aWarnImage.SetImage( rImg );
2264 Size aImageSize( rImg.GetSizePixel() );
2265 aImageSize.Width() += 4;
2266 aImageSize.Height() += 4;
2267 aWarnImage.SetSizePixel( aImageSize );
2269 aImageSize.Width() += aWarnImage.GetPosPixel().X();
2270 Size aSz(GetSizePixel());
2271 aSz.Width() += aImageSize.Width();
2272 SetSizePixel(aSz);
2274 Point aPos(aMessageFI.GetPosPixel());
2275 aPos.X() += aImageSize.Width();
2276 aMessageFI.SetPosPixel( aPos );
2278 aPos = aOK.GetPosPixel();
2279 aPos.X() += aImageSize.Width();
2280 aOK.SetPosPixel( aPos );
2281 aPos = aCancel.GetPosPixel();
2282 aPos.X() += aImageSize.Width();
2283 aCancel.SetPosPixel( aPos );
2287 String GetMessText() const { return aMessageFI.GetText(); }
2288 void SetMessText( const String& rText ) { aMessageFI.SetText( rText ); }
2294 void SwView::GenerateFormLetter(BOOL bUseCurrentDocument)
2296 if(bUseCurrentDocument)
2298 if(!GetWrtShell().IsAnyDatabaseFieldInDoc())
2300 //check availability of data sources (except biblio source)
2301 uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
2302 uno::Reference<XNameAccess> xDBContext;
2303 if( xMgr.is() )
2305 uno::Reference<XInterface> xInstance = xMgr->createInstance(
2306 OUString::createFromAscii( "com.sun.star.sdb.DatabaseContext" ));
2307 xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ;
2309 if(!xDBContext.is())
2310 return ;
2311 BOOL bCallAddressPilot = FALSE;
2312 if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2314 // no data sources are available - create a new one
2315 WarningBox aWarning(
2316 &GetViewFrame()->GetWindow(),
2317 SW_RES(MSG_DATA_SOURCES_UNAVAILABLE));
2318 // no cancel allowed
2319 if ( RET_OK != aWarning.Execute() )
2320 return;
2321 bCallAddressPilot = TRUE;
2323 else
2325 //take an existing data source or create a new one?
2326 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2327 DBG_ASSERT(pFact, "Dialogdiet fail!");
2328 AbstractMailMergeFieldConnectionsDlg* pConnectionsDlg = pFact->CreateMailMergeFieldConnectionsDlg(
2329 DLG_MERGE_FIELD_CONNECTIONS,
2330 &GetViewFrame()->GetWindow());
2331 DBG_ASSERT(pConnectionsDlg, "Dialogdiet fail!");
2332 if(RET_OK == pConnectionsDlg->Execute())
2333 bCallAddressPilot = !pConnectionsDlg->IsUseExistingConnections();
2334 else
2335 return;
2338 if(bCallAddressPilot)
2340 GetViewFrame()->GetDispatcher()->Execute(
2341 SID_ADDRESS_DATA_SOURCE, SFX_CALLMODE_SYNCHRON);
2342 if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2343 // no additional data source has been created
2344 // -> assume that the user has cancelled the pilot
2345 return;
2348 //call insert fields with database field page available, only
2349 SfxViewFrame* pVFrame = GetViewFrame();
2350 //at first hide the default field dialog if currently visible
2351 pVFrame->SetChildWindow(FN_INSERT_FIELD, FALSE);
2352 //enable the status of the db field dialog - it is disabled in the status method
2353 //to prevent creation of the dialog without mail merge active
2354 EnableMailMerge();
2355 //then show the "Data base only" field dialog
2356 SfxBoolItem aOn(FN_INSERT_FIELD_DATA_ONLY, TRUE);
2357 pVFrame->GetDispatcher()->Execute(FN_INSERT_FIELD_DATA_ONLY,
2358 SFX_CALLMODE_SYNCHRON, &aOn, 0L);
2359 return;
2361 else
2363 // check whether the
2364 String sSource;
2365 if(!GetWrtShell().IsFieldDataSourceAvailable(sSource))
2367 SwMergeSourceWarningBox_Impl aWarning( &GetViewFrame()->GetWindow());
2368 String sTmp(aWarning.GetMessText());
2369 sTmp.SearchAndReplaceAscii("%1", sSource);
2370 aWarning.SetMessText(sTmp);
2371 if(RET_OK == aWarning.Execute())
2373 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
2374 if ( pFact )
2376 VclAbstractDialog* pDlg = pFact->CreateVclDialog( NULL, SID_OPTIONS_DATABASES );
2377 pDlg->Execute();
2378 delete pDlg;
2381 return ;
2384 SwNewDBMgr* pNewDBMgr = GetWrtShell().GetNewDBMgr();
2386 SwDBData aData;
2387 SwWrtShell &rSh = GetWrtShell();
2388 aData = rSh.GetDBData();
2389 rSh.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer
2390 // das Mischen von DB-Feldern notwendig.
2391 AttrChangedNotify( &rSh );
2392 pNewDBMgr->SetMergeType( DBMGR_MERGE );
2394 if (pNewDBMgr)
2396 Sequence<PropertyValue> aProperties(3);
2397 PropertyValue* pValues = aProperties.getArray();
2398 pValues[0].Name = C2U("DataSourceName");
2399 pValues[1].Name = C2U("Command");
2400 pValues[2].Name = C2U("CommandType");
2401 pValues[0].Value <<= aData.sDataSource;
2402 pValues[1].Value <<= aData.sCommand;
2403 pValues[2].Value <<= aData.nCommandType;
2404 pNewDBMgr->ExecuteFormLetter(GetWrtShell(), aProperties, TRUE);
2407 else
2409 //call documents and template dialog
2410 SfxApplication* pSfxApp = SFX_APP();
2411 Window* pTopWin = pSfxApp->GetTopWindow();
2412 SvtDocumentTemplateDialog* pDocTemplDlg = new SvtDocumentTemplateDialog( pTopWin );
2413 pDocTemplDlg->SelectTemplateFolder();
2415 int nRet = pDocTemplDlg->Execute();
2416 sal_Bool bNewWin = sal_False;
2417 if ( nRet == RET_OK )
2419 if ( pTopWin != pSfxApp->GetTopWindow() )
2421 // the dialogue opens a document -> a new TopWindow appears
2422 pTopWin = pSfxApp->GetTopWindow();
2423 bNewWin = sal_True;
2427 delete pDocTemplDlg;
2428 if ( bNewWin )
2429 // after the destruction of the dialogue its parent comes to top,
2430 // but we want that the new document is on top
2431 pTopWin->ToTop();
2433 // return;
2437 IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
2439 if ( ERRCODE_NONE == _pFileDlg->GetError() )
2441 SfxMedium* pMed = pViewImpl->CreateMedium();
2442 if ( pMed )
2444 USHORT nSlot = pViewImpl->GetRequest()->GetSlot();
2445 long nFound = InsertMedium( nSlot, pMed, pViewImpl->GetParam() );
2447 if ( SID_INSERTDOC == nSlot )
2449 if ( pViewImpl->GetParam() == 0 )
2451 pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2452 pViewImpl->GetRequest()->Ignore();
2454 else
2456 pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2457 pViewImpl->GetRequest()->Done();
2460 else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot )
2462 pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) );
2464 if ( nFound > 0 ) // Redline-Browser anzeigen
2466 SfxViewFrame* pVFrame = GetViewFrame();
2467 pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
2469 // RedlineDlg neu initialisieren
2470 USHORT nId = SwRedlineAcceptChild::GetChildWindowId();
2471 SwRedlineAcceptChild* pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow( nId );
2472 if ( pRed )
2473 pRed->ReInitDlg( GetDocShell() );
2478 return 0;
2481 void SwView::ExecuteScan( SfxRequest& rReq )
2483 if (pViewImpl)
2484 pViewImpl->ExecuteScan(rReq) ;