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

Generated by: LCOV version 1.10