LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/shells - textsh1.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 76 840 9.0 %
Date: 2013-07-09 Functions: 3 6 50.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             : 
      21             : #include <com/sun/star/i18n/WordType.hpp>
      22             : #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
      23             : 
      24             : #include <comphelper/processfactory.hxx>
      25             : #include <hintids.hxx>
      26             : #include <cmdid.h>
      27             : #include <helpid.h>
      28             : 
      29             : #include <i18nlangtag/languagetag.hxx>
      30             : #include <svl/languageoptions.hxx>
      31             : #include <editeng/langitem.hxx>
      32             : #include <svtools/langtab.hxx>
      33             : #include <svl/slstitm.hxx>
      34             : #include <string.h>
      35             : #include <svl/stritem.hxx>
      36             : #include <sfx2/htmlmode.hxx>
      37             : #include <svl/whiter.hxx>
      38             : #include <sfx2/bindings.hxx>
      39             : #include <sfx2/dispatch.hxx>
      40             : #include <sfx2/objitem.hxx>
      41             : #include <vcl/unohelp2.hxx>
      42             : #include <sfx2/request.hxx>
      43             : #include <svl/eitem.hxx>
      44             : #include <svl/macitem.hxx>
      45             : #include <editeng/lrspitem.hxx>
      46             : #include <editeng/colritem.hxx>
      47             : #include <editeng/tstpitem.hxx>
      48             : #include <editeng/brushitem.hxx>
      49             : #include <editeng/svxacorr.hxx>
      50             : #include <svl/cjkoptions.hxx>
      51             : #include <svl/ctloptions.hxx>
      52             : #include <IDocumentSettingAccess.hxx>
      53             : #include <charfmt.hxx>
      54             : #include <editeng/fontitem.hxx>
      55             : #include <svx/SmartTagItem.hxx>
      56             : #include <fmtinfmt.hxx>
      57             : #include <swwait.hxx>
      58             : #include <wrtsh.hxx>
      59             : #include <wview.hxx>
      60             : #include <swmodule.hxx>
      61             : #include <viewopt.hxx>
      62             : #include <uitool.hxx>
      63             : #include <swevent.hxx>
      64             : #include <pagedesc.hxx>
      65             : #include <textsh.hxx>
      66             : #include <IMark.hxx>
      67             : #include <swdtflvr.hxx>
      68             : #include <docstat.hxx>
      69             : #include <outline.hxx>
      70             : #include <tablemgr.hxx>
      71             : #include <swundo.hxx>       // for Undo-IDs
      72             : #include <reffld.hxx>
      73             : #include <docsh.hxx>
      74             : #include <mdiexp.hxx>
      75             : #include <inputwin.hxx>
      76             : #include <pardlg.hxx>
      77             : #include <frmatr.hxx>
      78             : #include <fmtcol.hxx>
      79             : #include <cellatr.hxx>
      80             : #include <edtwin.hxx>
      81             : #include <redlndlg.hxx>
      82             : #include "fldmgr.hxx"
      83             : 
      84             : #include <globals.hrc>
      85             : #include <shells.hrc>
      86             : #include <app.hrc>
      87             : #include <web.hrc>
      88             : #include "paratr.hxx"
      89             : #include <crsskip.hxx>
      90             : #include <vcl/svapp.hxx>
      91             : #include <sfx2/app.hxx>
      92             : #include <breakit.hxx>
      93             : 
      94             : #include <SwSmartTagMgr.hxx>
      95             : 
      96             : #include <editeng/acorrcfg.hxx>
      97             : #include "swabstdlg.hxx"
      98             : #include "misc.hrc"
      99             : #include "chrdlg.hrc"
     100             : #include <IDocumentStatistics.hxx>
     101             : 
     102             : #include <sfx2/sfxdlg.hxx>
     103             : #include <unotools/lingucfg.hxx>
     104             : #include <com/sun/star/beans/XPropertySet.hpp>
     105             : #include <com/sun/star/util/XChangesBatch.hpp>
     106             : #include <com/sun/star/uno/Any.hxx>
     107             : #include <editeng/unolingu.hxx>
     108             : #include <unotools/syslocaleoptions.hxx>
     109             : #include <doc.hxx>
     110             : #include <view.hxx>
     111             : #include <ndtxt.hxx>
     112             : #include <pam.hxx>
     113             : #include <sfx2/objface.hxx>
     114             : #include <langhelper.hxx>
     115             : #include <uiitems.hxx>
     116             : #include <wordcountdialog.hxx>
     117             : #include <tools/diagnose_ex.h>
     118             : 
     119             : #ifndef _NBDTMGFACT_HXX
     120             : #include <svx/nbdtmgfact.hxx>
     121             : #endif
     122             : #ifndef _NBDTMG_HXX
     123             : #include <svx/nbdtmg.hxx>
     124             : #endif
     125             : 
     126             : 
     127             : #include <numrule.hxx>
     128             : 
     129             : 
     130             : using namespace ::com::sun::star;
     131             : using namespace svx::sidebar;
     132             : 
     133           0 : void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq )
     134             : {
     135           0 :     FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rWrtSh.GetView()));
     136           0 :     SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
     137           0 :     SfxItemSet aCoreSet( rWrtSh.GetView().GetPool(),
     138             :                         RES_CHRATR_BEGIN,      RES_CHRATR_END-1,
     139             :                         RES_TXTATR_INETFMT,    RES_TXTATR_INETFMT,
     140             :                         RES_BACKGROUND,        RES_BACKGROUND,
     141             :                         FN_PARAM_SELECTION,    FN_PARAM_SELECTION,
     142             :                         SID_HTML_MODE,         SID_HTML_MODE,
     143             :                         SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,   SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
     144           0 :                         0 );
     145           0 :     rWrtSh.GetCurAttr( aCoreSet );
     146           0 :     sal_Bool bSel = rWrtSh.HasSelection();
     147           0 :     sal_Bool bSelectionPut = sal_False;
     148           0 :     if(bSel || rWrtSh.IsInWord())
     149             :     {
     150           0 :         if(!bSel)
     151             :         {
     152           0 :             rWrtSh.StartAction();
     153           0 :             rWrtSh.Push();
     154           0 :             if(!rWrtSh.SelectTxtAttr( RES_TXTATR_INETFMT ))
     155           0 :                 rWrtSh.SelWrd();
     156             :         }
     157           0 :         aCoreSet.Put(SfxStringItem(FN_PARAM_SELECTION, rWrtSh.GetSelTxt()));
     158           0 :         bSelectionPut = sal_True;
     159           0 :         if(!bSel)
     160             :         {
     161           0 :             rWrtSh.Pop(sal_False);
     162           0 :             rWrtSh.EndAction();
     163             :         }
     164             :     }
     165             :         aCoreSet.Put( SfxUInt16Item( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
     166           0 :                     rWrtSh.GetScalingOfSelectedText() ) );
     167             :     // The CHRATR_BACKGROUND attribute will be converted for the
     168             :     // dialogue in a RES_BACKGROUND and back again ...
     169             :     const SfxPoolItem *pTmpBrush;
     170           0 :     if( SFX_ITEM_SET == aCoreSet.GetItemState( RES_CHRATR_BACKGROUND, sal_True, &pTmpBrush ) )
     171             :     {
     172           0 :         SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
     173           0 :         aTmpBrush.SetWhich( RES_BACKGROUND );
     174           0 :         aCoreSet.Put( aTmpBrush );
     175             :     }
     176             : 
     177           0 :     aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(rWrtSh.GetView().GetDocShell())));
     178           0 :     SfxAbstractTabDialog* pDlg = NULL;
     179           0 :     if ( bUseDialog && GetActiveView() )
     180             :     {
     181           0 :         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     182             :         OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     183             : 
     184           0 :         pDlg = pFact->CreateSwCharDlg(rWrtSh.GetView().GetWindow(), rWrtSh.GetView(), aCoreSet);
     185             :         OSL_ENSURE(pDlg, "Dialogdiet fail!");
     186           0 :         if( FN_INSERT_HYPERLINK == nSlot )
     187           0 :             pDlg->SetCurPageId("hyperlink");
     188             :     }
     189           0 :     if (nSlot == SID_CHAR_DLG_EFFECT)
     190             :     {
     191           0 :         pDlg->SetCurPageId(TP_CHAR_EXT);
     192             :     }
     193             : 
     194           0 :     const SfxItemSet* pSet = NULL;
     195           0 :     if ( !bUseDialog )
     196           0 :         pSet = pArgs;
     197           0 :     else if ( NULL != pDlg && pDlg->Execute() == RET_OK ) /* #110771# pDlg can be NULL */
     198             :     {
     199           0 :         pSet = pDlg->GetOutputItemSet();
     200             :     }
     201             : 
     202           0 :     if ( pSet)
     203             :     {
     204           0 :         SfxItemSet aTmpSet( *pSet );
     205           0 :         if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_BACKGROUND, sal_False, &pTmpBrush ) )
     206             :         {
     207           0 :             SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) );
     208           0 :             aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND );
     209           0 :             aTmpSet.Put( aTmpBrush );
     210             :         }
     211             : 
     212           0 :         aTmpSet.ClearItem( RES_BACKGROUND );
     213             : 
     214             :         const SfxPoolItem* pSelectionItem;
     215           0 :         sal_Bool bInsert = sal_False;
     216           0 :         xub_StrLen nInsert = 0;
     217             : 
     218             :         // The old item is for unknown reasons back in the set again.
     219           0 :         if( !bSelectionPut && SFX_ITEM_SET == aTmpSet.GetItemState(FN_PARAM_SELECTION, sal_False, &pSelectionItem) )
     220             :         {
     221           0 :             String sInsert = ((const SfxStringItem*)pSelectionItem)->GetValue();
     222           0 :             bInsert = sInsert.Len() != 0;
     223           0 :             if(bInsert)
     224             :             {
     225           0 :                 nInsert = sInsert.Len();
     226           0 :                 rWrtSh.StartAction();
     227           0 :                 rWrtSh.Insert( sInsert );
     228           0 :                 rWrtSh.SetMark();
     229           0 :                 rWrtSh.ExtendSelection(sal_False, sInsert.Len());
     230           0 :                 SfxRequest aReq( rWrtSh.GetView().GetViewFrame(), FN_INSERT_STRING );
     231           0 :                 aReq.AppendItem( SfxStringItem( FN_INSERT_STRING, sInsert ) );
     232           0 :                 aReq.Done();
     233           0 :                 SfxRequest aReq1( rWrtSh.GetView().GetViewFrame(), FN_CHAR_LEFT );
     234           0 :                 aReq1.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nInsert) );
     235           0 :                 aReq1.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, sal_True) );
     236           0 :                 aReq1.Done();
     237           0 :             }
     238             :         }
     239           0 :         aTmpSet.ClearItem(FN_PARAM_SELECTION);
     240             : 
     241           0 :         SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
     242           0 :         if(bSel && rWrtSh.IsSelFullPara() && pColl && pColl->IsAutoUpdateFmt())
     243             :         {
     244           0 :             rWrtSh.AutoUpdatePara(pColl, aTmpSet);
     245             :         }
     246             :         else
     247           0 :             rWrtSh.SetAttr( aTmpSet );
     248           0 :         if (pReq)
     249           0 :             pReq->Done(aTmpSet);
     250           0 :         if(bInsert)
     251             :         {
     252           0 :             SfxRequest aReq1( rWrtSh.GetView().GetViewFrame(), FN_CHAR_RIGHT );
     253           0 :             aReq1.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT, nInsert) );
     254           0 :             aReq1.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION, sal_False) );
     255           0 :             aReq1.Done();
     256           0 :             rWrtSh.SwapPam();
     257           0 :             rWrtSh.ClearMark();
     258           0 :             rWrtSh.DontExpandFmt();
     259           0 :             rWrtSh.EndAction();
     260           0 :         }
     261             :     }
     262             : 
     263           0 :     delete pDlg;
     264           0 : }
     265             : 
     266           0 : static short lcl_AskRedlineMode(Window *pWin)
     267             : {
     268             :     MessBox aQBox( pWin, 0,
     269             :                     String( SW_RES( STR_REDLINE_TITLE ) ),
     270           0 :                     String( SW_RES( STR_REDLINE_MSG ) ) );
     271           0 :     aQBox.SetImage( QueryBox::GetStandardImage() );
     272             :     sal_uInt16 nBtnFlags = BUTTONDIALOG_DEFBUTTON |
     273             :                         BUTTONDIALOG_OKBUTTON |
     274           0 :                         BUTTONDIALOG_FOCUSBUTTON;
     275             : 
     276           0 :     aQBox.AddButton(String(SW_RES(STR_REDLINE_ACCEPT_ALL)), RET_OK, nBtnFlags);
     277           0 :     aQBox.GetPushButton( RET_OK )->SetHelpId(HID_AUTOFORMAT_ACCEPT);
     278           0 :     aQBox.AddButton(String(SW_RES(STR_REDLINE_REJECT_ALL)), RET_CANCEL, BUTTONDIALOG_CANCELBUTTON);
     279           0 :     aQBox.GetPushButton( RET_CANCEL )->SetHelpId(HID_AUTOFORMAT_REJECT  );
     280           0 :     aQBox.AddButton(String(SW_RES(STR_REDLINE_EDIT)), 2, 0);
     281           0 :     aQBox.GetPushButton( 2 )->SetHelpId(HID_AUTOFORMAT_EDIT_CHG);
     282           0 :     aQBox.SetButtonHelpText( RET_OK, OUString() );
     283             : 
     284           0 :     return aQBox.Execute();
     285             : }
     286             : 
     287           0 : void SwTextShell::Execute(SfxRequest &rReq)
     288             : {
     289           0 :     bool bUseDialog = true;
     290           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
     291           0 :     SwWrtShell& rWrtSh = GetShell();
     292           0 :     const SfxPoolItem* pItem = 0;
     293           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     294           0 :     if(pArgs)
     295           0 :         pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
     296           0 :     switch( nSlot )
     297             :     {
     298             :         case SID_LANGUAGE_STATUS:
     299             :         {
     300             :             // get the language
     301           0 :             String aNewLangTxt;
     302           0 :             SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_LANGUAGE_STATUS , sal_False );
     303           0 :             if (pItem2)
     304           0 :                 aNewLangTxt = pItem2->GetValue();
     305             : 
     306             :             //!! Remember the view frame right now...
     307             :             //!! (call to GetView().GetViewFrame() will break if the
     308             :             //!! SwTextShell got destroyed meanwhile.)
     309           0 :             SfxViewFrame *pViewFrame = GetView().GetViewFrame();
     310             : 
     311           0 :             if (aNewLangTxt.EqualsAscii( "*" ))
     312             :             {
     313             :                 // open the dialog "Tools/Options/Language Settings - Language"
     314             :                 // to set the documents default language
     315           0 :                 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
     316           0 :                 if (pFact)
     317             :                 {
     318           0 :                     VclAbstractDialog* pDlg = pFact->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS );
     319           0 :                     pDlg->Execute();
     320           0 :                     delete pDlg;
     321             :                 }
     322             :             }
     323             :             else
     324             :             {
     325             :                 //!! We have to use StartAction / EndAction bracketing in
     326             :                 //!! order to prevent possible destruction of the SwTextShell
     327             :                 //!! due to the selection changes coming below.
     328           0 :                 rWrtSh.StartAction();
     329             :                 // prevent view from jumping because of (temporary) selection changes
     330           0 :                 rWrtSh.LockView( sal_True );
     331             : 
     332             :                 // save selection for later restoration
     333           0 :                 rWrtSh.Push();
     334             : 
     335             :                 // setting the new language...
     336           0 :                 if (aNewLangTxt.Len() > 0)
     337             :                 {
     338           0 :                     const OUString aSelectionLangPrefix("Current_");
     339           0 :                     const OUString aParagraphLangPrefix("Paragraph_");
     340           0 :                     const OUString aDocumentLangPrefix("Default_");
     341           0 :                     const String aStrNone( OUString("LANGUAGE_NONE") );
     342           0 :                     const String aStrResetLangs( OUString("RESET_LANGUAGES") );
     343             : 
     344           0 :                     SfxItemSet aCoreSet( GetPool(),
     345             :                             RES_CHRATR_LANGUAGE,        RES_CHRATR_LANGUAGE,
     346             :                             RES_CHRATR_CJK_LANGUAGE,    RES_CHRATR_CJK_LANGUAGE,
     347             :                             RES_CHRATR_CTL_LANGUAGE,    RES_CHRATR_CTL_LANGUAGE,
     348           0 :                             0 );
     349             : 
     350           0 :                     xub_StrLen nPos = 0;
     351           0 :                     bool bForSelection = true;
     352           0 :                     bool bForParagraph = false;
     353           0 :                     if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aSelectionLangPrefix, 0 )))
     354             :                     {
     355             :                         // ... for the current selection
     356           0 :                         aNewLangTxt = aNewLangTxt.Erase( nPos, aSelectionLangPrefix.getLength() );
     357           0 :                         bForSelection = true;
     358             :                     }
     359           0 :                     else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aParagraphLangPrefix , 0 )))
     360             :                     {
     361             :                         // ... for the current paragraph language
     362           0 :                         aNewLangTxt = aNewLangTxt.Erase( nPos, aParagraphLangPrefix.getLength() );
     363           0 :                         bForSelection = true;
     364           0 :                         bForParagraph = true;
     365             :                     }
     366           0 :                     else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aDocumentLangPrefix , 0 )))
     367             :                     {
     368             :                         // ... as default document language
     369           0 :                         aNewLangTxt = aNewLangTxt.Erase( nPos, aDocumentLangPrefix.getLength() );
     370           0 :                         bForSelection = false;
     371             :                     }
     372             : 
     373           0 :                     if (bForParagraph)
     374           0 :                         SwLangHelper::SelectCurrentPara( rWrtSh );
     375             : 
     376           0 :                     if (!bForSelection) // document language to be changed...
     377             :                     {
     378           0 :                         rWrtSh.SelAll();
     379           0 :                         rWrtSh.ExtendedSelectAll();
     380             :                     }
     381             : 
     382           0 :                     rWrtSh.StartUndo( ( !bForParagraph && !bForSelection ) ? UNDO_SETDEFTATTR : UNDO_EMPTY );
     383           0 :                     if (aNewLangTxt == aStrNone)
     384           0 :                         SwLangHelper::SetLanguage_None( rWrtSh, bForSelection, aCoreSet );
     385           0 :                     else if (aNewLangTxt == aStrResetLangs)
     386           0 :                         SwLangHelper::ResetLanguages( rWrtSh, bForSelection );
     387             :                     else
     388           0 :                         SwLangHelper::SetLanguage( rWrtSh, aNewLangTxt, bForSelection, aCoreSet );
     389           0 :                     rWrtSh.EndUndo();
     390             : 
     391             :                 }
     392             : 
     393             :                 // restore selection...
     394           0 :                 rWrtSh.Pop( sal_False );
     395             : 
     396           0 :                 rWrtSh.LockView( sal_False );
     397           0 :                 rWrtSh.EndAction();
     398             :             }
     399             : 
     400             :             // invalidate slot to get the new language displayed
     401           0 :             pViewFrame->GetBindings().Invalidate( nSlot );
     402             : 
     403           0 :             rReq.Done();
     404           0 :             break;
     405             :         }
     406             : 
     407             :         case SID_THES:
     408             :         {
     409             :             // replace word/selection with text from selected sub menu entry
     410           0 :             String aReplaceText;
     411           0 :             SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , sal_False );
     412           0 :             if (pItem2)
     413           0 :                 aReplaceText = pItem2->GetValue();
     414           0 :             if (aReplaceText.Len() > 0)
     415             :             {
     416           0 :                 SwView &rView2 = rWrtSh.GetView();
     417           0 :                 const bool bSelection = rWrtSh.HasSelection();
     418           0 :                 const String aLookUpText = rView2.GetThesaurusLookUpText( bSelection );
     419           0 :                 rView2.InsertThesaurusSynonym( aReplaceText, aLookUpText, bSelection );
     420           0 :             }
     421             :         }
     422           0 :         break;
     423             : 
     424             :         case SID_CHARMAP:
     425             :         {
     426           0 :             InsertSymbol( rReq );
     427             :         }
     428           0 :         break;
     429             :         case FN_INSERT_FOOTNOTE:
     430             :         case FN_INSERT_ENDNOTE:
     431             :         {
     432           0 :             String aStr;
     433           0 :             SFX_REQUEST_ARG( rReq, pFont, SfxStringItem, FN_PARAM_1 , sal_False );
     434           0 :             SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, nSlot , sal_False );
     435           0 :             if ( pNameItem )
     436           0 :                 aStr = pNameItem->GetValue();
     437           0 :             bool bFont = pFont && !pFont->GetValue().isEmpty();
     438           0 :             rWrtSh.StartUndo( UNDO_UI_INSERT_FOOTNOTE );
     439           0 :             rWrtSh.InsertFootnote( aStr, nSlot == FN_INSERT_ENDNOTE, !bFont );
     440           0 :             if ( bFont )
     441             :             {
     442           0 :                 rWrtSh.Left( CRSR_SKIP_CHARS, sal_True, 1, sal_False );
     443           0 :                 SfxItemSet aSet( rWrtSh.GetAttrPool(), RES_CHRATR_FONT, RES_CHRATR_FONT );
     444           0 :                 rWrtSh.GetCurAttr( aSet );
     445           0 :                 SvxFontItem &rFont = (SvxFontItem &) aSet.Get( RES_CHRATR_FONT );
     446           0 :                 SvxFontItem aFont( rFont.GetFamily(), pFont->GetValue(),
     447           0 :                                     rFont.GetStyleName(), rFont.GetPitch(), RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT );
     448           0 :                 rWrtSh.SetAttr( aSet, nsSetAttrMode::SETATTR_DONTEXPAND );
     449           0 :                 rWrtSh.ResetSelect(0, sal_False);
     450           0 :                 rWrtSh.EndSelect();
     451           0 :                 rWrtSh.GotoFtnTxt();
     452             :             }
     453           0 :             rWrtSh.EndUndo( UNDO_UI_INSERT_FOOTNOTE );
     454           0 :             rReq.Done();
     455             :         }
     456           0 :         break;
     457             :         case FN_INSERT_FOOTNOTE_DLG:
     458             :         {
     459           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     460             :             OSL_ENSURE(pFact, "Dialogdiet fail!");
     461             :             AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg(
     462           0 :                 GetView().GetWindow(), rWrtSh, sal_False);
     463             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     464           0 :             pDlg->SetHelpId(GetStaticInterface()->GetSlot(nSlot)->GetCommand());
     465           0 :             if ( pDlg->Execute() == RET_OK )
     466             :             {
     467           0 :                 sal_uInt16 nId = pDlg->IsEndNote() ? FN_INSERT_ENDNOTE : FN_INSERT_FOOTNOTE;
     468           0 :                 SfxRequest aReq( GetView().GetViewFrame(), nId );
     469           0 :                 if ( pDlg->GetStr().Len() )
     470           0 :                     aReq.AppendItem( SfxStringItem( nId, pDlg->GetStr() ) );
     471           0 :                 if ( pDlg->GetFontName().Len() )
     472           0 :                     aReq.AppendItem( SfxStringItem( FN_PARAM_1, pDlg->GetFontName() ) );
     473           0 :                 ExecuteSlot( aReq );
     474             :             }
     475             : 
     476           0 :             rReq.Ignore();
     477           0 :             delete pDlg;
     478             :         }
     479           0 :         break;
     480             :         case FN_FORMAT_FOOTNOTE_DLG:
     481             :         {
     482           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     483             :             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     484             : 
     485           0 :             VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), rWrtSh);
     486             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     487           0 :             pDlg->Execute();
     488           0 :             delete pDlg;
     489           0 :             break;
     490             :         }
     491             :         case SID_INSERTDOC:
     492             :         {
     493           0 :             GetView().ExecuteInsertDoc( rReq, pItem );
     494           0 :             break;
     495             :         }
     496             :         case FN_FORMAT_RESET:
     497             :         {
     498             :             // #i78856, reset all attributes but not the language attributes
     499             :             // (for this build an array of all relevant attributes and
     500             :             // remove the languages from that)
     501           0 :             std::set<sal_uInt16> aAttribs;
     502             : 
     503             :             sal_uInt16 aResetableSetRange[] = {
     504             :                 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
     505             :                 RES_CHRATR_BEGIN, RES_CHRATR_LANGUAGE - 1,
     506             :                 RES_CHRATR_LANGUAGE + 1, RES_CHRATR_CJK_LANGUAGE - 1,
     507             :                 RES_CHRATR_CJK_LANGUAGE + 1, RES_CHRATR_CTL_LANGUAGE - 1,
     508             :                 RES_CHRATR_CTL_LANGUAGE + 1, RES_CHRATR_END-1,
     509             :                 RES_PARATR_BEGIN, RES_PARATR_END-1,
     510             :                 RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
     511             :                 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
     512             :                 0
     513           0 :             };
     514           0 :             sal_uInt16 *pUShorts = aResetableSetRange;
     515           0 :             while (*pUShorts)
     516             :             {
     517           0 :                 sal_uInt16 nL = pUShorts[1] - pUShorts[0] + 1;
     518           0 :                 sal_uInt16 nE = pUShorts[0];
     519           0 :                 for (sal_uInt16 i = 0; i < nL; ++i)
     520           0 :                     aAttribs.insert( aAttribs.end(), nE++ );
     521           0 :                 pUShorts += 2;
     522             :             }
     523             :             // we don't want to change writing direction.
     524           0 :             aAttribs.erase( RES_FRAMEDIR );
     525           0 :             rWrtSh.ResetAttr( aAttribs );
     526           0 :             rReq.Done();
     527           0 :             break;
     528             :         }
     529             :         case FN_INSERT_BREAK_DLG:
     530             :         {
     531           0 :             sal_uInt16 nKind=0, nPageNumber=0;
     532           0 :             String aTemplateName;
     533           0 :             if ( pItem )
     534             :             {
     535           0 :                 nKind = ((SfxInt16Item*)pItem)->GetValue();
     536           0 :                 SFX_REQUEST_ARG( rReq, pTemplate, SfxStringItem, FN_PARAM_1 , sal_False );
     537           0 :                 SFX_REQUEST_ARG( rReq, pNumber, SfxUInt16Item, FN_PARAM_2 , sal_False );
     538           0 :                 if ( pTemplate )
     539           0 :                     aTemplateName = pTemplate->GetValue();
     540           0 :                 if ( pNumber )
     541           0 :                     nPageNumber = pNumber->GetValue();
     542             :             }
     543             :             else
     544             :             {
     545           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     546             :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     547             : 
     548           0 :                 AbstractSwBreakDlg* pDlg = pFact->CreateSwBreakDlg(GetView().GetWindow(), rWrtSh);
     549             :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     550           0 :                 if ( pDlg->Execute() == RET_OK )
     551             :                 {
     552           0 :                     nKind = pDlg->GetKind();
     553           0 :                     aTemplateName = pDlg->GetTemplateName();
     554           0 :                     nPageNumber = pDlg->GetPageNumber();
     555           0 :                     rReq.AppendItem( SfxInt16Item( FN_INSERT_BREAK_DLG, nKind ) );
     556           0 :                     rReq.AppendItem( SfxUInt16Item( FN_PARAM_2, nPageNumber ) );
     557           0 :                     rReq.AppendItem( SfxStringItem( FN_PARAM_1, aTemplateName ) );
     558           0 :                     rReq.Done();
     559             :                 }
     560             :                 else
     561           0 :                     rReq.Ignore();
     562           0 :                 delete pDlg;
     563             :             }
     564             : 
     565           0 :             switch ( nKind )
     566             :             {
     567             :                 case 1 :
     568           0 :                     rWrtSh.InsertLineBreak(); break;
     569             :                 case 2 :
     570           0 :                     rWrtSh.InsertColumnBreak(); break;
     571             :                 case 3 :
     572             :                 {
     573           0 :                     rWrtSh.StartAllAction();
     574           0 :                     if( aTemplateName.Len() )
     575           0 :                         rWrtSh.InsertPageBreak( &aTemplateName, nPageNumber );
     576             :                     else
     577           0 :                         rWrtSh.InsertPageBreak();
     578           0 :                     rWrtSh.EndAllAction();
     579             :                 }
     580             :             }
     581             : 
     582           0 :             break;
     583             :         }
     584             :         case FN_INSERT_BOOKMARK:
     585             :         {
     586           0 :             if ( pItem )
     587             :             {
     588           0 :                 OUString sName = ((SfxStringItem*)pItem)->GetValue();
     589           0 :                 rWrtSh.SetBookmark( KeyCode(), sName, aEmptyStr );
     590             :             }
     591             :             else
     592             :             {
     593           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     594             :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     595             : 
     596           0 :                 VclAbstractDialog* pDlg = pFact->CreateSwInsertBookmarkDlg( GetView().GetWindow(), rWrtSh, rReq, DLG_INSERT_BOOKMARK );
     597             :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     598           0 :                 pDlg->Execute();
     599           0 :                 delete pDlg;
     600             :             }
     601             : 
     602           0 :             break;
     603             :         }
     604             :         case FN_DELETE_BOOKMARK:
     605             :         {
     606           0 :             if ( pItem )
     607             :             {
     608           0 :                 IDocumentMarkAccess* const pMarkAccess = rWrtSh.getIDocumentMarkAccess();
     609           0 :                 pMarkAccess->deleteMark( pMarkAccess->findMark(((SfxStringItem*)pItem)->GetValue()) );
     610             :             }
     611           0 :             break;
     612             :         }
     613             :         case FN_AUTOFORMAT_REDLINE_APPLY:
     614             :         {
     615           0 :             SvxSwAutoFmtFlags aFlags(SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags());
     616             :             // This must always be sal_False for the postprocessing.
     617           0 :             aFlags.bAFmtByInput = sal_False;
     618           0 :             aFlags.bWithRedlining = sal_True;
     619           0 :             rWrtSh.AutoFormat( &aFlags );
     620           0 :             aFlags.bWithRedlining = sal_False;
     621             : 
     622           0 :             SfxViewFrame* pVFrame = GetView().GetViewFrame();
     623           0 :             if (pVFrame->HasChildWindow(FN_REDLINE_ACCEPT))
     624           0 :                 pVFrame->ToggleChildWindow(FN_REDLINE_ACCEPT);
     625             : 
     626           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     627             :             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     628             : 
     629           0 :             AbstractSwModalRedlineAcceptDlg* pDlg = pFact->CreateSwModalRedlineAcceptDlg(&GetView().GetEditWin());
     630             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     631             : 
     632           0 :             switch (lcl_AskRedlineMode(&GetView().GetEditWin()))
     633             :             {
     634             :                 case RET_OK:
     635             :                 {
     636           0 :                     pDlg->AcceptAll(sal_True);
     637           0 :                     SfxRequest aReq( pVFrame, FN_AUTOFORMAT_APPLY );
     638           0 :                     aReq.Done();
     639           0 :                     rReq.Ignore();
     640           0 :                     break;
     641             :                 }
     642             : 
     643             :                 case RET_CANCEL:
     644           0 :                     pDlg->AcceptAll(sal_False);
     645           0 :                     rReq.Ignore();
     646           0 :                     break;
     647             : 
     648             :                 case 2:
     649           0 :                     pDlg->Execute();
     650           0 :                     rReq.Done();
     651           0 :                     break;
     652             :             }
     653           0 :             delete pDlg;
     654             :         }
     655           0 :         break;
     656             : 
     657             :         case FN_AUTOFORMAT_APPLY:
     658             :         {
     659           0 :             SvxSwAutoFmtFlags aFlags(SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags());
     660             :             // This must always be sal_False for the postprocessing.
     661           0 :             aFlags.bAFmtByInput = sal_False;
     662           0 :             rWrtSh.AutoFormat( &aFlags );
     663           0 :             rReq.Done();
     664             :         }
     665           0 :         break;
     666             :         case FN_AUTOFORMAT_AUTO:
     667             :         {
     668           0 :             SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
     669           0 :             sal_Bool bSet = pItem ? ((const SfxBoolItem*)pItem)->GetValue() : !rACfg.IsAutoFmtByInput();
     670           0 :             if( bSet != rACfg.IsAutoFmtByInput() )
     671             :             {
     672           0 :                 rACfg.SetAutoFmtByInput( bSet );
     673           0 :                 GetView().GetViewFrame()->GetBindings().Invalidate( nSlot );
     674           0 :                 if ( !pItem )
     675           0 :                     rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), bSet ) );
     676           0 :                 rReq.Done();
     677             :             }
     678             :         }
     679           0 :         break;
     680             :         case FN_AUTO_CORRECT:
     681             :         {
     682             :             // At first set to blank as default.
     683           0 :             sal_Unicode cChar = ' ';
     684           0 :             rWrtSh.AutoCorrect( *SvxAutoCorrCfg::Get().GetAutoCorrect(), cChar );
     685           0 :             rReq.Done();
     686             :         }
     687           0 :         break;
     688             :         case FN_TABLE_SORT_DIALOG:
     689             :         case FN_SORTING_DLG:
     690             :         {
     691           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     692             :             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     693             : 
     694           0 :             VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rWrtSh, DLG_SORTING );
     695             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     696           0 :             pDlg->Execute();
     697           0 :             delete pDlg;
     698           0 :             rReq.Done();
     699             :         }
     700           0 :         break;
     701             :         case FN_NUMBERING_OUTLINE_DLG:
     702             :         {
     703           0 :             SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
     704           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     705             :             OSL_ENSURE(pFact, "Dialogdiet fail!");
     706             :             SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
     707           0 :                                                         GetView().GetWindow(), &aTmp, rWrtSh);
     708             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     709           0 :             pDlg->Execute();
     710           0 :             delete pDlg;
     711           0 :             rReq.Done();
     712             :         }
     713           0 :             break;
     714             :         case FN_CALCULATE:
     715             :             {
     716           0 :                 SwTransferable* pTransfer = new SwTransferable( rWrtSh );
     717             : /*??*/          uno::Reference<
     718             :                     datatransfer::XTransferable > xRef(
     719           0 :                                                     pTransfer );
     720           0 :                 pTransfer->CalculateAndCopy();
     721           0 :                 rReq.Done();
     722             :             }
     723           0 :             break;
     724             :         case FN_GOTO_REFERENCE:
     725             :         {
     726           0 :             SwField *pFld = rWrtSh.GetCurFld();
     727           0 :             if(pFld && pFld->GetTypeId() == TYP_GETREFFLD)
     728             :             {
     729           0 :                 rWrtSh.StartAllAction();
     730           0 :                 rWrtSh.SwCrsrShell::GotoRefMark( ((SwGetRefField*)pFld)->GetSetRefName(),
     731           0 :                                     ((SwGetRefField*)pFld)->GetSubType(),
     732           0 :                                     ((SwGetRefField*)pFld)->GetSeqNo() );
     733           0 :                 rWrtSh.EndAllAction();
     734           0 :                 rReq.Done();
     735             :             }
     736             :         }
     737           0 :             break;
     738             :         case FN_EDIT_FORMULA:
     739             :         {
     740           0 :             const sal_uInt16 nId = SwInputChild::GetChildWindowId();
     741           0 :             SfxViewFrame* pVFrame = GetView().GetViewFrame();
     742           0 :             if(pItem)
     743             :             {
     744             :                 //if the ChildWindow is active it has to be removed
     745           0 :                 if( pVFrame->HasChildWindow( nId ) )
     746             :                 {
     747           0 :                     pVFrame->ToggleChildWindow( nId );
     748           0 :                     pVFrame->GetBindings().InvalidateAll( sal_True );
     749             :                 }
     750             : 
     751           0 :                 String sFormula(((const SfxStringItem*)pItem)->GetValue());
     752           0 :                 SwFldMgr aFldMgr;
     753           0 :                 rWrtSh.StartAllAction();
     754             :                 sal_Bool bDelSel;
     755           0 :                 if( 0 != (bDelSel = rWrtSh.HasSelection()) )
     756             :                 {
     757           0 :                     rWrtSh.StartUndo( UNDO_START );
     758           0 :                     rWrtSh.DelRight();
     759             :                 }
     760             :                 else
     761             :                 {
     762           0 :                     rWrtSh.EnterStdMode();
     763             :                 }
     764             : 
     765           0 :                 if( !bDelSel && aFldMgr.GetCurFld() && TYP_FORMELFLD == aFldMgr.GetCurTypeId() )
     766           0 :                     aFldMgr.UpdateCurFld( aFldMgr.GetCurFld()->GetFormat(), aEmptyStr, sFormula );
     767           0 :                 else if( sFormula.Len() )
     768             :                 {
     769           0 :                     if( rWrtSh.IsCrsrInTbl() )
     770             :                     {
     771           0 :                         SfxItemSet aSet( rWrtSh.GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
     772           0 :                         aSet.Put( SwTblBoxFormula( sFormula ));
     773           0 :                         rWrtSh.SetTblBoxFormulaAttrs( aSet );
     774           0 :                         rWrtSh.UpdateTable();
     775             :                     }
     776             :                     else
     777             :                     {
     778           0 :                         SvNumberFormatter* pFormatter = rWrtSh.GetNumberFormatter();
     779           0 :                         sal_uLong nSysNumFmt = pFormatter->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM);
     780           0 :                         SwInsertFld_Data aData(TYP_FORMELFLD, nsSwGetSetExpType::GSE_FORMULA, aEmptyStr, sFormula, nSysNumFmt);
     781           0 :                         aFldMgr.InsertFld(aData);
     782             :                     }
     783             :                 }
     784             : 
     785           0 :                 if( bDelSel )
     786           0 :                     rWrtSh.EndUndo( UNDO_END );
     787           0 :                 rWrtSh.EndAllAction();
     788           0 :                 rReq.Done();
     789             :             }
     790             :             else
     791             :             {
     792           0 :                 rWrtSh.EndAllTblBoxEdit();
     793           0 :                 pVFrame->ToggleChildWindow( nId );
     794           0 :                 if( !pVFrame->HasChildWindow( nId ) )
     795           0 :                     pVFrame->GetBindings().InvalidateAll( sal_True );
     796           0 :                 rReq.Ignore();
     797             :             }
     798             :         }
     799             : 
     800           0 :         break;
     801             :         case FN_TABLE_UNSET_READ_ONLY:
     802             :         {
     803           0 :             rWrtSh.UnProtectTbls();
     804             :         }
     805           0 :         break;
     806             :         case FN_EDIT_HYPERLINK:
     807           0 :             GetView().GetViewFrame()->ToggleChildWindow(SID_HYPERLINK_DIALOG);
     808           0 :         break;
     809             :         case FN_REMOVE_HYPERLINK:
     810             :         {
     811           0 :             sal_Bool bSel = rWrtSh.HasSelection();
     812           0 :             if(!bSel)
     813             :             {
     814           0 :                 rWrtSh.StartAction();
     815           0 :                 rWrtSh.Push();
     816           0 :                 if(!rWrtSh.SelectTxtAttr( RES_TXTATR_INETFMT ))
     817           0 :                     rWrtSh.SelWrd();
     818             :             }
     819             :             //now remove the attribute
     820           0 :             std::set<sal_uInt16> aAttribs;
     821           0 :             aAttribs.insert( RES_TXTATR_INETFMT );
     822           0 :             rWrtSh.ResetAttr( aAttribs );
     823           0 :             if(!bSel)
     824             :             {
     825           0 :                 rWrtSh.Pop(sal_False);
     826           0 :                 rWrtSh.EndAction();
     827           0 :             }
     828             :         }
     829           0 :         break;
     830             :         case SID_ATTR_BRUSH_CHAR :
     831             :         case SID_ATTR_CHAR_SCALEWIDTH :
     832             :         case SID_ATTR_CHAR_ROTATED :
     833             :         case FN_TXTATR_INET :
     834             :         case FN_INSERT_HYPERLINK:
     835             :         {
     836           0 :             sal_uInt16 nWhich = GetPool().GetWhich( nSlot );
     837           0 :             if ( pArgs && pArgs->GetItemState( nWhich ) == SFX_ITEM_SET )
     838           0 :                 bUseDialog = false;
     839             :             // intentionally no break
     840             :         }
     841             :         case SID_CHAR_DLG:
     842             :         case SID_CHAR_DLG_EFFECT:
     843             :         {
     844           0 :             sw_CharDialog( rWrtSh, bUseDialog, nSlot, pArgs, &rReq );
     845             :         }
     846           0 :         break;
     847             :         case SID_CHAR_DLG_FOR_PARAGRAPH:
     848             :         {
     849           0 :             rWrtSh.Push();          //save current cursor
     850           0 :             SwLangHelper::SelectCurrentPara( rWrtSh );
     851           0 :             sw_CharDialog( rWrtSh, bUseDialog, nSlot, pArgs, &rReq );
     852           0 :             rWrtSh.Pop( sal_False );    //restore old cursor
     853             :         }
     854           0 :         break;
     855             :         case SID_ATTR_LRSPACE :
     856             :         case SID_ATTR_ULSPACE :
     857             :         case SID_ATTR_BRUSH :
     858             :         case SID_PARA_VERTALIGN :
     859             :         case SID_ATTR_PARA_NUMRULE :
     860             :         case SID_ATTR_PARA_REGISTER :
     861             :         case SID_ATTR_PARA_PAGENUM :
     862             :         case FN_FORMAT_LINENUMBER :
     863             :         case FN_NUMBER_NEWSTART :
     864             :         case FN_NUMBER_NEWSTART_AT :
     865             :         case FN_FORMAT_DROPCAPS :
     866             :         case FN_DROP_TEXT:
     867             :         case SID_ATTR_PARA_LRSPACE:
     868             :         {
     869           0 :             sal_uInt16 nWhich = GetPool().GetWhich( nSlot );
     870           0 :             if ( pArgs && pArgs->GetItemState( nWhich ) == SFX_ITEM_SET )
     871           0 :                 bUseDialog = false;
     872             :             // intentionally no break
     873             : 
     874             :         }
     875             :         case SID_PARA_DLG:
     876             :         {
     877           0 :             SwPaM* pPaM = NULL;
     878             : 
     879           0 :             if ( pArgs )
     880             :             {
     881           0 :                 const SfxPoolItem* pPaMItem = 0;
     882           0 :                 pArgs->GetItemState( GetPool().GetWhich( FN_PARAM_PAM ), sal_False, &pPaMItem );
     883           0 :                 if ( pPaMItem )
     884           0 :                     pPaM = static_cast< const SwPaMItem* >( pPaMItem )->GetValue( );
     885             :             }
     886             : 
     887           0 :             if ( !pPaM )
     888           0 :                 pPaM = rWrtSh.GetCrsr();
     889             : 
     890           0 :             bool bUseCurCrsr = true;
     891             : 
     892           0 :             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
     893           0 :             SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
     894             : 
     895           0 :             sal_Bool bApplyCharUnit = ::HasCharUnit(0 != PTR_CAST(SwWebView, &GetView()));
     896           0 :             SW_MOD()->PutItem(SfxBoolItem(SID_ATTR_APPLYCHARUNIT, bApplyCharUnit));
     897             : 
     898           0 :             SfxItemSet aCoreSet( GetPool(),
     899             :                             RES_PARATR_BEGIN,           RES_PARATR_END - 1,
     900             :                             RES_PARATR_LIST_BEGIN,      RES_PARATR_LIST_END - 1,
     901             :                             RES_FRMATR_BEGIN,           RES_FRMATR_END - 1,
     902             :                             SID_ATTR_TABSTOP_POS,       SID_ATTR_TABSTOP_POS,
     903             :                             SID_ATTR_TABSTOP_DEFAULTS,  SID_ATTR_TABSTOP_DEFAULTS,
     904             :                             SID_ATTR_TABSTOP_OFFSET,    SID_ATTR_TABSTOP_OFFSET,
     905             :                             SID_ATTR_BORDER_INNER,      SID_ATTR_BORDER_INNER,
     906             :                             SID_ATTR_PARA_MODEL,        SID_ATTR_PARA_KEEP,
     907             :                             SID_ATTR_PARA_PAGENUM,      SID_ATTR_PARA_PAGENUM,
     908             :                             SID_HTML_MODE,              SID_HTML_MODE,
     909             :                             FN_PARAM_1,                 FN_PARAM_1,
     910             :                             FN_NUMBER_NEWSTART,         FN_NUMBER_NEWSTART_AT,
     911             :                             FN_DROP_TEXT,               FN_DROP_CHAR_STYLE_NAME,
     912           0 :                             0);
     913             :             // get also the list level indent values merged as LR-SPACE item, if needed.
     914           0 :             rWrtSh.GetPaMAttr( pPaM, aCoreSet, true );
     915             :             aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE,
     916           0 :                             ::GetHtmlMode(GetView().GetDocShell())));
     917             : 
     918             :             // Tabulators: Put DefaultTabs into ItemSet
     919             :             const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
     920           0 :                             GetPool().GetDefaultItem(RES_PARATR_TABSTOP);
     921             : 
     922           0 :             sal_uInt16 nDefDist = ::GetTabDist( rDefTabs );
     923           0 :             SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist );
     924           0 :             aCoreSet.Put( aDefDistItem );
     925             : 
     926             :             // Current tabulator
     927           0 :             SfxUInt16Item aTabPos( SID_ATTR_TABSTOP_POS, 0 );
     928           0 :             aCoreSet.Put( aTabPos );
     929             : 
     930             :             // Left border as offset
     931             :             //#i24363# tab stops relative to indent
     932           0 :             const long nOff = rWrtSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT) ?
     933           0 :                 ((SvxLRSpaceItem&)aCoreSet.Get( RES_LR_SPACE )).GetTxtLeft() : 0;
     934           0 :             SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
     935           0 :             aCoreSet.Put( aOff );
     936             : 
     937             :             // Setting the BoxInfo if based on the current cursor
     938           0 :             if ( bUseCurCrsr )
     939           0 :                 ::PrepareBoxInfo( aCoreSet, rWrtSh );
     940             : 
     941             :             // Current page format
     942           0 :             ::SwToSfxPageDescAttr( aCoreSet );
     943             : 
     944           0 :             sal_uInt16 nDefPage = 0;
     945           0 :             if( pItem )
     946           0 :                 nDefPage = ((SfxUInt16Item *)pItem)->GetValue();
     947             : 
     948             :             // Properties of numbering
     949           0 :             if( rWrtSh.GetDoc()->GetCurrNumRule( *pPaM->GetPoint() ) )
     950             :             {
     951           0 :                 SfxBoolItem aStart( FN_NUMBER_NEWSTART, rWrtSh.IsNumRuleStart( pPaM ) );
     952           0 :                 aCoreSet.Put(aStart);
     953             :                 SfxUInt16Item aStartAt( FN_NUMBER_NEWSTART_AT,
     954           0 :                                         rWrtSh.GetNodeNumStart( pPaM ) );
     955           0 :                 aCoreSet.Put(aStartAt);
     956             :             }
     957           0 :             SfxAbstractTabDialog* pDlg = NULL;
     958             : 
     959           0 :             if ( bUseDialog && GetActiveView() )
     960             :             {
     961           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     962             :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     963             : 
     964           0 :                 pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet,DLG_STD, DLG_PARA,NULL, sal_False, nDefPage );
     965             :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     966             :             }
     967           0 :             SfxItemSet* pSet = NULL;
     968           0 :             if ( !bUseDialog )
     969             :             {
     970           0 :                 if ( nSlot == SID_ATTR_PARA_LRSPACE)
     971             :         {
     972           0 :             SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)pArgs->Get(nSlot));
     973           0 :             aParaMargin.SetWhich( RES_LR_SPACE);
     974           0 :             aCoreSet.Put(aParaMargin);
     975           0 :             pSet = &aCoreSet;
     976             : 
     977             :         } else
     978           0 :                     pSet = (SfxItemSet*) pArgs;
     979             : 
     980             :             }
     981           0 :             else if ( NULL != pDlg && pDlg->Execute() == RET_OK )
     982             :             {
     983             :                 // Apply defaults if nessecary.
     984           0 :                 pSet = (SfxItemSet*)pDlg->GetOutputItemSet();
     985             :                 sal_uInt16 nNewDist;
     986           0 :                 if( SFX_ITEM_SET == pSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS, sal_False, &pItem ) &&
     987           0 :                     nDefDist != (nNewDist = ((SfxUInt16Item*)pItem)->GetValue()) )
     988             :                 {
     989           0 :                     SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
     990           0 :                     MakeDefTabs( nNewDist, aDefTabs );
     991           0 :                     rWrtSh.SetDefault( aDefTabs );
     992           0 :                     pSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS );
     993             :                 }
     994             : 
     995           0 :                 if ( SFX_ITEM_SET == pSet->GetItemState(FN_PARAM_1,sal_False,&pItem) )
     996             :                 {
     997           0 :                     pSet->Put(SfxStringItem(FN_DROP_TEXT, ((const SfxStringItem*)pItem)->GetValue()));
     998           0 :                     pSet->ClearItem(FN_PARAM_1);
     999             :                 }
    1000             : 
    1001           0 :                 if( SFX_ITEM_SET == pSet->GetItemState( RES_PARATR_DROP, sal_False, &pItem ))
    1002             :                 {
    1003           0 :                     String sCharStyleName;
    1004           0 :                     if(((const SwFmtDrop*)pItem)->GetCharFmt())
    1005           0 :                         sCharStyleName = ((const SwFmtDrop*)pItem)->GetCharFmt()->GetName();
    1006           0 :                     pSet->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME, sCharStyleName));
    1007             :                 }
    1008             :             }
    1009             : 
    1010           0 :             if ( pSet )
    1011             :             {
    1012           0 :                 rReq.Done( *pSet );
    1013           0 :                 ::SfxToSwPageDescAttr( rWrtSh, *pSet );
    1014             :                 // #i56253#
    1015             :                 // enclose all undos.
    1016             :                 // Thus, check conditions, if actions will be performed.
    1017           0 :                 const bool bUndoNeeded( pSet->Count() ||
    1018           0 :                         SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART) ||
    1019           0 :                         SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) );
    1020           0 :                 if ( bUndoNeeded )
    1021             :                 {
    1022           0 :                     rWrtSh.StartUndo( UNDO_INSATTR );
    1023             :                 }
    1024           0 :                 if( pSet->Count() )
    1025             :                 {
    1026           0 :                     rWrtSh.StartAction();
    1027           0 :                     if ( SFX_ITEM_SET == pSet->GetItemState(FN_DROP_TEXT, sal_False, &pItem) )
    1028             :                     {
    1029           0 :                         if ( !((SfxStringItem*)pItem)->GetValue().isEmpty() )
    1030           0 :                             rWrtSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue(), pPaM);
    1031             :                     }
    1032           0 :                     rWrtSh.SetAttr( *pSet, 0, pPaM );
    1033           0 :                     rWrtSh.EndAction();
    1034           0 :                     SwTxtFmtColl* pColl = rWrtSh.GetPaMTxtFmtColl( pPaM );
    1035           0 :                     if(pColl && pColl->IsAutoUpdateFmt())
    1036             :                     {
    1037           0 :                         rWrtSh.AutoUpdatePara(pColl, *pSet, pPaM);
    1038             :                     }
    1039             :                 }
    1040             : 
    1041           0 :                 if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART) )
    1042             :                 {
    1043             :                     //SetNumRuleStart(sal_True) restarts the numbering at the value
    1044             :                     //that is defined at the starting point of the numbering level
    1045             :                     //otherwise the SetNodeNumStart() value determines the start
    1046             :                     //if it's set to something different than (sal_uInt16)0xFFFF
    1047             : 
    1048           0 :                     sal_Bool bStart = ((SfxBoolItem&)pSet->Get(FN_NUMBER_NEWSTART)).GetValue();
    1049             : 
    1050             :                     // Default value for restart value has to be (sal_uInt16)0xFFFF
    1051             :                     // in order to indicate that the restart value of the list
    1052             :                     // style has to be used on restart.
    1053           0 :                     sal_uInt16 nNumStart = (sal_uInt16)0xFFFF;
    1054           0 :                     if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
    1055             :                     {
    1056           0 :                         nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
    1057             :                     }
    1058           0 :                     rWrtSh.SetNumRuleStart(bStart, pPaM);
    1059           0 :                     rWrtSh.SetNodeNumStart(nNumStart);
    1060             :                 }
    1061           0 :                 else if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
    1062             :                 {
    1063           0 :                     sal_uInt16 nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
    1064           0 :                     rWrtSh.SetNodeNumStart(nNumStart);
    1065           0 :                     rWrtSh.SetNumRuleStart(sal_False, pPaM);
    1066             :                 }
    1067             :                 // #i56253#
    1068           0 :                 if ( bUndoNeeded )
    1069             :                 {
    1070           0 :                     rWrtSh.EndUndo( UNDO_INSATTR );
    1071             :                 }
    1072             :             }
    1073             : 
    1074           0 :             delete pDlg;
    1075             :         }
    1076           0 :         break;
    1077             :         case FN_NUM_CONTINUE:
    1078             :         {
    1079           0 :             String sContinuedListId;
    1080             :             const SwNumRule* pRule =
    1081           0 :                 rWrtSh.SearchNumRule( false, true, false, -1, sContinuedListId );
    1082             :             // #i86492#
    1083             :             // Search also for bullet list
    1084           0 :             if ( !pRule )
    1085             :             {
    1086           0 :                 pRule = rWrtSh.SearchNumRule( false, false, false, -1, sContinuedListId );
    1087             :             }
    1088           0 :             if ( pRule )
    1089             :             {
    1090           0 :                 rWrtSh.SetCurNumRule( *pRule, false, sContinuedListId );
    1091           0 :             }
    1092             :         }
    1093           0 :         break;
    1094             :         case FN_SELECT_PARA:
    1095             :         {
    1096           0 :             if(!rWrtSh.IsSttOfPara())
    1097           0 :                 rWrtSh.SttPara(sal_False);
    1098             :             else
    1099           0 :                 rWrtSh.EnterStdMode();
    1100           0 :             rWrtSh.EndPara(sal_True);
    1101             :         }
    1102           0 :         break;
    1103             : 
    1104             :         case SID_DEC_INDENT:
    1105             :         case SID_INC_INDENT:
    1106             :             rWrtSh.MoveLeftMargin( SID_INC_INDENT == nSlot,
    1107           0 :                                     rReq.GetModifier() != KEY_MOD1 );
    1108           0 :             rReq.Done();
    1109           0 :             break;
    1110             :         case FN_DEC_INDENT_OFFSET:
    1111             :         case FN_INC_INDENT_OFFSET:
    1112             :             rWrtSh.MoveLeftMargin( FN_INC_INDENT_OFFSET == nSlot,
    1113           0 :                                     rReq.GetModifier() == KEY_MOD1 );
    1114           0 :             rReq.Done();
    1115           0 :             break;
    1116             : 
    1117             :         case SID_ATTR_CHAR_COLOR2:
    1118             :         {
    1119           0 :             if(pItem)
    1120             :             {
    1121           0 :                 Color aSet = ((const SvxColorItem*)pItem)->GetValue();
    1122           0 :                 SwEditWin& rEditWin = GetView().GetEditWin();
    1123           0 :                 rEditWin.SetTextColor(aSet);
    1124           0 :                 SwApplyTemplate* pApply = rEditWin.GetApplyTemplate();
    1125             : 
    1126             :                 // If there is a selection, then set the color on it
    1127             :                 // otherwise, it'll be the color for the next text to be typed
    1128           0 :                 if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_EXT)
    1129             :                 {
    1130           0 :                     rWrtSh.SetAttr(SvxColorItem (aSet, RES_CHRATR_COLOR));
    1131             :                 }
    1132             : 
    1133           0 :                 rReq.Done();
    1134             :             }
    1135             :         }
    1136           0 :         break;
    1137             :         case SID_ATTR_CHAR_COLOR_BACKGROUND:
    1138             :         {
    1139           0 :             SwEditWin& rEdtWin = GetView().GetEditWin();
    1140           0 :             SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
    1141           0 :             rEdtWin.SetTextBackColorTransparent(0 == pItem);
    1142           0 :             Color aSet;
    1143           0 :             if(pItem)
    1144             :             {
    1145           0 :                 aSet = ((const SvxColorItem*)pItem)->GetValue();
    1146           0 :                 rEdtWin.SetTextBackColor(aSet); //select last color
    1147             :             }
    1148             :             else
    1149           0 :                 rEdtWin.SetTextBackColor(Color(COL_TRANSPARENT)); //if last was "no fill"
    1150           0 :             if(!pApply && (rWrtSh.HasSelection() || rReq.IsAPI()))
    1151             :             {
    1152           0 :                 SvxBrushItem aBrushItem(RES_CHRATR_BACKGROUND);
    1153           0 :                 if(pItem)
    1154           0 :                     aBrushItem.SetColor(aSet); //set the selected color
    1155             :                 else
    1156           0 :                     aBrushItem.SetColor(Color(COL_TRANSPARENT));//set "no fill" color
    1157           0 :                 rWrtSh.SetAttr( aBrushItem );
    1158             :             }
    1159           0 :             else if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_BACKGROUND_EXT)
    1160             :             {
    1161           0 :                 GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_BACKGROUND_EXT);
    1162             :             }
    1163             : 
    1164           0 :             rReq.Done();
    1165             : 
    1166             :         }
    1167           0 :         break;
    1168             :         case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
    1169             :         case SID_ATTR_CHAR_COLOR_EXT:
    1170             :         {
    1171           0 :             SwEditWin& rEdtWin = GetView().GetEditWin();
    1172           0 :             SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
    1173           0 :             SwApplyTemplate aTempl;
    1174           0 :             sal_Bool bSelection = rWrtSh.HasSelection();
    1175           0 :             if(bSelection)
    1176             :             {
    1177             : 
    1178           0 :                 if(nSlot == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT)
    1179             :                 {
    1180             :                     rWrtSh.SetAttr( SvxBrushItem(
    1181           0 :                         rEdtWin.GetTextBackColor(), RES_CHRATR_BACKGROUND) );
    1182             :                 }
    1183             :                 else
    1184             :                     rWrtSh.SetAttr( SvxColorItem( rEdtWin.GetTextColor(),
    1185           0 :                                                                 RES_CHRATR_COLOR) );
    1186             :             }
    1187             :             else
    1188             :             {
    1189           0 :                 if(!pApply || pApply->nColor != nSlot)
    1190           0 :                     aTempl.nColor = nSlot;
    1191           0 :                 rEdtWin.SetApplyTemplate(aTempl);
    1192             :             }
    1193             : 
    1194           0 :             rReq.Done();
    1195             :         }
    1196           0 :         break;
    1197             : 
    1198             :         case FN_NUM_BULLET_MOVEDOWN:
    1199           0 :             if (!rWrtSh.IsAddMode())
    1200           0 :                 rWrtSh.MoveParagraph(1);
    1201           0 :             rReq.Done();
    1202           0 :             break;
    1203             : 
    1204             :         case FN_NUM_BULLET_MOVEUP:
    1205           0 :             if (!rWrtSh.IsAddMode())
    1206           0 :                 rWrtSh.MoveParagraph(-1);
    1207           0 :             rReq.Done();
    1208           0 :             break;
    1209             :         case SID_RUBY_DIALOG:
    1210             :         case SID_HYPERLINK_DIALOG:
    1211             :         {
    1212           0 :             SfxRequest aReq(nSlot, SFX_CALLMODE_SLOT, SFX_APP()->GetPool());
    1213           0 :             GetView().GetViewFrame()->ExecuteSlot( aReq);
    1214           0 :             rReq.Ignore();
    1215             :         }
    1216           0 :         break;
    1217             :     case FN_INSERT_PAGEHEADER:
    1218             :     case FN_INSERT_PAGEFOOTER:
    1219           0 :     if(pArgs && pArgs->Count())
    1220             :     {
    1221           0 :         String sStyleName;
    1222           0 :         if(pItem)
    1223           0 :             sStyleName = ((const SfxStringItem*)pItem)->GetValue();
    1224           0 :         sal_Bool bOn = sal_True;
    1225           0 :         if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem))
    1226           0 :             bOn = ((const SfxBoolItem*)pItem)->GetValue();
    1227           0 :         rWrtSh.ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !rReq.IsAPI());
    1228           0 :         rReq.Done();
    1229             :     }
    1230           0 :     break;
    1231             :     case FN_READONLY_SELECTION_MODE :
    1232           0 :         if(GetView().GetDocShell()->IsReadOnly())
    1233             :         {
    1234             :             rWrtSh.SetReadonlySelectionOption(
    1235           0 :                 !rWrtSh.GetViewOptions()->IsSelectionInReadonly());
    1236           0 :             rWrtSh.ShowCrsr();
    1237             :         }
    1238           0 :     break;
    1239             :     case FN_SELECTION_MODE_DEFAULT:
    1240             :     case FN_SELECTION_MODE_BLOCK :
    1241             :     {
    1242           0 :         bool bSetBlockMode = !rWrtSh.IsBlockMode();
    1243           0 :         if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem))
    1244           0 :             bSetBlockMode = ((const SfxBoolItem*)pItem)->GetValue();
    1245           0 :         if( ( nSlot == FN_SELECTION_MODE_DEFAULT ) ^ bSetBlockMode )
    1246           0 :             rWrtSh.EnterBlockMode();
    1247             :         else
    1248           0 :             rWrtSh.EnterStdMode();
    1249           0 :         SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
    1250           0 :         rBnd.Invalidate(FN_STAT_SELMODE);
    1251           0 :         rBnd.Update(FN_STAT_SELMODE);
    1252             :     }
    1253           0 :     break;
    1254             :     case SID_OPEN_HYPERLINK:
    1255             :     case FN_COPY_HYPERLINK_LOCATION:
    1256             :     {
    1257           0 :         SfxItemSet aSet(GetPool(),
    1258             :                         RES_TXTATR_INETFMT,
    1259           0 :                         RES_TXTATR_INETFMT);
    1260           0 :         rWrtSh.GetCurAttr(aSet);
    1261           0 :         if(SFX_ITEM_SET <= aSet.GetItemState( RES_TXTATR_INETFMT, sal_True ))
    1262             :         {
    1263           0 :             const SwFmtINetFmt& rINetFmt = dynamic_cast<const SwFmtINetFmt&>( aSet.Get(RES_TXTATR_INETFMT, sal_True) );
    1264           0 :             if( nSlot == FN_COPY_HYPERLINK_LOCATION )
    1265             :             {
    1266           0 :                 ::uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetView().GetEditWin().GetClipboard();
    1267             :                 vcl::unohelper::TextDataObject::CopyStringTo(
    1268           0 :                         rINetFmt.GetValue(),
    1269           0 :                         xClipboard );
    1270             :             }
    1271             :             else
    1272           0 :                 rWrtSh.ClickToINetAttr(rINetFmt, URLLOAD_NOFILTER);
    1273           0 :         }
    1274             :     }
    1275           0 :     break;
    1276             :     case SID_OPEN_XML_FILTERSETTINGS:
    1277             :     {
    1278             :         try
    1279             :         {
    1280           0 :             uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
    1281           0 :             xDialog->execute();
    1282             :         }
    1283           0 :         catch (const uno::Exception&)
    1284             :         {
    1285             :             DBG_UNHANDLED_EXCEPTION();
    1286             :         }
    1287           0 :         rReq.Ignore ();
    1288             :     }
    1289           0 :     break;
    1290             :     case FN_FORMAT_APPLY_HEAD1:
    1291             :     {
    1292             :     }
    1293           0 :     break;
    1294             :     case FN_FORMAT_APPLY_HEAD2:
    1295             :     {
    1296             :     }
    1297           0 :     break;
    1298             :     case FN_FORMAT_APPLY_HEAD3:
    1299             :     {
    1300             :     }
    1301           0 :     break;
    1302             :     case FN_FORMAT_APPLY_DEFAULT:
    1303             :     {
    1304             :     }
    1305           0 :     break;
    1306             :     case FN_FORMAT_APPLY_TEXTBODY:
    1307             :     {
    1308             :     }
    1309           0 :     break;
    1310             :     case FN_WORDCOUNT_DIALOG:
    1311             :     {
    1312           0 :         SfxViewFrame* pVFrame = GetView().GetViewFrame();
    1313           0 :         if (pVFrame != NULL)
    1314             :         {
    1315           0 :             pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
    1316           0 :             Invalidate(rReq.GetSlot());
    1317             : 
    1318           0 :             SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
    1319           0 :             if (pWrdCnt)
    1320           0 :                 pWrdCnt->UpdateCounts();
    1321             :         }
    1322             :     }
    1323           0 :     break;
    1324             :     default:
    1325             :         OSL_ENSURE(!this, "wrong dispatcher");
    1326           0 :         return;
    1327             :     }
    1328             : }
    1329             : 
    1330        4327 : void SwTextShell::GetState( SfxItemSet &rSet )
    1331             : {
    1332        4327 :     SwWrtShell &rSh = GetShell();
    1333        4327 :     SfxWhichIter aIter( rSet );
    1334        4327 :     sal_uInt16 nWhich = aIter.FirstWhich();
    1335       15616 :     while ( nWhich )
    1336             :     {
    1337        6962 :         switch ( nWhich )
    1338             :         {
    1339             :         case SID_LANGUAGE_STATUS:
    1340             :             {
    1341             :                 // the value of used script types
    1342         264 :                 String aScriptTypesInUse( OUString::number( rSh.GetScriptType() ) );
    1343             : 
    1344         528 :                 SvtLanguageTable aLangTable;
    1345             : 
    1346             :                 // get keyboard language
    1347         528 :                 String aKeyboardLang;
    1348         264 :                 SwEditWin& rEditWin = GetView().GetEditWin();
    1349         264 :                 LanguageType nLang = rEditWin.GetInputLanguage();
    1350         264 :                 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
    1351           0 :                     aKeyboardLang = aLangTable.GetString( nLang );
    1352             : 
    1353             :                 // get the language that is in use
    1354         528 :                 String aCurrentLang = OUString("*");
    1355         264 :                 nLang = SwLangHelper::GetCurrentLanguage( rSh );
    1356         264 :                 if (nLang != LANGUAGE_DONTKNOW)
    1357         264 :                     aCurrentLang = aLangTable.GetString( nLang );
    1358             : 
    1359             :                 // build sequence for status value
    1360         528 :                 uno::Sequence< OUString > aSeq( 4 );
    1361         264 :                 aSeq[0] = aCurrentLang;
    1362         264 :                 aSeq[1] = aScriptTypesInUse;
    1363         264 :                 aSeq[2] = aKeyboardLang;
    1364         264 :                 aSeq[3] = SwLangHelper::GetTextForLanguageGuessing( rSh );
    1365             : 
    1366             :                 // set sequence as status value
    1367         528 :                 SfxStringListItem aItem( SID_LANGUAGE_STATUS );
    1368         264 :                 aItem.SetStringList( aSeq );
    1369         528 :                 rSet.Put( aItem, SID_LANGUAGE_STATUS );
    1370             :             }
    1371         264 :         break;
    1372             : 
    1373             :         case SID_THES:
    1374             :         {
    1375             :             // is there a valid selection to get text from?
    1376           0 :             String aText;
    1377           0 :             bool bValid = !rSh.HasSelection() ||
    1378           0 :                     (rSh.IsSelOnePara() && !rSh.IsMultiSelection());
    1379             :             // prevent context menu from showing when cursor is not in or at the end of a word
    1380             :             // (GetCurWord will return the next word if there is none at the current position...)
    1381           0 :             const sal_Int16 nWordType = ::i18n::WordType::DICTIONARY_WORD;
    1382           0 :             bool bWord = rSh.IsInWord( nWordType ) || rSh.IsStartWord( nWordType ) || rSh.IsEndWord( nWordType );
    1383           0 :             if (bValid && bWord)
    1384           0 :                aText = rSh.HasSelection()? rSh.GetSelTxt() : rSh.GetCurWord();
    1385             : 
    1386           0 :             LanguageType nLang = rSh.GetCurLang();
    1387           0 :             LanguageTag aLanguageTag( nLang);
    1388           0 :             lang::Locale aLocale( aLanguageTag.getLocale());
    1389           0 :             String aLangText( aLanguageTag.getBcp47() );
    1390             : 
    1391             :             // set word and locale to look up as status value
    1392           0 :             String aStatusVal( aText );
    1393           0 :             aStatusVal.AppendAscii( "#" );
    1394           0 :             aStatusVal += aLangText;
    1395             : 
    1396           0 :             rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
    1397             : 
    1398             :             // disable "Thesaurus" context menu entry if there is nothing to look up
    1399           0 :             uno::Reference< linguistic2::XThesaurus >  xThes( ::GetThesaurus() );
    1400           0 :             if (aText.Len() == 0 ||
    1401           0 :                 !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale ))
    1402           0 :                 rSet.DisableItem( SID_THES );
    1403             :         }
    1404           0 :         break;
    1405             : 
    1406             :         case FN_NUMBER_NEWSTART :
    1407           0 :             if(!rSh.GetCurNumRule())
    1408           0 :                     rSet.DisableItem(nWhich);
    1409             :             else
    1410             :                 rSet.Put(SfxBoolItem(FN_NUMBER_NEWSTART,
    1411           0 :                     rSh.IsNumRuleStart()));
    1412           0 :         break;
    1413             :         case FN_EDIT_FORMULA:
    1414             :         case SID_CHARMAP:
    1415             :             {
    1416           1 :                 const int nType = rSh.GetSelectionType();
    1417           1 :                 if (!(nType & nsSelectionType::SEL_TXT) &&
    1418           0 :                     !(nType & nsSelectionType::SEL_TBL) &&
    1419           0 :                     !(nType & nsSelectionType::SEL_NUM))
    1420           0 :                     rSet.DisableItem(nWhich);
    1421             :             }
    1422           1 :             break;
    1423             : 
    1424             :         case FN_INSERT_ENDNOTE:
    1425             :         case FN_INSERT_FOOTNOTE:
    1426             :         case FN_INSERT_FOOTNOTE_DLG:
    1427             :             {
    1428             :                 const sal_uInt16 nNoType = FRMTYPE_FLY_ANY | FRMTYPE_HEADER |
    1429           0 :                                         FRMTYPE_FOOTER  | FRMTYPE_FOOTNOTE;
    1430           0 :                 if ( (rSh.GetFrmType(0,sal_True) & nNoType) )
    1431           0 :                     rSet.DisableItem(nWhich);
    1432             :             }
    1433           0 :             break;
    1434             :         case FN_INSERT_TABLE:
    1435        1252 :             if ( rSh.GetTableFmt() ||
    1436         626 :                     (rSh.GetFrmType(0,sal_True) & FRMTYPE_FOOTNOTE) )
    1437           0 :                 rSet.DisableItem( nWhich );
    1438         626 :             break;
    1439             : 
    1440             :         case FN_CALCULATE:
    1441           0 :             if ( !rSh.IsSelection() )
    1442           0 :                 rSet.DisableItem(nWhich);
    1443           0 :             break;
    1444             :         case FN_GOTO_REFERENCE:
    1445             :             {
    1446           0 :                 SwField *pFld = rSh.GetCurFld();
    1447           0 :                 if ( !pFld || (pFld &&  pFld->GetTypeId() != TYP_GETREFFLD) )
    1448           0 :                     rSet.DisableItem(nWhich);
    1449             :             }
    1450           0 :             break;
    1451             :         case FN_AUTOFORMAT_AUTO:
    1452             :             {
    1453           0 :                 rSet.Put( SfxBoolItem( nWhich, SvxAutoCorrCfg::Get().IsAutoFmtByInput() ));
    1454             :             }
    1455           0 :             break;
    1456             : 
    1457             :         case SID_DEC_INDENT:
    1458             :         case SID_INC_INDENT:
    1459             :             {
    1460        1260 :                 sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
    1461        1260 :                 nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES;
    1462        2520 :                 if( (nHtmlMode == HTMLMODE_ON) || !rSh.IsMoveLeftMargin(
    1463        1260 :                                         SID_INC_INDENT == nWhich, true ))
    1464           5 :                     rSet.DisableItem( nWhich );
    1465             :             }
    1466        1260 :             break;
    1467             : 
    1468             :         case FN_DEC_INDENT_OFFSET:
    1469             :         case FN_INC_INDENT_OFFSET:
    1470             :             {
    1471           0 :                 sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
    1472           0 :                 nHtmlMode &= HTMLMODE_ON|HTMLMODE_SOME_STYLES;
    1473           0 :                 if( (nHtmlMode == HTMLMODE_ON) ||
    1474             :                     !rSh.IsMoveLeftMargin( FN_INC_INDENT_OFFSET == nWhich,
    1475           0 :                                             false ))
    1476           0 :                     rSet.DisableItem( nWhich );
    1477             :             }
    1478           0 :             break;
    1479             : 
    1480             :         case SID_ATTR_CHAR_COLOR2:
    1481             :             {
    1482         630 :                 rSet.Put(SvxColorItem(GetView().GetEditWin().GetTextColor(), SID_ATTR_CHAR_COLOR2));
    1483             :             }
    1484         630 :             break;
    1485             :         case SID_ATTR_CHAR_COLOR_BACKGROUND:
    1486             :             {
    1487         630 :               if(GetView().GetEditWin().IsTextBackColorTransparent())
    1488           0 :                   rSet.Put(SvxColorItem(Color(COL_TRANSPARENT), SID_ATTR_CHAR_COLOR_BACKGROUND));
    1489             :               else
    1490         630 :                     rSet.Put(SvxColorItem(GetView().GetEditWin().GetTextBackColor(), SID_ATTR_CHAR_COLOR_BACKGROUND));
    1491             :             }
    1492         630 :             break;
    1493             :         case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
    1494             :         case SID_ATTR_CHAR_COLOR_EXT:
    1495             :             {
    1496        1629 :                 SwEditWin& rEdtWin = GetView().GetEditWin();
    1497        1629 :                 SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
    1498        1629 :                 rSet.Put(SfxBoolItem(nWhich, pApply && pApply->nColor == nWhich));
    1499             :             }
    1500        1629 :             break;
    1501             :         case FN_INSERT_BOOKMARK:
    1502           2 :             if( rSh.IsTableMode() )
    1503           0 :                 rSet.DisableItem( nWhich );
    1504           2 :             break;
    1505             : 
    1506             :         case FN_INSERT_PAGEHEADER:
    1507             :         case FN_INSERT_PAGEFOOTER:
    1508             :             {
    1509           0 :                 rSet.Put( SfxObjectShellItem( nWhich, GetView().GetDocShell() ));
    1510             :             }
    1511           0 :             break;
    1512             :             case FN_TABLE_SORT_DIALOG:
    1513             :             case FN_SORTING_DLG:
    1514           7 :                 if(!rSh.HasSelection() ||
    1515           5 :                         (FN_TABLE_SORT_DIALOG == nWhich && !rSh.GetTableFmt()))
    1516           1 :                     rSet.DisableItem( nWhich );
    1517           6 :             break;
    1518             :             case SID_RUBY_DIALOG:
    1519             :             {
    1520           0 :                 SvtCJKOptions aCJKOptions;
    1521           0 :                 if(!aCJKOptions.IsRubyEnabled())
    1522             :                 {
    1523           0 :                     GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
    1524           0 :                     rSet.DisableItem(nWhich);
    1525             :                 }
    1526             :                 else
    1527           0 :                     GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
    1528           0 :                 break;
    1529             :             }
    1530             :             //no break!
    1531             :             case SID_HYPERLINK_DIALOG:
    1532        1266 :                 if( GetView().GetDocShell()->IsReadOnly() ||
    1533        1260 :                     (!GetView().GetViewFrame()->HasChildWindow(nWhich) &&
    1534         630 :                      rSh.HasReadonlySel()) )
    1535           3 :                     rSet.DisableItem(nWhich);
    1536             :                 else
    1537         630 :                     rSet.Put(SfxBoolItem( nWhich, 0 != GetView().
    1538        1260 :                                 GetViewFrame()->GetChildWindow( nWhich ) ));
    1539         633 :                 break;
    1540             :             case FN_EDIT_HYPERLINK:
    1541             :             case FN_COPY_HYPERLINK_LOCATION:
    1542             :             {
    1543           7 :                 SfxItemSet aSet(GetPool(),
    1544             :                                 RES_TXTATR_INETFMT,
    1545           7 :                                 RES_TXTATR_INETFMT);
    1546           7 :                 rSh.GetCurAttr(aSet);
    1547           7 :                 if(SFX_ITEM_SET > aSet.GetItemState( RES_TXTATR_INETFMT, sal_True ) || rSh.HasReadonlySel())
    1548             :                 {
    1549           7 :                     rSet.DisableItem(nWhich);
    1550           7 :                 }
    1551             :             }
    1552           7 :             break;
    1553             :             case FN_REMOVE_HYPERLINK:
    1554             :             {
    1555           0 :                 SfxItemSet aSet(GetPool(),
    1556             :                                 RES_TXTATR_INETFMT,
    1557           0 :                                 RES_TXTATR_INETFMT);
    1558           0 :                 rSh.GetCurAttr(aSet);
    1559             : 
    1560             :         // If a hyperlink is selected, either alone or along with other text...
    1561           0 :                 if( ((SFX_ITEM_DONTCARE & aSet.GetItemState( RES_TXTATR_INETFMT, sal_True )) == 0) || rSh.HasReadonlySel())
    1562             :                 {
    1563           0 :                     rSet.DisableItem(nWhich);
    1564           0 :                 }
    1565             :             }
    1566           0 :             break;
    1567             :             case SID_TRANSLITERATE_HALFWIDTH:
    1568             :             case SID_TRANSLITERATE_FULLWIDTH:
    1569             :             case SID_TRANSLITERATE_HIRAGANA:
    1570             :             case SID_TRANSLITERATE_KATAGANA:
    1571             :             {
    1572           0 :                 SvtCJKOptions aCJKOptions;
    1573           0 :                 if(!aCJKOptions.IsChangeCaseMapEnabled())
    1574             :                 {
    1575           0 :                     GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
    1576           0 :                     rSet.DisableItem(nWhich);
    1577             :                 }
    1578             :                 else
    1579           0 :                     GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
    1580             :             }
    1581           0 :             break;
    1582             :             case FN_READONLY_SELECTION_MODE :
    1583           7 :                 if(!GetView().GetDocShell()->IsReadOnly())
    1584           7 :                     rSet.DisableItem( nWhich );
    1585             :                 else
    1586             :                 {
    1587           0 :                     rSet.Put(SfxBoolItem(nWhich, rSh.GetViewOptions()->IsSelectionInReadonly()));
    1588             :                 }
    1589           7 :             break;
    1590             :             case FN_SELECTION_MODE_DEFAULT:
    1591             :             case FN_SELECTION_MODE_BLOCK :
    1592           0 :                     rSet.Put(SfxBoolItem(nWhich, (nWhich == FN_SELECTION_MODE_DEFAULT) != rSh.IsBlockMode()));
    1593           0 :             break;
    1594             :             case  SID_OPEN_HYPERLINK:
    1595             :             {
    1596           0 :                 SfxItemSet aSet(GetPool(),
    1597             :                                 RES_TXTATR_INETFMT,
    1598           0 :                                 RES_TXTATR_INETFMT);
    1599           0 :                 rSh.GetCurAttr(aSet);
    1600           0 :                 if(SFX_ITEM_SET > aSet.GetItemState( RES_TXTATR_INETFMT, sal_False ))
    1601           0 :                     rSet.DisableItem(nWhich);
    1602             :             }
    1603           0 :             break;
    1604             :             case  SID_OPEN_SMARTTAGMENU:
    1605             :             {
    1606           0 :                  uno::Sequence< OUString > aSmartTagTypes;
    1607           0 :                  uno::Sequence< uno::Reference< container::XStringKeyMap > > aStringKeyMaps;
    1608           0 :                  uno::Reference<text::XTextRange> xRange;
    1609             : 
    1610           0 :                  rSh.GetSmartTagTerm( aSmartTagTypes, aStringKeyMaps, xRange );
    1611             : 
    1612           0 :                  if ( xRange.is() && aSmartTagTypes.getLength() )
    1613             :                  {
    1614           0 :                      uno::Sequence < uno::Sequence< uno::Reference< smarttags::XSmartTagAction > > > aActionComponentsSequence;
    1615           0 :                      uno::Sequence < uno::Sequence< sal_Int32 > > aActionIndicesSequence;
    1616             : 
    1617           0 :                      const SmartTagMgr& rSmartTagMgr = SwSmartTagMgr::Get();
    1618             :                      rSmartTagMgr.GetActionSequences( aSmartTagTypes,
    1619             :                                                       aActionComponentsSequence,
    1620           0 :                                                       aActionIndicesSequence );
    1621             : 
    1622           0 :                      uno::Reference <frame::XController> xController = GetView().GetController();
    1623           0 :                      const lang::Locale aLocale( SW_BREAKITER()->GetLocale( GetAppLanguageTag() ) );
    1624           0 :                      const OUString aApplicationName( rSmartTagMgr.GetApplicationName() );
    1625           0 :                      const OUString aRangeText = xRange->getString();
    1626             : 
    1627             :                      const SvxSmartTagItem aItem( nWhich,
    1628             :                                                   aActionComponentsSequence,
    1629             :                                                   aActionIndicesSequence,
    1630             :                                                   aStringKeyMaps,
    1631             :                                                   xRange,
    1632             :                                                   xController,
    1633             :                                                   aLocale,
    1634             :                                                   aApplicationName,
    1635           0 :                                                   aRangeText );
    1636             : 
    1637           0 :                      rSet.Put( aItem );
    1638             :                  }
    1639             :                  else
    1640           0 :                      rSet.DisableItem(nWhich);
    1641             :             }
    1642           0 :             break;
    1643             :             case FN_NUM_NUMBERING_ON:
    1644         630 :                 rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON,rSh.SelectionHasNumber()));
    1645         630 :             break;
    1646             :             case FN_NUM_BULLET_ON:
    1647         630 :                 rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON,rSh.SelectionHasBullet()));
    1648         630 :             break;
    1649             :             case FN_BUL_NUM_RULE_INDEX:
    1650             :             case FN_NUM_NUM_RULE_INDEX:
    1651             :         {
    1652           0 :             SwNumRule* pCurRule = (SwNumRule*)(GetShell().GetCurNumRule());
    1653           0 :             sal_uInt16  nActNumLvl = (sal_uInt16)0xFFFF;
    1654           0 :             rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,DEFAULT_NONE));
    1655           0 :             rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,DEFAULT_NONE));
    1656           0 :             if( pCurRule )
    1657             :             {
    1658           0 :                 nActNumLvl = GetShell().GetNumLevel();
    1659           0 :                 if( nActNumLvl < MAXLEVEL )
    1660             :                 {
    1661           0 :                     nActNumLvl = 1<<nActNumLvl;
    1662             :                 }
    1663           0 :                 SvxNumRule aSvxRule = pCurRule->MakeSvxNumRule();
    1664           0 :                 if ( GetShell().HasBullet())
    1665             :                 {
    1666           0 :                     rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
    1667           0 :                     rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
    1668           0 :                     NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
    1669           0 :                     if ( pBullets )
    1670             :                     {
    1671           0 :                         sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(aSvxRule,nActNumLvl);
    1672           0 :                         rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,nBulIndex));
    1673             :                     }
    1674           0 :                 }else if ( GetShell().HasNumber() )
    1675             :                 {
    1676           0 :                     rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
    1677           0 :                     rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
    1678           0 :                     NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
    1679           0 :                     if ( pNumbering )
    1680             :                     {
    1681           0 :                         sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(aSvxRule,nActNumLvl);
    1682           0 :                         rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,nBulIndex));
    1683             :                     }
    1684           0 :                 }
    1685             :             }
    1686             :         }
    1687           0 :             break;
    1688             :             case FN_NUM_CONTINUE:
    1689             :             {
    1690             :                 {
    1691             :                     // #i86492#
    1692             :                     // Search also for bullet list
    1693           0 :                     String aDummy;
    1694             :                     const SwNumRule* pRule =
    1695           0 :                             rSh.SearchNumRule( false, true, false, -1, aDummy );
    1696           0 :                     if ( !pRule )
    1697             :                     {
    1698           0 :                         pRule = rSh.SearchNumRule( false, false, false, -1, aDummy );
    1699             :                     }
    1700           0 :                     if ( !pRule )
    1701           0 :                         rSet.DisableItem(nWhich);
    1702             :                 }
    1703             :             }
    1704           0 :             break;
    1705             :             case SID_INSERT_RLM :
    1706             :             case SID_INSERT_LRM :
    1707             :             case SID_INSERT_ZWNBSP :
    1708             :             case SID_INSERT_ZWSP:
    1709             :             {
    1710           0 :                 SvtCTLOptions aCTLOptions;
    1711           0 :                 sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled();
    1712           0 :                 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled );
    1713           0 :                 if(!bEnabled)
    1714           0 :                     rSet.DisableItem(nWhich);
    1715             :             }
    1716           0 :             break;
    1717             :         }
    1718        6962 :         nWhich = aIter.NextWhich();
    1719        4327 :     }
    1720        4426 : }
    1721             : 
    1722             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10