LCOV - code coverage report
Current view: top level - sw/source/uibase/uiview - view2.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 156 1231 12.7 %
Date: 2015-06-13 12:38:46 Functions: 7 25 28.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <config_features.h>
      21             : 
      22             : #include <com/sun/star/util/SearchOptions.hpp>
      23             : #include <com/sun/star/util/SearchFlags.hpp>
      24             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      25             : #include <vcl/graphicfilter.hxx>
      26             : #include <com/sun/star/sdb/DatabaseContext.hpp>
      27             : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
      28             : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      29             : #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
      30             : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      31             : #include <svl/aeitem.hxx>
      32             : #include <SwStyleNameMapper.hxx>
      33             : #include <docary.hxx>
      34             : #include <hintids.hxx>
      35             : #include <SwRewriter.hxx>
      36             : #include <numrule.hxx>
      37             : #include <swundo.hxx>
      38             : #include <caption.hxx>
      39             : #include <svl/PasswordHelper.hxx>
      40             : #include <svl/urihelper.hxx>
      41             : #include <svtools/miscopt.hxx>
      42             : #include <sfx2/passwd.hxx>
      43             : #include <sfx2/sfxdlg.hxx>
      44             : #include <sfx2/filedlghelper.hxx>
      45             : #include <sfx2/sfxhelp.hxx>
      46             : #include <editeng/langitem.hxx>
      47             : #include <svx/viewlayoutitem.hxx>
      48             : #include <svx/zoomslideritem.hxx>
      49             : #include <svtools/xwindowitem.hxx>
      50             : #include <svx/linkwarn.hxx>
      51             : #include <sfx2/htmlmode.hxx>
      52             : #include <vcl/svapp.hxx>
      53             : #include <vcl/wrkwin.hxx>
      54             : #include <sfx2/app.hxx>
      55             : #include <sfx2/request.hxx>
      56             : #include <sfx2/bindings.hxx>
      57             : #include <editeng/lrspitem.hxx>
      58             : #include <unotools/textsearch.hxx>
      59             : #include <editeng/unolingu.hxx>
      60             : #include <vcl/layout.hxx>
      61             : #include <vcl/msgbox.hxx>
      62             : #include <editeng/tstpitem.hxx>
      63             : #include <sfx2/event.hxx>
      64             : #include <sfx2/docfile.hxx>
      65             : #include <sfx2/docfilt.hxx>
      66             : #include <sfx2/fcontnr.hxx>
      67             : #include <editeng/sizeitem.hxx>
      68             : #include <sfx2/dispatch.hxx>
      69             : #include <svl/whiter.hxx>
      70             : #include <svl/ptitem.hxx>
      71             : #include <sfx2/linkmgr.hxx>
      72             : #include <tools/errinf.hxx>
      73             : #include <tools/urlobj.hxx>
      74             : #include <svx/svdview.hxx>
      75             : #include <swtypes.hxx>
      76             : #include <swwait.hxx>
      77             : #include <redlndlg.hxx>
      78             : #include <view.hxx>
      79             : #include <uivwimp.hxx>
      80             : #include <docsh.hxx>
      81             : #include <doc.hxx>
      82             : #include <IDocumentUndoRedo.hxx>
      83             : #include <IDocumentSettingAccess.hxx>
      84             : #include <IDocumentDrawModelAccess.hxx>
      85             : #include <IDocumentStatistics.hxx>
      86             : #include <wrtsh.hxx>
      87             : #include <viewopt.hxx>
      88             : #include <basesh.hxx>
      89             : #include <swmodule.hxx>
      90             : #include <uitool.hxx>
      91             : #include <shellio.hxx>
      92             : #include <fmtinfmt.hxx>
      93             : #include <mdiexp.hxx>
      94             : #include <drawbase.hxx>
      95             : #include <frmmgr.hxx>
      96             : #include <pagedesc.hxx>
      97             : #include <section.hxx>
      98             : #include <usrpref.hxx>
      99             : #include <IMark.hxx>
     100             : #include <navipi.hxx>
     101             : #include <tox.hxx>
     102             : #include <workctrl.hxx>
     103             : #include <scroll.hxx>
     104             : #include <edtwin.hxx>
     105             : #include <wview.hxx>
     106             : #include <textsh.hxx>
     107             : #include <tabsh.hxx>
     108             : #include <listsh.hxx>
     109             : #include <cmdid.h>
     110             : #include <comcore.hrc>
     111             : #include <poolfmt.hrc>
     112             : #include <statstr.hrc>
     113             : #include <swerror.h>
     114             : #include <globals.hrc>
     115             : #include <shells.hrc>
     116             : #include <web.hrc>
     117             : #include <view.hrc>
     118             : #include <app.hrc>
     119             : #include <fmtclds.hxx>
     120             : #include <helpid.h>
     121             : #include <sfx2/templatedlg.hxx>
     122             : #include <dbconfig.hxx>
     123             : #include <dbmgr.hxx>
     124             : #include <reffld.hxx>
     125             : 
     126             : #include <PostItMgr.hxx>
     127             : 
     128             : #include <ndtxt.hxx>
     129             : 
     130             : #include <comphelper/processfactory.hxx>
     131             : #include <comphelper/string.hxx>
     132             : 
     133             : #include <svx/svxdlg.hxx>
     134             : #include <svx/dialogs.hrc>
     135             : #include "swabstdlg.hxx"
     136             : #include <envelp.hrc>
     137             : #include <fmthdft.hxx>
     138             : #include <svx/ofaitem.hxx>
     139             : #include <unomid.h>
     140             : #include <unotextrange.hxx>
     141             : #include <docstat.hxx>
     142             : #include <wordcountdialog.hxx>
     143             : #include <sfx2/sidebar/Sidebar.hxx>
     144             : 
     145             : #include <vcl/GraphicNativeTransform.hxx>
     146             : #include <vcl/GraphicNativeMetadata.hxx>
     147             : #include <vcl/settings.hxx>
     148             : 
     149             : #include <boost/scoped_ptr.hpp>
     150             : 
     151             : const char sStatusDelim[] = " : ";
     152             : const char sStatusComma[] = " , ";
     153             : 
     154             : using namespace sfx2;
     155             : using namespace ::com::sun::star;
     156             : using namespace ::com::sun::star::i18n;
     157             : using namespace ::com::sun::star::util;
     158             : using namespace ::com::sun::star::uno;
     159             : using namespace ::com::sun::star::lang;
     160             : using namespace ::com::sun::star::scanner;
     161             : using namespace ::com::sun::star::beans;
     162             : using namespace ::com::sun::star::container;
     163             : using namespace ::com::sun::star::sdb;
     164             : using namespace ::com::sun::star::ui::dialogs;
     165             : 
     166           0 : static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, sal_uInt16 nWhichId )
     167             : {
     168           0 :     if (nWhichId == RES_CHRATR_LANGUAGE ||
     169           0 :         nWhichId == RES_CHRATR_CJK_LANGUAGE ||
     170           0 :         nWhichId == RES_CHRATR_CTL_LANGUAGE)
     171             :     {
     172           0 :         rWrtSh.StartAction();
     173           0 :         rWrtSh.LockView( true );
     174           0 :         rWrtSh.Push();
     175             : 
     176             :         // prepare to apply new language to all text in document
     177           0 :         rWrtSh.SelAll();
     178           0 :         rWrtSh.ExtendedSelectAll();
     179             : 
     180             :         // set language attribute to default for all text
     181           0 :         std::set<sal_uInt16> aAttribs;
     182           0 :         aAttribs.insert( nWhichId );
     183           0 :         rWrtSh.ResetAttr( aAttribs );
     184             : 
     185           0 :         rWrtSh.Pop( false );
     186           0 :         rWrtSh.LockView( false );
     187           0 :         rWrtSh.EndAction();
     188             :     }
     189           0 : }
     190             : 
     191             : /**
     192             :  * Create string for showing the page number in the statusbar
     193             :  *
     194             :  * @param nPhyNum  The physical page number
     195             :  * @param nVirtNum The logical page number (user-assigned)
     196             :  * @param rPgStr   User-defined page name (will be shown if different from logical page number)
     197             :  *
     198             :  * @return OUString Formatted string: Page 1/10 (Page nVirtNumv/rPgStr)
     199             :  **/
     200        1474 : OUString SwView::GetPageStr(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr)
     201             : {
     202             :     // Show user-defined page number in brackets if any.
     203        1474 :     OUString extra;
     204        1474 :     if (!rPgStr.isEmpty() && OUString::number(nPhyNum) != rPgStr)
     205         123 :         extra = rPgStr;
     206        1351 :     else if (nPhyNum != nVirtNum)
     207           0 :         extra = OUString::number(nVirtNum);
     208             : 
     209        1474 :     OUString aStr(extra.isEmpty() ? SW_RES(STR_PAGE_COUNT) : SW_RES(STR_PAGE_COUNT_CUSTOM));
     210        1474 :     aStr = aStr.replaceFirst("%1", OUString::number(nPhyNum));
     211        1474 :     aStr = aStr.replaceFirst("%2", OUString::number(GetWrtShell().GetPageCnt()));
     212        1474 :     aStr = aStr.replaceFirst("%3", extra);
     213        1474 :     return aStr;
     214             : }
     215             : 
     216           0 : int SwView::InsertGraphic( const OUString &rPath, const OUString &rFilter,
     217             :                                 bool bLink, GraphicFilter *pFilter,
     218             :                                 Graphic* pPreviewGrf, bool bRule )
     219             : {
     220           0 :     SwWait aWait( *GetDocShell(), true );
     221             : 
     222           0 :     Graphic aGraphic;
     223           0 :     int aResult = GRFILTER_OK;
     224           0 :     if ( pPreviewGrf )
     225           0 :         aGraphic = *pPreviewGrf;
     226             :     else
     227             :     {
     228           0 :         if( !pFilter )
     229             :         {
     230           0 :             pFilter = &GraphicFilter::GetGraphicFilter();
     231             :         }
     232           0 :         aResult = GraphicFilter::LoadGraphic( rPath, rFilter, aGraphic, pFilter );
     233             :     }
     234             : 
     235           0 :     if( GRFILTER_OK == aResult )
     236             :     {
     237           0 :         GraphicNativeMetadata aMetadata;
     238           0 :         if ( aMetadata.read(aGraphic) )
     239             :         {
     240           0 :             const sal_uInt16 aRotation = aMetadata.getRotation();
     241           0 :             if (aRotation != 0)
     242             :             {
     243           0 :                 ScopedVclPtrInstance< MessageDialog > aQueryBox( GetWindow(),"QueryRotateIntoStandardOrientationDialog","modules/swriter/ui/queryrotateintostandarddialog.ui");
     244           0 :                 if (aQueryBox->Execute() == RET_YES)
     245             :                 {
     246           0 :                     GraphicNativeTransform aTransform( aGraphic );
     247           0 :                     aTransform.rotate( aRotation );
     248           0 :                 }
     249             :             }
     250             :         }
     251             : 
     252           0 :         SwFlyFrmAttrMgr aFrameManager( true, GetWrtShellPtr(), FRMMGR_TYPE_GRF );
     253           0 :         SwWrtShell& rShell = GetWrtShell();
     254             : 
     255             :         // #i123922# determine if we really want to insert or replace the graphic at a selected object
     256           0 :         const bool bReplaceMode(rShell.HasSelection() && nsSelectionType::SEL_FRM == rShell.GetSelectionType());
     257             : 
     258           0 :         if(bReplaceMode)
     259             :         {
     260             :             // #i123922# Do same as in D&D, ReRead graphic and all is done
     261             :             rShell.ReRead(
     262             :                 bLink ? rPath : OUString(),
     263             :                 bLink ? rFilter : OUString(),
     264           0 :                 &aGraphic);
     265             :         }
     266             :         else
     267             :         {
     268           0 :             rShell.StartAction();
     269           0 :             if( bLink )
     270             :             {
     271           0 :                 SwDocShell* pDocSh = GetDocShell();
     272             :                 INetURLObject aTemp(
     273           0 :                     pDocSh->HasName() ?
     274           0 :                         pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) :
     275           0 :                         OUString());
     276             : 
     277             :                 OUString sURL = URIHelper::SmartRel2Abs(
     278           0 :                     aTemp, rPath, URIHelper::GetMaybeFileHdl() );
     279             : 
     280             :                 rShell.Insert( sURL,
     281           0 :                             rFilter, aGraphic, &aFrameManager, bRule );
     282             :             }
     283             :             else
     284             :             {
     285           0 :                 rShell.Insert( OUString(), OUString(), aGraphic, &aFrameManager );
     286             :             }
     287             : 
     288             :             // it is too late after "EndAction" because the Shell can already be destroyed.
     289           0 :             rShell.EndAction();
     290           0 :         }
     291             :     }
     292           0 :     return aResult;
     293             : }
     294             : 
     295           0 : bool SwView::InsertGraphicDlg( SfxRequest& rReq )
     296             : {
     297           0 :     bool bReturn = false;
     298           0 :     SwDocShell* pDocShell = GetDocShell();
     299           0 :     const sal_uInt16 nHtmlMode = ::GetHtmlMode(pDocShell);
     300             :     // when in HTML mode insert only as a link
     301             :     boost::scoped_ptr<FileDialogHelper> pFileDlg(new FileDialogHelper(
     302             :         ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE,
     303           0 :         SFXWB_GRAPHIC ));
     304           0 :     pFileDlg->SetTitle(SW_RESSTR(STR_INSERT_GRAPHIC ));
     305           0 :     pFileDlg->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC );
     306           0 :     uno::Reference < XFilePicker > xFP = pFileDlg->GetFilePicker();
     307           0 :     uno::Reference < XFilePickerControlAccess > xCtrlAcc(xFP, UNO_QUERY);
     308           0 :     if(nHtmlMode & HTMLMODE_ON)
     309             :     {
     310           0 :         xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, makeAny(true));
     311           0 :         xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False);
     312             :     }
     313             : 
     314           0 :     std::vector<OUString> aFormats;
     315           0 :     SwDoc* pDoc = pDocShell->GetDoc();
     316           0 :     const size_t nArrLen = pDoc->GetFrameFormats()->size();
     317           0 :     for( size_t i = 0; i < nArrLen; ++i )
     318             :     {
     319           0 :         const SwFrameFormat* pFormat = (*pDoc->GetFrameFormats())[ i ];
     320           0 :         if(pFormat->IsDefault() || pFormat->IsAuto())
     321           0 :             continue;
     322           0 :         aFormats.push_back(pFormat->GetName());
     323             :     }
     324             : 
     325             :     // pool formats
     326             : 
     327             :     const ::std::vector<OUString>& rFrmPoolArr(
     328           0 :             SwStyleNameMapper::GetFrameFormatUINameArray());
     329           0 :     for( size_t i = 0; i < rFrmPoolArr.size(); ++i )
     330             :     {
     331           0 :         aFormats.push_back(rFrmPoolArr[i]);
     332             :     }
     333             : 
     334           0 :     std::sort(aFormats.begin(), aFormats.end());
     335           0 :     aFormats.erase(std::unique(aFormats.begin(), aFormats.end()), aFormats.end());
     336             : 
     337           0 :     Sequence<OUString> aListBoxEntries(aFormats.size());
     338           0 :     OUString* pEntries = aListBoxEntries.getArray();
     339           0 :     sal_Int16 nSelect = 0;
     340           0 :     OUString sGraphicFormat = SW_RESSTR(STR_POOLFRM_GRAPHIC);
     341           0 :     for( size_t i = 0; i < aFormats.size(); ++i )
     342             :     {
     343           0 :         pEntries[i] = aFormats[i];
     344           0 :         if(pEntries[i].equals(sGraphicFormat))
     345           0 :             nSelect = i;
     346             :     }
     347             :     try
     348             :     {
     349           0 :         Any aTemplates(&aListBoxEntries, cppu::UnoType<decltype(aListBoxEntries)>::get());
     350             : 
     351           0 :         xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
     352           0 :             ListboxControlActions::ADD_ITEMS , aTemplates );
     353             : 
     354           0 :         Any aSelectPos(&nSelect, cppu::UnoType<decltype(nSelect)>::get());
     355           0 :         xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
     356           0 :             ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
     357             :     }
     358           0 :     catch (const Exception&)
     359             :     {
     360             :         OSL_FAIL("control access failed");
     361             :     }
     362             : 
     363           0 :     SFX_REQUEST_ARG( rReq, pName, SfxStringItem, SID_INSERT_GRAPHIC , false );
     364           0 :     bool bShowError = !pName;
     365           0 :     if( pName || ERRCODE_NONE == pFileDlg->Execute() )
     366             :     {
     367             : 
     368           0 :         OUString aFileName, aFilterName;
     369           0 :         if ( pName )
     370             :         {
     371           0 :             aFileName = pName->GetValue();
     372           0 :             SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, FN_PARAM_FILTER , false );
     373           0 :             if ( pFilter )
     374           0 :                 aFilterName = pFilter->GetValue();
     375             :         }
     376             :         else
     377             :         {
     378           0 :             aFileName = pFileDlg->GetPath();
     379           0 :             aFilterName = pFileDlg->GetCurrentFilter();
     380           0 :             rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) );
     381           0 :             rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) );
     382             : 
     383           0 :             bool bAsLink = false;
     384           0 :             if(nHtmlMode & HTMLMODE_ON)
     385           0 :                 bAsLink = true;
     386             :             else
     387             :             {
     388             :                 try
     389             :                 {
     390           0 :                     Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
     391             :                     OSL_ENSURE(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
     392           0 :                     bAsLink = !aVal.hasValue() || *static_cast<sal_Bool const *>(aVal.getValue());
     393           0 :                     Any aTemplateValue = xCtrlAcc->getValue(
     394             :                         ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
     395           0 :                         ListboxControlActions::GET_SELECTED_ITEM );
     396           0 :                     OUString sTmpl;
     397           0 :                     aTemplateValue >>= sTmpl;
     398           0 :                     rReq.AppendItem( SfxStringItem( FN_PARAM_2, sTmpl) );
     399             :                 }
     400           0 :                 catch (const Exception&)
     401             :                 {
     402             :                     OSL_FAIL("control access failed");
     403             :                 }
     404             :             }
     405           0 :             rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
     406             :         }
     407             : 
     408           0 :         SFX_REQUEST_ARG( rReq, pAsLink, SfxBoolItem, FN_PARAM_1 , false );
     409           0 :         SFX_REQUEST_ARG( rReq, pStyle, SfxStringItem, FN_PARAM_2 , false );
     410             : 
     411           0 :         bool bAsLink = false;
     412           0 :         if( nHtmlMode & HTMLMODE_ON )
     413           0 :             bAsLink = true;
     414             :         else
     415             :         {
     416           0 :             if ( rReq.GetArgs() )
     417             :             {
     418           0 :                 if ( pAsLink )
     419           0 :                     bAsLink = pAsLink->GetValue();
     420           0 :                 if ( pStyle && !pStyle->GetValue().isEmpty() )
     421           0 :                     sGraphicFormat = pStyle->GetValue();
     422             :             }
     423             :             else
     424             :             {
     425           0 :                 Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
     426             :                 OSL_ENSURE(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
     427           0 :                 bAsLink = !aVal.hasValue() || *static_cast<sal_Bool const *>(aVal.getValue());
     428           0 :                 Any aTemplateValue = xCtrlAcc->getValue(
     429             :                     ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
     430           0 :                     ListboxControlActions::GET_SELECTED_ITEM );
     431           0 :                 OUString sTmpl;
     432           0 :                 aTemplateValue >>= sTmpl;
     433           0 :                 if( !sTmpl.isEmpty() )
     434           0 :                     sGraphicFormat = sTmpl;
     435           0 :                 rReq.AppendItem( SfxStringItem( FN_PARAM_2, sGraphicFormat ) );
     436           0 :                 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
     437             :             }
     438             : 
     439             :             // really store as link only?
     440           0 :             if( bAsLink && SvtMiscOptions().ShowLinkWarningDialog() )
     441             :             {
     442           0 :                 ScopedVclPtrInstance< SvxLinkWarningDialog > aWarnDlg(GetWindow(),pFileDlg->GetPath());
     443           0 :                 if( aWarnDlg->Execute() != RET_OK )
     444           0 :                     bAsLink=false; // don't store as link
     445             :             }
     446             :         }
     447             : 
     448           0 :         SwWrtShell& rSh = GetWrtShell();
     449           0 :         rSh.LockPaint();
     450           0 :         rSh.StartAction();
     451             : 
     452           0 :         SwRewriter aRewriter;
     453           0 :         aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_GRAPHIC_DEFNAME));
     454             : 
     455             :         // #i123922# determine if we really want to insert or replace the graphic at a selected object
     456           0 :         const bool bReplaceMode(rSh.HasSelection() && nsSelectionType::SEL_FRM == rSh.GetSelectionType());
     457             : 
     458           0 :         rSh.StartUndo(UNDO_INSERT, &aRewriter);
     459             : 
     460           0 :         int nError = InsertGraphic( aFileName, aFilterName, bAsLink, &GraphicFilter::GetGraphicFilter() );
     461             : 
     462             :         // format not equal to current filter (with autodetection)
     463           0 :         if( nError == GRFILTER_FORMATERROR )
     464           0 :             nError = InsertGraphic( aFileName, OUString(), bAsLink, &GraphicFilter::GetGraphicFilter() );
     465             : 
     466             :         // #i123922# no new FrameFormat for replace mode, only when new object was created,
     467             :         // else this would reset the current setting for the frame holding the graphic
     468           0 :         if ( !bReplaceMode && rSh.IsFrmSelected() )
     469             :         {
     470           0 :             SwFrameFormat* pFormat = pDoc->FindFrameFormatByName( sGraphicFormat );
     471           0 :             if(!pFormat)
     472             :                 pFormat = pDoc->MakeFrameFormat(sGraphicFormat,
     473             :                                         pDocShell->GetDoc()->GetDfltFrameFormat(),
     474           0 :                                         true, false);
     475           0 :             rSh.SetFrameFormat( pFormat );
     476             :         }
     477             : 
     478           0 :         RESOURCE_TYPE nResId = 0;
     479           0 :         switch( nError )
     480             :         {
     481             :             case GRFILTER_OPENERROR:
     482           0 :                 nResId = STR_GRFILTER_OPENERROR;
     483           0 :                 break;
     484             :             case GRFILTER_IOERROR:
     485           0 :                 nResId = STR_GRFILTER_IOERROR;
     486           0 :                 break;
     487             :             case GRFILTER_FORMATERROR:
     488           0 :                 nResId = STR_GRFILTER_FORMATERROR;
     489           0 :                 break;
     490             :             case GRFILTER_VERSIONERROR:
     491           0 :                 nResId = STR_GRFILTER_VERSIONERROR;
     492           0 :                 break;
     493             :             case GRFILTER_FILTERERROR:
     494           0 :                 nResId = STR_GRFILTER_FILTERERROR;
     495           0 :                 break;
     496             :             case GRFILTER_TOOBIG:
     497           0 :                 nResId = STR_GRFILTER_TOOBIG;
     498           0 :                 break;
     499             :         }
     500             : 
     501           0 :         rSh.EndAction();
     502           0 :         rSh.UnlockPaint();
     503           0 :         if( nResId )
     504             :         {
     505           0 :             if( bShowError )
     506             :             {
     507           0 :                 ScopedVclPtrInstance< MessageDialog > aInfoBox( GetWindow(), SW_RESSTR( nResId ), VCL_MESSAGE_INFO);
     508           0 :                 aInfoBox->Execute();
     509             :             }
     510           0 :             rReq.Ignore();
     511             :         }
     512             :         else
     513             :         {
     514             :             // set the specific graphic attrbutes to the graphic
     515           0 :             bReturn = true;
     516           0 :             AutoCaption( GRAPHIC_CAP );
     517           0 :             rReq.Done();
     518             :         }
     519             : 
     520           0 :         rSh.EndUndo(); // due to possible change of Shell
     521             :     }
     522             : 
     523           0 :     return bReturn;
     524             : }
     525             : 
     526           1 : void SwView::Execute(SfxRequest &rReq)
     527             : {
     528           1 :     const sal_uInt16 nSlot = rReq.GetSlot();
     529           1 :     const SfxItemSet* pArgs = rReq.GetArgs();
     530             :     const SfxPoolItem* pItem;
     531           1 :     bool bIgnore = false;
     532           1 :     switch( nSlot )
     533             :     {
     534             :         case SID_CREATE_SW_DRAWVIEW:
     535           0 :             m_pWrtShell->getIDocumentDrawModelAccess()->GetOrCreateDrawModel();
     536           0 :             break;
     537             : 
     538             :         case FN_LINE_NUMBERING_DLG:
     539             :         {
     540           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     541             :             OSL_ENSURE(pFact, "Dialog creation failed!");
     542           0 :             boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclSwViewDialog(*this));
     543             :             OSL_ENSURE(pDlg, "Dialog creation failed!");
     544           0 :             pDlg->Execute();
     545           0 :             break;
     546             :         }
     547             :         case FN_EDIT_LINK_DLG:
     548           0 :             EditLinkDlg();
     549           0 :             break;
     550             :         case FN_REFRESH_VIEW:
     551           0 :             GetEditWin().Invalidate();
     552           0 :             break;
     553             :         case FN_PAGEUP:
     554             :         case FN_PAGEUP_SEL:
     555             :         case FN_PAGEDOWN:
     556             :         case FN_PAGEDOWN_SEL:
     557             :         {
     558           0 :             Rectangle aVis( GetVisArea() );
     559           0 :             SwEditWin& rTmpWin = GetEditWin();
     560           0 :             if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot )
     561           0 :                 PageUpCrsr(FN_PAGEUP_SEL == nSlot);
     562             :             else
     563           0 :                 PageDownCrsr(FN_PAGEDOWN_SEL == nSlot);
     564             : 
     565             :             rReq.SetReturnValue(SfxBoolItem(nSlot,
     566           0 :                                                 aVis != GetVisArea()));
     567             :             //#i42732# - notify the edit window that from now on we do not use the input language
     568           0 :             rTmpWin.SetUseInputLanguage( false );
     569             :         }
     570           0 :         break;
     571             :         case FN_REDLINE_ON:
     572             :         {
     573           0 :             if( pArgs &&
     574           0 :                 SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem ))
     575             :             {
     576           0 :                 IDocumentRedlineAccess* pIDRA = m_pWrtShell->getIDocumentRedlineAccess();
     577           0 :                 Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
     578           0 :                 if( aPasswd.getLength() )
     579             :                 {
     580             :                     OSL_ENSURE( !static_cast<const SfxBoolItem*>(pItem)->GetValue(), "SwView::Execute(): password set an redlining off doesn't match!" );
     581             :                     // xmlsec05:    new password dialog
     582             :                     vcl::Window* pParent;
     583             :                     const SfxPoolItem* pParentItem;
     584           0 :                     if( SfxItemState::SET == pArgs->GetItemState( SID_ATTR_XWINDOW, false, &pParentItem ) )
     585           0 :                         pParent = static_cast<const XWindowItem*>( pParentItem )->GetWindowPtr();
     586             :                     else
     587           0 :                         pParent = &GetViewFrame()->GetWindow();
     588           0 :                     ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg( pParent );
     589           0 :                     aPasswdDlg->SetMinLen( 1 );
     590             :                     //#i69751# the result of Execute() can be ignored
     591           0 :                     (void)aPasswdDlg->Execute();
     592           0 :                     OUString sNewPasswd( aPasswdDlg->GetPassword() );
     593           0 :                     Sequence <sal_Int8> aNewPasswd = pIDRA->GetRedlinePassword();
     594           0 :                     SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
     595           0 :                     if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
     596           0 :                         pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
     597             :                     else
     598             :                     {   // xmlsec05: message box for wrong password
     599           0 :                         break;
     600           0 :                     }
     601             :                 }
     602             : 
     603           0 :                 const sal_uInt16 nOn = static_cast<const SfxBoolItem*>(pItem)->GetValue()
     604           0 :                     ? nsRedlineMode_t::REDLINE_ON : 0;
     605           0 :                 const sal_uInt16 nMode = m_pWrtShell->GetRedlineMode();
     606           0 :                 m_pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
     607             :             }
     608             :         }
     609           0 :         break;
     610             :         case FN_REDLINE_PROTECT :
     611             :         {
     612           0 :             IDocumentRedlineAccess* pIDRA = m_pWrtShell->getIDocumentRedlineAccess();
     613           0 :             Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
     614           0 :             if( pArgs && SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem )
     615           0 :                 && static_cast<const SfxBoolItem*>(pItem)->GetValue() == ( aPasswd.getLength() != 0 ) )
     616           0 :                 break;
     617             : 
     618             :             // xmlsec05:    new password dialog
     619             :             //              message box for wrong password
     620             :             vcl::Window* pParent;
     621             :             const SfxPoolItem* pParentItem;
     622           0 :             if( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_ATTR_XWINDOW, false, &pParentItem ) )
     623           0 :                 pParent = static_cast<const XWindowItem*>( pParentItem )->GetWindowPtr();
     624             :             else
     625           0 :                 pParent = &GetViewFrame()->GetWindow();
     626           0 :             ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg( pParent );
     627           0 :             aPasswdDlg->SetMinLen( 1 );
     628           0 :             if(!aPasswd.getLength())
     629           0 :                 aPasswdDlg->ShowExtras(SfxShowExtras::CONFIRM);
     630           0 :             if (aPasswdDlg->Execute())
     631             :             {
     632           0 :                 sal_uInt16 nOn = nsRedlineMode_t::REDLINE_ON;
     633           0 :                 OUString sNewPasswd( aPasswdDlg->GetPassword() );
     634             :                 Sequence <sal_Int8> aNewPasswd =
     635           0 :                         pIDRA->GetRedlinePassword();
     636           0 :                 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
     637           0 :                 if(!aPasswd.getLength())
     638             :                 {
     639           0 :                     pIDRA->SetRedlinePassword(aNewPasswd);
     640             :                 }
     641           0 :                 else if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
     642             :                 {
     643           0 :                     pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
     644           0 :                     nOn = 0;
     645             :                 }
     646           0 :                 const sal_uInt16 nMode = pIDRA->GetRedlineMode();
     647           0 :                 m_pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
     648           0 :                 rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, ((nMode&nsRedlineMode_t::REDLINE_ON)==0) ) );
     649             :             }
     650             :             else
     651           0 :                 bIgnore = true;
     652             :         }
     653           0 :         break;
     654             :         case FN_REDLINE_SHOW:
     655             : 
     656           0 :             if( pArgs &&
     657           0 :                 SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem))
     658             :             {
     659             :                 sal_uInt16 nMode = ( ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)
     660           0 :                         & m_pWrtShell->GetRedlineMode() ) | nsRedlineMode_t::REDLINE_SHOW_INSERT;
     661           0 :                 if( static_cast<const SfxBoolItem*>(pItem)->GetValue() )
     662           0 :                     nMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
     663             : 
     664           0 :                 m_pWrtShell->SetRedlineModeAndCheckInsMode( nMode );
     665             :             }
     666           0 :             break;
     667             :         case FN_MAILMERGE_SENDMAIL_CHILDWINDOW:
     668             :         case FN_REDLINE_ACCEPT:
     669           0 :             GetViewFrame()->ToggleChildWindow(nSlot);
     670           0 :         break;
     671             :         case FN_REDLINE_ACCEPT_DIRECT:
     672             :         case FN_REDLINE_REJECT_DIRECT:
     673             :         {
     674           0 :             SwDoc *pDoc = m_pWrtShell->GetDoc();
     675           0 :             SwPaM *pCursor = m_pWrtShell->GetCrsr();
     676           0 :             if( pCursor->HasMark())
     677             :             {
     678           0 :                 if (FN_REDLINE_ACCEPT_DIRECT == nSlot)
     679           0 :                     m_pWrtShell->AcceptRedlinesInSelection();
     680             :                 else
     681           0 :                     m_pWrtShell->RejectRedlinesInSelection();
     682             :             }
     683             :             else
     684             :             {
     685             :                 // We check for a redline at the start of the selection/cursor, not the point.
     686             :                 // This ensures we work properly with FN_REDLINE_NEXT_CHANGE, which leaves the
     687             :                 // point at the *end* of the redline and the mark at the start (so GetRedline
     688             :                 // would return NULL if called on the point)
     689           0 :                 sal_uInt16 nRedline = 0;
     690           0 :                 const SwRangeRedline *pRedline = pDoc->getIDocumentRedlineAccess().GetRedline(*pCursor->Start(), &nRedline);
     691             :                 assert(pRedline != 0);
     692           0 :                 if (pRedline)
     693             :                 {
     694           0 :                     if (FN_REDLINE_ACCEPT_DIRECT == nSlot)
     695           0 :                         m_pWrtShell->AcceptRedline(nRedline);
     696             :                     else
     697           0 :                         m_pWrtShell->RejectRedline(nRedline);
     698             :                 }
     699             :             }
     700             :             // Go to next change after accepting or rejecting one (fdo#83953)
     701           0 :             GetViewFrame()->GetDispatcher()->Execute(FN_REDLINE_NEXT_CHANGE, SfxCallMode::ASYNCHRON);
     702             :         }
     703           0 :         break;
     704             : 
     705             :         case FN_REDLINE_NEXT_CHANGE:
     706             :         {
     707           0 :             const SwRangeRedline *pCurrent = m_pWrtShell->GetCurrRedline();
     708           0 :             const SwRangeRedline *pNext = m_pWrtShell->SelNextRedline();
     709             : 
     710             :             // FN_REDLINE_PREV_CHANGE leaves the selection point at the start of the redline.
     711             :             // In such cases, SelNextRedline (which starts searching from the selection point)
     712             :             // immediately finds the current redline and advances the selection point to its end.
     713             : 
     714             :             // This behavior means that PREV_CHANGE followed by NEXT_CHANGE would not change
     715             :             // the current redline, so we detect it and select the next redline again.
     716           0 :             if (pCurrent && pCurrent == pNext)
     717           0 :                 pNext = m_pWrtShell->SelNextRedline();
     718             : 
     719           0 :             if (pNext)
     720           0 :                 m_pWrtShell->SetInSelect();
     721             :         }
     722           0 :         break;
     723             : 
     724             :         case FN_REDLINE_PREV_CHANGE:
     725             :         {
     726           0 :             const SwPaM *pCursor = m_pWrtShell->GetCrsr();
     727           0 :             const SwPosition initialCursorStart = *pCursor->Start();
     728           0 :             const SwRangeRedline *pPrev = m_pWrtShell->SelPrevRedline();
     729             : 
     730           0 :             if (pPrev)
     731             :             {
     732             :                 // FN_REDLINE_NEXT_CHANGE leaves the selection point at the end of the redline.
     733             :                 // In such cases, SelPrevRedline (which starts searching from the selection point)
     734             :                 // immediately finds the current redline and advances the selection point to its
     735             :                 // start.
     736             : 
     737             :                 // This behavior means that NEXT_CHANGE followed by PREV_CHANGE would not change
     738             :                 // the current redline, so we detect it and move to the previous redline again.
     739           0 :                 if (initialCursorStart == *pPrev->Start())
     740           0 :                     pPrev = m_pWrtShell->SelPrevRedline();
     741             :             }
     742             : 
     743           0 :             if (pPrev)
     744           0 :                 m_pWrtShell->SetInSelect();
     745             :         }
     746           0 :         break;
     747             : 
     748             :         case SID_DOCUMENT_COMPARE:
     749             :         case SID_DOCUMENT_MERGE:
     750             :             {
     751           0 :                 OUString sFileName, sFilterName;
     752           0 :                 sal_Int16 nVersion = 0;
     753           0 :                 bool bHasFileName = false;
     754           0 :                 m_pViewImpl->SetParam( 0 );
     755           0 :                 bool bNoAcceptDialog = false;
     756             : 
     757           0 :                 if( pArgs )
     758             :                 {
     759           0 :                     if( SfxItemState::SET == pArgs->GetItemState( SID_FILE_NAME, false, &pItem ))
     760           0 :                         sFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
     761           0 :                     bHasFileName = !sFileName.isEmpty();
     762             : 
     763           0 :                     if( SfxItemState::SET == pArgs->GetItemState( SID_FILTER_NAME, false, &pItem ))
     764           0 :                         sFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue();
     765             : 
     766           0 :                     if( SfxItemState::SET == pArgs->GetItemState( SID_VERSION, false, &pItem ))
     767             :                     {
     768           0 :                         nVersion = static_cast<const SfxInt16Item *>(pItem)->GetValue();
     769           0 :                         m_pViewImpl->SetParam( nVersion );
     770             :                     }
     771           0 :                     if( SfxItemState::SET == pArgs->GetItemState( SID_NO_ACCEPT_DIALOG, false, &pItem ))
     772             :                     {
     773           0 :                         bNoAcceptDialog = static_cast<const SfxBoolItem *>(pItem)->GetValue();
     774             :                     }
     775             :                 }
     776             : 
     777           0 :                 m_pViewImpl->InitRequest( rReq );
     778           0 :                 long nFound = InsertDoc( nSlot, sFileName, sFilterName, nVersion );
     779             : 
     780           0 :                 if ( bHasFileName )
     781             :                 {
     782           0 :                     rReq.SetReturnValue( SfxInt32Item( nSlot, nFound ));
     783             : 
     784           0 :                     if (nFound > 0 && !bNoAcceptDialog) // show Redline browser
     785             :                     {
     786           0 :                         SfxViewFrame* pVFrame = GetViewFrame();
     787           0 :                         pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
     788             : 
     789             :                         // re-initialize the Redline dialog
     790           0 :                         const sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
     791             :                         SwRedlineAcceptChild *pRed = static_cast<SwRedlineAcceptChild*>(
     792           0 :                                                 pVFrame->GetChildWindow(nId));
     793           0 :                         if (pRed)
     794           0 :                             pRed->ReInitDlg(GetDocShell());
     795             :                     }
     796             :                 }
     797             :                 else
     798           0 :                     bIgnore = true;
     799             :             }
     800           0 :         break;
     801             :         case FN_SYNC_LABELS:
     802             :         case FN_MAILMERGE_CHILDWINDOW:
     803           0 :             GetViewFrame()->ShowChildWindow(nSlot, true);
     804           0 :         break;
     805             :         case FN_ESCAPE:
     806             :         {
     807           0 :             if ( m_pWrtShell->HasDrawView() && m_pWrtShell->GetDrawView()->IsDragObj() )
     808             :             {
     809           0 :                 m_pWrtShell->BreakDrag();
     810           0 :                 m_pWrtShell->EnterSelFrmMode();
     811             :             }
     812           0 :             else if ( m_pWrtShell->IsDrawCreate() )
     813             :             {
     814           0 :                 GetDrawFuncPtr()->BreakCreate();
     815           0 :                 AttrChangedNotify(m_pWrtShell); // shell change if needed
     816             :             }
     817           0 :             else if ( m_pWrtShell->HasSelection() || IsDrawMode() )
     818             :             {
     819           0 :                 SdrView *pSdrView = m_pWrtShell->HasDrawView() ? m_pWrtShell->GetDrawView() : 0;
     820           0 :                 if(pSdrView && pSdrView->AreObjectsMarked() &&
     821           0 :                     pSdrView->GetHdlList().GetFocusHdl())
     822             :                 {
     823           0 :                     const_cast<SdrHdlList&>(pSdrView->GetHdlList()).ResetFocusHdl();
     824             :                 }
     825             :                 else
     826             :                 {
     827           0 :                     if(pSdrView)
     828             :                     {
     829           0 :                         LeaveDrawCreate();
     830           0 :                         Point aPt(LONG_MIN, LONG_MIN);
     831             :                         //go out of the frame
     832           0 :                         m_pWrtShell->SelectObj(aPt, SW_LEAVE_FRAME);
     833           0 :                         SfxBindings& rBind = GetViewFrame()->GetBindings();
     834           0 :                         rBind.Invalidate( SID_ATTR_SIZE );
     835             :                     }
     836           0 :                     m_pWrtShell->EnterStdMode();
     837           0 :                     AttrChangedNotify(m_pWrtShell); // shell change if necessary
     838             :                 }
     839             :             }
     840           0 :             else if ( GetEditWin().GetApplyTemplate() )
     841             :             {
     842           0 :                 GetEditWin().SetApplyTemplate(SwApplyTemplate());
     843             :             }
     844           0 :             else if( static_cast<SfxObjectShell*>(GetDocShell())->IsInPlaceActive() )
     845             :             {
     846           0 :                 Escape();
     847             :             }
     848           0 :             else if ( GetEditWin().IsChainMode() )
     849             :             {
     850           0 :                 GetEditWin().SetChainMode( false );
     851             :             }
     852           0 :             else if( m_pWrtShell->GetFlyFrameFormat() )
     853             :             {
     854           0 :                 const SwFrameFormat* pFormat = m_pWrtShell->GetFlyFrameFormat();
     855           0 :                 if(m_pWrtShell->GotoFly( pFormat->GetName(), FLYCNTTYPE_FRM ))
     856             :                 {
     857           0 :                     m_pWrtShell->HideCrsr();
     858           0 :                     m_pWrtShell->EnterSelFrmMode();
     859             :                 }
     860             :             }
     861             :             else
     862             :             {
     863           0 :                 SfxBoolItem aItem( SID_WIN_FULLSCREEN, false );
     864           0 :                 GetViewFrame()->GetDispatcher()->Execute( SID_WIN_FULLSCREEN, SfxCallMode::RECORD, &aItem, 0L );
     865           0 :                 bIgnore = true;
     866             :             }
     867             :         }
     868           0 :         break;
     869             :         case SID_ATTR_BORDER_INNER:
     870             :         case SID_ATTR_BORDER_OUTER:
     871             :         case SID_ATTR_BORDER_SHADOW:
     872           0 :             if(pArgs)
     873           0 :                 m_pWrtShell->SetAttrSet(*pArgs);
     874           0 :             break;
     875             : 
     876             :         case SID_ATTR_PAGE:
     877             :         case SID_ATTR_PAGE_SIZE:
     878             :         case SID_ATTR_PAGE_MAXSIZE:
     879             :         case SID_ATTR_PAGE_PAPERBIN:
     880             :         case SID_ATTR_PAGE_EXT1:
     881             :         case FN_PARAM_FTN_INFO:
     882             :         {
     883           0 :             if(pArgs)
     884             :             {
     885           0 :                 const size_t nCurIdx = m_pWrtShell->GetCurPageDesc();
     886           0 :                 SwPageDesc aPageDesc( m_pWrtShell->GetPageDesc( nCurIdx ) );
     887           0 :                 ::ItemSetToPageDesc( *pArgs, aPageDesc );
     888             :                 // change the descriptor of the core
     889           0 :                 m_pWrtShell->ChgPageDesc( nCurIdx, aPageDesc );
     890             :             }
     891             :         }
     892           0 :         break;
     893             :         case FN_NAVIGATION_PI_GOTO_PAGE:
     894             :         {
     895           0 :             SfxViewFrame* pVFrame = GetViewFrame();
     896           0 :             SfxChildWindow* pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
     897           0 :             if(!pCh)
     898             :             {
     899           0 :                 pVFrame->ToggleChildWindow( SID_NAVIGATOR );
     900           0 :                 pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
     901             : 
     902             :             }
     903           0 :             if (pCh)
     904             :             {
     905           0 :                 static_cast<SwNavigationPI*>( pCh->GetContextWindow(SW_MOD()))->GotoPage();
     906             :             }
     907             :         }
     908           0 :         break;
     909             :         case  FN_EDIT_CURRENT_TOX:
     910             :         {
     911             :             GetViewFrame()->GetDispatcher()->Execute(
     912           0 :                                 FN_INSERT_MULTI_TOX, SfxCallMode::ASYNCHRON);
     913             :         }
     914           0 :         break;
     915             :         case FN_UPDATE_CUR_TOX:
     916             :         {
     917           0 :             const SwTOXBase* pBase = m_pWrtShell->GetCurTOX();
     918           0 :             if(pBase)
     919             :             {
     920           0 :                 m_pWrtShell->StartAction();
     921           0 :                 if(TOX_INDEX == pBase->GetType())
     922           0 :                     m_pWrtShell->ApplyAutoMark();
     923           0 :                 m_pWrtShell->UpdateTableOf( *pBase );
     924           0 :                 m_pWrtShell->EndAction();
     925             :             }
     926             :         }
     927           0 :         break;
     928             :         case FN_UPDATE_TOX:
     929             :         {
     930           0 :             m_pWrtShell->StartAction();
     931           0 :             m_pWrtShell->EnterStdMode();
     932           0 :             bool bOldCrsrInReadOnly = m_pWrtShell->IsReadOnlyAvailable();
     933           0 :             m_pWrtShell->SetReadOnlyAvailable( true );
     934             : 
     935           0 :             for( int i = 0; i < 2; ++i )
     936             :             {
     937           0 :                 if( m_pWrtShell->GetTOXCount() == 1 )
     938           0 :                     ++i;
     939             : 
     940           0 :                 while( m_pWrtShell->GotoPrevTOXBase() )
     941             :                     ;   // jump to the first "table of ..."
     942             : 
     943             :                 // if we are not in one, jump to next
     944           0 :                 const SwTOXBase* pBase = m_pWrtShell->GetCurTOX();
     945           0 :                 if( !pBase )
     946             :                 {
     947           0 :                     m_pWrtShell->GotoNextTOXBase();
     948           0 :                     pBase = m_pWrtShell->GetCurTOX();
     949             :                 }
     950             : 
     951           0 :                 bool bAutoMarkApplied = false;
     952           0 :                 while( pBase )
     953             :                 {
     954           0 :                     if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied)
     955             :                     {
     956           0 :                         m_pWrtShell->ApplyAutoMark();
     957           0 :                         bAutoMarkApplied = true;
     958             :                     }
     959             :                     // pBase is needed only for the interface. Should be changed in future! (JP 1996)
     960           0 :                     m_pWrtShell->UpdateTableOf( *pBase );
     961             : 
     962           0 :                     if( m_pWrtShell->GotoNextTOXBase() )
     963           0 :                         pBase = m_pWrtShell->GetCurTOX();
     964             :                     else
     965           0 :                         pBase = 0;
     966             :                 }
     967             :             }
     968           0 :             m_pWrtShell->SetReadOnlyAvailable( bOldCrsrInReadOnly );
     969           0 :             m_pWrtShell->EndAction();
     970             :         }
     971           0 :         break;
     972             :         case SID_ATTR_BRUSH:
     973             :         {
     974           0 :             if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_BACKGROUND, false, &pItem))
     975             :             {
     976           0 :                 const size_t nCurIdx = m_pWrtShell->GetCurPageDesc();
     977           0 :                 SwPageDesc aDesc( m_pWrtShell->GetPageDesc( nCurIdx ));
     978           0 :                 SwFrameFormat& rMaster = aDesc.GetMaster();
     979           0 :                 rMaster.SetFormatAttr(*pItem);
     980           0 :                 m_pWrtShell->ChgPageDesc( nCurIdx, aDesc);
     981             :             }
     982             :         }
     983           0 :         break;
     984             :         case SID_CLEARHISTORY:
     985             :         {
     986           0 :             m_pWrtShell->DelAllUndoObj();
     987             :         }
     988           0 :         break;
     989             :         case SID_UNDO:
     990             :         {
     991           0 :             m_pShell->ExecuteSlot(rReq);
     992             :         }
     993           0 :         break;
     994             :         case FN_INSERT_CTRL:
     995             :         case FN_INSERT_OBJ_CTRL:
     996             :         {
     997           0 :             if(pArgs && SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem))
     998             :             {
     999           0 :                 const sal_uInt16 nValue = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
    1000           0 :                 switch ( nSlot )
    1001             :                 {
    1002             :                     case FN_INSERT_CTRL:
    1003             :                     {
    1004           0 :                         bool bWeb = 0 != PTR_CAST(SwWebView, this);
    1005           0 :                         if(bWeb)
    1006           0 :                             SwView::m_nWebInsertCtrlState = nValue;
    1007             :                         else
    1008           0 :                             SwView::m_nInsertCtrlState = nValue;
    1009             :                     }
    1010           0 :                     break;
    1011           0 :                     case FN_INSERT_OBJ_CTRL:    SwView::m_nInsertObjectCtrlState = nValue  ;break;
    1012             :                 }
    1013             : 
    1014             :             }
    1015           0 :             GetViewFrame()->GetBindings().Invalidate( nSlot );
    1016             :         }
    1017           0 :         break;
    1018             : #if defined WNT || defined UNX
    1019             :         case SID_TWAIN_SELECT:
    1020             :         case SID_TWAIN_TRANSFER:
    1021           0 :             GetViewImpl()->ExecuteScan( rReq );
    1022           0 :         break;
    1023             : #endif
    1024             : 
    1025             :         case SID_ATTR_DEFTABSTOP:
    1026             :         {
    1027           0 :             if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_DEFTABSTOP, false, &pItem))
    1028             :             {
    1029           0 :                 SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
    1030           0 :                 const sal_uInt16 nTab = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
    1031           0 :                 MakeDefTabs( nTab, aDefTabs );
    1032           0 :                 m_pWrtShell->SetDefault( aDefTabs );
    1033             :             }
    1034             :         }
    1035           0 :         break;
    1036             :         case SID_ATTR_LANGUAGE  :
    1037           0 :         if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_LANGUAGE, false, &pItem))
    1038             :         {
    1039           0 :             SvxLanguageItem aLang(static_cast<const SvxLanguageItem*>(pItem)->GetLanguage(), RES_CHRATR_LANGUAGE);
    1040           0 :             m_pWrtShell->SetDefault( aLang );
    1041           0 :             lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_LANGUAGE );
    1042             :         }
    1043           0 :         break;
    1044             :         case  SID_ATTR_CHAR_CTL_LANGUAGE:
    1045           0 :         if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_CHRATR_CTL_LANGUAGE, false, &pItem))
    1046             :         {
    1047           0 :             m_pWrtShell->SetDefault( *pItem );
    1048           0 :             lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_CTL_LANGUAGE );
    1049             :         }
    1050           0 :         break;
    1051             :         case  SID_ATTR_CHAR_CJK_LANGUAGE:
    1052           0 :         if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_CHRATR_CJK_LANGUAGE, false, &pItem))
    1053             :         {
    1054           0 :             m_pWrtShell->SetDefault( *pItem );
    1055           0 :             lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_CJK_LANGUAGE );
    1056             :         }
    1057           0 :         break;
    1058             :         case FN_SCROLL_PREV:
    1059             :         case FN_SCROLL_NEXT:
    1060             :         {
    1061             :             // call the handlers of PageUp/DownButtons, only
    1062           0 :             bool *pbNext = new bool(true); // FN_SCROLL_NEXT
    1063           0 :             if (nSlot == FN_SCROLL_PREV)
    1064           0 :                 *pbNext = false;
    1065             :             // #i75416# move the execution of the search to an asynchronously called static link
    1066           0 :             Application::PostUserEvent( LINK(this, SwView, MoveNavigationHdl), pbNext );
    1067             :         }
    1068           0 :         break;
    1069             :         case FN_NAVIGATION_POPUP:
    1070             :         {
    1071           0 :             SfxViewFrame* pVFrame = GetViewFrame();
    1072           0 :             SfxChildWindow* pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
    1073           0 :             if (!pCh)
    1074             :             {
    1075           0 :                 pVFrame->ToggleChildWindow( SID_NAVIGATOR );
    1076           0 :                 pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
    1077             :             }
    1078           0 :             if (pCh)
    1079             :             {
    1080           0 :                 static_cast<SwNavigationPI*>( pCh->GetContextWindow(SW_MOD()))->CreateNavigationTool(
    1081           0 :                                 GetVisArea(), true, &pVFrame->GetWindow());
    1082             :             }
    1083             :         }
    1084           0 :         break;
    1085             :         case SID_JUMPTOMARK:
    1086           0 :             if( pArgs && SfxItemState::SET == pArgs->GetItemState(SID_JUMPTOMARK, false, &pItem))
    1087           0 :                 JumpToSwMark( static_cast<const SfxStringItem*>(pItem)->GetValue() );
    1088           0 :         break;
    1089             :         case SID_GALLERY :
    1090             :             // First make sure that the sidebar is visible
    1091           0 :             GetViewFrame()->ShowChildWindow(SID_SIDEBAR);
    1092             : 
    1093             :             ::sfx2::sidebar::Sidebar::ShowPanel(
    1094             :                 "GalleryPanel",
    1095           0 :                 GetViewFrame()->GetFrame().GetFrameInterface());
    1096           0 :         break;
    1097             :         case SID_AVMEDIA_PLAYER :
    1098           0 :             GetViewFrame()->ChildWindowExecute(rReq);
    1099           0 :         break;
    1100             :         case SID_VIEW_DATA_SOURCE_BROWSER:
    1101             :         {
    1102           1 :             SfxViewFrame* pVFrame = GetViewFrame();
    1103           1 :             pVFrame->ChildWindowExecute(rReq);
    1104           1 :             if(pVFrame->HasChildWindow(SID_BROWSER))
    1105             :             {
    1106           1 :                 const SwDBData& rData = GetWrtShell().GetDBDesc();
    1107           1 :                 SwModule::ShowDBObj(*this, rData, false);
    1108             :             }
    1109             :         }
    1110           1 :         break;
    1111             :         case FN_INSERT_FIELD_DATA_ONLY:
    1112             :         {
    1113           0 :             bool bShow = false;
    1114           0 :             if( pArgs &&
    1115           0 :                 SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem ))
    1116           0 :                 bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
    1117           0 :             if((bShow && m_bInMailMerge) != GetViewFrame()->HasChildWindow(nSlot))
    1118           0 :                 GetViewFrame()->ToggleChildWindow(nSlot);
    1119             :             //if fields have been successfully inserted call the "real"
    1120             :             //mail merge dialog
    1121             : #if HAVE_FEATURE_DBCONNECTIVITY
    1122           0 :             SwWrtShell &rSh = GetWrtShell();
    1123           0 :             if(m_bInMailMerge && rSh.IsAnyDatabaseFieldInDoc())
    1124             :             {
    1125           0 :                 SwDBManager* pDBManager = rSh.GetDBManager();
    1126           0 :                 if (pDBManager)
    1127             :                 {
    1128           0 :                     SwDBData aData;
    1129           0 :                     aData = rSh.GetDBData();
    1130           0 :                     rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields
    1131           0 :                     AttrChangedNotify( &rSh );
    1132             : 
    1133           0 :                     Sequence<PropertyValue> aProperties(3);
    1134           0 :                     PropertyValue* pValues = aProperties.getArray();
    1135           0 :                     pValues[0].Name = "DataSourceName";
    1136           0 :                     pValues[1].Name = "Command";
    1137           0 :                     pValues[2].Name = "CommandType";
    1138           0 :                     pValues[0].Value <<= aData.sDataSource;
    1139           0 :                     pValues[1].Value <<= aData.sCommand;
    1140           0 :                     pValues[2].Value <<= aData.nCommandType;
    1141           0 :                     pDBManager->ExecuteFormLetter(rSh, aProperties, true);
    1142             :                 }
    1143             :             }
    1144             : #endif
    1145           0 :             m_bInMailMerge &= bShow;
    1146           0 :             GetViewFrame()->GetBindings().Invalidate(FN_INSERT_FIELD);
    1147             :         }
    1148           0 :         break;
    1149             :         case FN_QRY_MERGE:
    1150             :         {
    1151           0 :             bool bUseCurrentDocument = true;
    1152           0 :             bool bQuery = !pArgs || SfxItemState::SET != pArgs->GetItemState(nSlot);
    1153           0 :             if(bQuery)
    1154             :             {
    1155           0 :                 SfxViewFrame* pTmpFrame = GetViewFrame();
    1156           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
    1157             :                 OSL_ENSURE(pFact, "Dialog creation failed!");
    1158           0 :                 AbstractMailMergeCreateFromDlg* pDlg = pFact->CreateMailMergeCreateFromDlg(&pTmpFrame->GetWindow());
    1159             :                 OSL_ENSURE(pDlg, "Dialog creation failed!");
    1160           0 :                 if(RET_OK == pDlg->Execute())
    1161           0 :                     bUseCurrentDocument = pDlg->IsThisDocument();
    1162             :                 else
    1163           0 :                     break;
    1164             :             }
    1165           0 :             GenerateFormLetter(bUseCurrentDocument);
    1166             :         }
    1167           0 :         break;
    1168             :         case SID_RECHECK_DOCUMENT:
    1169             :         {
    1170           0 :             SwDocShell* pDocShell = GetDocShell();
    1171           0 :             SwDoc* pDoc = pDocShell->GetDoc();
    1172           0 :             uno::Reference< linguistic2::XProofreadingIterator >  xGCIterator( pDoc->GetGCIterator() );
    1173           0 :             if( xGCIterator.is() )
    1174             :             {
    1175           0 :                 xGCIterator->resetIgnoreRules();
    1176             :             }
    1177             :             // reset ignore lists
    1178           0 :             pDoc->SpellItAgainSam( true, false, false );
    1179             :             // clear ignore dictionary
    1180           0 :             uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY );
    1181           0 :             if( xDictionary.is() )
    1182           0 :                 xDictionary->clear();
    1183             :             // put cursor to the start of the document
    1184           0 :             m_pWrtShell->SttDoc();
    1185             :         }
    1186             :         // no break; - but call spell/grammar dialog
    1187             :         case FN_SPELL_GRAMMAR_DIALOG:
    1188             :         {
    1189           0 :             SfxViewFrame* pViewFrame = GetViewFrame();
    1190           0 :             if (rReq.GetArgs() != NULL)
    1191             :                 pViewFrame->SetChildWindow (FN_SPELL_GRAMMAR_DIALOG,
    1192             :                     static_cast<const SfxBoolItem&>( (rReq.GetArgs()->
    1193           0 :                         Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue());
    1194             :             else
    1195           0 :                 pViewFrame->ToggleChildWindow(FN_SPELL_GRAMMAR_DIALOG);
    1196             : 
    1197           0 :             pViewFrame->GetBindings().Invalidate(FN_SPELL_GRAMMAR_DIALOG);
    1198           0 :             rReq.Ignore ();
    1199             :         }
    1200           0 :         break;
    1201             :         case SID_ALIGN_ANY_LEFT :
    1202             :         case SID_ALIGN_ANY_HCENTER  :
    1203             :         case SID_ALIGN_ANY_RIGHT    :
    1204             :         case SID_ALIGN_ANY_JUSTIFIED:
    1205             :         case SID_ALIGN_ANY_TOP      :
    1206             :         case SID_ALIGN_ANY_VCENTER  :
    1207             :         case SID_ALIGN_ANY_BOTTOM   :
    1208             :         case SID_ALIGN_ANY_HDEFAULT :
    1209             :         case SID_ALIGN_ANY_VDEFAULT :
    1210             :         {
    1211           0 :             sal_uInt16 nAlias = 0;
    1212           0 :             if( m_nSelectionType & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_TXT) )
    1213             :             {
    1214           0 :                 switch( nSlot )
    1215             :                 {
    1216           0 :                     case SID_ALIGN_ANY_LEFT :       nAlias = SID_ATTR_PARA_ADJUST_LEFT; break;
    1217           0 :                     case SID_ALIGN_ANY_HCENTER  :   nAlias = SID_ATTR_PARA_ADJUST_CENTER; break;
    1218           0 :                     case SID_ALIGN_ANY_RIGHT    :   nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break;
    1219           0 :                     case SID_ALIGN_ANY_JUSTIFIED:   nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break;
    1220           0 :                     case SID_ALIGN_ANY_TOP      :   nAlias = SID_TABLE_VERT_NONE; break;
    1221           0 :                     case SID_ALIGN_ANY_VCENTER  :   nAlias = SID_TABLE_VERT_CENTER; break;
    1222           0 :                     case SID_ALIGN_ANY_BOTTOM   :   nAlias = SID_TABLE_VERT_BOTTOM; break;
    1223             :                 }
    1224             :             }
    1225             :             else
    1226             :             {
    1227           0 :                 switch( nSlot )
    1228             :                 {
    1229           0 :                     case SID_ALIGN_ANY_LEFT :       nAlias = SID_OBJECT_ALIGN_LEFT    ; break;
    1230           0 :                     case SID_ALIGN_ANY_HCENTER  :   nAlias = SID_OBJECT_ALIGN_CENTER ; break;
    1231           0 :                     case SID_ALIGN_ANY_RIGHT    :   nAlias = SID_OBJECT_ALIGN_RIGHT  ; break;
    1232           0 :                     case SID_ALIGN_ANY_TOP      :   nAlias = SID_OBJECT_ALIGN_UP     ;  break;
    1233           0 :                     case SID_ALIGN_ANY_VCENTER  :   nAlias = SID_OBJECT_ALIGN_MIDDLE ;  break;
    1234           0 :                     case SID_ALIGN_ANY_BOTTOM   :   nAlias = SID_OBJECT_ALIGN_DOWN    ; break;
    1235             :                 }
    1236             :             }
    1237             :             //special handling for the draw shell
    1238           0 :             if(nAlias && (m_nSelectionType & (nsSelectionType::SEL_DRW)))
    1239             :             {
    1240           0 :                 SfxAllEnumItem aEnumItem(SID_OBJECT_ALIGN, nAlias - SID_OBJECT_ALIGN_LEFT);
    1241             :                 GetViewFrame()->GetDispatcher()->Execute(
    1242           0 :                                 SID_OBJECT_ALIGN, SfxCallMode::ASYNCHRON, &aEnumItem, 0L);
    1243             :             }
    1244           0 :             else if(nAlias)
    1245             :             //these slots are either re-mapped to text or object alignment
    1246             :                 GetViewFrame()->GetDispatcher()->Execute(
    1247           0 :                                 nAlias, SfxCallMode::ASYNCHRON);
    1248             :         }
    1249           0 :         break;
    1250             :         case SID_RESTORE_EDITING_VIEW:
    1251             :         {
    1252             :             //#i33307# restore editing position
    1253           0 :             Point aCrsrPos;
    1254             :             bool bSelectObj;
    1255           0 :             if(m_pViewImpl->GetRestorePosition(aCrsrPos, bSelectObj))
    1256             :             {
    1257           0 :                 m_pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
    1258           0 :                 if( bSelectObj )
    1259             :                 {
    1260           0 :                     m_pWrtShell->SelectObj( aCrsrPos );
    1261           0 :                     m_pWrtShell->EnterSelFrmMode( &aCrsrPos );
    1262             :                 }
    1263             :             }
    1264             :         }
    1265           0 :         break;
    1266             :         case SID_INSERT_GRAPHIC:
    1267             :         {
    1268           0 :             rReq.SetReturnValue(SfxBoolItem(nSlot, InsertGraphicDlg( rReq )));
    1269             :         }
    1270           0 :         break;
    1271             : 
    1272             :         default:
    1273             :             OSL_ENSURE(false, "wrong dispatcher");
    1274           0 :             return;
    1275             :     }
    1276           1 :     if(!bIgnore)
    1277           1 :         rReq.Done();
    1278             : }
    1279             : 
    1280             : /// invalidate page numbering field
    1281         604 : void SwView::UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr)
    1282             : {
    1283         604 :     OUString sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr ));
    1284        1208 :     const SfxStringItem aTmp( FN_STAT_PAGE, sTemp );
    1285             :     // Used to distinguish which tooltip to show
    1286             :     const SfxBoolItem bExtendedTooltip( FN_STAT_PAGE,
    1287        2416 :                                         !rPgStr.isEmpty() && OUString::number(nPhyNum) != rPgStr
    1288        1935 :                                         && nPhyNum != nVirtNum );
    1289             : 
    1290         604 :     SfxBindings &rBnd = GetViewFrame()->GetBindings();
    1291         604 :     rBnd.SetState( aTmp );
    1292         604 :     rBnd.Update( FN_STAT_PAGE );
    1293         604 :     rBnd.SetState( bExtendedTooltip );
    1294        1208 :     rBnd.Update( FN_STAT_PAGE );
    1295         604 : }
    1296             : 
    1297          18 : void SwView::UpdateDocStats()
    1298             : {
    1299          18 :     SfxBindings &rBnd = GetViewFrame()->GetBindings();
    1300          18 :     rBnd.Invalidate( FN_STAT_WORDCOUNT );
    1301          18 :     rBnd.Update( FN_STAT_WORDCOUNT );
    1302          18 : }
    1303             : 
    1304           0 : void SwView::SetAnnotationMode(bool bMode)
    1305             : {
    1306           0 :     m_bAnnotationMode = bMode;
    1307           0 : }
    1308             : 
    1309             : /// get status of the status line
    1310        4691 : void SwView::StateStatusLine(SfxItemSet &rSet)
    1311             : {
    1312        4691 :     SwWrtShell& rShell = GetWrtShell();
    1313             : 
    1314        4691 :     SfxWhichIter aIter( rSet );
    1315        4691 :     sal_uInt16 nWhich = aIter.FirstWhich();
    1316             :     OSL_ENSURE( nWhich, "empty set");
    1317             : 
    1318             :     //get section change event
    1319        4691 :     const SwSection* CurrSect = rShell.GetCurrSection();
    1320        4691 :     if( CurrSect )
    1321             :     {
    1322           0 :         OUString sCurrentSectionName = CurrSect->GetSectionName();
    1323           0 :         if(sCurrentSectionName != m_sOldSectionName)
    1324             :         {
    1325           0 :             SwCrsrShell::FireSectionChangeEvent(2, 1);
    1326             :         }
    1327           0 :         m_sOldSectionName = sCurrentSectionName;
    1328             :     }
    1329        4691 :     else if (!m_sOldSectionName.isEmpty())
    1330             :     {
    1331           0 :         SwCrsrShell::FireSectionChangeEvent(2, 1);
    1332           0 :         m_sOldSectionName= OUString();
    1333             :     }
    1334             :     //get column change event
    1335        4691 :     if(rShell.bColumnChange())
    1336             :     {
    1337           0 :         SwCrsrShell::FireColumnChangeEvent(2, 1);
    1338             :     }
    1339             : 
    1340       19333 :     while( nWhich )
    1341             :     {
    1342        9951 :         switch( nWhich )
    1343             :         {
    1344             :             case FN_STAT_PAGE: {
    1345             :                 // number of pages, log. page number
    1346             :                 sal_uInt16 nPage, nLogPage;
    1347         870 :                 OUString sDisplay;
    1348         870 :                 rShell.GetPageNumber( -1, rShell.IsCrsrVisible(), nPage, nLogPage, sDisplay );
    1349             :                 rSet.Put( SfxStringItem( FN_STAT_PAGE,
    1350         870 :                             GetPageStr( nPage, nLogPage, sDisplay) ));
    1351             :                 //if existing page number is not equal to old page number, send out this event.
    1352         870 :                 if (m_nOldPageNum != nLogPage )
    1353             :                 {
    1354         354 :                     if (m_nOldPageNum != 0)
    1355           8 :                         SwCrsrShell::FirePageChangeEvent(m_nOldPageNum, nLogPage);
    1356         354 :                     m_nOldPageNum = nLogPage;
    1357             :                 }
    1358         870 :                 const sal_uInt16 nCnt = GetWrtShell().GetPageCnt();
    1359         870 :                 if (m_nPageCnt != nCnt)   // notify Basic
    1360             :                 {
    1361         356 :                     m_nPageCnt = nCnt;
    1362         356 :                     SfxGetpApp()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), false);
    1363         870 :                 }
    1364             :             }
    1365         870 :             break;
    1366             : 
    1367             :             case FN_STAT_WORDCOUNT:
    1368             :             {
    1369         887 :                 SwDocStat selectionStats;
    1370         887 :                 SwDocStat documentStats;
    1371         887 :                 rShell.CountWords(selectionStats);
    1372         887 :                 documentStats = rShell.GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( true /* complete-async */, false /* don't update fields */ );
    1373             : 
    1374         887 :                 sal_uLong nWord = selectionStats.nWord ? selectionStats.nWord : documentStats.nWord;
    1375         887 :                 sal_uLong nChar = selectionStats.nChar ? selectionStats.nChar : documentStats.nChar;
    1376         887 :                 OUString aWordCount( SW_RES( selectionStats.nWord ? STR_STATUSBAR_WORDCOUNT : STR_STATUSBAR_WORDCOUNT_NO_SELECTION ) );
    1377         887 :                 const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetUILocaleDataWrapper();
    1378         887 :                 aWordCount = aWordCount.replaceFirst( "%1", rLocaleData.getNum( nWord, 0 ) );
    1379         887 :                 aWordCount = aWordCount.replaceFirst( "%2", rLocaleData.getNum( nChar, 0 ) );
    1380         887 :                 rSet.Put( SfxStringItem( FN_STAT_WORDCOUNT, aWordCount ) );
    1381             : 
    1382         887 :                 SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()));
    1383         887 :                 if (pWrdCnt)
    1384           0 :                     pWrdCnt->SetCounts(selectionStats, documentStats);
    1385             :             }
    1386         887 :             break;
    1387             : 
    1388             :             case FN_STAT_TEMPLATE:
    1389             :             {
    1390             :                 rSet.Put(SfxStringItem( FN_STAT_TEMPLATE,
    1391         872 :                                         rShell.GetCurPageStyle(false)));
    1392             : 
    1393             :             }
    1394         872 :             break;
    1395             :             case SID_ATTR_ZOOM:
    1396             :             {
    1397        1216 :                 if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
    1398             :                 {
    1399        1216 :                     const SwViewOption* pVOpt = rShell.GetViewOptions();
    1400        1216 :                     SvxZoomType eZoom = (SvxZoomType) pVOpt->GetZoomType();
    1401             :                     SvxZoomItem aZoom(eZoom,
    1402        1216 :                                         pVOpt->GetZoom());
    1403        1216 :                     if( pVOpt->getBrowseMode() )
    1404             :                     {
    1405             :                         aZoom.SetValueSet(
    1406             :                                 SvxZoomEnableFlags::N50|
    1407             :                                 SvxZoomEnableFlags::N75|
    1408             :                                 SvxZoomEnableFlags::N100|
    1409           8 :                                 SvxZoomEnableFlags::N150|
    1410           8 :                                 SvxZoomEnableFlags::N200);
    1411             :                     }
    1412        1216 :                     rSet.Put( aZoom );
    1413             :                 }
    1414             :                 else
    1415           0 :                     rSet.DisableItem( SID_ATTR_ZOOM );
    1416             :             }
    1417        1216 :             break;
    1418             :             case SID_ATTR_VIEWLAYOUT:
    1419             :             {
    1420         870 :                 if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
    1421             :                 {
    1422         870 :                     const SwViewOption* pVOpt = rShell.GetViewOptions();
    1423         870 :                     const sal_uInt16 nColumns  = pVOpt->GetViewLayoutColumns();
    1424         870 :                     const bool  bBookMode = pVOpt->IsViewLayoutBookMode();
    1425         870 :                     SvxViewLayoutItem aViewLayout(nColumns, bBookMode);
    1426         870 :                     rSet.Put( aViewLayout );
    1427             :                 }
    1428             :                 else
    1429           0 :                     rSet.DisableItem( SID_ATTR_VIEWLAYOUT );
    1430             :             }
    1431         870 :             break;
    1432             :             case SID_ATTR_ZOOMSLIDER:
    1433             :             {
    1434         877 :                 if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
    1435             :                 {
    1436         877 :                     const SwViewOption* pVOpt = rShell.GetViewOptions();
    1437         877 :                     const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
    1438         877 :                     SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
    1439         877 :                     aZoomSliderItem.AddSnappingPoint( 100 );
    1440             : 
    1441         877 :                     if ( !m_pWrtShell->getIDocumentSettingAccess()->get(DocumentSettingId::BROWSE_MODE) )
    1442             :                     {
    1443         876 :                         const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
    1444         876 :                         const bool bAutomaticViewLayout = 0 == nColumns;
    1445         876 :                         const SwPostItMgr* pMgr = GetPostItMgr();
    1446             : 
    1447             :                         // snapping points:
    1448             :                         // automatic mode: 1 Page, 2 Pages, 100%
    1449             :                         // n Columns mode: n Pages, 100%
    1450             :                         // n Columns book mode: nPages without gaps, 100%
    1451         876 :                         const SwRect aPageRect( m_pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) );
    1452         876 :                         const SwRect aRootRect( m_pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) ); // width of columns
    1453         876 :                         Size aPageSize( aPageRect.SSize() );
    1454        1753 :                         aPageSize.Width() += pMgr->HasNotes() && pMgr->ShowNotes() ?
    1455           1 :                                              pMgr->GetSidebarWidth() + pMgr->GetSidebarBorderWidth() :
    1456        1753 :                                              0;
    1457             : 
    1458         876 :                         Size aRootSize( aRootRect.SSize() );
    1459             : 
    1460         876 :                         const MapMode aTmpMap( MAP_TWIP );
    1461         876 :                         const Size& rEditSize = GetEditWin().GetOutputSizePixel();
    1462         876 :                         const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
    1463             : 
    1464         876 :                         const long nOf = DOCUMENTBORDER * 2L;
    1465         876 :                         long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
    1466         876 :                         nTmpWidth += nOf;
    1467         876 :                         aPageSize.Height() += nOf;
    1468         876 :                         long nFac = aWindowSize.Width() * 100 / nTmpWidth;
    1469             : 
    1470         876 :                         long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
    1471         876 :                         nFac = std::min( nFac, nVisPercent );
    1472             : 
    1473         876 :                         aZoomSliderItem.AddSnappingPoint( nFac );
    1474             : 
    1475         876 :                         if ( bAutomaticViewLayout )
    1476             :                         {
    1477           7 :                             nTmpWidth += aPageSize.Width() + GAPBETWEENPAGES;
    1478           7 :                             nFac = aWindowSize.Width() * 100 / nTmpWidth;
    1479           7 :                             nFac = std::min( nFac, nVisPercent );
    1480           7 :                             aZoomSliderItem.AddSnappingPoint( nFac );
    1481         876 :                         }
    1482             :                     }
    1483             : 
    1484         877 :                     rSet.Put( aZoomSliderItem );
    1485             :                 }
    1486             :                 else
    1487           0 :                     rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
    1488             :             }
    1489         877 :             break;
    1490             :             case SID_TABLE_CELL:
    1491             : 
    1492         872 :             if( rShell.IsFrmSelected() || rShell.IsObjSelected() )
    1493             :             {
    1494             :                 // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem.
    1495             :                 // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot
    1496             :                 // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied
    1497             :                 // in SID_ATTR_SIZE).
    1498             :             }
    1499             :             else
    1500             :             {
    1501         872 :                 OUString sStr;
    1502         872 :                 if( rShell.IsCrsrInTable() )
    1503             :                 {
    1504             :                     // table name + cell coordinate
    1505           3 :                     sStr = rShell.GetTableFormat()->GetName();
    1506           3 :                     sStr += ":";
    1507           3 :                     sStr += rShell.GetBoxNms();
    1508             :                 }
    1509             :                 else
    1510             :                 {
    1511         869 :                     const SwSection* pCurrSect = rShell.GetCurrSection();
    1512         869 :                     if( pCurrSect )
    1513             :                     {
    1514           0 :                         switch( pCurrSect->GetType() )
    1515             :                         {
    1516             :                         case TOX_HEADER_SECTION:
    1517             :                         case TOX_CONTENT_SECTION:
    1518             :                             {
    1519           0 :                                 const SwTOXBase* pTOX = m_pWrtShell->GetCurTOX();
    1520           0 :                                 if( pTOX )
    1521           0 :                                     sStr = pTOX->GetTOXName();
    1522             :                                 else
    1523             :                                 {
    1524             :                                     OSL_ENSURE( false,
    1525             :                                         "Unknown kind of section" );
    1526           0 :                                     sStr = pCurrSect->GetSectionName();
    1527             :                                 }
    1528             :                             }
    1529           0 :                             break;
    1530             :                         default:
    1531           0 :                             sStr = pCurrSect->GetSectionName();
    1532           0 :                             break;
    1533             :                         }
    1534             :                     }
    1535             :                 }
    1536             : 
    1537         872 :                 const SwNumRule* pNumRule = rShell.GetNumRuleAtCurrCrsrPos();
    1538         872 :                 const bool bOutlineNum = pNumRule && pNumRule->IsOutlineRule();
    1539             : 
    1540         872 :                 if (pNumRule && !bOutlineNum )  // cursor in numbering
    1541             :                 {
    1542           0 :                     sal_uInt8 nNumLevel = rShell.GetNumLevel();
    1543           0 :                     if ( nNumLevel < MAXLEVEL )
    1544             :                     {
    1545           0 :                         if(!pNumRule->IsAutoRule())
    1546             :                         {
    1547           0 :                             SfxItemSet aSet(GetPool(),
    1548           0 :                                     RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
    1549           0 :                             rShell.GetCurAttr(aSet);
    1550           0 :                             if(SfxItemState::DEFAULT <=
    1551           0 :                                aSet.GetItemState(RES_PARATR_NUMRULE, true))
    1552             :                             {
    1553             :                                 const OUString& rNumStyle =
    1554             :                                     static_cast<const SfxStringItem &>(
    1555           0 :                                      aSet.Get(RES_PARATR_NUMRULE)).GetValue();
    1556           0 :                                 if(!rNumStyle.isEmpty())
    1557             :                                 {
    1558           0 :                                     if(!sStr.isEmpty())
    1559           0 :                                         sStr += sStatusDelim;
    1560           0 :                                     sStr += rNumStyle;
    1561             :                                 }
    1562           0 :                             }
    1563             :                         }
    1564           0 :                         if (!sStr.isEmpty())
    1565           0 :                             sStr += sStatusDelim;
    1566           0 :                         sStr += SW_RESSTR(STR_NUM_LEVEL);
    1567           0 :                         sStr += OUString::number( nNumLevel + 1 );
    1568             : 
    1569             :                     }
    1570             :                 }
    1571         872 :                 const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel();
    1572         872 :                 if( nOutlineLevel != 0 )
    1573             :                 {
    1574           0 :                     if (!sStr.isEmpty())
    1575           0 :                         sStr += sStatusComma;
    1576           0 :                     if( bOutlineNum )
    1577             :                     {
    1578           0 :                         sStr += SW_RESSTR(STR_OUTLINE_NUMBERING);
    1579           0 :                         sStr += sStatusDelim;
    1580           0 :                         sStr += SW_RESSTR(STR_NUM_LEVEL);
    1581             :                     }
    1582             :                     else
    1583           0 :                         sStr += SW_RESSTR(STR_NUM_OUTLINE);
    1584           0 :                     sStr += OUString::number( nOutlineLevel);
    1585             :                 }
    1586             : 
    1587         872 :                 if( rShell.HasReadonlySel() )
    1588             :                 {
    1589           0 :                     if (!sStr.isEmpty())
    1590           0 :                         sStr = sStatusDelim + sStr;
    1591           0 :                     sStr = SW_RESSTR(SW_STR_READONLY) + sStr;
    1592             :                 }
    1593         872 :                 if (!sStr.isEmpty())
    1594           3 :                     rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr ));
    1595             :             }
    1596         872 :             break;
    1597             :             case FN_STAT_SELMODE:
    1598             :             {
    1599         873 :                 if(rShell.IsStdMode())
    1600         873 :                     rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
    1601           0 :                 else if(rShell.IsAddMode())
    1602           0 :                     rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 2));
    1603           0 :                 else if(rShell.IsBlockMode())
    1604           0 :                     rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 3));
    1605             :                 else
    1606           0 :                     rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 1));
    1607         873 :                 break;
    1608             :             }
    1609             :             case SID_ATTR_INSERT:
    1610         870 :                 if( rShell.IsRedlineOn() )
    1611           0 :                     rSet.DisableItem( nWhich );
    1612             :                 else
    1613             :                 {
    1614         870 :                     rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode()));
    1615             :                 }
    1616         870 :                 break;
    1617             :         }
    1618        9951 :         nWhich = aIter.NextWhich();
    1619        4691 :     }
    1620        4691 : }
    1621             : 
    1622             : /** execute method for the status line
    1623             :  *
    1624             :  * @param rReq ???
    1625             :  */
    1626           0 : void SwView::ExecuteStatusLine(SfxRequest &rReq)
    1627             : {
    1628           0 :     SwWrtShell &rSh = GetWrtShell();
    1629           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
    1630           0 :     const SfxPoolItem* pItem=NULL;
    1631           0 :     bool bUp = false;
    1632           0 :     sal_uInt16 nWhich = rReq.GetSlot();
    1633           0 :     switch( nWhich )
    1634             :     {
    1635             :         case FN_STAT_PAGE:
    1636             :         {
    1637             :             GetViewFrame()->GetDispatcher()->Execute( SID_NAVIGATOR,
    1638           0 :                                       SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
    1639             :         }
    1640           0 :         break;
    1641             : 
    1642             :         case FN_STAT_WORDCOUNT:
    1643             :         {
    1644             :             GetViewFrame()->GetDispatcher()->Execute(FN_WORDCOUNT_DIALOG,
    1645           0 :                                       SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
    1646             :         }
    1647           0 :         break;
    1648             : 
    1649             :         case FN_STAT_BOOKMARK:
    1650           0 :         if ( pArgs )
    1651             :         {
    1652           0 :             if (SfxItemState::SET == pArgs->GetItemState( nWhich, true, &pItem))
    1653             :             {
    1654           0 :                 const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess();
    1655           0 :                 const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
    1656           0 :                 if(nIdx < pMarkAccess->getBookmarksCount())
    1657             :                 {
    1658           0 :                     const IDocumentMarkAccess::const_iterator_t ppBookmark = rSh.getIDocumentMarkAccess()->getBookmarksBegin() + nIdx;
    1659           0 :                     rSh.EnterStdMode();
    1660           0 :                     rSh.GotoMark( ppBookmark->get() );
    1661             :                 }
    1662             :                 else
    1663             :                     OSL_FAIL("SwView::ExecuteStatusLine(..)"
    1664             :                         " - Ignoring out of range bookmark index");
    1665             :             }
    1666             :         }
    1667           0 :         break;
    1668             : 
    1669             :         case FN_STAT_TEMPLATE:
    1670             :         {
    1671             :             GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG,
    1672           0 :                                         SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
    1673             :         }
    1674           0 :         break;
    1675             :         case SID_ATTR_ZOOM:
    1676             :         {
    1677           0 :             if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
    1678             :             {
    1679           0 :                 const SfxItemSet *pSet = 0;
    1680           0 :                 boost::scoped_ptr<AbstractSvxZoomDialog> pDlg;
    1681           0 :                 if ( pArgs )
    1682           0 :                     pSet = pArgs;
    1683             :                 else
    1684             :                 {
    1685           0 :                     const SwViewOption& rViewOptions = *rSh.GetViewOptions();
    1686           0 :                     SfxItemSet aCoreSet(m_pShell->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM, SID_ATTR_VIEWLAYOUT, SID_ATTR_VIEWLAYOUT, 0 );
    1687           0 :                     SvxZoomItem aZoom( (SvxZoomType)rViewOptions.GetZoomType(), rViewOptions.GetZoom() );
    1688             : 
    1689           0 :                     const bool bBrowseMode = rSh.GetViewOptions()->getBrowseMode();
    1690           0 :                     if( bBrowseMode )
    1691             :                     {
    1692             :                         aZoom.SetValueSet(
    1693             :                                 SvxZoomEnableFlags::N50|
    1694             :                                 SvxZoomEnableFlags::N75|
    1695             :                                 SvxZoomEnableFlags::N100|
    1696           0 :                                 SvxZoomEnableFlags::N150|
    1697           0 :                                 SvxZoomEnableFlags::N200);
    1698             :                     }
    1699           0 :                     aCoreSet.Put( aZoom );
    1700             : 
    1701           0 :                     if ( !bBrowseMode )
    1702             :                     {
    1703           0 :                         const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() );
    1704           0 :                         aCoreSet.Put( aViewLayout );
    1705             :                     }
    1706             : 
    1707           0 :                     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    1708           0 :                     if(pFact)
    1709             :                     {
    1710           0 :                         pDlg.reset(pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet));
    1711             :                         OSL_ENSURE(pDlg, "Zooming fail!");
    1712           0 :                         if (pDlg)
    1713             :                         {
    1714           0 :                             pDlg->SetLimits( MINZOOM, MAXZOOM );
    1715           0 :                             if( pDlg->Execute() != RET_CANCEL )
    1716           0 :                                 pSet = pDlg->GetOutputItemSet();
    1717             :                         }
    1718           0 :                     }
    1719             :                 }
    1720             : 
    1721           0 :                 const SfxPoolItem* pViewLayoutItem = 0;
    1722           0 :                 if ( pSet && SfxItemState::SET == pSet->GetItemState(SID_ATTR_VIEWLAYOUT, true, &pViewLayoutItem))
    1723             :                 {
    1724           0 :                     const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem *>(pViewLayoutItem)->GetValue();
    1725           0 :                     const bool bBookMode  = static_cast<const SvxViewLayoutItem *>(pViewLayoutItem)->IsBookMode();
    1726           0 :                     SetViewLayout( nColumns, bBookMode );
    1727             :                 }
    1728             : 
    1729           0 :                 if ( pSet && SfxItemState::SET == pSet->GetItemState(SID_ATTR_ZOOM, true, &pItem))
    1730             :                 {
    1731           0 :                     SvxZoomType eType = static_cast<const SvxZoomItem *>(pItem)->GetType();
    1732           0 :                     SetZoom( eType, static_cast<const SvxZoomItem *>(pItem)->GetValue() );
    1733             :                 }
    1734           0 :                 bUp = true;
    1735           0 :                 if ( pItem )
    1736           0 :                     rReq.AppendItem( *pItem );
    1737           0 :                 rReq.Done();
    1738             :             }
    1739             :         }
    1740           0 :         break;
    1741             : 
    1742             :         case SID_ATTR_VIEWLAYOUT:
    1743             :         {
    1744           0 :             if ( pArgs && !rSh.getIDocumentSettingAccess()->get(DocumentSettingId::BROWSE_MODE) &&
    1745           0 :                 ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
    1746             :             {
    1747           0 :                 if ( SfxItemState::SET == pArgs->GetItemState(SID_ATTR_VIEWLAYOUT, true, &pItem ))
    1748             :                 {
    1749           0 :                     const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem *>(pItem)->GetValue();
    1750           0 :                     const bool bBookMode  = !(0 == nColumns || 0 != (nColumns % 2)) &&
    1751           0 :                                             static_cast<const SvxViewLayoutItem *>(pItem)->IsBookMode();
    1752             : 
    1753           0 :                     SetViewLayout( nColumns, bBookMode );
    1754             :                 }
    1755             : 
    1756           0 :                 bUp = true;
    1757           0 :                 rReq.Done();
    1758             : 
    1759           0 :                 InvalidateRulerPos();
    1760             :             }
    1761             :         }
    1762           0 :         break;
    1763             : 
    1764             :         case SID_ATTR_ZOOMSLIDER:
    1765             :         {
    1766           0 :             if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
    1767             :             {
    1768           0 :                 if ( SfxItemState::SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem ))
    1769             :                 {
    1770           0 :                     const sal_uInt16 nCurrentZoom = static_cast<const SvxZoomSliderItem *>(pItem)->GetValue();
    1771           0 :                     SetZoom( SvxZoomType::PERCENT, nCurrentZoom );
    1772             :                 }
    1773             : 
    1774           0 :                 bUp = true;
    1775           0 :                 rReq.Done();
    1776             :             }
    1777             :         }
    1778           0 :         break;
    1779             : 
    1780             :         case FN_STAT_SELMODE:
    1781             :         {
    1782           0 :             if ( pArgs )
    1783             :             {
    1784           0 :                 if (SfxItemState::SET == pArgs->GetItemState( nWhich, true, &pItem))
    1785             :                 {
    1786           0 :                     switch ( static_cast<const SfxUInt16Item *>(pItem)->GetValue() )
    1787             :                     {
    1788           0 :                         case 0: rSh.EnterStdMode(); break;
    1789           0 :                         case 1: rSh.EnterExtMode(); break;
    1790           0 :                         case 2: rSh.EnterAddMode(); break;
    1791           0 :                         case 3: rSh.EnterBlockMode(); break;
    1792             :                     }
    1793             :                 }
    1794             :             }
    1795             :             else
    1796             :             {
    1797             : 
    1798           0 :                 if( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
    1799           0 :                     rSh.ToggleExtMode();
    1800           0 :                 else if ( rSh.IsExtMode() )
    1801             :                 {
    1802           0 :                     rSh.ToggleExtMode();
    1803           0 :                     rSh.ToggleAddMode();
    1804             :                 }
    1805           0 :                 else if ( rSh.IsAddMode() )
    1806             :                 {
    1807           0 :                     rSh.ToggleAddMode();
    1808           0 :                     rSh.ToggleBlockMode();
    1809             :                 }
    1810             :                 else
    1811           0 :                     rSh.ToggleBlockMode();
    1812             :             }
    1813           0 :             bUp = true;
    1814           0 :             break;
    1815             :         }
    1816             :         case FN_SET_ADD_MODE:
    1817           0 :             rSh.ToggleAddMode();
    1818           0 :             nWhich = FN_STAT_SELMODE;
    1819           0 :             bUp = true;
    1820           0 :         break;
    1821             :         case FN_SET_BLOCK_MODE:
    1822           0 :             rSh.ToggleBlockMode();
    1823           0 :             nWhich = FN_STAT_SELMODE;
    1824           0 :             bUp = true;
    1825           0 :         break;
    1826             :         case FN_SET_EXT_MODE:
    1827           0 :             rSh.ToggleExtMode();
    1828           0 :             nWhich = FN_STAT_SELMODE;
    1829           0 :             bUp = true;
    1830           0 :         break;
    1831             :         case SID_ATTR_INSERT:
    1832           0 :             SwPostItMgr* pMgr = GetPostItMgr();
    1833           0 :             if ( pMgr && pMgr->HasActiveSidebarWin() )
    1834             :             {
    1835           0 :                 pMgr->ToggleInsModeOnActiveSidebarWin();
    1836             :             }
    1837             :             else
    1838           0 :                 rSh.ToggleInsMode();
    1839           0 :             bUp = true;
    1840           0 :         break;
    1841             : 
    1842             :     }
    1843           0 :     if ( bUp )
    1844             :     {
    1845           0 :         SfxBindings &rBnd = GetViewFrame()->GetBindings();
    1846           0 :         rBnd.Invalidate(nWhich);
    1847           0 :         rBnd.Update(nWhich);
    1848             :     }
    1849           0 : }
    1850             : 
    1851           0 : void SwView::InsFrmMode(sal_uInt16 nCols)
    1852             : {
    1853           0 :     if ( m_pWrtShell->HasWholeTabSelection() )
    1854             :     {
    1855           0 :         SwFlyFrmAttrMgr aMgr( true, m_pWrtShell, FRMMGR_TYPE_TEXT );
    1856             : 
    1857             :         const SwFrameFormat &rPageFormat =
    1858           0 :                 m_pWrtShell->GetPageDesc(m_pWrtShell->GetCurPageDesc()).GetMaster();
    1859           0 :         SwTwips lWidth = rPageFormat.GetFrmSize().GetWidth();
    1860           0 :         const SvxLRSpaceItem &rLR = rPageFormat.GetLRSpace();
    1861           0 :         lWidth -= rLR.GetLeft() + rLR.GetRight();
    1862           0 :         aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height()));
    1863           0 :         if(nCols > 1)
    1864             :         {
    1865           0 :             SwFormatCol aCol;
    1866           0 :             aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
    1867           0 :             aMgr.SetCol( aCol );
    1868             :         }
    1869           0 :         aMgr.InsertFlyFrm();
    1870             :     }
    1871             :     else
    1872           0 :         GetEditWin().InsFrm(nCols);
    1873           0 : }
    1874             : 
    1875             : /// show "edit link" dialog
    1876           0 : void SwView::EditLinkDlg()
    1877             : {
    1878           0 :     bool bWeb = 0 != PTR_CAST(SwWebView, this);
    1879           0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    1880           0 :     boost::scoped_ptr<SfxAbstractLinksDialog> pDlg(pFact->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb ));
    1881           0 :     if ( pDlg )
    1882             :     {
    1883           0 :         pDlg->Execute();
    1884           0 :     }
    1885           0 : }
    1886             : 
    1887           0 : bool SwView::JumpToSwMark( const OUString& rMark )
    1888             : {
    1889           0 :     bool bRet = false;
    1890           0 :     if( !rMark.isEmpty() )
    1891             :     {
    1892             :         // place bookmark at top-center
    1893           0 :         bool bSaveCC = IsCrsrAtCenter();
    1894           0 :         bool bSaveCT = IsCrsrAtTop();
    1895           0 :         SetCrsrAtTop( true );
    1896             : 
    1897             :         // For scrolling the FrameSet, the corresponding shell needs to have the focus.
    1898           0 :         bool bHasShFocus = m_pWrtShell->HasShFcs();
    1899           0 :         if( !bHasShFocus )
    1900           0 :             m_pWrtShell->ShGetFcs( false );
    1901             : 
    1902             :         const SwFormatINetFormat* pINet;
    1903           0 :         OUString sCmp;
    1904             :         OUString  sMark( INetURLObject::decode( rMark,
    1905             :                                            INetURLObject::DECODE_WITH_CHARSET,
    1906           0 :                                         RTL_TEXTENCODING_UTF8 ));
    1907             : 
    1908           0 :         sal_Int32 nLastPos, nPos = sMark.indexOf( cMarkSeparator );
    1909           0 :         if( -1 != nPos )
    1910           0 :             while( -1 != ( nLastPos = sMark.indexOf( cMarkSeparator, nPos + 1 )) )
    1911           0 :                 nPos = nLastPos;
    1912             : 
    1913           0 :         IDocumentMarkAccess::const_iterator_t ppMark;
    1914           0 :         IDocumentMarkAccess* const pMarkAccess = m_pWrtShell->getIDocumentMarkAccess();
    1915           0 :         if( -1 != nPos )
    1916           0 :             sCmp = comphelper::string::remove(sMark.copy(nPos + 1), ' ');
    1917             : 
    1918           0 :         if( !sCmp.isEmpty() )
    1919             :         {
    1920           0 :             OUString sName( sMark.copy( 0, nPos ) );
    1921           0 :             sCmp = sCmp.toAsciiLowerCase();
    1922           0 :             FlyCntType eFlyType = FLYCNTTYPE_ALL;
    1923             : 
    1924           0 :             if( sCmp == "region" )
    1925             :             {
    1926           0 :                 m_pWrtShell->EnterStdMode();
    1927           0 :                 bRet = m_pWrtShell->GotoRegion( sName );
    1928             :             }
    1929           0 :             else if( sCmp == "outline" )
    1930             :             {
    1931           0 :                 m_pWrtShell->EnterStdMode();
    1932           0 :                 bRet = m_pWrtShell->GotoOutline( sName );
    1933             :             }
    1934           0 :             else if( sCmp == "frame" )
    1935           0 :                 eFlyType = FLYCNTTYPE_FRM;
    1936           0 :             else if( sCmp == "graphic" )
    1937           0 :                 eFlyType = FLYCNTTYPE_GRF;
    1938           0 :             else if( sCmp == "ole" )
    1939           0 :                 eFlyType = FLYCNTTYPE_OLE;
    1940           0 :             else if( sCmp == "table" )
    1941             :             {
    1942           0 :                 m_pWrtShell->EnterStdMode();
    1943           0 :                 bRet = m_pWrtShell->GotoTable( sName );
    1944             :             }
    1945           0 :             else if( sCmp == "sequence" )
    1946             :             {
    1947           0 :                 m_pWrtShell->EnterStdMode();
    1948           0 :                 sal_Int32 nNoPos = sName.indexOf( cSequenceMarkSeparator );
    1949           0 :                 if ( nNoPos != -1 )
    1950             :                 {
    1951           0 :                     sal_uInt16 nSeqNo = sName.copy( nNoPos + 1 ).toInt32();
    1952           0 :                     sName = sName.copy( 0, nNoPos );
    1953           0 :                     m_pWrtShell->GotoRefMark( sName, REF_SEQUENCEFLD, nSeqNo );
    1954             :                 }
    1955             :             }
    1956           0 :             else if( sCmp == "text" )
    1957             :             {
    1958             :                 // normal text search
    1959           0 :                 m_pWrtShell->EnterStdMode();
    1960             : 
    1961             :                 SearchOptions aSearchOpt(
    1962             :                                     SearchAlgorithms_ABSOLUTE, 0,
    1963             :                                     sName, OUString(),
    1964           0 :                                     SvtSysLocale().GetLanguageTag().getLocale(),
    1965             :                                     0,0,0,
    1966           0 :                                     TransliterationModules_IGNORE_CASE );
    1967             : 
    1968             :                 //todo/mba: assuming that notes shouldn't be searched
    1969           0 :                 bool bSearchInNotes = false;
    1970           0 :                 if( m_pWrtShell->SearchPattern( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END ))
    1971             :                 {
    1972           0 :                     m_pWrtShell->EnterStdMode(); // remove the selection
    1973           0 :                     bRet = true;
    1974           0 :                 }
    1975             :             }
    1976           0 :             else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) )
    1977           0 :                 m_pWrtShell->GotoMark( ppMark->get(), false, true ), bRet = true;
    1978           0 :             else if( 0 != ( pINet = m_pWrtShell->FindINetAttr( sMark ) )) {
    1979           0 :                 m_pWrtShell->addCurrentPosition();
    1980           0 :                 bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTextINetFormat() );
    1981             :             }
    1982             : 
    1983             :             // for all types of Flys
    1984           0 :             if( FLYCNTTYPE_ALL != eFlyType && m_pWrtShell->GotoFly( sName, eFlyType ))
    1985             :             {
    1986           0 :                 bRet = true;
    1987           0 :                 if( FLYCNTTYPE_FRM == eFlyType )
    1988             :                 {
    1989             :                     // TextFrames: set Cursor in the frame
    1990           0 :                     m_pWrtShell->UnSelectFrm();
    1991           0 :                     m_pWrtShell->LeaveSelFrmMode();
    1992             :                 }
    1993             :                 else
    1994             :                 {
    1995           0 :                     m_pWrtShell->HideCrsr();
    1996           0 :                     m_pWrtShell->EnterSelFrmMode();
    1997             :                 }
    1998           0 :             }
    1999             :         }
    2000           0 :         else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)))
    2001           0 :             m_pWrtShell->GotoMark( ppMark->get(), false, true ), bRet = true;
    2002           0 :         else if( 0 != ( pINet = m_pWrtShell->FindINetAttr( sMark ) ))
    2003           0 :             bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTextINetFormat() );
    2004             : 
    2005             :         // make selection visible later
    2006           0 :         if ( m_aVisArea.IsEmpty() )
    2007           0 :             m_bMakeSelectionVisible = true;
    2008             : 
    2009             :         // reset ViewStatus
    2010           0 :         SetCrsrAtTop( bSaveCT, bSaveCC );
    2011             : 
    2012           0 :         if( !bHasShFocus )
    2013           0 :             m_pWrtShell->ShLooseFcs();
    2014             :     }
    2015           0 :     return bRet;
    2016             : }
    2017             : 
    2018             : // #i67305# Undo after insert from file:
    2019             : // Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled
    2020             : // Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains
    2021             : // page styles with active header/footer => disabled for those documents
    2022           0 : static size_t lcl_PageDescWithHeader( const SwDoc& rDoc )
    2023             : {
    2024           0 :     size_t nRet = 0;
    2025           0 :     size_t nCnt = rDoc.GetPageDescCnt();
    2026           0 :     for( size_t i = 0; i < nCnt; ++i )
    2027             :     {
    2028           0 :         const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i );
    2029           0 :         const SwFrameFormat& rMaster = rPageDesc.GetMaster();
    2030             :         const SfxPoolItem* pItem;
    2031           0 :         if( ( SfxItemState::SET == rMaster.GetAttrSet().GetItemState( RES_HEADER, false, &pItem ) &&
    2032           0 :               static_cast<const SwFormatHeader*>(pItem)->IsActive() ) ||
    2033           0 :             ( SfxItemState::SET == rMaster.GetAttrSet().GetItemState( RES_FOOTER, false, &pItem )  &&
    2034           0 :               static_cast<const SwFormatFooter*>(pItem)->IsActive()) )
    2035           0 :             ++nRet;
    2036             :     }
    2037           0 :     return nRet; // number of page styles with active header/footer
    2038             : }
    2039             : 
    2040           0 : void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem )
    2041             : {
    2042           0 :     m_pViewImpl->InitRequest( rRequest );
    2043           0 :     m_pViewImpl->SetParam( pItem ? 1 : 0 );
    2044           0 :     const sal_uInt16 nSlot = rRequest.GetSlot();
    2045             : 
    2046           0 :     if ( !pItem )
    2047             :     {
    2048           0 :         OUString sEmpty;
    2049           0 :         InsertDoc( nSlot, sEmpty, sEmpty );
    2050             :     }
    2051             :     else
    2052             :     {
    2053           0 :         OUString sFile, sFilter;
    2054           0 :         sFile = static_cast<const SfxStringItem *>( pItem )->GetValue();
    2055           0 :         if ( SfxItemState::SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, true, &pItem ) )
    2056           0 :             sFilter = static_cast<const SfxStringItem *>(pItem )->GetValue();
    2057             : 
    2058           0 :         bool bHasFileName = !sFile.isEmpty();
    2059           0 :         long nFound = InsertDoc( nSlot, sFile, sFilter );
    2060             : 
    2061           0 :         if ( bHasFileName )
    2062             :         {
    2063           0 :             rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
    2064           0 :             rRequest.Done();
    2065           0 :         }
    2066             :     }
    2067           0 : }
    2068             : 
    2069           0 : long SwView::InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName, const OUString& rFilterName, sal_Int16 nVersion )
    2070             : {
    2071           0 :     SfxMedium* pMed = 0;
    2072           0 :     SwDocShell* pDocSh = GetDocShell();
    2073             : 
    2074           0 :     if( !rFileName.isEmpty() )
    2075             :     {
    2076           0 :         SfxObjectFactory& rFact = pDocSh->GetFactory();
    2077           0 :         const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
    2078           0 :         if ( !pFilter )
    2079             :         {
    2080           0 :             pMed = new SfxMedium(rFileName, StreamMode::READ, 0, 0 );
    2081           0 :             SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
    2082           0 :             pMed->UseInteractionHandler( true );
    2083           0 :             ErrCode nErr = aMatcher.GuessFilter(*pMed, &pFilter, SfxFilterFlags::NONE);
    2084           0 :             if ( nErr )
    2085           0 :                 DELETEZ(pMed);
    2086             :             else
    2087           0 :                 pMed->SetFilter( pFilter );
    2088             :         }
    2089             :         else
    2090           0 :             pMed = new SfxMedium(rFileName, StreamMode::READ, pFilter, 0);
    2091             :     }
    2092             :     else
    2093             :     {
    2094           0 :         OUString sFactory = OUString::createFromAscii( pDocSh->GetFactory().GetShortName() );
    2095           0 :         m_pViewImpl->StartDocumentInserter( sFactory, LINK( this, SwView, DialogClosedHdl ) );
    2096           0 :         return -1;
    2097             :     }
    2098             : 
    2099           0 :     if( !pMed )
    2100           0 :         return -1;
    2101             : 
    2102           0 :     return InsertMedium( nSlotId, pMed, nVersion );
    2103             : }
    2104             : 
    2105           0 : long SwView::InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVersion )
    2106             : {
    2107           0 :     bool bInsert = false, bCompare = false;
    2108           0 :     long nFound = 0;
    2109           0 :     SwDocShell* pDocSh = GetDocShell();
    2110             : 
    2111           0 :     switch( nSlotId )
    2112             :     {
    2113           0 :         case SID_DOCUMENT_MERGE:                        break;
    2114           0 :         case SID_DOCUMENT_COMPARE: bCompare = true; break;
    2115           0 :         case SID_INSERTDOC:        bInsert = true;  break;
    2116             : 
    2117             :         default:
    2118             :             OSL_ENSURE( false, "unknown SlotId!" );
    2119           0 :             bInsert = true;
    2120           0 :             nSlotId = SID_INSERTDOC;
    2121           0 :             break;
    2122             :     }
    2123             : 
    2124           0 :     if( bInsert )
    2125             :     {
    2126             :         uno::Reference< frame::XDispatchRecorder > xRecorder =
    2127           0 :                 GetViewFrame()->GetBindings().GetRecorder();
    2128           0 :         if ( xRecorder.is() )
    2129             :         {
    2130           0 :             SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC);
    2131           0 :             aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL()));
    2132           0 :             if(pMedium->GetFilter())
    2133           0 :                 aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName()));
    2134           0 :             aRequest.Done();
    2135             :         }
    2136             : 
    2137           0 :         SfxObjectShellRef aRef( pDocSh );
    2138             : 
    2139           0 :         sal_uInt32 nError = SfxObjectShell::HandleFilter( pMedium, pDocSh );
    2140             :         // #i16722# aborted?
    2141           0 :         if(nError != ERRCODE_NONE)
    2142             :         {
    2143           0 :             delete pMedium;
    2144           0 :             return -1;
    2145             :         }
    2146             : 
    2147           0 :         pMedium->Download();    // start download if needed
    2148           0 :         if( aRef.Is() && 1 < aRef->GetRefCount() )  // still a valid ref?
    2149             :         {
    2150             :             SwReader* pRdr;
    2151           0 :             Reader *pRead = pDocSh->StartConvertFrom( *pMedium, &pRdr, m_pWrtShell );
    2152           0 :             if( pRead ||
    2153           0 :                 (pMedium->GetFilter()->GetFilterFlags() & SfxFilterFlags::STARONEFILTER) )
    2154             :             {
    2155           0 :                 size_t nUndoCheck = 0;
    2156           0 :                 SwDoc *pDoc = pDocSh->GetDoc();
    2157           0 :                 if( pRead && pDocSh->GetDoc() )
    2158           0 :                     nUndoCheck = lcl_PageDescWithHeader( *pDoc );
    2159             :                 sal_uLong nErrno;
    2160             :                 {   //Scope for SwWait-Object, to be able to execute slots
    2161             :                     //outside this scope.
    2162           0 :                     SwWait aWait( *GetDocShell(), true );
    2163           0 :                     m_pWrtShell->StartAllAction();
    2164           0 :                     if ( m_pWrtShell->HasSelection() )
    2165           0 :                         m_pWrtShell->DelRight();      // delete selections
    2166           0 :                     if( pRead )
    2167             :                     {
    2168           0 :                         nErrno = pRdr->Read( *pRead );  // and insert document
    2169           0 :                         delete pRdr;
    2170             :                     }
    2171             :                     else
    2172             :                     {
    2173           0 :                         ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
    2174             :                         uno::Reference<text::XTextRange> const xInsertPosition(
    2175             :                             SwXTextRange::CreateXTextRange(*pDoc,
    2176           0 :                                 *m_pWrtShell->GetCrsr()->GetPoint(), 0));
    2177           0 :                         nErrno = pDocSh->ImportFrom(*pMedium, xInsertPosition)
    2178           0 :                                     ? 0 : ERR_SWG_READ_ERROR;
    2179           0 :                     }
    2180             : 
    2181             :                 }
    2182             : 
    2183             :                 // update all "table of ..." sections if needed
    2184           0 :                 if( m_pWrtShell->IsUpdateTOX() )
    2185             :                 {
    2186           0 :                     SfxRequest aReq( FN_UPDATE_TOX, SfxCallMode::SLOT, GetPool() );
    2187           0 :                     Execute( aReq );
    2188           0 :                     m_pWrtShell->SetUpdateTOX( false ); // reset
    2189             :                 }
    2190             : 
    2191           0 :                 if( pDoc )
    2192             :                 { // Disable Undo for .sdw or
    2193             :                   // if the number of page styles with header/footer has changed
    2194           0 :                     if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) )
    2195             :                     {
    2196           0 :                         pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
    2197             :                     }
    2198             :                 }
    2199             : 
    2200           0 :                 m_pWrtShell->EndAllAction();
    2201           0 :                 if( nErrno )
    2202             :                 {
    2203           0 :                     ErrorHandler::HandleError( nErrno );
    2204           0 :                     nFound = IsError( nErrno ) ? -1 : 0;
    2205             :                 }
    2206             :                 else
    2207           0 :                     nFound = 0;
    2208             :             }
    2209           0 :         }
    2210             :     }
    2211             :     else
    2212             :     {
    2213           0 :         SfxObjectShellRef xDocSh;
    2214           0 :         SfxObjectShellLock xLockRef;
    2215             : 
    2216           0 :         OUString sFltNm;
    2217           0 :         const int nRet = SwFindDocShell( xDocSh, xLockRef, pMedium->GetName(), OUString(),
    2218           0 :                                     sFltNm, nVersion, pDocSh );
    2219           0 :         if( nRet )
    2220             :         {
    2221           0 :             SwWait aWait( *GetDocShell(), true );
    2222           0 :             m_pWrtShell->StartAllAction();
    2223             : 
    2224           0 :             m_pWrtShell->EnterStdMode(); // delete selections
    2225             : 
    2226           0 :             if( bCompare )
    2227           0 :                 nFound = m_pWrtShell->CompareDoc( *static_cast<SwDocShell*>(&xDocSh)->GetDoc() );
    2228             :             else
    2229           0 :                 nFound = m_pWrtShell->MergeDoc( *static_cast<SwDocShell*>(&xDocSh)->GetDoc() );
    2230             : 
    2231           0 :             m_pWrtShell->EndAllAction();
    2232             : 
    2233           0 :             if (!bCompare && !nFound)
    2234             :             {
    2235           0 :                 vcl::Window* pWin = &GetEditWin();
    2236           0 :                 ScopedVclPtrInstance<MessageDialog>::Create(pWin, SW_RES(STR_NO_MERGE_ENTRY), VCL_MESSAGE_INFO)->Execute();
    2237             :             }
    2238           0 :             if( nRet==2 && xDocSh.Is() )
    2239           0 :                 xDocSh->DoClose();
    2240           0 :         }
    2241             :     }
    2242             : 
    2243           0 :     delete pMedium;
    2244           0 :     return nFound;
    2245             : }
    2246             : 
    2247           0 : void SwView::EnableMailMerge(bool bEnable )
    2248             : {
    2249           0 :     m_bInMailMerge = bEnable;
    2250           0 :     SfxBindings& rBind = GetViewFrame()->GetBindings();
    2251           0 :     rBind.Invalidate(FN_INSERT_FIELD_DATA_ONLY);
    2252           0 :     rBind.Update(FN_INSERT_FIELD_DATA_ONLY);
    2253           0 : }
    2254             : 
    2255             : #if HAVE_FEATURE_DBCONNECTIVITY
    2256             : 
    2257             : namespace
    2258             : {
    2259           0 :     bool lcl_NeedAdditionalDataSource( const uno::Reference< XDatabaseContext >& _rDatasourceContext )
    2260             :     {
    2261           0 :         Sequence < OUString > aNames = _rDatasourceContext->getElementNames();
    2262             : 
    2263           0 :         return  (   !aNames.getLength()
    2264           0 :                 ||  (   ( 1 == aNames.getLength() )
    2265           0 :                     &&  aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
    2266             :                     )
    2267           0 :                 );
    2268             :     }
    2269             : }
    2270             : 
    2271             : #endif
    2272             : 
    2273           0 : void SwView::GenerateFormLetter(bool bUseCurrentDocument)
    2274             : {
    2275             : #if !HAVE_FEATURE_DBCONNECTIVITY
    2276             :     (void) bUseCurrentDocument;
    2277             : #else
    2278           0 :     if(bUseCurrentDocument)
    2279             :     {
    2280           0 :         if(!GetWrtShell().IsAnyDatabaseFieldInDoc())
    2281             :         {
    2282             :             //check availability of data sources (except biblio source)
    2283           0 :             uno::Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
    2284           0 :             uno::Reference<XDatabaseContext>  xDBContext = DatabaseContext::create(xContext);
    2285           0 :             bool bCallAddressPilot = false;
    2286           0 :             if ( lcl_NeedAdditionalDataSource( xDBContext ) )
    2287             :             {
    2288             :                 // no data sources are available - create a new one
    2289           0 :                 ScopedVclPtrInstance<MessageDialog> aQuery(&GetViewFrame()->GetWindow(),
    2290             :                     "DataSourcesUnavailableDialog",
    2291           0 :                     "modules/swriter/ui/datasourcesunavailabledialog.ui");
    2292             :                 // no cancel allowed
    2293           0 :                 if (RET_OK != aQuery->Execute())
    2294           0 :                     return;
    2295           0 :                 bCallAddressPilot = true;
    2296             :             }
    2297             :             else
    2298             :             {
    2299             :                 //take an existing data source or create a new one?
    2300           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
    2301             :                 OSL_ENSURE(pFact, "Dialog creation failed!");
    2302           0 :                 AbstractMailMergeFieldConnectionsDlg* pConnectionsDlg = pFact->CreateMailMergeFieldConnectionsDlg(&GetViewFrame()->GetWindow());
    2303             :                 OSL_ENSURE(pConnectionsDlg, "Dialog creation failed!");
    2304           0 :                 if(RET_OK == pConnectionsDlg->Execute())
    2305           0 :                     bCallAddressPilot = !pConnectionsDlg->IsUseExistingConnections();
    2306             :                 else
    2307           0 :                     return;
    2308             : 
    2309             :             }
    2310           0 :             if(bCallAddressPilot)
    2311             :             {
    2312             :                 GetViewFrame()->GetDispatcher()->Execute(
    2313           0 :                                 SID_ADDRESS_DATA_SOURCE, SfxCallMode::SYNCHRON);
    2314           0 :                 if ( lcl_NeedAdditionalDataSource( xDBContext ) )
    2315             :                     // no additional data source has been created
    2316             :                     // -> assume that the user has cancelled the pilot
    2317           0 :                     return;
    2318             :             }
    2319             : 
    2320             :             //call insert fields with database field page available, only
    2321           0 :             SfxViewFrame* pVFrame = GetViewFrame();
    2322             :             //at first hide the default field dialog if currently visible
    2323           0 :             pVFrame->SetChildWindow(FN_INSERT_FIELD, false);
    2324             :             //enable the status of the db field dialog - it is disabled in the status method
    2325             :             //to prevent creation of the dialog without mail merge active
    2326           0 :             EnableMailMerge();
    2327             :             //then show the "Data base only" field dialog
    2328           0 :             SfxBoolItem aOn(FN_INSERT_FIELD_DATA_ONLY, true);
    2329             :             pVFrame->GetDispatcher()->Execute(FN_INSERT_FIELD_DATA_ONLY,
    2330           0 :                                                 SfxCallMode::SYNCHRON, &aOn, 0L);
    2331           0 :             return;
    2332             :         }
    2333             :         else
    2334             :         {
    2335           0 :             OUString sSource;
    2336           0 :             if(!GetWrtShell().IsFieldDataSourceAvailable(sSource))
    2337             :             {
    2338           0 :                 ScopedVclPtrInstance<MessageDialog> aWarning(&GetViewFrame()->GetWindow(),
    2339             :                     "WarnDataSourceDialog",
    2340           0 :                     "modules/swriter/ui/warndatasourcedialog.ui");
    2341           0 :                 OUString sTmp(aWarning->get_primary_text());
    2342           0 :                 aWarning->set_primary_text(sTmp.replaceFirst("%1", sSource));
    2343           0 :                 if (RET_OK == aWarning->Execute())
    2344             :                 {
    2345           0 :                     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
    2346           0 :                     if ( pFact )
    2347             :                     {
    2348           0 :                         boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( NULL, SID_OPTIONS_DATABASES ));
    2349           0 :                         pDlg->Execute();
    2350             :                     }
    2351             :                 }
    2352           0 :                 return ;
    2353           0 :             }
    2354             :         }
    2355           0 :         SwDBManager* pDBManager = GetWrtShell().GetDBManager();
    2356             : 
    2357           0 :         SwDBData aData;
    2358           0 :         SwWrtShell &rSh = GetWrtShell();
    2359             : 
    2360           0 :         std::vector<OUString> aDBNameList;
    2361           0 :         std::vector<OUString> aAllDBNames;
    2362           0 :         rSh.GetAllUsedDB( aDBNameList, &aAllDBNames );
    2363           0 :         if(!aDBNameList.empty())
    2364             :         {
    2365           0 :             OUString sDBName(aDBNameList[0]);
    2366           0 :             aData.sDataSource = sDBName.getToken(0, DB_DELIM);
    2367           0 :             aData.sCommand = sDBName.getToken(1, DB_DELIM);
    2368           0 :             aData.nCommandType = sDBName.getToken(2, DB_DELIM ).toInt32();
    2369             :         }
    2370           0 :         rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields
    2371           0 :         AttrChangedNotify( &rSh );
    2372             : 
    2373           0 :         if (pDBManager)
    2374             :         {
    2375           0 :             Sequence<PropertyValue> aProperties(3);
    2376           0 :             PropertyValue* pValues = aProperties.getArray();
    2377           0 :             pValues[0].Name = "DataSourceName";
    2378           0 :             pValues[1].Name = "Command";
    2379           0 :             pValues[2].Name = "CommandType";
    2380           0 :             pValues[0].Value <<= aData.sDataSource;
    2381           0 :             pValues[1].Value <<= aData.sCommand;
    2382           0 :             pValues[2].Value <<= aData.nCommandType;
    2383           0 :             pDBManager->ExecuteFormLetter(GetWrtShell(), aProperties, true);
    2384           0 :         }
    2385             :     }
    2386             :     else
    2387             :     {
    2388             :         // call documents and template dialog
    2389           0 :         SfxApplication* pSfxApp = SfxGetpApp();
    2390           0 :         vcl::Window* pTopWin = pSfxApp->GetTopWindow();
    2391             : 
    2392           0 :         ScopedVclPtrInstance< SfxTemplateManagerDlg > aDocTemplDlg;
    2393           0 :         int nRet = aDocTemplDlg->Execute();
    2394           0 :         bool bNewWin = false;
    2395           0 :         if ( nRet == RET_OK )
    2396             :         {
    2397           0 :             if ( pTopWin != pSfxApp->GetTopWindow() )
    2398             :             {
    2399             :                 // the dialogue opens a document -> a new TopWindow appears
    2400           0 :                 pTopWin = pSfxApp->GetTopWindow();
    2401           0 :                 bNewWin = true;
    2402             :             }
    2403             :         }
    2404             : 
    2405           0 :         if ( bNewWin )
    2406             :             // after the destruction of the dialogue its parent comes to top,
    2407             :             // but we want that the new document is on top
    2408           0 :             pTopWin->ToTop();
    2409             :     }
    2410             : #endif
    2411             : }
    2412             : 
    2413           0 : IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
    2414             : {
    2415           0 :     if ( ERRCODE_NONE == _pFileDlg->GetError() )
    2416             :     {
    2417           0 :         SfxMedium* pMed = m_pViewImpl->CreateMedium();
    2418           0 :         if ( pMed )
    2419             :         {
    2420           0 :             const sal_uInt16 nSlot = m_pViewImpl->GetRequest()->GetSlot();
    2421           0 :             long nFound = InsertMedium( nSlot, pMed, m_pViewImpl->GetParam() );
    2422             : 
    2423           0 :             if ( SID_INSERTDOC == nSlot )
    2424             :             {
    2425           0 :                 if ( m_pViewImpl->GetParam() == 0 )
    2426             :                 {
    2427           0 :                     m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
    2428           0 :                     m_pViewImpl->GetRequest()->Ignore();
    2429             :                 }
    2430             :                 else
    2431             :                 {
    2432           0 :                     m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
    2433           0 :                     m_pViewImpl->GetRequest()->Done();
    2434             :                 }
    2435             :             }
    2436           0 :             else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot )
    2437             :             {
    2438           0 :                 m_pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) );
    2439             : 
    2440           0 :                 if ( nFound > 0 ) // show Redline browser
    2441             :                 {
    2442           0 :                     SfxViewFrame* pVFrame = GetViewFrame();
    2443           0 :                     pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
    2444             : 
    2445             :                     // re-initialize Redline dialog
    2446           0 :                     sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
    2447           0 :                     SwRedlineAcceptChild* pRed = static_cast<SwRedlineAcceptChild*>(pVFrame->GetChildWindow( nId ));
    2448           0 :                     if ( pRed )
    2449           0 :                         pRed->ReInitDlg( GetDocShell() );
    2450             :                 }
    2451             :             }
    2452             :         }
    2453             :     }
    2454           0 :     return 0;
    2455             : }
    2456             : 
    2457           0 : void SwView::ExecuteScan( SfxRequest& rReq )
    2458             : {
    2459           0 :     if (m_pViewImpl)
    2460           0 :         m_pViewImpl->ExecuteScan(rReq) ;
    2461         177 : }
    2462             : 
    2463             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11