xref: /trunk/main/sw/source/ui/uiview/view2.cxx (revision 69a74367)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <com/sun/star/util/SearchOptions.hpp>
28 #include <com/sun/star/util/SearchFlags.hpp>
29 #include <com/sun/star/i18n/TransliterationModules.hpp>
30 #include <svtools/filter.hxx>
31 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
32 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
33 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
34 
35 #define _SVSTDARR_STRINGSSORTDTOR
36 #include <svl/svstdarr.hxx>
37 #include <svl/aeitem.hxx>
38 
39 #include <SwStyleNameMapper.hxx>
40 #include <docary.hxx>
41 #include <hintids.hxx>
42 #include <SwRewriter.hxx>
43 #include <numrule.hxx>
44 #include <swundo.hxx>
45 #include <caption.hxx>
46 #include <svl/PasswordHelper.hxx>
47 #include <svl/urihelper.hxx>
48 #include <sfx2/passwd.hxx>
49 #include <sfx2/sfxdlg.hxx>
50 #include <sfx2/filedlghelper.hxx>
51 #include <sfx2/sfxhelp.hxx>
52 #include <editeng/langitem.hxx>
53 #include <svx/viewlayoutitem.hxx>
54 #include <svx/zoomslideritem.hxx>
55 #include <svtools/xwindowitem.hxx>
56 #include <svx/htmlmode.hxx>
57 #include <vcl/svapp.hxx>
58 #include <vcl/wrkwin.hxx>
59 #include <sfx2/app.hxx>
60 #include <sfx2/request.hxx>
61 #include <sfx2/bindings.hxx>
62 #include <editeng/lrspitem.hxx>
63 #include <svtools/txtcmp.hxx>
64 #include "editeng/unolingu.hxx"
65 #include <vcl/msgbox.hxx>
66 #include <editeng/tstpitem.hxx>
67 #include <sfx2/event.hxx>
68 #include <sfx2/docfile.hxx>
69 #include <sfx2/docfilt.hxx>
70 #include <sfx2/fcontnr.hxx>
71 #include <editeng/sizeitem.hxx>
72 #include <sfx2/dispatch.hxx>
73 #include <svl/whiter.hxx>
74 #include <svl/ptitem.hxx>
75 #include <sfx2/linkmgr.hxx>
76 #include <tools/errinf.hxx>
77 #include <tools/urlobj.hxx>
78 #include <svx/svdview.hxx>
79 #include <swtypes.hxx>
80 #include <swwait.hxx>
81 #include <redlndlg.hxx>
82 #include <view.hxx>
83 #include <uivwimp.hxx>
84 #include <docsh.hxx>
85 #include <doc.hxx>
86 #include <IDocumentUndoRedo.hxx>
87 #include <wrtsh.hxx>
88 #include <viewopt.hxx>
89 #include <basesh.hxx>
90 #include <swmodule.hxx>
91 #include <uitool.hxx>
92 #include <shellio.hxx>
93 #include <fmtinfmt.hxx>
94 #include <mdiexp.hxx>
95 #include <drawbase.hxx>
96 #include <frmmgr.hxx>
97 #include <pagedesc.hxx>
98 #include <section.hxx>
99 #include <usrpref.hxx>
100 #include <IMark.hxx>
101 #include <navipi.hxx>
102 #include <tox.hxx>
103 #include <workctrl.hxx>
104 #include <scroll.hxx>
105 #include <edtwin.hxx>
106 #include <wview.hxx>
107 #include <textsh.hxx>
108 #include <tabsh.hxx>
109 #include <listsh.hxx>
110 #include <cmdid.h>
111 #include <comcore.hrc>
112 #include <poolfmt.hrc>
113 #include <statstr.hrc>
114 #include <swerror.h>
115 #include <globals.hrc>
116 #include <shells.hrc>
117 #include <web.hrc>
118 #include <view.hrc>
119 #include <app.hrc>
120 #include <fmtclds.hxx>
121 #include <helpid.h>
122 #include <svtools/templdlg.hxx>
123 #include <dbconfig.hxx>
124 #include <dbmgr.hxx>
125 
126 #include <PostItMgr.hxx>
127 
128 #include <ndtxt.hxx> //#outline level,added by zhaojianwei
129 
130 #include <comphelper/processfactory.hxx>
131 
132 #include <svx/svxdlg.hxx>
133 #include <svx/dialogs.hrc>
134 #include "swabstdlg.hxx"
135 #include "globals.hrc"
136 #include <envelp.hrc>
137 #include <fmthdft.hxx>
138 #include <svx/ofaitem.hxx>
139 #include <unomid.h>
140 
141 const char __FAR_DATA sStatusDelim[] = " : ";
142 const char __FAR_DATA sStatusComma[] = " , ";//#outlinelevel, define a Variable for "," add by zhaojianwei
143 
144 using ::rtl::OUString;
145 using namespace sfx2;
146 using namespace ::com::sun::star;
147 using namespace ::com::sun::star::i18n;
148 using namespace ::com::sun::star::util;
149 using namespace ::com::sun::star::uno;
150 using namespace ::com::sun::star::lang;
151 using namespace ::com::sun::star::scanner;
152 using namespace ::com::sun::star::i18n;
153 using namespace ::com::sun::star::beans;
154 using namespace ::com::sun::star::container;
155 using namespace ::com::sun::star::ui::dialogs;
156 
157 
158 static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, sal_uInt16 nWhichId )
159 {
160 	if (nWhichId == RES_CHRATR_LANGUAGE ||
161 		nWhichId == RES_CHRATR_CJK_LANGUAGE ||
162 		nWhichId == RES_CHRATR_CTL_LANGUAGE)
163 	{
164 		rWrtSh.StartAction();
165 		rWrtSh.LockView( sal_True );
166 		rWrtSh.Push();
167 
168 		// prepare to apply new language to all text in document
169 		rWrtSh.SelAll();
170 		rWrtSh.ExtendedSelectAll();
171 
172 		// set language attribute to default for all text
173 		SvUShortsSort aAttribs;
174 		aAttribs.Insert( nWhichId );
175 		rWrtSh.ResetAttr( &aAttribs );
176 
177 		rWrtSh.Pop( sal_False );
178 		rWrtSh.LockView( sal_False );
179 		rWrtSh.EndAction();
180 	}
181 }
182 
183 /*---------------------------------------------------------------------------
184 	Beschreibung:	String fuer die Seitenanzeige in der Statusbar basteln.
185  ----------------------------------------------------------------------------*/
186 
187 String SwView::GetPageStr( sal_uInt16 nPg, sal_uInt16 nLogPg,
188 							const String& rDisplay )
189 {
190 	String aStr( aPageStr );
191 	if( rDisplay.Len() )
192 		aStr += rDisplay;
193 	else
194 		aStr += String::CreateFromInt32(nLogPg);
195 
196 	if( nLogPg && nLogPg != nPg )
197 	{
198 		aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM("   "));
199 		aStr += String::CreateFromInt32(nPg);
200 	}
201 	aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / "));
202 	aStr += String::CreateFromInt32( GetWrtShell().GetPageCnt() );
203 
204 	return aStr;
205 }
206 
207 
208 int SwView::InsertGraphic( const String &rPath, const String &rFilter,
209                                 sal_Bool bLink, GraphicFilter *pFlt,
210                                 Graphic* pPreviewGrf, sal_Bool bRule )
211 {
212     SwWait aWait( *GetDocShell(), sal_True );
213 
214     Graphic aGrf;
215     int nRes = GRFILTER_OK;
216     if ( pPreviewGrf )
217         aGrf = *pPreviewGrf;
218     else
219     {
220         if( !pFlt )
221             pFlt = GraphicFilter::GetGraphicFilter();
222         nRes = GraphicFilter::LoadGraphic( rPath, rFilter, aGrf, pFlt /*, nFilter*/ );
223     }
224 
225     if( GRFILTER_OK == nRes )
226     {
227         SwFlyFrmAttrMgr aFrmMgr( sal_True, GetWrtShellPtr(), FRMMGR_TYPE_GRF );
228 
229         SwWrtShell &rSh = GetWrtShell();
230         rSh.StartAction();
231         if( bLink )
232         {
233             SwDocShell* pDocSh = GetDocShell();
234             INetURLObject aTemp(
235                 pDocSh->HasName() ?
236                     pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) :
237                     rtl::OUString());
238 
239             String sURL = URIHelper::SmartRel2Abs(
240                 aTemp, rPath, URIHelper::GetMaybeFileHdl() );
241 
242             rSh.Insert( sURL,
243                         rFilter, aGrf, &aFrmMgr, bRule );
244         }
245         else
246             rSh.Insert( aEmptyStr, aEmptyStr, aGrf, &aFrmMgr );
247         // nach dem EndAction ist es zu spaet, weil die Shell dann schon zerstoert sein kann
248         rSh.EndAction();
249     }
250     return nRes;
251 }
252 
253 
254 sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq )
255 {
256 #ifndef ENABLE_PROP_WITHOUTLINK
257 #define ENABLE_PROP_WITHOUTLINK 0x08
258 #endif
259 
260     sal_Bool bReturn = sal_False;
261     SwDocShell* pDocShell = GetDocShell();
262     sal_uInt16 nHtmlMode = ::GetHtmlMode(pDocShell);
263     // im HTML-Mode nur verknuepft einfuegen
264     FileDialogHelper* pFileDlg = new FileDialogHelper( SFXWB_GRAPHIC | SFXWB_SHOWSTYLES );
265     pFileDlg->SetTitle(SW_RESSTR(STR_INSERT_GRAPHIC ));
266     pFileDlg->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC );
267     uno::Reference < XFilePicker > xFP = pFileDlg->GetFilePicker();
268     uno::Reference < XFilePickerControlAccess > xCtrlAcc(xFP, UNO_QUERY);
269     if(nHtmlMode & HTMLMODE_ON)
270     {
271         sal_Bool bTrue = sal_True;
272         Any aVal(&bTrue, ::getBooleanCppuType());
273         xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aVal);
274         xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False);
275     }
276 
277     SvStringsSortDtor aFormats;
278     SwDoc* pDoc = pDocShell->GetDoc();
279     const sal_uInt16 nArrLen = pDoc->GetFrmFmts()->Count();
280     sal_uInt16 i;
281     for( i = 0; i < nArrLen; i++ )
282     {
283         SwFrmFmt* pFmt = (*pDoc->GetFrmFmts())[ i ];
284         if(pFmt->IsDefault() || pFmt->IsAuto())
285             continue;
286         String *pFormat = new String(pFmt->GetName());
287         aFormats.Insert(pFormat);
288     }
289 
290     // pool formats
291     //
292     const SvStringsDtor& rFrmPoolArr = SwStyleNameMapper::GetFrmFmtUINameArray();
293     for( i = 0; i < rFrmPoolArr.Count(); i++ )
294     {
295         String *pFormat = new String(*rFrmPoolArr[i]);
296         if (!aFormats.Insert(pFormat))
297             delete pFormat;
298     }
299 
300     Sequence<OUString> aListBoxEntries(aFormats.Count());
301     OUString* pEntries = aListBoxEntries.getArray();
302     sal_Int16 nSelect = 0;
303     String sGraphicFormat = SW_RESSTR(STR_POOLFRM_GRAPHIC);
304     for(i = 0; i < aFormats.Count(); ++i)
305     {
306         pEntries[i] = *aFormats[i];
307         if(pEntries[i].equals(sGraphicFormat))
308             nSelect = i;
309     }
310     try
311     {
312         Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries));
313 
314         xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
315             ListboxControlActions::ADD_ITEMS , aTemplates );
316 
317         Any aSelectPos(&nSelect, ::getCppuType(&nSelect));
318         xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
319             ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
320     }
321     catch(Exception& )
322     {
323         DBG_ERROR("control acces failed");
324     }
325 
326     SFX_REQUEST_ARG( rReq, pName, SfxStringItem, SID_INSERT_GRAPHIC , sal_False );
327     sal_Bool bShowError = !pName;
328     if( pName || ERRCODE_NONE == pFileDlg->Execute() )
329     {
330 
331         String aFileName, aFilterName;
332         if ( pName )
333         {
334             aFileName = pName->GetValue();
335             SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, FN_PARAM_FILTER , sal_False );
336             if ( pFilter )
337                 aFilterName = pFilter->GetValue();
338         }
339         else
340         {
341             aFileName = pFileDlg->GetPath();
342             aFilterName = pFileDlg->GetCurrentFilter();
343             rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) );
344             rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) );
345 
346             sal_Bool bAsLink = sal_False;
347             if(nHtmlMode & HTMLMODE_ON)
348                 bAsLink = sal_True;
349             else
350             {
351                 try
352                 {
353                     Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
354                     DBG_ASSERT(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
355                     bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True;
356                     Any aTemplateValue = xCtrlAcc->getValue(
357                         ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
358                         ListboxControlActions::GET_SELECTED_ITEM );
359                     OUString sTmpl;
360                     aTemplateValue >>= sTmpl;
361                     rReq.AppendItem( SfxStringItem( FN_PARAM_2, sTmpl) );
362                 }
363                 catch(Exception& )
364                 {
365                     DBG_ERROR("control acces failed");
366                 }
367             }
368             rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
369         }
370 
371         SFX_REQUEST_ARG( rReq, pAsLink, SfxBoolItem, FN_PARAM_1 , sal_False );
372         SFX_REQUEST_ARG( rReq, pStyle, SfxStringItem, FN_PARAM_2 , sal_False );
373 
374         sal_Bool bAsLink = sal_False;
375         if( nHtmlMode & HTMLMODE_ON )
376             bAsLink = sal_True;
377         else
378         {
379             if ( rReq.GetArgs() )
380             {
381                 if ( pAsLink )
382                     bAsLink = pAsLink->GetValue();
383                 if ( pStyle && pStyle->GetValue().Len() )
384                     sGraphicFormat = pStyle->GetValue();
385             }
386             else
387             {
388                 Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
389                 DBG_ASSERT(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
390                 bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True;
391                 Any aTemplateValue = xCtrlAcc->getValue(
392                     ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
393                     ListboxControlActions::GET_SELECTED_ITEM );
394                 OUString sTmpl;
395                 aTemplateValue >>= sTmpl;
396                 if( sTmpl.getLength() )
397                     sGraphicFormat = sTmpl;
398                 rReq.AppendItem( SfxStringItem( FN_PARAM_2, sGraphicFormat ) );
399                 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
400             }
401         }
402 
403         SwWrtShell& rSh = GetWrtShell();
404         rSh.LockPaint();
405         rSh.StartAction();
406 
407         /// #111827#
408         SwRewriter aRewriter;
409         aRewriter.AddRule(UNDO_ARG1, String(SW_RES(STR_GRAPHIC_DEFNAME)));
410 
411         rSh.StartUndo(UNDO_INSERT, &aRewriter);
412 
413         int nError = InsertGraphic( aFileName, aFilterName, bAsLink, GraphicFilter::GetGraphicFilter() );
414 
415         // Format ist ungleich Current Filter, jetzt mit auto. detection
416         if( nError == GRFILTER_FORMATERROR )
417             nError = InsertGraphic( aFileName, aEmptyStr, bAsLink, GraphicFilter::GetGraphicFilter() );
418         if ( rSh.IsFrmSelected() )
419         {
420             SwFrmFmt* pFmt = pDoc->FindFrmFmtByName( sGraphicFormat );
421             if(!pFmt)
422                 pFmt = pDoc->MakeFrmFmt(sGraphicFormat,
423                                         pDocShell->GetDoc()->GetDfltFrmFmt(),
424                                         sal_True, sal_False);
425             rSh.SetFrmFmt( pFmt );
426         }
427 
428         RESOURCE_TYPE nResId = 0;
429         switch( nError )
430         {
431             case GRFILTER_OPENERROR:
432                 nResId = STR_GRFILTER_OPENERROR;
433                 break;
434             case GRFILTER_IOERROR:
435                 nResId = STR_GRFILTER_IOERROR;
436                 break;
437             case GRFILTER_FORMATERROR:
438                 nResId = STR_GRFILTER_FORMATERROR;
439                 break;
440             case GRFILTER_VERSIONERROR:
441                 nResId = STR_GRFILTER_VERSIONERROR;
442                 break;
443             case GRFILTER_FILTERERROR:
444                 nResId = STR_GRFILTER_FILTERERROR;
445                 break;
446             case GRFILTER_TOOBIG:
447                 nResId = STR_GRFILTER_TOOBIG;
448                 break;
449         }
450 
451         rSh.EndAction();
452         rSh.UnlockPaint();
453         if( nResId )
454         {
455             if( bShowError )
456             {
457                 InfoBox aInfoBox( GetWindow(), SW_RESSTR( nResId ));
458                 aInfoBox.Execute();
459             }
460             rReq.Ignore();
461         }
462         else
463         {
464             // set the specific graphic attrbutes to the graphic
465             bReturn = sal_True;
466             AutoCaption( GRAPHIC_CAP );
467             rReq.Done();
468         }
469 
470         rSh.EndUndo(); // due to possible change of Shell
471     }
472 
473     delete pFileDlg;
474 
475     return bReturn;
476 }
477 
478 
479 void __EXPORT SwView::Execute(SfxRequest &rReq)
480 {
481 	sal_uInt16 nSlot = rReq.GetSlot();
482 	const SfxItemSet* pArgs = rReq.GetArgs();
483 	const SfxPoolItem* pItem;
484     sal_Bool bIgnore = sal_False;
485 	switch( nSlot )
486 	{
487 		case SID_CREATE_SW_DRAWVIEW:
488             // --> OD 2005-08-08 #i52858# - method name changed
489             pWrtShell->getIDocumentDrawModelAccess()->GetOrCreateDrawModel();
490             // <--
491 			break;
492 
493 		case FN_LINE_NUMBERING_DLG:
494 		{
495 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
496             DBG_ASSERT(pFact, "Dialogdiet fail!");
497             VclAbstractDialog* pDlg = pFact->CreateVclSwViewDialog( DLG_LINE_NUMBERING,    *this);
498             DBG_ASSERT(pDlg, "Dialogdiet fail!");
499 			pDlg->Execute();
500 			delete pDlg;
501 			break;
502 		}
503 		case FN_EDIT_LINK_DLG:
504 			EditLinkDlg();
505 			break;
506 		case FN_REFRESH_VIEW:
507 			GetEditWin().Invalidate();
508 			break;
509 		case FN_PAGEUP:
510 		case FN_PAGEUP_SEL:
511 		case FN_PAGEDOWN:
512 		case FN_PAGEDOWN_SEL:
513 		{
514 			Rectangle aVis( GetVisArea() );
515             SwEditWin& rTmpWin = GetEditWin();
516             if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot )
517 			    PageUpCrsr(FN_PAGEUP_SEL == nSlot);
518             else
519     			PageDownCrsr(FN_PAGEDOWN_SEL == nSlot);
520 
521 			rReq.SetReturnValue(SfxBoolItem(nSlot,
522 												aVis != GetVisArea()));
523             //#i42732# - notify the edit window that from now on we do not use the input language
524             rTmpWin.SetUseInputLanguage( sal_False );
525         }
526 		break;
527 		case FN_REDLINE_ON:
528 		{
529 			if( pArgs &&
530 				SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem ))
531 			{
532                 IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess();
533                 Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
534 				if( aPasswd.getLength() )
535 				{
536 					DBG_ASSERT( !((const SfxBoolItem*)pItem)->GetValue(), "SwView::Execute(): password set an redlining off doesn't match!" );
537 					// xmlsec05:	new password dialog
538 					Window* pParent;
539 					const SfxPoolItem* pParentItem;
540                     if( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, sal_False, &pParentItem ) )
541                         pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr();
542 					else
543 						pParent = &GetViewFrame()->GetWindow();
544 					SfxPasswordDialog aPasswdDlg( pParent );
545                     aPasswdDlg.SetMinLen( 1 );
546 					//#i69751# the result of Execute() can be ignored
547                     aPasswdDlg.Execute();
548 					String sNewPasswd( aPasswdDlg.GetPassword() );
549                     Sequence <sal_Int8> aNewPasswd = pIDRA->GetRedlinePassword();
550 					SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
551 					if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
552                         pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
553 					else
554 					{	// xmlsec05: message box for wrong password
555 						break;
556 					}
557 				}
558 
559 				sal_uInt16 nOn = ((const SfxBoolItem*)pItem)->GetValue() ? nsRedlineMode_t::REDLINE_ON : 0;
560 				sal_uInt16 nMode = pWrtShell->GetRedlineMode();
561                 pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
562 			}
563 		}
564 		break;
565         case FN_REDLINE_PROTECT :
566         {
567             IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess();
568             Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
569             if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem )
570 				&& ((SfxBoolItem*)pItem)->GetValue() == ( aPasswd.getLength() != 0 ) )
571                 break;
572 
573 			// xmlsec05:	new password dialog
574 			//				message box for wrong password
575 			Window* pParent;
576 			const SfxPoolItem* pParentItem;
577             if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, sal_False, &pParentItem ) )
578                 pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr();
579 			else
580 				pParent = &GetViewFrame()->GetWindow();
581             SfxPasswordDialog aPasswdDlg( pParent );
582             aPasswdDlg.SetMinLen( 1 );
583             if(!aPasswd.getLength())
584                 aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
585             if (aPasswdDlg.Execute())
586             {
587                 sal_uInt16 nOn = nsRedlineMode_t::REDLINE_ON;
588                 String sNewPasswd( aPasswdDlg.GetPassword() );
589                 Sequence <sal_Int8> aNewPasswd =
590                         pIDRA->GetRedlinePassword();
591                 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
592                 if(!aPasswd.getLength())
593                 {
594                     pIDRA->SetRedlinePassword(aNewPasswd);
595                 }
596                 else if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
597                 {
598                     pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
599                     nOn = 0;
600                 }
601                 sal_uInt16 nMode = pIDRA->GetRedlineMode();
602                 pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
603                 rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, ((nMode&nsRedlineMode_t::REDLINE_ON)==0) ) );
604             }
605             else
606                 bIgnore = sal_True;
607         }
608         break;
609 		case FN_REDLINE_SHOW:
610 
611 			if( pArgs &&
612 				SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem))
613 			{
614 				sal_uInt16 nMode = ( ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)
615 						& pWrtShell->GetRedlineMode() ) | nsRedlineMode_t::REDLINE_SHOW_INSERT;
616 				if( ((const SfxBoolItem*)pItem)->GetValue() )
617 					nMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
618 
619                 pWrtShell->SetRedlineModeAndCheckInsMode( nMode );
620 			}
621 			break;
622         case FN_MAILMERGE_SENDMAIL_CHILDWINDOW:
623         case FN_REDLINE_ACCEPT:
624             GetViewFrame()->ToggleChildWindow(nSlot);
625         break;
626         case FN_REDLINE_ACCEPT_DIRECT:
627         case FN_REDLINE_REJECT_DIRECT:
628         {
629             SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE );
630             Point aCrsrPos = pWrtShell->GetCrsrDocPos( sal_True );
631             if( pWrtShell->GetContentAtPos( aCrsrPos, aCntntAtPos ) )
632             {
633                 sal_uInt16 nCount = pWrtShell->GetRedlineCount();
634                 for( sal_uInt16 nRedline = 0; nRedline < nCount; ++nRedline )
635                 {
636                     const SwRedline& rRedline = pWrtShell->GetRedline( nRedline );
637                     if( *aCntntAtPos.aFnd.pRedl == rRedline )
638                     {
639                         if( FN_REDLINE_ACCEPT_DIRECT == nSlot )
640                             pWrtShell->AcceptRedline( nRedline );
641                         else
642                             pWrtShell->RejectRedline( nRedline );
643                         break;
644                     }
645                 }
646             }
647         }
648         break;
649 		case SID_DOCUMENT_COMPARE:
650 		case SID_DOCUMENT_MERGE:
651 			{
652 				String sFileName, sFilterName;
653 				sal_Int16 nVersion = 0;
654                 bool bHasFileName = false;
655                 pViewImpl->SetParam( 0 );
656 
657 				if( pArgs )
658 				{
659 					if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILE_NAME, sal_False, &pItem ))
660 						sFileName = ((const SfxStringItem*)pItem)->GetValue();
661                     bHasFileName = ( sFileName.Len() > 0 );
662 
663 					if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILTER_NAME, sal_False, &pItem ))
664 						sFilterName = ((const SfxStringItem*)pItem)->GetValue();
665 
666 					if( SFX_ITEM_SET == pArgs->GetItemState( SID_VERSION, sal_False, &pItem ))
667                     {
668 						nVersion = ((const SfxInt16Item *)pItem)->GetValue();
669                         pViewImpl->SetParam( nVersion );
670                     }
671 				}
672 
673                 pViewImpl->InitRequest( rReq );
674                 long nFound = InsertDoc( nSlot, sFileName, sFilterName, nVersion );
675 
676                 if ( bHasFileName )
677                 {
678                     rReq.SetReturnValue( SfxInt32Item( nSlot, nFound ));
679 
680                     if (nFound > 0) // Redline-Browser anzeigen
681                     {
682                         SfxViewFrame* pVFrame = GetViewFrame();
683                         pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
684 
685                         // RedlineDlg neu initialisieren
686                         sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
687                         SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)
688                                                 pVFrame->GetChildWindow(nId);
689                         if (pRed)
690                             pRed->ReInitDlg(GetDocShell());
691                     }
692                 }
693                 else
694                     bIgnore = sal_True;
695             }
696 		break;
697 		case FN_SYNC_LABELS:
698         case FN_MAILMERGE_CHILDWINDOW:
699             GetViewFrame()->ShowChildWindow(nSlot, sal_True);
700         break;
701         case FN_ESCAPE:
702 		{
703 			if ( pWrtShell->HasDrawView() && pWrtShell->GetDrawView()->IsDragObj() )
704 			{
705 				pWrtShell->BreakDrag();
706 				pWrtShell->EnterSelFrmMode();
707 			}
708 			else if ( pWrtShell->IsDrawCreate() )
709 			{
710 				GetDrawFuncPtr()->BreakCreate();
711 				AttrChangedNotify(pWrtShell); // ggf Shellwechsel...
712 			}
713 			else if ( pWrtShell->HasSelection() || IsDrawMode() )
714 			{
715                 SdrView *pSdrView = pWrtShell->HasDrawView() ? pWrtShell->GetDrawView() : 0;
716                 if(pSdrView && pSdrView->AreObjectsMarked() &&
717                     pSdrView->GetHdlList().GetFocusHdl())
718                 {
719                     ((SdrHdlList&)pSdrView->GetHdlList()).ResetFocusHdl();
720                 }
721                 else
722                 {
723                     if(pSdrView)
724                     {
725                         LeaveDrawCreate();
726                         Point aPt(LONG_MIN, LONG_MIN);
727                         //go out of the frame
728                         pWrtShell->SelectObj(aPt, SW_LEAVE_FRAME);
729                         SfxBindings& rBind = GetViewFrame()->GetBindings();
730                         rBind.Invalidate( SID_ATTR_SIZE );
731                     }
732                     pWrtShell->EnterStdMode();
733                     AttrChangedNotify(pWrtShell); // ggf Shellwechsel...
734                 }
735 			}
736 			else if ( GetEditWin().GetApplyTemplate() )
737 			{
738 				GetEditWin().SetApplyTemplate(SwApplyTemplate());
739 			}
740             else if( ((SfxObjectShell*)GetDocShell())->IsInPlaceActive() )
741 			{
742                 Escape();
743             }
744 			else if ( GetEditWin().IsChainMode() )
745 			{
746 				GetEditWin().SetChainMode( sal_False );
747 			}
748             else if( pWrtShell->GetFlyFrmFmt() )
749             {
750                 const SwFrmFmt* pFmt = pWrtShell->GetFlyFrmFmt();
751                 if(pWrtShell->GotoFly( pFmt->GetName(), FLYCNTTYPE_FRM ))
752                 {
753                     pWrtShell->HideCrsr();
754                     pWrtShell->EnterSelFrmMode();
755                 }
756             }
757 			else
758 			{
759 				SfxBoolItem aItem( SID_WIN_FULLSCREEN, sal_False );
760 				GetViewFrame()->GetDispatcher()->Execute( SID_WIN_FULLSCREEN, SFX_CALLMODE_RECORD, &aItem, 0L );
761                 bIgnore = sal_True;
762 			}
763 		}
764         break;
765 		case SID_ATTR_BORDER_INNER:
766 		case SID_ATTR_BORDER_OUTER:
767 		case SID_ATTR_BORDER_SHADOW:
768 			if(pArgs)
769 				pWrtShell->SetAttrSet(*pArgs);
770 			break;
771 
772 		case SID_ATTR_PAGE:
773 		case SID_ATTR_PAGE_SIZE:
774 		case SID_ATTR_PAGE_MAXSIZE:
775 		case SID_ATTR_PAGE_PAPERBIN:
776 		case SID_ATTR_PAGE_EXT1:
777 		case FN_PARAM_FTN_INFO:
778 		{
779 			if(pArgs)
780 			{
781 				const sal_uInt16 nCurIdx = pWrtShell->GetCurPageDesc();
782 				SwPageDesc aPageDesc( pWrtShell->GetPageDesc( nCurIdx ) );
783 				::ItemSetToPageDesc( *pArgs, aPageDesc );
784 				// Den Descriptor der Core veraendern.
785 				pWrtShell->ChgPageDesc( nCurIdx, aPageDesc );
786 			}
787 		}
788 		break;
789 		case FN_NAVIGATION_PI_GOTO_PAGE:
790 		{
791 			SfxViewFrame* pVFrame = GetViewFrame();
792 			SfxChildWindow* pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
793 			if(!pCh)
794 			{
795 				pVFrame->ToggleChildWindow( SID_NAVIGATOR );
796 				pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
797 
798 			}
799 				((SwNavigationPI*) pCh->GetContextWindow(SW_MOD()))->GotoPage();
800 		}
801 		break;
802 		case  FN_EDIT_CURRENT_TOX:
803 		{
804 			GetViewFrame()->GetDispatcher()->Execute(
805 								FN_INSERT_MULTI_TOX, SFX_CALLMODE_ASYNCHRON);
806 		}
807 		break;
808 		case FN_UPDATE_CUR_TOX:
809 		{
810 			const SwTOXBase* pBase = pWrtShell->GetCurTOX();
811 			if(pBase)
812 			{
813 				pWrtShell->StartAction();
814 				if(TOX_INDEX == pBase->GetType())
815 					pWrtShell->ApplyAutoMark();
816 				pWrtShell->UpdateTableOf( *pBase );
817 				pWrtShell->EndAction();
818 			}
819 		}
820 		break;
821 		case FN_UPDATE_TOX:
822 		{
823 			pWrtShell->StartAction();
824 			pWrtShell->EnterStdMode();
825 			sal_Bool bOldCrsrInReadOnly = pWrtShell->IsReadOnlyAvailable();
826 			pWrtShell->SetReadOnlyAvailable( sal_True );
827 
828 			for( sal_uInt16 i = 0; i < 2; ++i )
829 			{
830 				sal_uInt16 nCount = pWrtShell->GetTOXCount();
831 				if( 1 == nCount )
832 					++i;
833 
834 				while( pWrtShell->GotoPrevTOXBase() )
835 					;   // aufs erste Verzeichnis springen
836 
837 				// falls wir nicht mehr in einem stehen, dann zum naechsten
838 				// springen.
839 				const SwTOXBase* pBase = pWrtShell->GetCurTOX();
840 				if( !pBase )
841 				{
842 					pWrtShell->GotoNextTOXBase();
843 					pBase = pWrtShell->GetCurTOX();
844 				}
845 
846 				sal_Bool bAutoMarkApplied = sal_False;
847 				while( pBase )
848 				{
849 					if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied)
850 					{
851 						pWrtShell->ApplyAutoMark();
852 						bAutoMarkApplied = sal_True;
853 					}
854 					// JP 15.07.96: das pBase wird nur fuer die Schnittstelle
855 					//              benoetigt. Muss mal umgetstellt werden!!!
856 					pWrtShell->UpdateTableOf( *pBase );
857 
858 					if( pWrtShell->GotoNextTOXBase() )
859 						pBase = pWrtShell->GetCurTOX();
860 					else
861 						pBase = 0;
862 				}
863 			}
864 			pWrtShell->SetReadOnlyAvailable( bOldCrsrInReadOnly );
865 			pWrtShell->EndAction();
866 		}
867 		break;
868 		case SID_ATTR_BRUSH:
869 		{
870 			if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_BACKGROUND, sal_False, &pItem))
871 			{
872 				const sal_uInt16 nCurIdx = pWrtShell->GetCurPageDesc();
873 				SwPageDesc aDesc( pWrtShell->GetPageDesc( nCurIdx ));
874 				SwFrmFmt& rMaster = aDesc.GetMaster();
875                 rMaster.SetFmtAttr(*pItem);
876 				pWrtShell->ChgPageDesc( nCurIdx, aDesc);
877 			}
878 		}
879 		break;
880 		case SID_CLEARHISTORY:
881 		{
882 			pWrtShell->DelAllUndoObj();
883 		}
884 		break;
885 		case SID_UNDO:
886 		{
887 			pShell->ExecuteSlot(rReq);
888 		}
889 		break;
890 		case FN_INSERT_CTRL:
891 		case FN_INSERT_OBJ_CTRL:
892 		{
893 			if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem))
894 			{
895 				sal_uInt16 nValue = ((SfxUInt16Item*)pItem)->GetValue();
896 				switch ( nSlot )
897 				{
898 					case FN_INSERT_CTRL:
899 					{
900 						sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
901 						if(bWeb)
902 							SwView::nWebInsertCtrlState = nValue;
903 						else
904 							SwView::nInsertCtrlState = nValue;
905 					}
906 					break;
907 					case FN_INSERT_OBJ_CTRL:    SwView::nInsertObjectCtrlState = nValue  ;break;
908 				}
909 
910 			}
911 			GetViewFrame()->GetBindings().Invalidate( nSlot );
912 		}
913 		break;
914 #if defined WNT || defined UNX
915         case SID_TWAIN_SELECT:
916         case SID_TWAIN_TRANSFER:
917             GetViewImpl()->ExecuteScan( rReq );
918 		break;
919 #endif
920 
921 		case SID_ATTR_DEFTABSTOP:
922 		{
923 			if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_DEFTABSTOP, sal_False, &pItem))
924 			{
925                 SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
926 				sal_uInt16 nTab = ((const SfxUInt16Item*)pItem)->GetValue();
927 				MakeDefTabs( nTab, aDefTabs );
928 				pWrtShell->SetDefault( aDefTabs );
929 			}
930 		}
931 		break;
932 		case SID_ATTR_LANGUAGE	:
933 		if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_LANGUAGE, sal_False, &pItem))
934 		{
935 			SvxLanguageItem aLang(((SvxLanguageItem*)pItem)->GetLanguage(), RES_CHRATR_LANGUAGE);
936 			pWrtShell->SetDefault( aLang );
937 			lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_LANGUAGE );
938 		}
939 		break;
940 		case  SID_ATTR_CHAR_CTL_LANGUAGE:
941 		if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CTL_LANGUAGE, sal_False, &pItem))
942 		{
943 			pWrtShell->SetDefault( *pItem );
944 			lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_CTL_LANGUAGE );
945 		}
946 		break;
947 		case  SID_ATTR_CHAR_CJK_LANGUAGE:
948 		if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CJK_LANGUAGE, sal_False, &pItem))
949 		{
950 			pWrtShell->SetDefault( *pItem );
951 			lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_CJK_LANGUAGE );
952 		}
953 		break;
954         case FN_SCROLL_NEXT_PREV:
955 			if(pArgs && pArgs->GetItemState(FN_SCROLL_NEXT_PREV, sal_False, &pItem))
956 			{
957                 // call the handlers of PageUp/DownButtons, only
958                 bool* pbNext = new bool ( ((const SfxBoolItem*)pItem)->GetValue() );
959                 // #i75416# move the execution of the search to an asynchronously called static link
960                 Application::PostUserEvent( STATIC_LINK(this, SwView, MoveNavigationHdl), pbNext );
961 			}
962 			break;
963 		case SID_JUMPTOMARK:
964 			if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_JUMPTOMARK, sal_False, &pItem))
965 				JumpToSwMark( (( const SfxStringItem*)pItem)->GetValue() );
966 			break;
967 		case SID_GALLERY :
968             GetViewFrame()->ChildWindowExecute(rReq);//ToggleChildWindow(SID_GALLERY);
969 		break;
970 		case SID_AVMEDIA_PLAYER :
971             GetViewFrame()->ChildWindowExecute(rReq);//ToggleChildWindow(SID_AVMEDIA_PLAYER);
972 		break;
973         case SID_VIEW_DATA_SOURCE_BROWSER:
974 		{
975             SfxViewFrame* pVFrame = GetViewFrame();
976             pVFrame->ChildWindowExecute(rReq);
977             if(pVFrame->HasChildWindow(SID_BROWSER))
978             {
979                 const SwDBData& rData = GetWrtShell().GetDBDesc();
980                 SW_MOD()->ShowDBObj(*this, rData, sal_False);
981             }
982         }
983 		break;
984         case FN_INSERT_FIELD_DATA_ONLY :
985 		{
986 			sal_Bool bShow = sal_False;
987 			if( pArgs &&
988 				SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem ))
989 				bShow = ((const SfxBoolItem*)pItem)->GetValue();
990             //GetViewFrame()->ShowChildWindow(nSlot, bShow && bInMailMerge);
991             if((bShow && bInMailMerge) != GetViewFrame()->HasChildWindow(nSlot))
992                 GetViewFrame()->ToggleChildWindow(nSlot);
993             //if fields have been succesfully inserted call the "real"
994             //mail merge dialog
995             SwWrtShell &rSh = GetWrtShell();
996             if(bInMailMerge && rSh.IsAnyDatabaseFieldInDoc())
997             {
998                 SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr();
999                 if (pNewDBMgr)
1000                 {
1001                     SwDBData aData;
1002                     aData = rSh.GetDBData();
1003                     rSh.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer
1004                                         // das Mischen von DB-Feldern notwendig.
1005                     AttrChangedNotify( &rSh );
1006                     pNewDBMgr->SetMergeType( DBMGR_MERGE );
1007 
1008                     Sequence<PropertyValue> aProperties(3);
1009                     PropertyValue* pValues = aProperties.getArray();
1010                     pValues[0].Name = C2U("DataSourceName");
1011                     pValues[1].Name = C2U("Command");
1012                     pValues[2].Name = C2U("CommandType");
1013                     pValues[0].Value <<= aData.sDataSource;
1014                     pValues[1].Value <<= aData.sCommand;
1015                     pValues[2].Value <<= aData.nCommandType;
1016                     pNewDBMgr->ExecuteFormLetter(rSh, aProperties, sal_True);
1017                 }
1018             }
1019             bInMailMerge &= bShow;
1020             GetViewFrame()->GetBindings().Invalidate(FN_INSERT_FIELD);
1021 		}
1022         break;
1023         case FN_QRY_MERGE:
1024         {
1025             sal_Bool bUseCurrentDocument = sal_True;
1026             sal_Bool bQuery = !pArgs||SFX_ITEM_SET != pArgs->GetItemState(nSlot);
1027             if(bQuery)
1028             {
1029                 SfxViewFrame* pTmpFrame = GetViewFrame();
1030                 SfxHelp::OpenHelpAgent( &pTmpFrame->GetFrame(), HID_MAIL_MERGE_SELECT );
1031 				SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1032                 DBG_ASSERT(pFact, "Dialogdiet fail!");
1033                 AbstractMailMergeCreateFromDlg* pDlg = pFact->CreateMailMergeCreateFromDlg( DLG_MERGE_CREATE,
1034 														&pTmpFrame->GetWindow());
1035                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
1036 				if(RET_OK == pDlg->Execute())
1037                     bUseCurrentDocument = pDlg->IsThisDocument();
1038                 else
1039                     break;
1040             }
1041             GenerateFormLetter(bUseCurrentDocument);
1042         }
1043         break;
1044         case SID_RECHECK_DOCUMENT:
1045         {
1046             SwDocShell* pDocShell = GetDocShell();
1047             SwDoc* pDoc = pDocShell->GetDoc();
1048             uno::Reference< linguistic2::XProofreadingIterator >  xGCIterator( pDoc->GetGCIterator() );
1049             if( xGCIterator.is() )
1050             {
1051                 xGCIterator->resetIgnoreRules();
1052             }
1053             // reset ignore lists
1054             pDoc->SpellItAgainSam( sal_True, sal_False, sal_False );
1055             // clear ignore dictionary
1056             uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY );
1057             if( xDictionary.is() )
1058                 xDictionary->clear();
1059             // put cursor to the start of the document
1060             pWrtShell->SttDoc();
1061         }
1062         // no break; - but call spell/grammar dialog
1063         case FN_SPELL_GRAMMAR_DIALOG:
1064         {
1065             SfxViewFrame* pViewFrame = GetViewFrame();
1066             if (rReq.GetArgs() != NULL)
1067                 pViewFrame->SetChildWindow (FN_SPELL_GRAMMAR_DIALOG,
1068                     ((const SfxBoolItem&) (rReq.GetArgs()->
1069                         Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue());
1070             else
1071                 pViewFrame->ToggleChildWindow(FN_SPELL_GRAMMAR_DIALOG);
1072 
1073             pViewFrame->GetBindings().Invalidate(FN_SPELL_GRAMMAR_DIALOG);
1074             rReq.Ignore ();
1075         }
1076         break;
1077         case SID_ALIGN_ANY_LEFT :
1078         case SID_ALIGN_ANY_HCENTER  :
1079         case SID_ALIGN_ANY_RIGHT    :
1080         case SID_ALIGN_ANY_JUSTIFIED:
1081         case SID_ALIGN_ANY_TOP      :
1082         case SID_ALIGN_ANY_VCENTER  :
1083         case SID_ALIGN_ANY_BOTTOM   :
1084         case SID_ALIGN_ANY_HDEFAULT :
1085         case SID_ALIGN_ANY_VDEFAULT :
1086         {
1087             sal_uInt16 nAlias = 0;
1088             if( nSelectionType & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_TXT) )
1089             {
1090                 switch( nSlot )
1091                 {
1092                     case SID_ALIGN_ANY_LEFT :       nAlias = SID_ATTR_PARA_ADJUST_LEFT; break;
1093                     case SID_ALIGN_ANY_HCENTER  :   nAlias = SID_ATTR_PARA_ADJUST_CENTER; break;
1094                     case SID_ALIGN_ANY_RIGHT    :   nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break;
1095                     case SID_ALIGN_ANY_JUSTIFIED:   nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break;
1096                     case SID_ALIGN_ANY_TOP      :   nAlias = SID_TABLE_VERT_NONE; break;
1097                     case SID_ALIGN_ANY_VCENTER  :   nAlias = SID_TABLE_VERT_CENTER; break;
1098                     case SID_ALIGN_ANY_BOTTOM   :   nAlias = SID_TABLE_VERT_BOTTOM; break;
1099                 }
1100             }
1101             else
1102             {
1103                 switch( nSlot )
1104                 {
1105                     case SID_ALIGN_ANY_LEFT :       nAlias = SID_OBJECT_ALIGN_LEFT    ; break;
1106                     case SID_ALIGN_ANY_HCENTER  :   nAlias = SID_OBJECT_ALIGN_CENTER ; break;
1107                     case SID_ALIGN_ANY_RIGHT    :   nAlias = SID_OBJECT_ALIGN_RIGHT  ; break;
1108                     case SID_ALIGN_ANY_TOP      :   nAlias = SID_OBJECT_ALIGN_UP     ;  break;
1109                     case SID_ALIGN_ANY_VCENTER  :   nAlias = SID_OBJECT_ALIGN_MIDDLE ;  break;
1110                     case SID_ALIGN_ANY_BOTTOM   :   nAlias = SID_OBJECT_ALIGN_DOWN    ; break;
1111                 }
1112             }
1113             //special handling for the draw shell
1114             if(nAlias && (nSelectionType & (nsSelectionType::SEL_DRW)))
1115             {
1116                 SfxAllEnumItem aEnumItem(SID_OBJECT_ALIGN, nAlias - SID_OBJECT_ALIGN_LEFT);
1117                 GetViewFrame()->GetDispatcher()->Execute(
1118                                 SID_OBJECT_ALIGN, SFX_CALLMODE_ASYNCHRON, &aEnumItem, 0L);
1119             }
1120             else if(nAlias)
1121             //these slots are either re-mapped to text or object alignment
1122                 GetViewFrame()->GetDispatcher()->Execute(
1123                                 nAlias, SFX_CALLMODE_ASYNCHRON);
1124         }
1125         break;
1126         case SID_RESTORE_EDITING_VIEW:
1127         {
1128             //#i33307# restore editing position
1129             Point aCrsrPos;
1130             bool bSelectObj;
1131             if(pViewImpl->GetRestorePosition(aCrsrPos, bSelectObj))
1132             {
1133                 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1134                 if( bSelectObj )
1135                 {
1136                     pWrtShell->SelectObj( aCrsrPos );
1137                     pWrtShell->EnterSelFrmMode( &aCrsrPos );
1138                 }
1139             }
1140         }
1141         break;
1142         case SID_INSERT_GRAPHIC:
1143         {
1144             rReq.SetReturnValue(SfxBoolItem(nSlot, InsertGraphicDlg( rReq )));
1145         }
1146         break;
1147 
1148 
1149         default:
1150 			ASSERT(!this, falscher Dispatcher);
1151 			return;
1152 	}
1153     if(!bIgnore)
1154         rReq.Done();
1155 }
1156 
1157 /*--------------------------------------------------------------------
1158 	Beschreibung:	SeitenNr-Feld invalidieren
1159  --------------------------------------------------------------------*/
1160 
1161 void SwView::UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const String& rPgStr)
1162 {
1163 	String sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr ));
1164 	const SfxStringItem aTmp( FN_STAT_PAGE, sTemp );
1165 	SfxBindings &rBnd = GetViewFrame()->GetBindings();
1166 	rBnd.SetState( aTmp );
1167 	rBnd.Update( FN_STAT_PAGE );
1168 }
1169 
1170 /*--------------------------------------------------------------------
1171 	Beschreibung:	Status der Stauszeile
1172  --------------------------------------------------------------------*/
1173 
1174 
1175 void SwView::StateStatusLine(SfxItemSet &rSet)
1176 {
1177 	SwWrtShell& rShell = GetWrtShell();
1178 
1179 	SfxWhichIter aIter( rSet );
1180 	sal_uInt16 nWhich = aIter.FirstWhich();
1181 	ASSERT( nWhich, "leeres Set");
1182 	//IAccessibility2 Implementation 2009-----
1183 	if (Application::IsAccessibilityEnabled())
1184 	{
1185 		//get section chang event
1186 		const SwSection* CurrSect = rShell.GetCurrSection();
1187 		if( CurrSect )
1188 		{
1189             String sCurrentSectionName = CurrSect->GetSectionName();
1190 			if(sCurrentSectionName != nOldSectionName)
1191 			{
1192 				rShell.FireSectionChangeEvent(2, 1);
1193 			}
1194 			nOldSectionName = sCurrentSectionName;
1195 		}
1196 		else if ( !(nOldSectionName.Equals(String()))  )
1197 		{
1198 			rShell.FireSectionChangeEvent(2, 1);
1199 			nOldSectionName = String();
1200 		}
1201 		//get column change event
1202 		if(rShell.bColumnChange())
1203 		{
1204 			rShell.FireColumnChangeEvent(2, 1);
1205 		}
1206 	}
1207 	//-----IAccessibility2 Implementation 2009
1208 
1209 	while( nWhich )
1210 	{
1211 		switch( nWhich )
1212 		{
1213 			case FN_STAT_PAGE:
1214 /*
1215 //JP 07.01.00: is a nice feature - show the selektion of DrawObjects
1216 			if( rShell.IsObjSelected()
1217 //???				|| rShell.IsFrmSelected()
1218 				)
1219 			{
1220 				String sDisplay( rShell.GetDrawView()->GetMarkedObjectList().
1221 									GetDescriptionOfMarkedObjects() );
1222 				rSet.Put( SfxStringItem( FN_STAT_PAGE, sDisplay ));
1223 			}
1224 			else
1225 */			{
1226 				// Anzahl der Seiten, log. SeitenNr. SeitenNr ermitteln
1227 				sal_uInt16 nPage, nLogPage;
1228 				String sDisplay;
1229 				rShell.GetPageNumber( -1, rShell.IsCrsrVisible(), nPage, nLogPage, sDisplay );
1230 				rSet.Put( SfxStringItem( FN_STAT_PAGE,
1231 							GetPageStr( nPage, nLogPage, sDisplay) ));
1232 				//IAccessibility2 Implementation 2009-----
1233 				//if existing page number is not equal to old page number, send out this event.
1234 				if (nOldPageNum != nLogPage )
1235 				{
1236 					if (nOldPageNum != 0)
1237 						rShell.FirePageChangeEvent(nOldPageNum, nLogPage);
1238 					nOldPageNum = nLogPage;
1239 				}
1240 				//-----IAccessibility2 Implementation 2009
1241 				sal_uInt16 nCnt = GetWrtShell().GetPageCnt();
1242 				if (nPageCnt != nCnt)	// Basic benachrichtigen
1243 				{
1244 					nPageCnt = nCnt;
1245                     SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), sal_False);
1246 				}
1247 			}
1248 			break;
1249 			case FN_STAT_TEMPLATE:
1250 			{
1251 				rSet.Put(SfxStringItem( FN_STAT_TEMPLATE,
1252 										rShell.GetCurPageStyle(sal_False)));
1253 
1254 			}
1255 			break;
1256 			case SID_ATTR_ZOOM:
1257 			{
1258 				if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1259 				{
1260 					const SwViewOption* pVOpt = rShell.GetViewOptions();
1261 					SvxZoomType eZoom = (SvxZoomType) pVOpt->GetZoomType();
1262 					SvxZoomItem aZoom(eZoom,
1263 										pVOpt->GetZoom());
1264 					if( pVOpt->getBrowseMode() )
1265 					{
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);
1272 					}
1273 					rSet.Put( aZoom );
1274                 }
1275 				else
1276 					rSet.DisableItem( SID_ATTR_ZOOM );
1277 			}
1278 			break;
1279             case SID_ATTR_VIEWLAYOUT:
1280             {
1281 				if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1282                 {
1283                     const SwViewOption* pVOpt = rShell.GetViewOptions();
1284                     const sal_uInt16 nColumns  = pVOpt->GetViewLayoutColumns();
1285                     const bool  bBookMode = pVOpt->IsViewLayoutBookMode();
1286                     SvxViewLayoutItem aViewLayout(nColumns, bBookMode);
1287                     rSet.Put( aViewLayout );
1288                 }
1289                 else
1290                     rSet.DisableItem( SID_ATTR_VIEWLAYOUT );
1291             }
1292             break;
1293             case SID_ATTR_ZOOMSLIDER:
1294             {
1295 				if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1296                 {
1297                     const SwViewOption* pVOpt = rShell.GetViewOptions();
1298                     const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
1299                     SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
1300                     aZoomSliderItem.AddSnappingPoint( 100 );
1301 
1302                     if ( !pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
1303                     {
1304                         const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
1305                         const bool bAutomaticViewLayout = 0 == nColumns;
1306                         const SwPostItMgr* pMgr = GetPostItMgr();
1307 
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() :
1317                                              0;
1318 
1319                         Size aRootSize( aRootRect.SSize() );
1320 
1321     		            const MapMode aTmpMap( MAP_TWIP );
1322                         const Size& rEditSize = GetEditWin().GetOutputSizePixel();
1323 		                const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
1324 
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;
1330 
1331                         long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
1332 			            nFac = Min( nFac, nVisPercent );
1333 
1334                         aZoomSliderItem.AddSnappingPoint( nFac );
1335 
1336                         if ( bAutomaticViewLayout )
1337                         {
1338                             nTmpWidth += aPageSize.Width() + GAPBETWEENPAGES;
1339                             nFac = aWindowSize.Width() * 100 / nTmpWidth;
1340                             nFac = Min( nFac, nVisPercent );
1341                             aZoomSliderItem.AddSnappingPoint( nFac );
1342                         }
1343                     }
1344 
1345                     rSet.Put( aZoomSliderItem );
1346                 }
1347                 else
1348                     rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
1349             }
1350             break;
1351             case SID_ATTR_POSITION:
1352 			case SID_ATTR_SIZE:
1353 			{
1354 				if( !rShell.IsFrmSelected() && !rShell.IsObjSelected() )
1355 					SwBaseShell::_SetFrmMode( FLY_DRAG_END );
1356 				else
1357 				{
1358                     FlyMode eFrameMode = SwBaseShell::GetFrmMode();
1359                     if ( eFrameMode == FLY_DRAG_START || eFrameMode == FLY_DRAG )
1360 					{
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()));
1367 					}
1368 				}
1369 			}
1370 			break;
1371 			case SID_TABLE_CELL:
1372 
1373 			if( rShell.IsFrmSelected() || rShell.IsObjSelected() )
1374 			{
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).
1379 			}
1380 			else
1381 			{
1382 				String sStr;
1383 				if( rShell.IsCrsrInTbl() )
1384 				{
1385 					// table name + cell coordinate
1386 					sStr = rShell.GetTableFmt()->GetName();
1387 					sStr += ':';
1388 					sStr += rShell.GetBoxNms();
1389 				}
1390 				else
1391 				{
1392 					const SwSection* pCurrSect = rShell.GetCurrSection();
1393 					if( pCurrSect )
1394 					{
1395 						switch( pCurrSect->GetType() )
1396 						{
1397 						case TOX_HEADER_SECTION:
1398 						case TOX_CONTENT_SECTION:
1399 							{
1400 								const SwTOXBase* pTOX = pWrtShell->GetCurTOX();
1401 								if( pTOX )
1402 									sStr = pTOX->GetTOXName();
1403 								else
1404 								{
1405 									ASSERT( !this,
1406 										"was ist das fuer ein Verzeichnis?" );
1407                                     sStr = pCurrSect->GetSectionName();
1408 								}
1409 							}
1410 							break;
1411 						default:
1412                             sStr = pCurrSect->GetSectionName();
1413 							break;
1414 						}
1415 					}
1416 				}
1417 
1418 				//#outline level, removed by zhaojianwei
1419 				//const SwNumRule* pNumRule = rShell.GetCurNumRule();
1420 				//if (pNumRule)	// Cursor in Numerierung
1421 				//{
1422 				//	sal_uInt8 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, sal_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
1455 
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();
1460 
1461 				if (pNumRule && !bOutlineNum )	// Cursor in Numerierung
1462 				{
1463 					sal_uInt8 nNumLevel = rShell.GetNumLevel();
1464                     // --> OD 2008-04-02 #refactorlists#
1465 //                    if( IsShowNum(nNumLevel) && MAXLEVEL >
1466 //                        ( nNumLevel = GetRealLevel( nNumLevel )) )
1467                     if ( nNumLevel < MAXLEVEL )
1468                     // <--
1469 					{
1470 						if(!pNumRule->IsAutoRule())
1471 						{
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, sal_True
1478 												 /*, &pItem */ ))
1479 							{
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())
1487 								{
1488 									if( sStr.Len() )
1489 										sStr.AppendAscii(sStatusDelim);
1490 									sStr += rNumStyle;
1491 								}
1492 							}
1493 						}
1494 						if( sStr.Len() )
1495 							sStr.AppendAscii(sStatusDelim);
1496 						sStr += SW_RESSTR(STR_NUM_LEVEL);
1497 						sStr += String::CreateFromInt32( nNumLevel + 1 );
1498 
1499 					}
1500 				}
1501 				const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel();
1502 				if( nOutlineLevel != 0 )
1503 				{
1504 					if( sStr.Len() )
1505 						sStr.AppendAscii(sStatusComma);
1506 					if( bOutlineNum )
1507 					{
1508 						sStr += SW_RESSTR(STR_OUTLINE_NUMBERING);
1509 						sStr.AppendAscii(sStatusDelim);
1510 						sStr += SW_RESSTR(STR_NUM_LEVEL);
1511 					}
1512 					else
1513 						sStr += SW_RESSTR(STR_NUM_OUTLINE);
1514 					sStr += String::CreateFromInt32( nOutlineLevel);
1515 				}
1516 				//<-end ,zhaojianwei
1517 
1518 				if( rShell.HasReadonlySel() )
1519 				{
1520 					if( sStr.Len() )
1521 						sStr.InsertAscii( sStatusDelim, 0 );
1522 					sStr.Insert( SW_RESSTR( STR_READONLY_SEL ), 0 );
1523 				}
1524 				if( sStr.Len() )
1525 					rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr ));
1526 			}
1527 			break;
1528 			case FN_STAT_SELMODE:
1529 			{
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;
1539 			}
1540 			case SID_ATTR_INSERT:
1541 				if( rShell.IsRedlineOn() )
1542 					rSet.DisableItem( nWhich );
1543 				else
1544 				{
1545 					rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode()));
1546 				}
1547 				break;
1548 		}
1549 		nWhich = aIter.NextWhich();
1550 	}
1551 }
1552 
1553 /*--------------------------------------------------------------------
1554 	Beschreibung:	Execute fuer die Stauszeile
1555  --------------------------------------------------------------------*/
1556 
1557 
1558 void SwView::ExecuteStatusLine(SfxRequest &rReq)
1559 {
1560 	SwWrtShell &rSh = GetWrtShell();
1561 	const SfxItemSet* pArgs = rReq.GetArgs();
1562     const SfxPoolItem* pItem=NULL;
1563 	sal_Bool bUp = sal_False;
1564 	sal_uInt16 nWhich = rReq.GetSlot();
1565 	switch( nWhich )
1566 	{
1567 		case FN_STAT_PAGE:
1568 		{
1569 			GetViewFrame()->GetDispatcher()->Execute( SID_NAVIGATOR,
1570 									  SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
1571 		}
1572 		break;
1573 
1574         case FN_STAT_BOOKMARK:
1575         if ( pArgs )
1576         {
1577             if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, sal_True, &pItem))
1578             {
1579                 const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess();
1580                 const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1581                 if(nIdx < pMarkAccess->getBookmarksCount())
1582                 {
1583                     const IDocumentMarkAccess::const_iterator_t ppBookmark = rSh.getIDocumentMarkAccess()->getBookmarksBegin() + nIdx;
1584                     rSh.EnterStdMode();
1585                     rSh.GotoMark( ppBookmark->get() );
1586                 }
1587                 else
1588                     OSL_ENSURE(false,
1589                         "SwView::ExecuteStatusLine(..)"
1590                         " - Ignoring out of range bookmark index");
1591             }
1592         }
1593 		break;
1594 
1595 		case FN_STAT_TEMPLATE:
1596 		{
1597 			GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG,
1598 										SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
1599 		}
1600 		break;
1601 		case SID_ATTR_ZOOM:
1602 		{
1603 			if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1604 			{
1605 				const SfxItemSet *pSet = 0;
1606 				AbstractSvxZoomDialog *pDlg = 0;
1607 				if ( pArgs )
1608 					pSet = pArgs;
1609 				else
1610 				{
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() );
1614 
1615                     const bool bBrowseMode = rSh.GetViewOptions()->getBrowseMode();
1616 					if( bBrowseMode )
1617 					{
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);
1624 					}
1625 					aCoreSet.Put( aZoom );
1626 
1627                     // PAGES01
1628                     if ( !bBrowseMode )
1629                     {
1630                         const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() );
1631                         aCoreSet.Put( aViewLayout );
1632                     }
1633 
1634 					SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1635 					if(pFact)
1636 					{
1637                         pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet);
1638                         DBG_ASSERT(pDlg, "Dialogdiet fail!");
1639 					}
1640 
1641 					pDlg->SetLimits( MINZOOM, MAXZOOM );
1642 
1643 					if( pDlg->Execute() != RET_CANCEL )
1644 						pSet = pDlg->GetOutputItemSet();
1645 				}
1646 
1647                 // PAGES01
1648                 const SfxPoolItem* pViewLayoutItem = 0;
1649                 if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_VIEWLAYOUT, sal_True, &pViewLayoutItem))
1650                 {
1651                     const sal_uInt16 nColumns = ((const SvxViewLayoutItem *)pViewLayoutItem)->GetValue();
1652                     const bool bBookMode  = ((const SvxViewLayoutItem *)pViewLayoutItem)->IsBookMode();
1653                     SetViewLayout( nColumns, bBookMode );
1654                 }
1655 
1656 				if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_ZOOM, sal_True, &pItem))
1657 				{
1658                     enum SvxZoomType eType = ((const SvxZoomItem *)pItem)->GetType();
1659 					SetZoom( eType, ((const SvxZoomItem *)pItem)->GetValue() );
1660 				}
1661 				bUp = sal_True;
1662 				if ( pItem )
1663 					rReq.AppendItem( *pItem );
1664 				rReq.Done();
1665 
1666 				delete pDlg;
1667 			}
1668 		}
1669 		break;
1670 
1671         case SID_ATTR_VIEWLAYOUT:
1672         {
1673             if ( pArgs && !rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
1674 				( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1675             {
1676                 // PAGES01
1677                 if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_VIEWLAYOUT, sal_True, &pItem ))
1678                 {
1679                     const sal_uInt16 nColumns = ((const SvxViewLayoutItem *)pItem)->GetValue();
1680                     const bool bBookMode  = (0 == nColumns || 0 != (nColumns % 2)) ?
1681                                             false :
1682                                             ((const SvxViewLayoutItem *)pItem)->IsBookMode();
1683 
1684                     SetViewLayout( nColumns, bBookMode );
1685                 }
1686 
1687                 bUp = sal_True;
1688                 rReq.Done();
1689 
1690                 InvalidateRulerPos();
1691             }
1692         }
1693         break;
1694 
1695         case SID_ATTR_ZOOMSLIDER:
1696         {
1697 			if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1698             {
1699                 // PAGES01
1700                 if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, sal_True, &pItem ))
1701                 {
1702                     const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
1703                     SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom );
1704                 }
1705 
1706                 bUp = sal_True;
1707                 rReq.Done();
1708             }
1709         }
1710         break;
1711 
1712 		case SID_ATTR_SIZE:
1713 		{
1714 			sal_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
1722 			{
1723 				const SwNumRule* pNumRule = rSh.GetCurNumRule();
1724 				if( pNumRule )	// Cursor in Numerierung
1725 				{
1726 					if( pNumRule->IsAutoRule() )
1727 						nId = FN_NUMBER_BULLETS;
1728 					else
1729 					{
1730 						// Dialog vom Gestalter starten ;-)
1731 						nId = 0;
1732 					}
1733 				}
1734 				else if( rSh.IsFrmSelected() )
1735 					nId = FN_FORMAT_FRAME_DLG;
1736 				else if( rSh.IsObjSelected() )
1737 					nId = SID_ATTR_TRANSFORM;
1738 			}
1739 			if( nId )
1740 				GetViewFrame()->GetDispatcher()->Execute(
1741 					static_cast< sal_uInt16 >( nId ), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
1742 		}
1743 		break;
1744 
1745 		case FN_STAT_SELMODE:
1746 		{
1747 			if ( pArgs )
1748 			{
1749 				if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, sal_True, &pItem))
1750 				{
1751 					switch ( ((const SfxUInt16Item *)pItem)->GetValue() )
1752 					{
1753 						case 0: rSh.EnterStdMode(); break;
1754 						case 1: rSh.EnterExtMode(); break;
1755 						case 2: rSh.EnterAddMode(); break;
1756 						case 3: rSh.EnterBlockMode(); break;
1757 					}
1758 				}
1759 			}
1760 			else
1761 			{
1762 
1763 				if( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
1764 					rSh.ToggleExtMode();
1765 				else if ( rSh.IsExtMode() )
1766 				{
1767 					rSh.ToggleExtMode();
1768 					rSh.ToggleAddMode();
1769 				}
1770 				else if ( rSh.IsAddMode() )
1771                 {
1772 					rSh.ToggleAddMode();
1773 					rSh.ToggleBlockMode();
1774                 }
1775                 else
1776 					rSh.ToggleBlockMode();
1777 			}
1778 			bUp = sal_True;
1779 			break;
1780 		}
1781 		case FN_SET_ADD_MODE:
1782 			rSh.ToggleAddMode();
1783 			nWhich = FN_STAT_SELMODE;
1784 			bUp = sal_True;
1785 		break;
1786 		case FN_SET_BLOCK_MODE:
1787 			rSh.ToggleBlockMode();
1788 			nWhich = FN_STAT_SELMODE;
1789 			bUp = sal_True;
1790 		break;
1791 		case FN_SET_EXT_MODE:
1792 			rSh.ToggleExtMode();
1793 			nWhich = FN_STAT_SELMODE;
1794 			bUp = sal_True;
1795 		break;
1796 		case SID_ATTR_INSERT:
1797 			SwPostItMgr* pMgr = GetPostItMgr();
1798             if ( pMgr && pMgr->HasActiveSidebarWin() )
1799             {
1800                 pMgr->ToggleInsModeOnActiveSidebarWin();
1801             }
1802 			else
1803 				rSh.ToggleInsMode();
1804 			bUp = sal_True;
1805 		break;
1806 
1807 	}
1808 	if ( bUp )
1809 	{
1810 		SfxBindings &rBnd = GetViewFrame()->GetBindings();
1811 		rBnd.Invalidate(nWhich);
1812 		rBnd.Update(nWhich);
1813 	}
1814 }
1815 
1816 void SwView::InsFrmMode(sal_uInt16 nCols)
1817 {
1818 	if ( pWrtShell->HasWholeTabSelection() )
1819 	{
1820 		SwFlyFrmAttrMgr aMgr( sal_True, pWrtShell, FRMMGR_TYPE_TEXT );
1821 
1822 		const SwFrmFmt &rPageFmt =
1823 				pWrtShell->GetPageDesc(pWrtShell->GetCurPageDesc()).GetMaster();
1824 		SwTwips lWidth = rPageFmt.GetFrmSize().GetWidth();
1825 		const SvxLRSpaceItem &rLR = rPageFmt.GetLRSpace();
1826 		lWidth -= rLR.GetLeft() + rLR.GetRight();
1827 		aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height()));
1828 		if(nCols > 1)
1829 		{
1830 			SwFmtCol aCol;
1831 			aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
1832 			aMgr.SetCol( aCol );
1833 		}
1834 		aMgr.InsertFlyFrm();
1835 	}
1836 	else
1837 		GetEditWin().InsFrm(nCols);
1838 }
1839 
1840 /*--------------------------------------------------------------------
1841 	Beschreibung:	Links bearbeiten
1842  --------------------------------------------------------------------*/
1843 
1844 void SwView::EditLinkDlg()
1845 {
1846 	sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
1847     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1848     SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb );
1849     if ( pDlg )
1850     {
1851         pDlg->Execute();
1852         delete pDlg;
1853     }
1854 /*
1855 	SwLinkDlg* pDlg = new SwLinkDlg(GetFrameWindow());
1856 	pDlg->SetShell(&GetWrtShell());
1857 	pDlg->Execute();
1858 
1859 	DELETEZ(pDlg);
1860 */
1861 }
1862 
1863 sal_Bool SwView::JumpToSwMark( const String& rMark )
1864 {
1865 	sal_Bool bRet = sal_False;
1866 	if( rMark.Len() )
1867 	{
1868 		// wir wollen den Bookmark aber am oberen Rand haben
1869 		sal_Bool bSaveCC = IsCrsrAtCenter();
1870 		sal_Bool bSaveCT = IsCrsrAtTop();
1871 		SetCrsrAtTop( sal_True );
1872 
1873 		//JP 27.04.98: Bug 49786
1874 		// Damit in FrameSet auch gescrollt werden kann, muss die
1875 		// entsprechende Shell auch das Focus-Flag gesetzt haben!
1876 		sal_Bool bHasShFocus = pWrtShell->HasShFcs();
1877 		if( !bHasShFocus )
1878 			pWrtShell->ShGetFcs( sal_False );
1879 
1880 		const SwFmtINetFmt* pINet;
1881 		String sCmp, sMark( INetURLObject::decode( rMark, INET_HEX_ESCAPE,
1882 						   				INetURLObject::DECODE_WITH_CHARSET,
1883 										RTL_TEXTENCODING_UTF8 ));
1884 
1885 		xub_StrLen nLastPos, nPos = sMark.Search( cMarkSeperator );
1886 		if( STRING_NOTFOUND != nPos )
1887 			while( STRING_NOTFOUND != ( nLastPos =
1888 				sMark.Search( cMarkSeperator, nPos + 1 )) )
1889 				nPos = nLastPos;
1890 
1891         IDocumentMarkAccess::const_iterator_t ppMark;
1892         IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
1893 		if( STRING_NOTFOUND != nPos &&
1894 			( sCmp = sMark.Copy( nPos + 1 ) ).EraseAllChars().Len() )
1895 		{
1896 			String sName( sMark.Copy( 0, nPos ) );
1897 			sCmp.ToLowerAscii();
1898 			FlyCntType eFlyType = FLYCNTTYPE_ALL;
1899 
1900 			if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToRegion ) )
1901 			{
1902 				pWrtShell->EnterStdMode();
1903 				bRet = pWrtShell->GotoRegion( sName );
1904 			}
1905 			else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOutline ) )
1906 			{
1907 				pWrtShell->EnterStdMode();
1908 				bRet = pWrtShell->GotoOutline( sName );
1909 			}
1910 			else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToFrame ) )
1911 				eFlyType = FLYCNTTYPE_FRM;
1912 			else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToGraphic ) )
1913 				eFlyType = FLYCNTTYPE_GRF;
1914 			else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOLE ) )
1915 				eFlyType = FLYCNTTYPE_OLE;
1916 			else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToTable ) )
1917 			{
1918 				pWrtShell->EnterStdMode();
1919 				bRet = pWrtShell->GotoTable( sName );
1920 			}
1921 			else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToText ) )
1922 			{
1923 				// Normale Textsuche
1924 				pWrtShell->EnterStdMode();
1925 
1926 				SearchOptions aSearchOpt(
1927 									SearchAlgorithms_ABSOLUTE, 0,
1928 									sName, rtl::OUString(),
1929 									SvxCreateLocale( LANGUAGE_SYSTEM ),
1930 									0,0,0,
1931 									TransliterationModules_IGNORE_CASE );
1932 
1933 				//todo/mba: assuming that notes shouldn't be searched
1934 				sal_Bool bSearchInNotes = sal_False;
1935 				if( pWrtShell->SearchPattern( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END ))
1936 				{
1937 					pWrtShell->EnterStdMode();		// Selektion wieder aufheben
1938 					bRet = sal_True;
1939 				}
1940 			}
1941 			else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) )
1942 				pWrtShell->GotoMark( ppMark->get(), sal_False, sal_True ), bRet = sal_True;
1943 			else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) ))
1944 				bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
1945 
1946 			// fuer alle Arten von Flys
1947 			if( FLYCNTTYPE_ALL != eFlyType && pWrtShell->GotoFly( sName, eFlyType ))
1948 			{
1949 				bRet = sal_True;
1950 				if( FLYCNTTYPE_FRM == eFlyType )
1951 				{
1952 					// TextFrames: Cursor in den Frame setzen
1953 					pWrtShell->UnSelectFrm();
1954 					pWrtShell->LeaveSelFrmMode();
1955 				}
1956 				else
1957 				{
1958 					pWrtShell->HideCrsr();
1959 					pWrtShell->EnterSelFrmMode();
1960 				}
1961 			}
1962 		}
1963         else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)))
1964 			pWrtShell->GotoMark( ppMark->get(), sal_False, sal_True ), bRet = sal_True;
1965 		else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) ))
1966 			bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
1967 
1968         // #b6330459# make selection visible later
1969         if ( aVisArea.IsEmpty() )
1970             bMakeSelectionVisible = sal_True;
1971 
1972         // ViewStatus wieder zurueck setzen
1973 		SetCrsrAtTop( bSaveCT, bSaveCC );
1974 
1975 		if( !bHasShFocus )
1976 			pWrtShell->ShLooseFcs();
1977 	}
1978 	return bRet;
1979 }
1980 
1981 // #i67305, #1367991: Undo after insert from file:
1982 // Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled
1983 // Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains
1984 // page styles with active header/footer => disabled for those documents
1985 
1986 sal_uInt16 lcl_PageDescWithHeader( const SwDoc& rDoc )
1987 {
1988     sal_uInt16 nRet = 0;
1989     sal_uInt16 nCnt = rDoc.GetPageDescCnt();
1990     for( sal_uInt16 i = 0; i < nCnt; ++i )
1991     {
1992         const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i );
1993         const SwFrmFmt& rMaster = rPageDesc.GetMaster();
1994         const SfxPoolItem* pItem;
1995         if( ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_HEADER, sal_False, &pItem ) &&
1996               ((SwFmtHeader*)pItem)->IsActive() ) ||
1997             ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_FOOTER, sal_False, &pItem )  &&
1998               ((SwFmtFooter*)pItem)->IsActive()) )
1999             ++nRet;
2000     }
2001     return nRet; // number of page styles with active header/footer
2002 }
2003 
2004 /*--------------------------------------------------------------------
2005 	Beschreibung:	Links bearbeiten
2006  --------------------------------------------------------------------*/
2007 
2008 void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem )
2009 {
2010     pViewImpl->InitRequest( rRequest );
2011     pViewImpl->SetParam( pItem ? 1 : 0 );
2012     sal_uInt16 nSlot = rRequest.GetSlot();
2013 
2014     if ( !pItem )
2015     {
2016         String sEmpty;
2017         InsertDoc( nSlot, sEmpty, sEmpty );
2018     }
2019     else
2020     {
2021         String sFile, sFilter;
2022         sFile = ( (const SfxStringItem *)pItem )->GetValue();
2023         if ( SFX_ITEM_SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, sal_True, &pItem ) )
2024             sFilter = ( (const SfxStringItem *)pItem )->GetValue();
2025 
2026         bool bHasFileName = ( sFile.Len() > 0 );
2027         long nFound = InsertDoc( nSlot, sFile, sFilter );
2028 
2029         if ( bHasFileName )
2030         {
2031             rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2032             rRequest.Done();
2033         }
2034     }
2035 }
2036 
2037 long SwView::InsertDoc( sal_uInt16 nSlotId, const String& rFileName, const String& rFilterName, sal_Int16 nVersion )
2038 {
2039 	SfxMedium* pMed = 0;
2040 	SwDocShell* pDocSh = GetDocShell();
2041 
2042 	if( rFileName.Len() )
2043 	{
2044 		SfxObjectFactory& rFact = pDocSh->GetFactory();
2045         const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
2046 		if ( !pFilter )
2047 		{
2048 			pMed = new SfxMedium(rFileName, STREAM_READ, sal_True, 0, 0 );
2049 			SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
2050             pMed->UseInteractionHandler( sal_True );
2051 			ErrCode nErr = aMatcher.GuessFilter( *pMed, &pFilter, sal_False );
2052 			if ( nErr )
2053 				DELETEZ(pMed);
2054 			else
2055 				pMed->SetFilter( pFilter );
2056 		}
2057 		else
2058 			pMed = new SfxMedium(rFileName, STREAM_READ, sal_True, pFilter, 0);
2059 	}
2060 	else
2061 	{
2062         String sFactory = String::CreateFromAscii( pDocSh->GetFactory().GetShortName() );
2063         pViewImpl->StartDocumentInserter( sFactory, LINK( this, SwView, DialogClosedHdl ) );
2064         return -1;
2065 	}
2066 
2067     if( !pMed )
2068 		return -1;
2069 
2070     return InsertMedium( nSlotId, pMed, nVersion );
2071 }
2072 
2073 long SwView::InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVersion )
2074 {
2075     sal_Bool bInsert = sal_False, bCompare = sal_False, bMerge = sal_False;
2076     long nFound = 0;
2077     SwDocShell* pDocSh = GetDocShell();
2078 
2079     switch( nSlotId )
2080     {
2081         case SID_DOCUMENT_MERGE:        bMerge = sal_True;      break;
2082         case SID_DOCUMENT_COMPARE:      bCompare = sal_True;    break;
2083         case SID_INSERTDOC:             bInsert = sal_True;     break;
2084 
2085         default:
2086             ASSERT( !this, "Unbekannte SlotId!" );
2087             bInsert = sal_True;
2088             nSlotId = SID_INSERTDOC;
2089             break;
2090     }
2091 
2092     if( bInsert )
2093 	{
2094         uno::Reference< frame::XDispatchRecorder > xRecorder =
2095                 GetViewFrame()->GetBindings().GetRecorder();
2096 		if ( xRecorder.is() )
2097         {
2098             SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC);
2099             aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL()));
2100             if(pMedium->GetFilter())
2101             aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName()));
2102             aRequest.Done();
2103         }
2104 
2105         SfxObjectShellRef aRef( pDocSh );
2106 
2107         sal_uInt32 nError = SfxObjectShell::HandleFilter( pMedium, pDocSh );
2108         // #i16722# aborted?
2109         if(nError != ERRCODE_NONE)
2110         {
2111             delete pMedium;
2112             return -1;
2113         }
2114         pDocSh->RegisterTransfer( *pMedium );
2115         pMedium->DownLoad();    // ggfs. den DownLoad anstossen
2116 		if( aRef.Is() && 1 < aRef->GetRefCount() )	// noch gueltige Ref?
2117 		{
2118 			SwReader* pRdr;
2119             Reader *pRead = pDocSh->StartConvertFrom( *pMedium, &pRdr, pWrtShell );
2120 			if( pRead ||
2121                 (pMedium->GetFilter()->GetFilterFlags() & SFX_FILTER_STARONEFILTER) != 0 )
2122 			{
2123                 sal_uInt16 nUndoCheck = 0;
2124                 SwDoc *pDoc = pDocSh->GetDoc();
2125                 if( pRead && pDocSh->GetDoc() )
2126                     nUndoCheck = lcl_PageDescWithHeader( *pDoc );
2127 				sal_uLong nErrno;
2128 				{	//Scope for SwWait-Object, to be able to execute slots
2129 					//outside this scope.
2130 					SwWait aWait( *GetDocShell(), sal_True );
2131 					pWrtShell->StartAllAction();
2132 					if ( pWrtShell->HasSelection() )
2133 						pWrtShell->DelRight();		// Selektionen loeschen
2134 					if( pRead )
2135 					{
2136 						nErrno = pRdr->Read( *pRead );	// und Dokument einfuegen
2137 						delete pRdr;
2138 					}
2139 					else
2140 					{
2141                         ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
2142                         nErrno = pDocSh->InsertFrom( *pMedium ) ? 0 : ERR_SWG_READ_ERROR;
2143 					}
2144 
2145 				}
2146 
2147 				// ggfs. alle Verzeichnisse updaten:
2148 				if( pWrtShell->IsUpdateTOX() )
2149 				{
2150 					SfxRequest aReq( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
2151 					Execute( aReq );
2152 					pWrtShell->SetUpdateTOX( sal_False );		// wieder zurueck setzen
2153 				}
2154 
2155                 if( pDoc )
2156                 { // Disable Undo for .sdw (136991) or
2157                   // if the number of page styles with header/footer has changed (#i67305)
2158                     if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) )
2159                     {
2160                         pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
2161                     }
2162                 }
2163 
2164 				pWrtShell->EndAllAction();
2165 				if( nErrno )
2166 				{
2167 					ErrorHandler::HandleError( nErrno );
2168 					nFound = IsError( nErrno ) ? -1 : 0;
2169 				}
2170 				else
2171 					nFound = 0;
2172 			}
2173 		}
2174 	}
2175 	else
2176 	{
2177 		SfxObjectShellRef xDocSh;
2178 		SfxObjectShellLock xLockRef;
2179 
2180 extern int lcl_FindDocShell( SfxObjectShellRef& xDocSh, SfxObjectShellLock& xLockRef,
2181 							const String& rFileName, const String& rPasswd,
2182 							String& rFilter, sal_Int16 nVersion,
2183 							SwDocShell* pDestSh );
2184 
2185 		String sFltNm;
2186         int nRet = lcl_FindDocShell( xDocSh, xLockRef, pMedium->GetName(), aEmptyStr,
2187 									sFltNm, nVersion, pDocSh );
2188 		if( nRet )
2189 		{
2190 			SwWait aWait( *GetDocShell(), sal_True );
2191 			pWrtShell->StartAllAction();
2192 
2193 			pWrtShell->EnterStdMode();			// Selektionen loeschen
2194 
2195 			if( bCompare )
2196 				nFound = pWrtShell->CompareDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
2197 			else
2198 				nFound = pWrtShell->MergeDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
2199 
2200 			pWrtShell->EndAllAction();
2201 
2202 			if (!bCompare && !nFound)
2203 			{
2204 				Window* pWin = &GetEditWin();
2205 				InfoBox(pWin, SW_RES(MSG_NO_MERGE_ENTRY)).Execute();
2206 			}
2207 		}
2208 		if( 2 == nRet && xDocSh.Is() )
2209 			xDocSh->DoClose();
2210 	}
2211 
2212     delete pMedium;
2213 	return nFound;
2214 }
2215 /* -----------------05.02.2003 12:06-----------------
2216  *
2217  * --------------------------------------------------*/
2218 void SwView::EnableMailMerge(sal_Bool bEnable )
2219 {
2220     bInMailMerge = bEnable;
2221     SfxBindings& rBind = GetViewFrame()->GetBindings();
2222     rBind.Invalidate(FN_INSERT_FIELD_DATA_ONLY);
2223     rBind.Update(FN_INSERT_FIELD_DATA_ONLY);
2224 }
2225 /*
2226 */
2227 namespace
2228 {
2229 	sal_Bool lcl_NeedAdditionalDataSource( const uno::Reference< XNameAccess >& _rDatasourceContext )
2230 	{
2231 		Sequence < OUString > aNames = _rDatasourceContext->getElementNames();
2232 
2233 		return	(	!aNames.getLength()
2234 				||	(	( 1 == aNames.getLength() )
2235 					&&	aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
2236 					)
2237 				);
2238 	}
2239 }
2240 
2241 /* -----------------27.11.2002 12:12-----------------
2242  *
2243  * --------------------------------------------------*/
2244 
2245 class SwMergeSourceWarningBox_Impl : public ModalDialog
2246 {
2247         FixedInfo       aMessageFI;
2248         OKButton        aOK;
2249         CancelButton    aCancel;
2250 
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                   ) )
2259                     {
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 );
2268 
2269                         aImageSize.Width() += aWarnImage.GetPosPixel().X();
2270                         Size aSz(GetSizePixel());
2271                         aSz.Width() += aImageSize.Width();
2272                         SetSizePixel(aSz);
2273 
2274                         Point aPos(aMessageFI.GetPosPixel());
2275                         aPos.X() += aImageSize.Width();
2276                         aMessageFI.SetPosPixel( aPos );
2277 
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 );
2284 
2285                     }
2286 
2287         String          GetMessText() const { return aMessageFI.GetText(); }
2288         void            SetMessText( const String& rText ) { aMessageFI.SetText( rText ); }
2289 };
2290 
2291 
2292 
2293 
2294 void SwView::GenerateFormLetter(sal_Bool bUseCurrentDocument)
2295 {
2296     if(bUseCurrentDocument)
2297     {
2298         if(!GetWrtShell().IsAnyDatabaseFieldInDoc())
2299         {
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() )
2304             {
2305                 uno::Reference<XInterface> xInstance = xMgr->createInstance(
2306                     OUString::createFromAscii( "com.sun.star.sdb.DatabaseContext" ));
2307                 xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ;
2308             }
2309             if(!xDBContext.is())
2310                 return ;
2311             sal_Bool bCallAddressPilot = sal_False;
2312 			if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2313             {
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 = sal_True;
2322             }
2323             else
2324             {
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;
2336 
2337             }
2338             if(bCallAddressPilot)
2339             {
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;
2346             }
2347 
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, sal_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, sal_True);
2357             pVFrame->GetDispatcher()->Execute(FN_INSERT_FIELD_DATA_ONLY,
2358                                                 SFX_CALLMODE_SYNCHRON, &aOn, 0L);
2359             return;
2360         }
2361         else
2362         {
2363             // check whether the
2364             String sSource;
2365             if(!GetWrtShell().IsFieldDataSourceAvailable(sSource))
2366             {
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())
2372                 {
2373                     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
2374                     if ( pFact )
2375                     {
2376                         VclAbstractDialog* pDlg = pFact->CreateVclDialog( NULL, SID_OPTIONS_DATABASES );
2377                         pDlg->Execute();
2378                         delete pDlg;
2379                     }
2380                 }
2381                 return ;
2382             }
2383         }
2384         SwNewDBMgr* pNewDBMgr = GetWrtShell().GetNewDBMgr();
2385 
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 );
2393 
2394         if (pNewDBMgr)
2395         {
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, sal_True);
2405         }
2406     }
2407     else
2408     {
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();
2414 
2415         int nRet = pDocTemplDlg->Execute();
2416         sal_Bool bNewWin = sal_False;
2417         if ( nRet == RET_OK )
2418         {
2419             if ( pTopWin != pSfxApp->GetTopWindow() )
2420             {
2421                 // the dialogue opens a document -> a new TopWindow appears
2422                 pTopWin = pSfxApp->GetTopWindow();
2423                 bNewWin = sal_True;
2424             }
2425         }
2426 
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();
2432 
2433 //        return;
2434     }
2435 }
2436 
2437 IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
2438 {
2439     if ( ERRCODE_NONE == _pFileDlg->GetError() )
2440     {
2441         SfxMedium* pMed = pViewImpl->CreateMedium();
2442         if ( pMed )
2443         {
2444             sal_uInt16 nSlot = pViewImpl->GetRequest()->GetSlot();
2445             long nFound = InsertMedium( nSlot, pMed, pViewImpl->GetParam() );
2446 
2447             if ( SID_INSERTDOC == nSlot )
2448             {
2449                 if ( pViewImpl->GetParam() == 0 )
2450                 {
2451                     pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2452                     pViewImpl->GetRequest()->Ignore();
2453                 }
2454                 else
2455                 {
2456                     pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2457                     pViewImpl->GetRequest()->Done();
2458                 }
2459             }
2460             else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot )
2461             {
2462                 pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) );
2463 
2464                 if ( nFound > 0 ) // Redline-Browser anzeigen
2465                 {
2466                     SfxViewFrame* pVFrame = GetViewFrame();
2467                     pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
2468 
2469                     // RedlineDlg neu initialisieren
2470                     sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
2471                     SwRedlineAcceptChild* pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow( nId );
2472                     if ( pRed )
2473                         pRed->ReInitDlg( GetDocShell() );
2474                 }
2475             }
2476         }
2477     }
2478     return 0;
2479 }
2480 
2481 void SwView::ExecuteScan( SfxRequest& rReq )
2482 {
2483 	if (pViewImpl)
2484 		pViewImpl->ExecuteScan(rReq) ;
2485 }
2486 
2487