xref: /trunk/main/sw/source/ui/uiview/view2.cxx (revision a9ab3c7b3d31474a75bf54404ada03e2f02464cb)
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     if (Application::IsAccessibilityEnabled())
1183     {
1184         //get section chang event
1185         const SwSection* CurrSect = rShell.GetCurrSection();
1186         if( CurrSect )
1187         {
1188             String sCurrentSectionName = CurrSect->GetSectionName();
1189             if(sCurrentSectionName != nOldSectionName)
1190             {
1191                 rShell.FireSectionChangeEvent(2, 1);
1192             }
1193             nOldSectionName = sCurrentSectionName;
1194         }
1195         else if ( !(nOldSectionName.Equals(String()))  )
1196         {
1197             rShell.FireSectionChangeEvent(2, 1);
1198             nOldSectionName = String();
1199         }
1200         //get column change event
1201         if(rShell.bColumnChange())
1202         {
1203             rShell.FireColumnChangeEvent(2, 1);
1204         }
1205     }
1206 
1207     while( nWhich )
1208     {
1209         switch( nWhich )
1210         {
1211             case FN_STAT_PAGE:
1212 /*
1213 //JP 07.01.00: is a nice feature - show the selektion of DrawObjects
1214             if( rShell.IsObjSelected()
1215 //???               || rShell.IsFrmSelected()
1216                 )
1217             {
1218                 String sDisplay( rShell.GetDrawView()->GetMarkedObjectList().
1219                                     GetDescriptionOfMarkedObjects() );
1220                 rSet.Put( SfxStringItem( FN_STAT_PAGE, sDisplay ));
1221             }
1222             else
1223 */          {
1224                 // Anzahl der Seiten, log. SeitenNr. SeitenNr ermitteln
1225                 sal_uInt16 nPage, nLogPage;
1226                 String sDisplay;
1227                 rShell.GetPageNumber( -1, rShell.IsCrsrVisible(), nPage, nLogPage, sDisplay );
1228                 rSet.Put( SfxStringItem( FN_STAT_PAGE,
1229                             GetPageStr( nPage, nLogPage, sDisplay) ));
1230                 //if existing page number is not equal to old page number, send out this event.
1231                 if (nOldPageNum != nLogPage )
1232                 {
1233                     if (nOldPageNum != 0)
1234                         rShell.FirePageChangeEvent(nOldPageNum, nLogPage);
1235                     nOldPageNum = nLogPage;
1236                 }
1237                 sal_uInt16 nCnt = GetWrtShell().GetPageCnt();
1238                 if (nPageCnt != nCnt)   // Basic benachrichtigen
1239                 {
1240                     nPageCnt = nCnt;
1241                     SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), sal_False);
1242                 }
1243             }
1244             break;
1245             case FN_STAT_TEMPLATE:
1246             {
1247                 rSet.Put(SfxStringItem( FN_STAT_TEMPLATE,
1248                                         rShell.GetCurPageStyle(sal_False)));
1249 
1250             }
1251             break;
1252             case SID_ATTR_ZOOM:
1253             {
1254                 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1255                 {
1256                     const SwViewOption* pVOpt = rShell.GetViewOptions();
1257                     SvxZoomType eZoom = (SvxZoomType) pVOpt->GetZoomType();
1258                     SvxZoomItem aZoom(eZoom,
1259                                         pVOpt->GetZoom());
1260                     if( pVOpt->getBrowseMode() )
1261                     {
1262                         aZoom.SetValueSet(
1263                                 SVX_ZOOM_ENABLE_50|
1264                                 SVX_ZOOM_ENABLE_75|
1265                                 SVX_ZOOM_ENABLE_100|
1266                                 SVX_ZOOM_ENABLE_150|
1267                                 SVX_ZOOM_ENABLE_200);
1268                     }
1269                     rSet.Put( aZoom );
1270                 }
1271                 else
1272                     rSet.DisableItem( SID_ATTR_ZOOM );
1273             }
1274             break;
1275             case SID_ATTR_VIEWLAYOUT:
1276             {
1277                 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1278                 {
1279                     const SwViewOption* pVOpt = rShell.GetViewOptions();
1280                     const sal_uInt16 nColumns  = pVOpt->GetViewLayoutColumns();
1281                     const bool  bBookMode = pVOpt->IsViewLayoutBookMode();
1282                     SvxViewLayoutItem aViewLayout(nColumns, bBookMode);
1283                     rSet.Put( aViewLayout );
1284                 }
1285                 else
1286                     rSet.DisableItem( SID_ATTR_VIEWLAYOUT );
1287             }
1288             break;
1289             case SID_ATTR_ZOOMSLIDER:
1290             {
1291                 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1292                 {
1293                     const SwViewOption* pVOpt = rShell.GetViewOptions();
1294                     const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
1295                     SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
1296                     aZoomSliderItem.AddSnappingPoint( 100 );
1297 
1298                     if ( !pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
1299                     {
1300                         const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
1301                         const bool bAutomaticViewLayout = 0 == nColumns;
1302                         const SwPostItMgr* pMgr = GetPostItMgr();
1303 
1304                         // snapping points:
1305                         // automatic mode: 1 Page, 2 Pages, 100%
1306                         // n Columns mode: n Pages, 100%
1307                         // n Columns book mode: nPages without gaps, 100%
1308                         const SwRect aPageRect( pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) );
1309                         const SwRect aRootRect( pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) ); // width of columns
1310                         Size aPageSize( aPageRect.SSize() );
1311                         aPageSize.Width() += pMgr->HasNotes() && pMgr->ShowNotes() ?
1312                                              pMgr->GetSidebarWidth() + pMgr->GetSidebarBorderWidth() :
1313                                              0;
1314 
1315                         Size aRootSize( aRootRect.SSize() );
1316 
1317                         const MapMode aTmpMap( MAP_TWIP );
1318                         const Size& rEditSize = GetEditWin().GetOutputSizePixel();
1319                         const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
1320 
1321                         const long nOf = DOCUMENTBORDER * 2L;
1322                         long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
1323                         nTmpWidth += nOf;
1324                         aPageSize.Height() += nOf;
1325                         long nFac = aWindowSize.Width() * 100 / nTmpWidth;
1326 
1327                         long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
1328                         nFac = Min( nFac, nVisPercent );
1329 
1330                         aZoomSliderItem.AddSnappingPoint( nFac );
1331 
1332                         if ( bAutomaticViewLayout )
1333                         {
1334                             nTmpWidth += aPageSize.Width() + GAPBETWEENPAGES;
1335                             nFac = aWindowSize.Width() * 100 / nTmpWidth;
1336                             nFac = Min( nFac, nVisPercent );
1337                             aZoomSliderItem.AddSnappingPoint( nFac );
1338                         }
1339                     }
1340 
1341                     rSet.Put( aZoomSliderItem );
1342                 }
1343                 else
1344                     rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
1345             }
1346             break;
1347             case SID_ATTR_POSITION:
1348             case SID_ATTR_SIZE:
1349             {
1350                 if( !rShell.IsFrmSelected() && !rShell.IsObjSelected() )
1351                     SwBaseShell::_SetFrmMode( FLY_DRAG_END );
1352                 else
1353                 {
1354                     FlyMode eFrameMode = SwBaseShell::GetFrmMode();
1355                     if ( eFrameMode == FLY_DRAG_START || eFrameMode == FLY_DRAG )
1356                     {
1357                         if ( nWhich == SID_ATTR_POSITION )
1358                             rSet.Put( SfxPointItem( SID_ATTR_POSITION,
1359                                                     rShell.GetAnchorObjDiff()));
1360                         else
1361                             rSet.Put( SvxSizeItem( SID_ATTR_SIZE,
1362                                                    rShell.GetObjSize()));
1363                     }
1364                 }
1365             }
1366             break;
1367             case SID_TABLE_CELL:
1368 
1369             if( rShell.IsFrmSelected() || rShell.IsObjSelected() )
1370             {
1371                 // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem.
1372                 // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot
1373                 // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied
1374                 // in SID_ATTR_SIZE).
1375             }
1376             else
1377             {
1378                 String sStr;
1379                 if( rShell.IsCrsrInTbl() )
1380                 {
1381                     // table name + cell coordinate
1382                     sStr = rShell.GetTableFmt()->GetName();
1383                     sStr += ':';
1384                     sStr += rShell.GetBoxNms();
1385                 }
1386                 else
1387                 {
1388                     const SwSection* pCurrSect = rShell.GetCurrSection();
1389                     if( pCurrSect )
1390                     {
1391                         switch( pCurrSect->GetType() )
1392                         {
1393                         case TOX_HEADER_SECTION:
1394                         case TOX_CONTENT_SECTION:
1395                             {
1396                                 const SwTOXBase* pTOX = pWrtShell->GetCurTOX();
1397                                 if( pTOX )
1398                                     sStr = pTOX->GetTOXName();
1399                                 else
1400                                 {
1401                                     ASSERT( !this,
1402                                         "was ist das fuer ein Verzeichnis?" );
1403                                     sStr = pCurrSect->GetSectionName();
1404                                 }
1405                             }
1406                             break;
1407                         default:
1408                             sStr = pCurrSect->GetSectionName();
1409                             break;
1410                         }
1411                     }
1412                 }
1413 
1414                 //#outline level, removed by zhaojianwei
1415                 //const SwNumRule* pNumRule = rShell.GetCurNumRule();
1416                 //if (pNumRule) // Cursor in Numerierung
1417                 //{
1418                 //  sal_uInt8 nNumLevel = rShell.GetNumLevel();
1419                 //  if( IsShowNum(nNumLevel) && MAXLEVEL >
1420                 //      ( nNumLevel = GetRealLevel( nNumLevel )) )
1421                 //  {
1422                 //      if( sStr.Len() )
1423                 //          sStr.AppendAscii(sStatusDelim);
1424                 //      sStr += SW_RESSTR(STR_NUM_LEVEL);
1425                 //      sStr += String::CreateFromInt32( nNumLevel + 1 );
1426                 //      if(!pNumRule->IsAutoRule())
1427                 //      {
1428                 //          SfxItemSet aSet(GetPool(),
1429                 //              RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
1430                 //          rShell.GetCurAttr(aSet);
1431                 //          /* const SfxPoolItem* pItem; */
1432                 //          if(SFX_ITEM_AVAILABLE <=
1433                 //              aSet.GetItemState(RES_PARATR_NUMRULE, sal_True
1434                 //              /*, &pItem */ ))
1435                 //          {
1436                 //              const String& rNumStyle =
1437                 //                  ((const SfxStringItem &)
1438                 //                  aSet.Get(RES_PARATR_NUMRULE)).GetValue();
1439                 //              /* #i5116# GetItemState does not necessarily
1440                 //              change pItem */
1441                 //              // ((const SfxStringItem*)pItem)->GetValue();
1442                 //              if(rNumStyle.Len())
1443                 //              {
1444                 //                  sStr.AppendAscii(sStatusDelim);
1445                 //                  sStr += rNumStyle;
1446                 //              }
1447                 //          }
1448                 //      }
1449                 //  }
1450                 //}//<-removed end ,zhaojianwei
1451 
1452                 //-->#outline level,added by zhaojianwei
1453                 const SwNumRule* pNumRule = rShell.GetCurNumRule();
1454                 const bool bOutlineNum = pNumRule ? pNumRule->IsOutlineRule() : 0;
1455                        //((SwTxtFmtColl*)rShell.GetCrsr()->GetNode()->GetTxtNode()->GetFmtColl())->IsAssignedToListLevelOfOutlineStyle();
1456 
1457                 if (pNumRule && !bOutlineNum )  // Cursor in Numerierung
1458                 {
1459                     sal_uInt8 nNumLevel = rShell.GetNumLevel();
1460                     // --> OD 2008-04-02 #refactorlists#
1461 //                    if( IsShowNum(nNumLevel) && MAXLEVEL >
1462 //                        ( nNumLevel = GetRealLevel( nNumLevel )) )
1463                     if ( nNumLevel < MAXLEVEL )
1464                     // <--
1465                     {
1466                         if(!pNumRule->IsAutoRule())
1467                         {
1468                             SfxItemSet aSet(GetPool(),
1469                                     RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
1470                             rShell.GetCurAttr(aSet);
1471                             /* const SfxPoolItem* pItem; */
1472                             if(SFX_ITEM_AVAILABLE <=
1473                                aSet.GetItemState(RES_PARATR_NUMRULE, sal_True
1474                                                  /*, &pItem */ ))
1475                             {
1476                                 const String& rNumStyle =
1477                                     ((const SfxStringItem &)
1478                                      aSet.Get(RES_PARATR_NUMRULE)).GetValue();
1479                                 /* #i5116# GetItemState does not necessarily
1480                                    change pItem */
1481                                 // ((const SfxStringItem*)pItem)->GetValue();
1482                                 if(rNumStyle.Len())
1483                                 {
1484                                     if( sStr.Len() )
1485                                         sStr.AppendAscii(sStatusDelim);
1486                                     sStr += rNumStyle;
1487                                 }
1488                             }
1489                         }
1490                         if( sStr.Len() )
1491                             sStr.AppendAscii(sStatusDelim);
1492                         sStr += SW_RESSTR(STR_NUM_LEVEL);
1493                         sStr += String::CreateFromInt32( nNumLevel + 1 );
1494 
1495                     }
1496                 }
1497                 const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel();
1498                 if( nOutlineLevel != 0 )
1499                 {
1500                     if( sStr.Len() )
1501                         sStr.AppendAscii(sStatusComma);
1502                     if( bOutlineNum )
1503                     {
1504                         sStr += SW_RESSTR(STR_OUTLINE_NUMBERING);
1505                         sStr.AppendAscii(sStatusDelim);
1506                         sStr += SW_RESSTR(STR_NUM_LEVEL);
1507                     }
1508                     else
1509                         sStr += SW_RESSTR(STR_NUM_OUTLINE);
1510                     sStr += String::CreateFromInt32( nOutlineLevel);
1511                 }
1512                 //<-end ,zhaojianwei
1513 
1514                 if( rShell.HasReadonlySel() )
1515                 {
1516                     if( sStr.Len() )
1517                         sStr.InsertAscii( sStatusDelim, 0 );
1518                     sStr.Insert( SW_RESSTR( STR_READONLY_SEL ), 0 );
1519                 }
1520                 if( sStr.Len() )
1521                     rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr ));
1522             }
1523             break;
1524             case FN_STAT_SELMODE:
1525             {
1526                 if(rShell.IsStdMode())
1527                     rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
1528                 else if(rShell.IsAddMode())
1529                     rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 2));
1530                 else if(rShell.IsBlockMode())
1531                     rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 3));
1532                 else
1533                     rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 1));
1534                 break;
1535             }
1536             case SID_ATTR_INSERT:
1537                 if( rShell.IsRedlineOn() )
1538                     rSet.DisableItem( nWhich );
1539                 else
1540                 {
1541                     rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode()));
1542                 }
1543                 break;
1544         }
1545         nWhich = aIter.NextWhich();
1546     }
1547 }
1548 
1549 /*--------------------------------------------------------------------
1550     Beschreibung:   Execute fuer die Stauszeile
1551  --------------------------------------------------------------------*/
1552 
1553 
1554 void SwView::ExecuteStatusLine(SfxRequest &rReq)
1555 {
1556     SwWrtShell &rSh = GetWrtShell();
1557     const SfxItemSet* pArgs = rReq.GetArgs();
1558     const SfxPoolItem* pItem=NULL;
1559     sal_Bool bUp = sal_False;
1560     sal_uInt16 nWhich = rReq.GetSlot();
1561     switch( nWhich )
1562     {
1563         case FN_STAT_PAGE:
1564         {
1565             GetViewFrame()->GetDispatcher()->Execute( SID_NAVIGATOR,
1566                                       SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
1567         }
1568         break;
1569 
1570         case FN_STAT_BOOKMARK:
1571         if ( pArgs )
1572         {
1573             if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, sal_True, &pItem))
1574             {
1575                 const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess();
1576                 const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1577                 if(nIdx < pMarkAccess->getBookmarksCount())
1578                 {
1579                     const IDocumentMarkAccess::const_iterator_t ppBookmark = rSh.getIDocumentMarkAccess()->getBookmarksBegin() + nIdx;
1580                     rSh.EnterStdMode();
1581                     rSh.GotoMark( ppBookmark->get() );
1582                 }
1583                 else
1584                     OSL_ENSURE(false,
1585                         "SwView::ExecuteStatusLine(..)"
1586                         " - Ignoring out of range bookmark index");
1587             }
1588         }
1589         break;
1590 
1591         case FN_STAT_TEMPLATE:
1592         {
1593             GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG,
1594                                         SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
1595         }
1596         break;
1597         case SID_ATTR_ZOOM:
1598         {
1599             if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1600             {
1601                 const SfxItemSet *pSet = 0;
1602                 AbstractSvxZoomDialog *pDlg = 0;
1603                 if ( pArgs )
1604                     pSet = pArgs;
1605                 else
1606                 {
1607                     const SwViewOption& rViewOptions = *rSh.GetViewOptions();
1608                     SfxItemSet aCoreSet(pShell->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM, SID_ATTR_VIEWLAYOUT, SID_ATTR_VIEWLAYOUT, 0 );
1609                     SvxZoomItem aZoom( (SvxZoomType)rViewOptions.GetZoomType(), rViewOptions.GetZoom() );
1610 
1611                     const bool bBrowseMode = rSh.GetViewOptions()->getBrowseMode();
1612                     if( bBrowseMode )
1613                     {
1614                         aZoom.SetValueSet(
1615                                 SVX_ZOOM_ENABLE_50|
1616                                 SVX_ZOOM_ENABLE_75|
1617                                 SVX_ZOOM_ENABLE_100|
1618                                 SVX_ZOOM_ENABLE_150|
1619                                 SVX_ZOOM_ENABLE_200);
1620                     }
1621                     aCoreSet.Put( aZoom );
1622 
1623                     // PAGES01
1624                     if ( !bBrowseMode )
1625                     {
1626                         const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() );
1627                         aCoreSet.Put( aViewLayout );
1628                     }
1629 
1630                     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1631                     if(pFact)
1632                     {
1633                         pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet);
1634                         DBG_ASSERT(pDlg, "Dialogdiet fail!");
1635                     }
1636 
1637                     pDlg->SetLimits( MINZOOM, MAXZOOM );
1638 
1639                     if( pDlg->Execute() != RET_CANCEL )
1640                         pSet = pDlg->GetOutputItemSet();
1641                 }
1642 
1643                 // PAGES01
1644                 const SfxPoolItem* pViewLayoutItem = 0;
1645                 if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_VIEWLAYOUT, sal_True, &pViewLayoutItem))
1646                 {
1647                     const sal_uInt16 nColumns = ((const SvxViewLayoutItem *)pViewLayoutItem)->GetValue();
1648                     const bool bBookMode  = ((const SvxViewLayoutItem *)pViewLayoutItem)->IsBookMode();
1649                     SetViewLayout( nColumns, bBookMode );
1650                 }
1651 
1652                 if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_ZOOM, sal_True, &pItem))
1653                 {
1654                     enum SvxZoomType eType = ((const SvxZoomItem *)pItem)->GetType();
1655                     SetZoom( eType, ((const SvxZoomItem *)pItem)->GetValue() );
1656                 }
1657                 bUp = sal_True;
1658                 if ( pItem )
1659                     rReq.AppendItem( *pItem );
1660                 rReq.Done();
1661 
1662                 delete pDlg;
1663             }
1664         }
1665         break;
1666 
1667         case SID_ATTR_VIEWLAYOUT:
1668         {
1669             if ( pArgs && !rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
1670                 ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1671             {
1672                 // PAGES01
1673                 if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_VIEWLAYOUT, sal_True, &pItem ))
1674                 {
1675                     const sal_uInt16 nColumns = ((const SvxViewLayoutItem *)pItem)->GetValue();
1676                     const bool bBookMode  = (0 == nColumns || 0 != (nColumns % 2)) ?
1677                                             false :
1678                                             ((const SvxViewLayoutItem *)pItem)->IsBookMode();
1679 
1680                     SetViewLayout( nColumns, bBookMode );
1681                 }
1682 
1683                 bUp = sal_True;
1684                 rReq.Done();
1685 
1686                 InvalidateRulerPos();
1687             }
1688         }
1689         break;
1690 
1691         case SID_ATTR_ZOOMSLIDER:
1692         {
1693             if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1694             {
1695                 // PAGES01
1696                 if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, sal_True, &pItem ))
1697                 {
1698                     const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
1699                     SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom );
1700                 }
1701 
1702                 bUp = sal_True;
1703                 rReq.Done();
1704             }
1705         }
1706         break;
1707 
1708         case SID_ATTR_SIZE:
1709         {
1710             sal_uLong nId = FN_INSERT_FIELD;
1711             if( rSh.IsCrsrInTbl() )
1712                 nId = FN_FORMAT_TABLE_DLG;
1713             else if( rSh.GetCurTOX() )
1714                 nId = FN_INSERT_MULTI_TOX;
1715             else if( rSh.GetCurrSection() )
1716                 nId = FN_EDIT_REGION;
1717             else
1718             {
1719                 const SwNumRule* pNumRule = rSh.GetCurNumRule();
1720                 if( pNumRule )  // Cursor in Numerierung
1721                 {
1722                     if( pNumRule->IsAutoRule() )
1723                         nId = FN_NUMBER_BULLETS;
1724                     else
1725                     {
1726                         // Dialog vom Gestalter starten ;-)
1727                         nId = 0;
1728                     }
1729                 }
1730                 else if( rSh.IsFrmSelected() )
1731                     nId = FN_FORMAT_FRAME_DLG;
1732                 else if( rSh.IsObjSelected() )
1733                     nId = SID_ATTR_TRANSFORM;
1734             }
1735             if( nId )
1736                 GetViewFrame()->GetDispatcher()->Execute(
1737                     static_cast< sal_uInt16 >( nId ), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
1738         }
1739         break;
1740 
1741         case FN_STAT_SELMODE:
1742         {
1743             if ( pArgs )
1744             {
1745                 if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, sal_True, &pItem))
1746                 {
1747                     switch ( ((const SfxUInt16Item *)pItem)->GetValue() )
1748                     {
1749                         case 0: rSh.EnterStdMode(); break;
1750                         case 1: rSh.EnterExtMode(); break;
1751                         case 2: rSh.EnterAddMode(); break;
1752                         case 3: rSh.EnterBlockMode(); break;
1753                     }
1754                 }
1755             }
1756             else
1757             {
1758 
1759                 if( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
1760                     rSh.ToggleExtMode();
1761                 else if ( rSh.IsExtMode() )
1762                 {
1763                     rSh.ToggleExtMode();
1764                     rSh.ToggleAddMode();
1765                 }
1766                 else if ( rSh.IsAddMode() )
1767                 {
1768                     rSh.ToggleAddMode();
1769                     rSh.ToggleBlockMode();
1770                 }
1771                 else
1772                     rSh.ToggleBlockMode();
1773             }
1774             bUp = sal_True;
1775             break;
1776         }
1777         case FN_SET_ADD_MODE:
1778             rSh.ToggleAddMode();
1779             nWhich = FN_STAT_SELMODE;
1780             bUp = sal_True;
1781         break;
1782         case FN_SET_BLOCK_MODE:
1783             rSh.ToggleBlockMode();
1784             nWhich = FN_STAT_SELMODE;
1785             bUp = sal_True;
1786         break;
1787         case FN_SET_EXT_MODE:
1788             rSh.ToggleExtMode();
1789             nWhich = FN_STAT_SELMODE;
1790             bUp = sal_True;
1791         break;
1792         case SID_ATTR_INSERT:
1793             SwPostItMgr* pMgr = GetPostItMgr();
1794             if ( pMgr && pMgr->HasActiveSidebarWin() )
1795             {
1796                 pMgr->ToggleInsModeOnActiveSidebarWin();
1797             }
1798             else
1799                 rSh.ToggleInsMode();
1800             bUp = sal_True;
1801         break;
1802 
1803     }
1804     if ( bUp )
1805     {
1806         SfxBindings &rBnd = GetViewFrame()->GetBindings();
1807         rBnd.Invalidate(nWhich);
1808         rBnd.Update(nWhich);
1809     }
1810 }
1811 
1812 void SwView::InsFrmMode(sal_uInt16 nCols)
1813 {
1814     if ( pWrtShell->HasWholeTabSelection() )
1815     {
1816         SwFlyFrmAttrMgr aMgr( sal_True, pWrtShell, FRMMGR_TYPE_TEXT );
1817 
1818         const SwFrmFmt &rPageFmt =
1819                 pWrtShell->GetPageDesc(pWrtShell->GetCurPageDesc()).GetMaster();
1820         SwTwips lWidth = rPageFmt.GetFrmSize().GetWidth();
1821         const SvxLRSpaceItem &rLR = rPageFmt.GetLRSpace();
1822         lWidth -= rLR.GetLeft() + rLR.GetRight();
1823         aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height()));
1824         if(nCols > 1)
1825         {
1826             SwFmtCol aCol;
1827             aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
1828             aMgr.SetCol( aCol );
1829         }
1830         aMgr.InsertFlyFrm();
1831     }
1832     else
1833         GetEditWin().InsFrm(nCols);
1834 }
1835 
1836 /*--------------------------------------------------------------------
1837     Beschreibung:   Links bearbeiten
1838  --------------------------------------------------------------------*/
1839 
1840 void SwView::EditLinkDlg()
1841 {
1842     sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
1843     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1844     SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb );
1845     if ( pDlg )
1846     {
1847         pDlg->Execute();
1848         delete pDlg;
1849     }
1850 /*
1851     SwLinkDlg* pDlg = new SwLinkDlg(GetFrameWindow());
1852     pDlg->SetShell(&GetWrtShell());
1853     pDlg->Execute();
1854 
1855     DELETEZ(pDlg);
1856 */
1857 }
1858 
1859 sal_Bool SwView::JumpToSwMark( const String& rMark )
1860 {
1861     sal_Bool bRet = sal_False;
1862     if( rMark.Len() )
1863     {
1864         // wir wollen den Bookmark aber am oberen Rand haben
1865         sal_Bool bSaveCC = IsCrsrAtCenter();
1866         sal_Bool bSaveCT = IsCrsrAtTop();
1867         SetCrsrAtTop( sal_True );
1868 
1869         //JP 27.04.98: Bug 49786
1870         // Damit in FrameSet auch gescrollt werden kann, muss die
1871         // entsprechende Shell auch das Focus-Flag gesetzt haben!
1872         sal_Bool bHasShFocus = pWrtShell->HasShFcs();
1873         if( !bHasShFocus )
1874             pWrtShell->ShGetFcs( sal_False );
1875 
1876         const SwFmtINetFmt* pINet;
1877         String sCmp, sMark( INetURLObject::decode( rMark, INET_HEX_ESCAPE,
1878                                         INetURLObject::DECODE_WITH_CHARSET,
1879                                         RTL_TEXTENCODING_UTF8 ));
1880 
1881         xub_StrLen nLastPos, nPos = sMark.Search( cMarkSeperator );
1882         if( STRING_NOTFOUND != nPos )
1883             while( STRING_NOTFOUND != ( nLastPos =
1884                 sMark.Search( cMarkSeperator, nPos + 1 )) )
1885                 nPos = nLastPos;
1886 
1887         IDocumentMarkAccess::const_iterator_t ppMark;
1888         IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess();
1889         if( STRING_NOTFOUND != nPos &&
1890             ( sCmp = sMark.Copy( nPos + 1 ) ).EraseAllChars().Len() )
1891         {
1892             String sName( sMark.Copy( 0, nPos ) );
1893             sCmp.ToLowerAscii();
1894             FlyCntType eFlyType = FLYCNTTYPE_ALL;
1895 
1896             if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToRegion ) )
1897             {
1898                 pWrtShell->EnterStdMode();
1899                 bRet = pWrtShell->GotoRegion( sName );
1900             }
1901             else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOutline ) )
1902             {
1903                 pWrtShell->EnterStdMode();
1904                 bRet = pWrtShell->GotoOutline( sName );
1905             }
1906             else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToFrame ) )
1907                 eFlyType = FLYCNTTYPE_FRM;
1908             else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToGraphic ) )
1909                 eFlyType = FLYCNTTYPE_GRF;
1910             else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOLE ) )
1911                 eFlyType = FLYCNTTYPE_OLE;
1912             else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToTable ) )
1913             {
1914                 pWrtShell->EnterStdMode();
1915                 bRet = pWrtShell->GotoTable( sName );
1916             }
1917             else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToText ) )
1918             {
1919                 // Normale Textsuche
1920                 pWrtShell->EnterStdMode();
1921 
1922                 SearchOptions aSearchOpt(
1923                                     SearchAlgorithms_ABSOLUTE, 0,
1924                                     sName, rtl::OUString(),
1925                                     SvxCreateLocale( LANGUAGE_SYSTEM ),
1926                                     0,0,0,
1927                                     TransliterationModules_IGNORE_CASE );
1928 
1929                 //todo/mba: assuming that notes shouldn't be searched
1930                 sal_Bool bSearchInNotes = sal_False;
1931                 if( pWrtShell->SearchPattern( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END ))
1932                 {
1933                     pWrtShell->EnterStdMode();      // Selektion wieder aufheben
1934                     bRet = sal_True;
1935                 }
1936             }
1937             else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) )
1938                 pWrtShell->GotoMark( ppMark->get(), sal_False, sal_True ), bRet = sal_True;
1939             else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) ))
1940                 bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
1941 
1942             // fuer alle Arten von Flys
1943             if( FLYCNTTYPE_ALL != eFlyType && pWrtShell->GotoFly( sName, eFlyType ))
1944             {
1945                 bRet = sal_True;
1946                 if( FLYCNTTYPE_FRM == eFlyType )
1947                 {
1948                     // TextFrames: Cursor in den Frame setzen
1949                     pWrtShell->UnSelectFrm();
1950                     pWrtShell->LeaveSelFrmMode();
1951                 }
1952                 else
1953                 {
1954                     pWrtShell->HideCrsr();
1955                     pWrtShell->EnterSelFrmMode();
1956                 }
1957             }
1958         }
1959         else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)))
1960             pWrtShell->GotoMark( ppMark->get(), sal_False, sal_True ), bRet = sal_True;
1961         else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) ))
1962             bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
1963 
1964         // #b6330459# make selection visible later
1965         if ( aVisArea.IsEmpty() )
1966             bMakeSelectionVisible = sal_True;
1967 
1968         // ViewStatus wieder zurueck setzen
1969         SetCrsrAtTop( bSaveCT, bSaveCC );
1970 
1971         if( !bHasShFocus )
1972             pWrtShell->ShLooseFcs();
1973     }
1974     return bRet;
1975 }
1976 
1977 // #i67305, #1367991: Undo after insert from file:
1978 // Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled
1979 // Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains
1980 // page styles with active header/footer => disabled for those documents
1981 
1982 sal_uInt16 lcl_PageDescWithHeader( const SwDoc& rDoc )
1983 {
1984     sal_uInt16 nRet = 0;
1985     sal_uInt16 nCnt = rDoc.GetPageDescCnt();
1986     for( sal_uInt16 i = 0; i < nCnt; ++i )
1987     {
1988         const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i );
1989         const SwFrmFmt& rMaster = rPageDesc.GetMaster();
1990         const SfxPoolItem* pItem;
1991         if( ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_HEADER, sal_False, &pItem ) &&
1992               ((SwFmtHeader*)pItem)->IsActive() ) ||
1993             ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_FOOTER, sal_False, &pItem )  &&
1994               ((SwFmtFooter*)pItem)->IsActive()) )
1995             ++nRet;
1996     }
1997     return nRet; // number of page styles with active header/footer
1998 }
1999 
2000 /*--------------------------------------------------------------------
2001     Beschreibung:   Links bearbeiten
2002  --------------------------------------------------------------------*/
2003 
2004 void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem )
2005 {
2006     pViewImpl->InitRequest( rRequest );
2007     pViewImpl->SetParam( pItem ? 1 : 0 );
2008     sal_uInt16 nSlot = rRequest.GetSlot();
2009 
2010     if ( !pItem )
2011     {
2012         String sEmpty;
2013         InsertDoc( nSlot, sEmpty, sEmpty );
2014     }
2015     else
2016     {
2017         String sFile, sFilter;
2018         sFile = ( (const SfxStringItem *)pItem )->GetValue();
2019         if ( SFX_ITEM_SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, sal_True, &pItem ) )
2020             sFilter = ( (const SfxStringItem *)pItem )->GetValue();
2021 
2022         bool bHasFileName = ( sFile.Len() > 0 );
2023         long nFound = InsertDoc( nSlot, sFile, sFilter );
2024 
2025         if ( bHasFileName )
2026         {
2027             rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2028             rRequest.Done();
2029         }
2030     }
2031 }
2032 
2033 long SwView::InsertDoc( sal_uInt16 nSlotId, const String& rFileName, const String& rFilterName, sal_Int16 nVersion )
2034 {
2035     SfxMedium* pMed = 0;
2036     SwDocShell* pDocSh = GetDocShell();
2037 
2038     if( rFileName.Len() )
2039     {
2040         SfxObjectFactory& rFact = pDocSh->GetFactory();
2041         const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
2042         if ( !pFilter )
2043         {
2044             pMed = new SfxMedium(rFileName, STREAM_READ, sal_True, 0, 0 );
2045             SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
2046             pMed->UseInteractionHandler( sal_True );
2047             ErrCode nErr = aMatcher.GuessFilter( *pMed, &pFilter, sal_False );
2048             if ( nErr )
2049                 DELETEZ(pMed);
2050             else
2051                 pMed->SetFilter( pFilter );
2052         }
2053         else
2054             pMed = new SfxMedium(rFileName, STREAM_READ, sal_True, pFilter, 0);
2055     }
2056     else
2057     {
2058         String sFactory = String::CreateFromAscii( pDocSh->GetFactory().GetShortName() );
2059         pViewImpl->StartDocumentInserter( sFactory, LINK( this, SwView, DialogClosedHdl ) );
2060         return -1;
2061     }
2062 
2063     if( !pMed )
2064         return -1;
2065 
2066     return InsertMedium( nSlotId, pMed, nVersion );
2067 }
2068 
2069 long SwView::InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVersion )
2070 {
2071     sal_Bool bInsert = sal_False, bCompare = sal_False, bMerge = sal_False;
2072     long nFound = 0;
2073     SwDocShell* pDocSh = GetDocShell();
2074 
2075     switch( nSlotId )
2076     {
2077         case SID_DOCUMENT_MERGE:        bMerge = sal_True;      break;
2078         case SID_DOCUMENT_COMPARE:      bCompare = sal_True;    break;
2079         case SID_INSERTDOC:             bInsert = sal_True;     break;
2080 
2081         default:
2082             ASSERT( !this, "Unbekannte SlotId!" );
2083             bInsert = sal_True;
2084             nSlotId = SID_INSERTDOC;
2085             break;
2086     }
2087 
2088     if( bInsert )
2089     {
2090         uno::Reference< frame::XDispatchRecorder > xRecorder =
2091                 GetViewFrame()->GetBindings().GetRecorder();
2092         if ( xRecorder.is() )
2093         {
2094             SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC);
2095             aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL()));
2096             if(pMedium->GetFilter())
2097             aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName()));
2098             aRequest.Done();
2099         }
2100 
2101         SfxObjectShellRef aRef( pDocSh );
2102 
2103         sal_uInt32 nError = SfxObjectShell::HandleFilter( pMedium, pDocSh );
2104         // #i16722# aborted?
2105         if(nError != ERRCODE_NONE)
2106         {
2107             delete pMedium;
2108             return -1;
2109         }
2110         pDocSh->RegisterTransfer( *pMedium );
2111         pMedium->DownLoad();    // ggfs. den DownLoad anstossen
2112         if( aRef.Is() && 1 < aRef->GetRefCount() )  // noch gueltige Ref?
2113         {
2114             SwReader* pRdr;
2115             Reader *pRead = pDocSh->StartConvertFrom( *pMedium, &pRdr, pWrtShell );
2116             if( pRead ||
2117                 (pMedium->GetFilter()->GetFilterFlags() & SFX_FILTER_STARONEFILTER) != 0 )
2118             {
2119                 sal_uInt16 nUndoCheck = 0;
2120                 SwDoc *pDoc = pDocSh->GetDoc();
2121                 if( pRead && pDocSh->GetDoc() )
2122                     nUndoCheck = lcl_PageDescWithHeader( *pDoc );
2123                 sal_uLong nErrno;
2124                 {   //Scope for SwWait-Object, to be able to execute slots
2125                     //outside this scope.
2126                     SwWait aWait( *GetDocShell(), sal_True );
2127                     pWrtShell->StartAllAction();
2128                     if ( pWrtShell->HasSelection() )
2129                         pWrtShell->DelRight();      // Selektionen loeschen
2130                     if( pRead )
2131                     {
2132                         nErrno = pRdr->Read( *pRead );  // und Dokument einfuegen
2133                         delete pRdr;
2134                     }
2135                     else
2136                     {
2137                         ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
2138                         nErrno = pDocSh->InsertFrom( *pMedium ) ? 0 : ERR_SWG_READ_ERROR;
2139                     }
2140 
2141                 }
2142 
2143                 // ggfs. alle Verzeichnisse updaten:
2144                 if( pWrtShell->IsUpdateTOX() )
2145                 {
2146                     SfxRequest aReq( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
2147                     Execute( aReq );
2148                     pWrtShell->SetUpdateTOX( sal_False );       // wieder zurueck setzen
2149                 }
2150 
2151                 if( pDoc )
2152                 { // Disable Undo for .sdw (136991) or
2153                   // if the number of page styles with header/footer has changed (#i67305)
2154                     if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) )
2155                     {
2156                         pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
2157                     }
2158                 }
2159 
2160                 pWrtShell->EndAllAction();
2161                 if( nErrno )
2162                 {
2163                     ErrorHandler::HandleError( nErrno );
2164                     nFound = IsError( nErrno ) ? -1 : 0;
2165                 }
2166                 else
2167                     nFound = 0;
2168             }
2169         }
2170     }
2171     else
2172     {
2173         SfxObjectShellRef xDocSh;
2174         SfxObjectShellLock xLockRef;
2175 
2176 extern int lcl_FindDocShell( SfxObjectShellRef& xDocSh, SfxObjectShellLock& xLockRef,
2177                             const String& rFileName, const String& rPasswd,
2178                             String& rFilter, sal_Int16 nVersion,
2179                             SwDocShell* pDestSh );
2180 
2181         String sFltNm;
2182         int nRet = lcl_FindDocShell( xDocSh, xLockRef, pMedium->GetName(), aEmptyStr,
2183                                     sFltNm, nVersion, pDocSh );
2184         if( nRet )
2185         {
2186             SwWait aWait( *GetDocShell(), sal_True );
2187             pWrtShell->StartAllAction();
2188 
2189             pWrtShell->EnterStdMode();          // Selektionen loeschen
2190 
2191             if( bCompare )
2192                 nFound = pWrtShell->CompareDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
2193             else
2194                 nFound = pWrtShell->MergeDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
2195 
2196             pWrtShell->EndAllAction();
2197 
2198             if (!bCompare && !nFound)
2199             {
2200                 Window* pWin = &GetEditWin();
2201                 InfoBox(pWin, SW_RES(MSG_NO_MERGE_ENTRY)).Execute();
2202             }
2203         }
2204         if( 2 == nRet && xDocSh.Is() )
2205             xDocSh->DoClose();
2206     }
2207 
2208     delete pMedium;
2209     return nFound;
2210 }
2211 /* -----------------05.02.2003 12:06-----------------
2212  *
2213  * --------------------------------------------------*/
2214 void SwView::EnableMailMerge(sal_Bool bEnable )
2215 {
2216     bInMailMerge = bEnable;
2217     SfxBindings& rBind = GetViewFrame()->GetBindings();
2218     rBind.Invalidate(FN_INSERT_FIELD_DATA_ONLY);
2219     rBind.Update(FN_INSERT_FIELD_DATA_ONLY);
2220 }
2221 /*
2222 */
2223 namespace
2224 {
2225     sal_Bool lcl_NeedAdditionalDataSource( const uno::Reference< XNameAccess >& _rDatasourceContext )
2226     {
2227         Sequence < OUString > aNames = _rDatasourceContext->getElementNames();
2228 
2229         return  (   !aNames.getLength()
2230                 ||  (   ( 1 == aNames.getLength() )
2231                     &&  aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
2232                     )
2233                 );
2234     }
2235 }
2236 
2237 /* -----------------27.11.2002 12:12-----------------
2238  *
2239  * --------------------------------------------------*/
2240 
2241 class SwMergeSourceWarningBox_Impl : public ModalDialog
2242 {
2243         FixedInfo       aMessageFI;
2244         OKButton        aOK;
2245         CancelButton    aCancel;
2246 
2247         FixedImage      aWarnImage;
2248     public:
2249         SwMergeSourceWarningBox_Impl( Window* pParent ) :
2250             ModalDialog( pParent, SW_RES( DLG_MERGE_SOURCE_UNAVAILABLE   ) ),
2251                     aMessageFI( this, SW_RES( ST_MERGE_SOURCE_UNAVAILABLE ) ),
2252                     aOK(        this, SW_RES( PB_MERGE_OK                 ) ),
2253                     aCancel(    this, SW_RES( PB_MERGE_CANCEL             ) ),
2254                     aWarnImage( this, SW_RES( IMG_MERGE                   ) )
2255                     {
2256                         FreeResource();
2257                         SetText( Application::GetDisplayName() );
2258                         const Image& rImg = WarningBox::GetStandardImage();
2259                         aWarnImage.SetImage( rImg );
2260                         Size aImageSize( rImg.GetSizePixel() );
2261                         aImageSize.Width()  += 4;
2262                         aImageSize.Height() += 4;
2263                         aWarnImage.SetSizePixel( aImageSize );
2264 
2265                         aImageSize.Width() += aWarnImage.GetPosPixel().X();
2266                         Size aSz(GetSizePixel());
2267                         aSz.Width() += aImageSize.Width();
2268                         SetSizePixel(aSz);
2269 
2270                         Point aPos(aMessageFI.GetPosPixel());
2271                         aPos.X() += aImageSize.Width();
2272                         aMessageFI.SetPosPixel( aPos );
2273 
2274                         aPos = aOK.GetPosPixel();
2275                         aPos.X() += aImageSize.Width();
2276                         aOK.SetPosPixel( aPos );
2277                         aPos = aCancel.GetPosPixel();
2278                         aPos.X() += aImageSize.Width();
2279                         aCancel.SetPosPixel( aPos );
2280 
2281                     }
2282 
2283         String          GetMessText() const { return aMessageFI.GetText(); }
2284         void            SetMessText( const String& rText ) { aMessageFI.SetText( rText ); }
2285 };
2286 
2287 
2288 
2289 
2290 void SwView::GenerateFormLetter(sal_Bool bUseCurrentDocument)
2291 {
2292     if(bUseCurrentDocument)
2293     {
2294         if(!GetWrtShell().IsAnyDatabaseFieldInDoc())
2295         {
2296             //check availability of data sources (except biblio source)
2297             uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
2298             uno::Reference<XNameAccess>  xDBContext;
2299             if( xMgr.is() )
2300             {
2301                 uno::Reference<XInterface> xInstance = xMgr->createInstance(
2302                     OUString::createFromAscii( "com.sun.star.sdb.DatabaseContext" ));
2303                 xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ;
2304             }
2305             if(!xDBContext.is())
2306                 return ;
2307             sal_Bool bCallAddressPilot = sal_False;
2308             if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2309             {
2310                 // no data sources are available - create a new one
2311                 WarningBox aWarning(
2312                             &GetViewFrame()->GetWindow(),
2313                             SW_RES(MSG_DATA_SOURCES_UNAVAILABLE));
2314                 // no cancel allowed
2315                 if ( RET_OK != aWarning.Execute() )
2316                     return;
2317                 bCallAddressPilot = sal_True;
2318             }
2319             else
2320             {
2321                 //take an existing data source or create a new one?
2322                     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2323                     DBG_ASSERT(pFact, "Dialogdiet fail!");
2324                     AbstractMailMergeFieldConnectionsDlg* pConnectionsDlg = pFact->CreateMailMergeFieldConnectionsDlg(
2325                                                         DLG_MERGE_FIELD_CONNECTIONS,
2326                                                         &GetViewFrame()->GetWindow());
2327                     DBG_ASSERT(pConnectionsDlg, "Dialogdiet fail!");
2328                     if(RET_OK == pConnectionsDlg->Execute())
2329                         bCallAddressPilot = !pConnectionsDlg->IsUseExistingConnections();
2330                     else
2331                         return;
2332 
2333             }
2334             if(bCallAddressPilot)
2335             {
2336                 GetViewFrame()->GetDispatcher()->Execute(
2337                                 SID_ADDRESS_DATA_SOURCE, SFX_CALLMODE_SYNCHRON);
2338                 if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2339                     // no additional data source has been created
2340                     // -> assume that the user has cancelled the pilot
2341                     return;
2342             }
2343 
2344             //call insert fields with database field page available, only
2345             SfxViewFrame* pVFrame = GetViewFrame();
2346             //at first hide the default field dialog if currently visible
2347             pVFrame->SetChildWindow(FN_INSERT_FIELD, sal_False);
2348             //enable the status of the db field dialog - it is disabled in the status method
2349             //to prevent creation of the dialog without mail merge active
2350             EnableMailMerge();
2351             //then show the "Data base only" field dialog
2352             SfxBoolItem aOn(FN_INSERT_FIELD_DATA_ONLY, sal_True);
2353             pVFrame->GetDispatcher()->Execute(FN_INSERT_FIELD_DATA_ONLY,
2354                                                 SFX_CALLMODE_SYNCHRON, &aOn, 0L);
2355             return;
2356         }
2357         else
2358         {
2359             // check whether the
2360             String sSource;
2361             if(!GetWrtShell().IsFieldDataSourceAvailable(sSource))
2362             {
2363                 SwMergeSourceWarningBox_Impl aWarning( &GetViewFrame()->GetWindow());
2364                 String sTmp(aWarning.GetMessText());
2365                 sTmp.SearchAndReplaceAscii("%1", sSource);
2366                 aWarning.SetMessText(sTmp);
2367                 if(RET_OK == aWarning.Execute())
2368                 {
2369                     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
2370                     if ( pFact )
2371                     {
2372                         VclAbstractDialog* pDlg = pFact->CreateVclDialog( NULL, SID_OPTIONS_DATABASES );
2373                         pDlg->Execute();
2374                         delete pDlg;
2375                     }
2376                 }
2377                 return ;
2378             }
2379         }
2380         SwNewDBMgr* pNewDBMgr = GetWrtShell().GetNewDBMgr();
2381 
2382         SwDBData aData;
2383         SwWrtShell &rSh = GetWrtShell();
2384         aData = rSh.GetDBData();
2385         rSh.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer
2386                             // das Mischen von DB-Feldern notwendig.
2387         AttrChangedNotify( &rSh );
2388         pNewDBMgr->SetMergeType( DBMGR_MERGE );
2389 
2390         if (pNewDBMgr)
2391         {
2392             Sequence<PropertyValue> aProperties(3);
2393             PropertyValue* pValues = aProperties.getArray();
2394             pValues[0].Name = C2U("DataSourceName");
2395             pValues[1].Name = C2U("Command");
2396             pValues[2].Name = C2U("CommandType");
2397             pValues[0].Value <<= aData.sDataSource;
2398             pValues[1].Value <<= aData.sCommand;
2399             pValues[2].Value <<= aData.nCommandType;
2400             pNewDBMgr->ExecuteFormLetter(GetWrtShell(), aProperties, sal_True);
2401         }
2402     }
2403     else
2404     {
2405         //call documents and template dialog
2406         SfxApplication* pSfxApp = SFX_APP();
2407         Window* pTopWin = pSfxApp->GetTopWindow();
2408         SvtDocumentTemplateDialog* pDocTemplDlg = new SvtDocumentTemplateDialog( pTopWin );
2409         pDocTemplDlg->SelectTemplateFolder();
2410 
2411         int nRet = pDocTemplDlg->Execute();
2412         sal_Bool bNewWin = sal_False;
2413         if ( nRet == RET_OK )
2414         {
2415             if ( pTopWin != pSfxApp->GetTopWindow() )
2416             {
2417                 // the dialogue opens a document -> a new TopWindow appears
2418                 pTopWin = pSfxApp->GetTopWindow();
2419                 bNewWin = sal_True;
2420             }
2421         }
2422 
2423         delete pDocTemplDlg;
2424         if ( bNewWin )
2425             // after the destruction of the dialogue its parent comes to top,
2426             // but we want that the new document is on top
2427             pTopWin->ToTop();
2428 
2429 //        return;
2430     }
2431 }
2432 
2433 IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
2434 {
2435     if ( ERRCODE_NONE == _pFileDlg->GetError() )
2436     {
2437         SfxMedium* pMed = pViewImpl->CreateMedium();
2438         if ( pMed )
2439         {
2440             sal_uInt16 nSlot = pViewImpl->GetRequest()->GetSlot();
2441             long nFound = InsertMedium( nSlot, pMed, pViewImpl->GetParam() );
2442 
2443             if ( SID_INSERTDOC == nSlot )
2444             {
2445                 if ( pViewImpl->GetParam() == 0 )
2446                 {
2447                     pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2448                     pViewImpl->GetRequest()->Ignore();
2449                 }
2450                 else
2451                 {
2452                     pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2453                     pViewImpl->GetRequest()->Done();
2454                 }
2455             }
2456             else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot )
2457             {
2458                 pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) );
2459 
2460                 if ( nFound > 0 ) // Redline-Browser anzeigen
2461                 {
2462                     SfxViewFrame* pVFrame = GetViewFrame();
2463                     pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
2464 
2465                     // RedlineDlg neu initialisieren
2466                     sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
2467                     SwRedlineAcceptChild* pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow( nId );
2468                     if ( pRed )
2469                         pRed->ReInitDlg( GetDocShell() );
2470                 }
2471             }
2472         }
2473     }
2474     return 0;
2475 }
2476 
2477 void SwView::ExecuteScan( SfxRequest& rReq )
2478 {
2479     if (pViewImpl)
2480         pViewImpl->ExecuteScan(rReq) ;
2481 }
2482 
2483