LCOV - code coverage report
Current view: top level - sw/source/core/uibase/shells - textsh.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 31 592 5.2 %
Date: 2014-04-11 Functions: 13 21 61.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <hintids.hxx>
      21             : #include <comphelper/string.hxx>
      22             : #include <svl/globalnameitem.hxx>
      23             : #include <svl/ownlist.hxx>
      24             : #include <sfx2/frmdescr.hxx>
      25             : #include <sfx2/objface.hxx>
      26             : #include <sfx2/lnkbase.hxx>
      27             : 
      28             : #include <tools/errinf.hxx>
      29             : #include <svx/svdview.hxx>
      30             : #include <svl/ptitem.hxx>
      31             : #include <svl/stritem.hxx>
      32             : #include <unotools/moduleoptions.hxx>
      33             : #include <vcl/msgbox.hxx>
      34             : #include <sfx2/fcontnr.hxx>
      35             : #include <svx/hlnkitem.hxx>
      36             : #include <svl/srchitem.hxx>
      37             : #include <sfx2/dispatch.hxx>
      38             : #include <sfx2/docfile.hxx>
      39             : #include <svl/urihelper.hxx>
      40             : #include <basic/sbxvar.hxx>
      41             : #include <svl/whiter.hxx>
      42             : #include <sfx2/request.hxx>
      43             : #include <editeng/opaqitem.hxx>
      44             : #include <editeng/fontitem.hxx>
      45             : #include <editeng/adjustitem.hxx>
      46             : #include <editeng/boxitem.hxx>
      47             : #include <editeng/sizeitem.hxx>
      48             : #include <editeng/svxacorr.hxx>
      49             : #include <editeng/scripttypeitem.hxx>
      50             : #include <vcl/graphicfilter.hxx>
      51             : #include <sfx2/htmlmode.hxx>
      52             : #include <svx/pfiledlg.hxx>
      53             : #include <svtools/htmlcfg.hxx>
      54             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      55             : #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
      56             : #include <com/sun/star/embed/Aspects.hpp>
      57             : 
      58             : #include <comphelper/classids.hxx>
      59             : #include <editeng/acorrcfg.hxx>
      60             : #include <wdocsh.hxx>
      61             : #include <fmtinfmt.hxx>
      62             : #include <fmtclds.hxx>
      63             : #include <fmtsrnd.hxx>
      64             : #include <fmtfsize.hxx>
      65             : #include <swmodule.hxx>
      66             : #include <wrtsh.hxx>
      67             : #include <view.hxx>
      68             : #include <docsh.hxx>
      69             : #include <doc.hxx>
      70             : #include <uitool.hxx>
      71             : #include <cmdid.h>
      72             : #include <globals.hrc>
      73             : #include <frmmgr.hxx>
      74             : #include <textsh.hxx>
      75             : #include <frmfmt.hxx>
      76             : #include <tablemgr.hxx>
      77             : #include <swundo.hxx>
      78             : #include <shellio.hxx>
      79             : #include <frmdlg.hxx>
      80             : #include <usrpref.hxx>
      81             : #include <swtable.hxx>
      82             : #include <tblafmt.hxx>
      83             : #include <caption.hxx>
      84             : #include <idxmrk.hxx>
      85             : #include <poolfmt.hxx>
      86             : #include <breakit.hxx>
      87             : #include <crsskip.hxx>
      88             : #include <modcfg.hxx>
      89             : #include <column.hxx>
      90             : #include <edtwin.hxx>
      91             : #include <shells.hrc>
      92             : #include <popup.hrc>
      93             : #include <swerror.h>
      94             : #include <unochart.hxx>
      95             : 
      96             : #include <chartins.hxx>
      97             : 
      98             : #define SwTextShell
      99             : #include <sfx2/msg.hxx>
     100             : #include <sfx2/sidebar/EnumContext.hxx>
     101             : #include <swslots.hxx>
     102             : #include <SwRewriter.hxx>
     103             : #include <comcore.hrc>
     104             : 
     105             : using namespace ::com::sun::star;
     106             : 
     107             : #include <svx/svxdlg.hxx>
     108             : #include <svx/dialogs.hrc>
     109             : #include "swabstdlg.hxx"
     110             : #include <misc.hrc>
     111             : #include <table.hrc>
     112             : #include <frmui.hrc>
     113             : #include <unomid.h>
     114             : 
     115      202871 : SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell, SW_RES(STR_SHELLNAME_TEXT))
     116             : {
     117          37 :     SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TEXT_POPUPMENU));
     118          37 :     SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
     119          37 :     SFX_CHILDWINDOW_REGISTRATION(FN_EDIT_FORMULA);
     120          37 :     SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD);
     121          37 :     SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_IDX_ENTRY_DLG);
     122          37 :     SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_AUTH_ENTRY_DLG);
     123          37 :     SFX_CHILDWINDOW_REGISTRATION(SID_RUBY_DIALOG);
     124          37 :     SFX_CHILDWINDOW_REGISTRATION(FN_WORDCOUNT_DIALOG);
     125          37 : }
     126             : 
     127       28687 : TYPEINIT1(SwTextShell,SwBaseShell)
     128             : 
     129           2 : void SwTextShell::ExecInsert(SfxRequest &rReq)
     130             : {
     131           2 :     SwWrtShell &rSh = GetShell();
     132             : 
     133             :     OSL_ENSURE( !rSh.IsObjSelected() && !rSh.IsFrmSelected(),
     134             :             "wrong shell on dispatcher" );
     135             : 
     136           2 :     const SfxItemSet *pArgs = rReq.GetArgs();
     137           2 :     const SfxPoolItem* pItem = 0;
     138           2 :     sal_uInt16 nSlot = rReq.GetSlot();
     139           2 :     if(pArgs)
     140           2 :         pArgs->GetItemState(nSlot, false, &pItem );
     141             : 
     142           2 :     switch( nSlot )
     143             :     {
     144             :     case FN_INSERT_STRING:
     145           2 :         if( pItem )
     146           2 :             rSh.InsertByWord(((const SfxStringItem *)pItem)->GetValue());
     147           2 :         break;
     148             : 
     149             :     case FN_INSERT_SOFT_HYPHEN:
     150           0 :         if( CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( sal_True, 0 ) &&
     151           0 :             CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( sal_True, -1 ))
     152           0 :             rSh.Insert( OUString( CHAR_SOFTHYPHEN ) );
     153           0 :         break;
     154             : 
     155             :     case FN_INSERT_HARDHYPHEN:
     156             :     case FN_INSERT_HARD_SPACE:
     157             :         {
     158           0 :             const sal_Unicode cIns = FN_INSERT_HARD_SPACE == nSlot ? CHAR_HARDBLANK : CHAR_HARDHYPHEN;
     159             : 
     160           0 :             SvxAutoCorrCfg& rACfg = SvxAutoCorrCfg::Get();
     161           0 :             SvxAutoCorrect* pACorr = rACfg.GetAutoCorrect();
     162           0 :             if( pACorr && rACfg.IsAutoFmtByInput()
     163           0 :                 && pACorr->IsAutoCorrFlag(
     164           0 :                     CptlSttSntnc | CptlSttWrd | AddNonBrkSpace | ChgOrdinalNumber | ChgToEnEmDash | SetINetAttr | Autocorrect ) )
     165             :             {
     166           0 :                 rSh.AutoCorrect( *pACorr, cIns );
     167             :             }
     168             :             else
     169             :             {
     170           0 :                 rSh.Insert( OUString( cIns ) );
     171             :             }
     172             :         }
     173           0 :         break;
     174             : 
     175             :     case SID_INSERT_RLM :
     176             :     case SID_INSERT_LRM :
     177             :     case SID_INSERT_ZWNBSP :
     178             :     case SID_INSERT_ZWSP:
     179             :     {
     180           0 :         sal_Unicode cIns = 0;
     181           0 :         switch(nSlot)
     182             :         {
     183           0 :             case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
     184           0 :             case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
     185           0 :             case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
     186           0 :             case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
     187             :         }
     188           0 :         rSh.Insert( OUString( cIns ) );
     189             :     }
     190           0 :     break;
     191             : 
     192             :     case FN_INSERT_BREAK:
     193             :         {
     194           0 :             if( !rSh.CrsrInsideInputFld() )
     195             :             {
     196           0 :                 rSh.SplitNode();
     197             :             }
     198             :             else
     199             :             {
     200           0 :                 rSh.InsertLineBreak();
     201             :             }
     202             :         }
     203           0 :         rReq.Done();
     204           0 :         break;
     205             : 
     206             :     case FN_INSERT_PAGEBREAK:
     207           0 :         rSh.InsertPageBreak();
     208           0 :         rReq.Done();
     209           0 :         break;
     210             : 
     211             :     case FN_INSERT_LINEBREAK:
     212           0 :         rSh.InsertLineBreak();
     213           0 :         rReq.Done();
     214           0 :         break;
     215             : 
     216             :     case FN_INSERT_COLUMN_BREAK:
     217           0 :         rSh.InsertColumnBreak();
     218           0 :         rReq.Done();
     219           0 :         break;
     220             : 
     221             :     case SID_HYPERLINK_SETLINK:
     222           0 :         if (pItem)
     223           0 :             InsertHyperlink(*((const SvxHyperlinkItem *)pItem));
     224           0 :         rReq.Done();
     225           0 :         break;
     226             : 
     227             :     case SID_INSERT_AVMEDIA:
     228           0 :         rReq.SetReturnValue(SfxBoolItem(nSlot, InsertMediaDlg( rReq )));
     229           0 :         break;
     230             : 
     231             :     case  SID_INSERT_SOUND:
     232             :     case  SID_INSERT_VIDEO:
     233             :     {
     234           0 :         SvxPluginFileDlg aDlg( &GetView().GetViewFrame()->GetWindow(), nSlot );
     235           0 :         aDlg.SetContext( nSlot == SID_INSERT_SOUND? sfx2::FileDialogHelper::SW_INSERT_SOUND : sfx2::FileDialogHelper::SW_INSERT_VIDEO );
     236             : 
     237           0 :         if ( ERRCODE_NONE == aDlg.Execute() )
     238             :         {
     239             :             // Determine URL
     240           0 :             OUString aStrURL( aDlg.GetPath() );
     241           0 :             aStrURL = URIHelper::SmartRel2Abs(
     242           0 :                 INetURLObject(), aStrURL, URIHelper::GetMaybeFileHdl() );
     243             : 
     244           0 :             INetURLObject url;
     245           0 :             url.SetSmartProtocol( INET_PROT_FILE );
     246             : 
     247           0 :             if ( url.SetURL( aStrURL, INetURLObject::WAS_ENCODED ) )
     248             :             {
     249           0 :                 OUString aName;
     250           0 :                 comphelper::EmbeddedObjectContainer aCnt;
     251           0 :                 svt::EmbeddedObjectRef xObj( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aName ), embed::Aspects::MSOLE_CONTENT );
     252           0 :                 if ( xObj.is() )
     253             :                 {
     254           0 :                     svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
     255             : 
     256             :                     // set properties from dialog
     257           0 :                     uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
     258           0 :                     if ( xSet.is() )
     259             :                     {
     260           0 :                         xSet->setPropertyValue("PluginURL",
     261           0 :                                 uno::makeAny( OUString( url.GetMainURL( INetURLObject::NO_DECODE ) ) ) );
     262           0 :                     }
     263             :                 }
     264             : 
     265           0 :                 rSh.InsertObject( xObj, 0, sal_True, nSlot);
     266           0 :             }
     267           0 :         }
     268             :     }
     269           0 :     break;
     270             : 
     271             :     case SID_INSERT_OBJECT:
     272             :     case SID_INSERT_PLUGIN:
     273             :     {
     274           0 :         SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, false );
     275           0 :         SvGlobalName *pName = NULL;
     276           0 :         SvGlobalName aName;
     277           0 :         if ( pNameItem )
     278             :         {
     279           0 :             aName = pNameItem->GetValue();
     280           0 :             pName = &aName;
     281             :         }
     282             : 
     283           0 :         SFX_REQUEST_ARG( rReq, pClassLocationItem,  SfxStringItem, FN_PARAM_2, false );
     284           0 :         SFX_REQUEST_ARG( rReq, pCommandsItem,       SfxStringItem, FN_PARAM_3, false );
     285             :         //TODO/LATER: recording currently not working, need code for Commandlist
     286           0 :         svt::EmbeddedObjectRef xObj;
     287           0 :         if( nSlot == SID_INSERT_PLUGIN && ( pClassLocationItem || pCommandsItem ) )
     288             :         {
     289           0 :             OUString sClassLocation;
     290           0 :             if(pClassLocationItem)
     291           0 :                 sClassLocation = pClassLocationItem->GetValue();
     292             : 
     293           0 :             SvCommandList aCommandList;
     294           0 :             if(pCommandsItem)
     295             :             {
     296             :                 sal_Int32 nTemp;
     297           0 :                 aCommandList.AppendCommands( pCommandsItem->GetValue(), &nTemp );
     298             :             }
     299             : 
     300             :             {
     301           0 :                 comphelper::EmbeddedObjectContainer aCnt;
     302           0 :                 OUString sName;
     303             :                 xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), sName ),
     304           0 :                             embed::Aspects::MSOLE_CONTENT );
     305           0 :                 svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
     306           0 :                 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
     307           0 :                 if ( xSet.is() )
     308             :                 {
     309             :                     try
     310             :                     {
     311           0 :                         if ( !sClassLocation.isEmpty() )
     312           0 :                             xSet->setPropertyValue("PluginURL",
     313             :                                 uno::makeAny(
     314             :                                     OUString(
     315             :                                         URIHelper::SmartRel2Abs(
     316             :                                             INetURLObject(), sClassLocation,
     317           0 :                                             URIHelper::GetMaybeFileHdl()) ) ) );
     318           0 :                         uno::Sequence< beans::PropertyValue > aSeq;
     319           0 :                         if ( aCommandList.size() )
     320             :                         {
     321           0 :                             aCommandList.FillSequence( aSeq );
     322           0 :                             xSet->setPropertyValue("PluginCommands", uno::makeAny( aSeq ) );
     323           0 :                         }
     324             :                     }
     325           0 :                     catch (const uno::Exception&)
     326             :                     {
     327             :                     }
     328           0 :                 }
     329             :             }
     330             : 
     331           0 :             if(xObj.is())
     332           0 :                 rSh.InsertOleObject( xObj );
     333             :         }
     334             :         else
     335             :         {
     336             :             OSL_ENSURE( !pNameItem || nSlot == SID_INSERT_OBJECT, "Superfluous argument!" );
     337           0 :             rSh.InsertObject( xObj, pName, sal_True, nSlot);
     338           0 :             rReq.Done();
     339             :         }
     340           0 :         break;
     341             :     }
     342             :     case SID_INSERT_FLOATINGFRAME:
     343             :     {
     344           0 :         svt::EmbeddedObjectRef xObj;
     345           0 :         SFX_REQUEST_ARG( rReq, pNameItem,   SfxStringItem, FN_PARAM_1, false );
     346           0 :         SFX_REQUEST_ARG( rReq, pURLItem,    SfxStringItem, FN_PARAM_2, false );
     347           0 :         SFX_REQUEST_ARG( rReq, pMarginItem, SvxSizeItem, FN_PARAM_3, false );
     348           0 :         SFX_REQUEST_ARG( rReq, pScrollingItem, SfxByteItem, FN_PARAM_4, false );
     349           0 :         SFX_REQUEST_ARG( rReq, pBorderItem, SfxBoolItem, FN_PARAM_5, false );
     350             : 
     351           0 :         if(pURLItem) // URL is a _must_
     352             :         {
     353           0 :             comphelper::EmbeddedObjectContainer aCnt;
     354           0 :             OUString aName;
     355             :             xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aName ),
     356           0 :                         embed::Aspects::MSOLE_CONTENT );
     357           0 :             svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
     358           0 :             uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
     359           0 :             if ( xSet.is() )
     360             :             {
     361             :                 try
     362             :                 {
     363           0 :                     ScrollingMode eScroll = ScrollingAuto;
     364           0 :                     if( pScrollingItem && pScrollingItem->GetValue() <= ScrollingAuto )
     365           0 :                         eScroll = (ScrollingMode) pScrollingItem->GetValue();
     366             : 
     367           0 :                     Size aMargin;
     368           0 :                     if ( pMarginItem )
     369           0 :                         aMargin = pMarginItem->GetSize();
     370             : 
     371           0 :                     if ( pURLItem )
     372           0 :                         xSet->setPropertyValue("FrameURL", uno::makeAny( OUString( pURLItem->GetValue() ) ) );
     373           0 :                     if ( pNameItem )
     374           0 :                         xSet->setPropertyValue("FrameName", uno::makeAny( OUString( pNameItem->GetValue() ) ) );
     375             : 
     376           0 :                     if ( eScroll == ScrollingAuto )
     377           0 :                         xSet->setPropertyValue("FrameIsAutoScroll",
     378           0 :                             uno::makeAny( sal_True ) );
     379             :                     else
     380           0 :                         xSet->setPropertyValue("FrameIsScrollingMode",
     381           0 :                             uno::makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) );
     382             : 
     383           0 :                     if ( pBorderItem )
     384           0 :                         xSet->setPropertyValue("FrameIsBorder",
     385           0 :                             uno::makeAny( (sal_Bool) pBorderItem->GetValue() ) );
     386             : 
     387           0 :                     if ( pMarginItem )
     388             :                     {
     389           0 :                         xSet->setPropertyValue("FrameMarginWidth",
     390           0 :                             uno::makeAny( sal_Int32( aMargin.Width() ) ) );
     391             : 
     392           0 :                         xSet->setPropertyValue("FrameMarginHeight",
     393           0 :                             uno::makeAny( sal_Int32( aMargin.Height() ) ) );
     394             :                     }
     395             :                 }
     396           0 :                 catch (const uno::Exception&)
     397             :                 {
     398             :                 }
     399             :             }
     400             : 
     401           0 :             rSh.InsertOleObject( xObj );
     402             :         }
     403             :         else
     404             :         {
     405           0 :             rSh.InsertObject( xObj, 0, sal_True, nSlot);
     406           0 :             rReq.Done();
     407           0 :         }
     408             :     }
     409           0 :     break;
     410             :     case SID_INSERT_DIAGRAM:
     411             :         {
     412           0 :             SvtModuleOptions aMOpt;
     413           0 :             if ( !aMOpt.IsChart() )
     414           0 :                 break;
     415           0 :             if(!rReq.IsAPI())
     416             :             {
     417           0 :                 SfxViewFrame* pVFrame = GetView().GetViewFrame();
     418           0 :                 SwInsertChart( &GetView().GetEditWin(), &pVFrame->GetBindings() );
     419             :             }
     420             :             else
     421             :             {
     422           0 :                 uno::Reference< chart2::data::XDataProvider > xDataProvider;
     423           0 :                 sal_Bool bFillWithData = sal_True;
     424           0 :                 OUString aRangeString;
     425           0 :                 if (!GetShell().IsTblComplexForChart())
     426             :                 {
     427           0 :                     SwFrmFmt* pTblFmt = GetShell().GetTableFmt();
     428           0 :                     aRangeString = pTblFmt->GetName();
     429           0 :                     aRangeString += OUString( '.' );
     430           0 :                     aRangeString += GetShell().GetBoxNms();
     431             : 
     432             :                     // get table data provider
     433           0 :                     xDataProvider.set( GetView().GetDocShell()->getIDocumentChartDataProviderAccess()->GetChartDataProvider() );
     434             :                 }
     435             :                 else
     436           0 :                     bFillWithData = sal_False;  // will create chart with only it's default image
     437             : 
     438           0 :                 SwTableFUNC( &rSh, sal_False ).InsertChart( xDataProvider, bFillWithData, aRangeString );
     439           0 :                 rSh.LaunchOLEObj();
     440             : 
     441           0 :                 svt::EmbeddedObjectRef& xObj = rSh.GetOLEObject();
     442           0 :                 if(pItem && xObj.is())
     443             :                 {
     444           0 :                     Size aSize(((SvxSizeItem*)pItem)->GetSize());
     445             :                     aSize = OutputDevice::LogicToLogic
     446           0 :                                     ( aSize, MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ) );
     447             : 
     448           0 :                     if(aSize.Width() > MINLAY&& aSize.Height()> MINLAY)
     449             :                     {
     450           0 :                         awt::Size aSz;
     451           0 :                         aSz.Width = aSize.Width();
     452           0 :                         aSz.Height = aSize.Height();
     453           0 :                         xObj->setVisualAreaSize( xObj.GetViewAspect(), aSz );
     454             :                     }
     455           0 :                 }
     456           0 :             }
     457             :         }
     458           0 :         break;
     459             : 
     460             :     case FN_INSERT_SMA:
     461             :         {
     462             :             // #i34343# Inserting a math object into an autocompletion crashes
     463             :             // the suggestion has to be removed before
     464           0 :             GetView().GetEditWin().StopQuickHelp();
     465           0 :             SvGlobalName aGlobalName( SO3_SM_CLASSID );
     466           0 :             rSh.InsertObject( svt::EmbeddedObjectRef(), &aGlobalName, sal_True, 0 );
     467             :         }
     468           0 :         break;
     469             : 
     470             :     case FN_INSERT_TABLE:
     471           0 :         InsertTable( rReq );
     472           0 :         break;
     473             : 
     474             :     case FN_INSERT_FRAME_INTERACT_NOCOL:
     475             :     case FN_INSERT_FRAME_INTERACT:
     476             :     {
     477           0 :         sal_uInt16 nCols = 1;
     478           0 :         bool bModifier1 = rReq.GetModifier() == KEY_MOD1;
     479           0 :         if(pArgs)
     480             :         {
     481           0 :             if(FN_INSERT_FRAME_INTERACT_NOCOL != nSlot &&
     482           0 :                 pArgs->GetItemState(SID_ATTR_COLUMNS, false, &pItem) == SFX_ITEM_SET)
     483           0 :                 nCols = ((SfxUInt16Item *)pItem)->GetValue();
     484           0 :             if(pArgs->GetItemState(SID_MODIFIER, false, &pItem) == SFX_ITEM_SET)
     485           0 :                 bModifier1 |= KEY_MOD1 == ((SfxUInt16Item *)pItem)->GetValue();
     486             :         }
     487           0 :         if(bModifier1 )
     488             :         {
     489           0 :             SwEditWin& rEdtWin = GetView().GetEditWin();
     490           0 :             Size aWinSize = rEdtWin.GetSizePixel();
     491           0 :             Point aStartPos(aWinSize.Width()/2, aWinSize.Height() / 2);
     492           0 :             aStartPos = rEdtWin.PixelToLogic(aStartPos);
     493           0 :             aStartPos.X() -= 8 * MM50;
     494           0 :             aStartPos.Y() -= 4 * MM50;
     495           0 :             Size aSize(16 * MM50, 8 * MM50);
     496           0 :             GetShell().LockPaint();
     497           0 :             GetShell().StartAllAction();
     498           0 :             SwFlyFrmAttrMgr aMgr( sal_True, GetShellPtr(), FRMMGR_TYPE_TEXT );
     499           0 :             if(nCols > 1)
     500             :             {
     501           0 :                 SwFmtCol aCol;
     502           0 :                 aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
     503           0 :                 aMgr.SetCol( aCol );
     504             :             }
     505           0 :             aMgr.InsertFlyFrm(FLY_AT_PARA, aStartPos, aSize);
     506           0 :             GetShell().EndAllAction();
     507           0 :             GetShell().UnlockPaint();
     508             :         }
     509             :         else
     510             :         {
     511           0 :             GetView().InsFrmMode(nCols);
     512             :         }
     513           0 :         rReq.Ignore();
     514             :     }
     515           0 :     break;
     516             :     case FN_INSERT_FRAME:
     517             :     {
     518           0 :         bool bSingleCol = false;
     519           0 :         if( 0!= dynamic_cast< SwWebDocShell*>( GetView().GetDocShell()) )
     520             :         {
     521           0 :             SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
     522           0 :             sal_uInt16 nExport = rHtmlOpt.GetExportMode();
     523           0 :             if( HTML_CFG_MSIE == nExport )
     524             :             {
     525           0 :                 bSingleCol = true;
     526             :             }
     527             : 
     528             :         }
     529             :         // Create new border
     530           0 :         SwFlyFrmAttrMgr aMgr( sal_True, GetShellPtr(), FRMMGR_TYPE_TEXT );
     531           0 :         if(pArgs)
     532             :         {
     533           0 :             Size aSize(aMgr.GetSize());
     534           0 :             aSize.Width() = GetShell().GetAnyCurRect(RECT_PAGE_PRT).Width();
     535           0 :             Point aPos = aMgr.GetPos();
     536           0 :             RndStdIds eAnchor = FLY_AT_PARA;
     537           0 :             if(pArgs->GetItemState(nSlot, false, &pItem) == SFX_ITEM_SET)
     538           0 :                 eAnchor = (RndStdIds)((SfxUInt16Item *)pItem)->GetValue();
     539           0 :             if(pArgs->GetItemState(FN_PARAM_1, false, &pItem)  == SFX_ITEM_SET)
     540           0 :                 aPos = ((SfxPointItem *)pItem)->GetValue();
     541           0 :             if(pArgs->GetItemState(FN_PARAM_2, false, &pItem)  == SFX_ITEM_SET)
     542           0 :                 aSize = ((SvxSizeItem *)pItem)->GetSize();
     543           0 :             if(pArgs->GetItemState(SID_ATTR_COLUMNS, false, &pItem)  == SFX_ITEM_SET)
     544             :             {
     545           0 :                 sal_uInt16 nCols = ((SfxUInt16Item *)pItem)->GetValue();
     546           0 :                 if( !bSingleCol && 1 < nCols )
     547             :                 {
     548           0 :                     SwFmtCol aFmtCol;
     549           0 :                     aFmtCol.Init( nCols , (rReq.IsAPI() ? 0
     550           0 :                                         : DEF_GUTTER_WIDTH), USHRT_MAX );
     551           0 :                     aMgr.SetCol(aFmtCol);
     552             :                 }
     553             :             }
     554             : 
     555           0 :             GetShell().LockPaint();
     556           0 :             GetShell().StartAllAction();
     557             : 
     558           0 :             aMgr.InsertFlyFrm(eAnchor, aPos, aSize);
     559             : 
     560           0 :             GetShell().EndAllAction();
     561           0 :             GetShell().UnlockPaint();
     562             :         }
     563             :         else
     564             :         {
     565             :             static const sal_uInt16 aFrmAttrRange[] =
     566             :             {
     567             :                 RES_FRMATR_BEGIN,       RES_FRMATR_END-1,
     568             :                 SID_ATTR_BORDER_INNER,  SID_ATTR_BORDER_INNER,
     569             :                 FN_GET_PRINT_AREA,      FN_GET_PRINT_AREA,
     570             :                 SID_ATTR_PAGE_SIZE,     SID_ATTR_PAGE_SIZE,
     571             :                 FN_SET_FRM_NAME,        FN_SET_FRM_NAME,
     572             :                 SID_HTML_MODE,          SID_HTML_MODE,
     573             :                 0
     574             :             };
     575             : 
     576           0 :             SfxItemSet aSet(GetPool(), aFrmAttrRange );
     577           0 :             aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
     578           0 :             const SwRect &rPg = GetShell().GetAnyCurRect(RECT_PAGE);
     579           0 :             SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height());
     580           0 :             aFrmSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE));
     581           0 :             aSet.Put(aFrmSize);
     582             : 
     583           0 :             const SwRect &rPr = GetShell().GetAnyCurRect(RECT_PAGE_PRT);
     584           0 :             SwFmtFrmSize aPrtSize(ATT_VAR_SIZE, rPr.Width(), rPr.Height());
     585           0 :             aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA));
     586           0 :             aSet.Put(aPrtSize);
     587             : 
     588           0 :             aSet.Put(aMgr.GetAttrSet());
     589           0 :             aSet.SetParent( aMgr.GetAttrSet().GetParent() );
     590             : 
     591             :             // Delete minimum size in columns.
     592           0 :             SvxBoxInfoItem aBoxInfo((SvxBoxInfoItem &)aSet.Get(SID_ATTR_BORDER_INNER));
     593           0 :             const SvxBoxItem& rBox = (const SvxBoxItem&)aSet.Get(RES_BOX);
     594           0 :             aBoxInfo.SetMinDist(false);
     595           0 :             aBoxInfo.SetDefDist(rBox.GetDistance(BOX_LINE_LEFT));
     596           0 :             aSet.Put(aBoxInfo);
     597             : 
     598           0 :             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, GetView().GetDocShell()));
     599           0 :             SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
     600           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     601             :             OSL_ENSURE(pFact, "Dialogdiet fail!");
     602             :             SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog("FrameDialog",
     603           0 :                                                     GetView().GetViewFrame(),
     604           0 :                                                     &GetView().GetViewFrame()->GetWindow(),
     605           0 :                                                     aSet, true);
     606             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     607           0 :             if(pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet())
     608             :             {
     609             :                 //local variable necessary at least after call of .AutoCaption() because this could be deleted at this point
     610           0 :                 SwWrtShell& rShell = GetShell();
     611           0 :                 rShell.LockPaint();
     612           0 :                 rShell.StartAllAction();
     613           0 :                 rShell.StartUndo(UNDO_INSERT);
     614             : 
     615           0 :                 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
     616           0 :                 aMgr.SetAttrSet(*pOutSet);
     617             : 
     618             :                 // At first delete the selection at the ClickToEditField.
     619           0 :                 if( rShell.IsInClickToEdit() )
     620           0 :                     rShell.DelRight();
     621             : 
     622           0 :                 aMgr.InsertFlyFrm();
     623             : 
     624             :                 uno::Reference< frame::XDispatchRecorder > xRecorder =
     625           0 :                         GetView().GetViewFrame()->GetBindings().GetRecorder();
     626           0 :                 if ( xRecorder.is() )
     627             :                 {
     628             :                     //FN_INSERT_FRAME
     629           0 :                     sal_uInt16 nAnchor = (sal_uInt16)aMgr.GetAnchor();
     630           0 :                         rReq.AppendItem(SfxUInt16Item(nSlot, nAnchor));
     631           0 :                         rReq.AppendItem(SfxPointItem(FN_PARAM_1, rShell.GetObjAbsPos()));
     632           0 :                         rReq.AppendItem(SvxSizeItem(FN_PARAM_2, rShell.GetObjSize()));
     633           0 :                     rReq.Done();
     634             :                 }
     635             : 
     636           0 :                 GetView().AutoCaption(FRAME_CAP);
     637             : 
     638             :                 {
     639           0 :                     SwRewriter aRewriter;
     640             : 
     641           0 :                     aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_FRAME));
     642             : 
     643           0 :                     rShell.EndUndo(UNDO_INSERT, &aRewriter);
     644             :                 }
     645           0 :                 rShell.EndAllAction();
     646           0 :                 rShell.UnlockPaint();
     647             :             }
     648             : 
     649           0 :             DELETEZ(pDlg);
     650             :         }
     651           0 :         break;
     652             :     }
     653             :     case FN_FORMAT_COLUMN :
     654             :     {
     655           0 :         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     656             :         OSL_ENSURE(pFact, "Dialogdiet fail!");
     657           0 :         VclAbstractDialog* pColDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_COLUMN);
     658             :         OSL_ENSURE(pColDlg, "Dialogdiet fail!");
     659           0 :         pColDlg->Execute();
     660           0 :         delete pColDlg;
     661             :     }
     662           0 :     break;
     663             : 
     664             :     default:
     665             :         OSL_ENSURE(!this, "wrong  dispatcher");
     666           0 :         return;
     667             :     }
     668             : }
     669             : 
     670           0 : static bool lcl_IsMarkInSameSection( SwWrtShell& rWrtSh, const SwSection* pSect )
     671             : {
     672           0 :     rWrtSh.SwapPam();
     673           0 :     bool bRet = pSect == rWrtSh.GetCurrSection();
     674           0 :     rWrtSh.SwapPam();
     675           0 :     return bRet;
     676             : }
     677             : 
     678           0 : void SwTextShell::StateInsert( SfxItemSet &rSet )
     679             : {
     680           0 :     sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
     681           0 :     SfxWhichIter aIter( rSet );
     682           0 :     SwWrtShell &rSh = GetShell();
     683           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     684           0 :     SvtModuleOptions aMOpt;
     685             :     SfxObjectCreateMode eCreateMode =
     686           0 :                         GetView().GetDocShell()->GetCreateMode();
     687             : 
     688           0 :     rSh.Push();
     689           0 :     const sal_Bool bCrsrInHidden = rSh.SelectHiddenRange();
     690           0 :     rSh.Pop();
     691             : 
     692           0 :     while ( nWhich )
     693             :     {
     694           0 :         switch ( nWhich )
     695             :         {
     696             :         case SID_INSERT_AVMEDIA:
     697             :         case SID_INSERT_SOUND:
     698             :         case SID_INSERT_VIDEO:
     699           0 :             if ( GetShell().IsSelFrmMode()
     700           0 :                  || GetShell().CrsrInsideInputFld()
     701           0 :                  || SFX_CREATE_MODE_EMBEDDED == eCreateMode
     702           0 :                  || bCrsrInHidden )
     703             :             {
     704           0 :                 rSet.DisableItem( nWhich );
     705             :             }
     706           0 :             break;
     707             : 
     708             :         case SID_INSERT_DIAGRAM:
     709           0 :             if( !aMOpt.IsChart()
     710           0 :                 || GetShell().CrsrInsideInputFld()
     711           0 :                 || eCreateMode == SFX_CREATE_MODE_EMBEDDED
     712           0 :                 || bCrsrInHidden )
     713             :             {
     714           0 :                 rSet.DisableItem( nWhich );
     715             :             }
     716           0 :             break;
     717             : 
     718             :             case FN_INSERT_SMA:
     719           0 :                 if( !aMOpt.IsMath()
     720           0 :                     || eCreateMode == SFX_CREATE_MODE_EMBEDDED
     721           0 :                     || bCrsrInHidden
     722           0 :                     || rSh.CrsrInsideInputFld() )
     723             :                 {
     724           0 :                     rSet.DisableItem( nWhich );
     725             :                 }
     726           0 :                 break;
     727             : 
     728             :             case SID_INSERT_FLOATINGFRAME:
     729             :             case SID_INSERT_OBJECT:
     730             :             case SID_INSERT_PLUGIN:
     731             :                 {
     732           0 :                     if( eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden )
     733             :                     {
     734           0 :                         rSet.DisableItem( nWhich );
     735             :                     }
     736           0 :                     else if( GetShell().IsSelFrmMode()
     737           0 :                              || GetShell().CrsrInsideInputFld() )
     738             :                     {
     739           0 :                         rSet.DisableItem( nWhich );
     740             :                     }
     741           0 :                     else if(SID_INSERT_FLOATINGFRAME == nWhich && nHtmlMode&HTMLMODE_ON)
     742             :                     {
     743           0 :                         SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
     744           0 :                         sal_uInt16 nExport = rHtmlOpt.GetExportMode();
     745           0 :                         if(HTML_CFG_MSIE != nExport && HTML_CFG_WRITER != nExport )
     746           0 :                             rSet.DisableItem(nWhich);
     747             :                     }
     748             :                 }
     749           0 :                 break;
     750             : 
     751             :             case FN_INSERT_FRAME_INTERACT_NOCOL :
     752             :             case FN_INSERT_FRAME_INTERACT:
     753             :                 {
     754           0 :                     if( GetShell().IsSelFrmMode()
     755           0 :                         || GetShell().CrsrInsideInputFld()
     756           0 :                         || bCrsrInHidden )
     757           0 :                         rSet.DisableItem(nWhich);
     758             :                 }
     759           0 :                 break;
     760             : 
     761             :             case SID_HYPERLINK_GETLINK:
     762             :                 {
     763           0 :                     SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
     764           0 :                     rSh.GetCurAttr( aSet );
     765             : 
     766           0 :                     SvxHyperlinkItem aHLinkItem;
     767             :                     const SfxPoolItem* pItem;
     768           0 :                     if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, false, &pItem))
     769             :                     {
     770           0 :                         const SwFmtINetFmt* pINetFmt = (const SwFmtINetFmt*)pItem;
     771           0 :                         aHLinkItem.SetURL(pINetFmt->GetValue());
     772           0 :                         aHLinkItem.SetTargetFrame(pINetFmt->GetTargetFrame());
     773           0 :                         aHLinkItem.SetIntName(pINetFmt->GetName());
     774           0 :                         const SvxMacro *pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOVER_OBJECT );
     775           0 :                         if( pMacro )
     776           0 :                             aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOVER_OBJECT, *pMacro);
     777             : 
     778           0 :                         pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSECLICK_OBJECT );
     779           0 :                         if( pMacro )
     780           0 :                             aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSECLICK_OBJECT, *pMacro);
     781             : 
     782           0 :                         pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOUT_OBJECT );
     783           0 :                         if( pMacro )
     784           0 :                             aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOUT_OBJECT, *pMacro);
     785             : 
     786             :                         // Get the text of the Link.
     787           0 :                         rSh.StartAction();
     788           0 :                         rSh.CreateCrsr();
     789           0 :                         rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT,sal_True);
     790           0 :                         OUString sLinkName = rSh.GetSelTxt();
     791           0 :                         aHLinkItem.SetName(sLinkName);
     792           0 :                         aHLinkItem.SetInsertMode(HLINK_FIELD);
     793           0 :                         rSh.DestroyCrsr();
     794           0 :                         rSh.EndAction();
     795             :                     }
     796             :                     else
     797             :                     {
     798           0 :                         OUString sReturn = rSh.GetSelTxt();
     799           0 :                         sReturn = sReturn.copy(0, std::min<sal_Int32>(255, sReturn.getLength()));
     800           0 :                         aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
     801             :                     }
     802             : 
     803           0 :                     aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
     804           0 :                         ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
     805             :                     aHLinkItem.SetMacroEvents ( HYPERDLG_EVENT_MOUSEOVER_OBJECT|
     806           0 :                         HYPERDLG_EVENT_MOUSECLICK_OBJECT | HYPERDLG_EVENT_MOUSEOUT_OBJECT );
     807             : 
     808           0 :                     rSet.Put(aHLinkItem);
     809             :                 }
     810           0 :                 break;
     811             : 
     812             :             case FN_INSERT_FRAME:
     813           0 :                 if (rSh.IsSelFrmMode() )
     814             :                 {
     815           0 :                     const int nSel = rSh.GetSelectionType();
     816           0 :                     if( ((nsSelectionType::SEL_GRF | nsSelectionType::SEL_OLE ) & nSel ) || bCrsrInHidden )
     817           0 :                         rSet.DisableItem(nWhich);
     818             :                 }
     819           0 :                 else if ( rSh.CrsrInsideInputFld() )
     820             :                 {
     821           0 :                     rSet.DisableItem(nWhich);
     822             :                 }
     823           0 :                 break;
     824             : 
     825             :             case FN_FORMAT_COLUMN :
     826             :             {
     827             :                 //#i80458# column dialog cannot work if the selection contains different page styles and different sections
     828           0 :                 bool bDisable = true;
     829           0 :                 if( rSh.GetFlyFrmFmt() || rSh.GetSelectedPageDescs() )
     830           0 :                     bDisable = false;
     831           0 :                 if( bDisable )
     832             :                 {
     833           0 :                     const SwSection* pCurrSection = rSh.GetCurrSection();
     834           0 :                     sal_uInt16 nFullSectCnt = rSh.GetFullSelectedSectionCount();
     835           0 :                     if( pCurrSection && ( !rSh.HasSelection() || 0 != nFullSectCnt ))
     836           0 :                         bDisable = false;
     837           0 :                     else if(
     838           0 :                         rSh.HasSelection() && rSh.IsInsRegionAvailable() &&
     839           0 :                             ( !pCurrSection || ( 1 != nFullSectCnt &&
     840           0 :                                 lcl_IsMarkInSameSection( rSh, pCurrSection ) )))
     841           0 :                         bDisable = false;
     842             :                 }
     843           0 :                 if(bDisable)
     844           0 :                     rSet.DisableItem(nWhich);
     845             :             }
     846           0 :             break;
     847             :         }
     848           0 :         nWhich = aIter.NextWhich();
     849           0 :     }
     850           0 : }
     851             : 
     852           0 : void  SwTextShell::ExecDelete(SfxRequest &rReq)
     853             : {
     854           0 :     SwWrtShell &rSh = GetShell();
     855           0 :     switch( rReq.GetSlot() )
     856             :     {
     857             :         case FN_DELETE_SENT:
     858           0 :             if( rSh.IsTableMode() )
     859             :             {
     860           0 :                 rSh.DeleteRow();
     861           0 :                 rSh.EnterStdMode();
     862             :             }
     863             :             else
     864           0 :                 rSh.DelToEndOfSentence();
     865           0 :             break;
     866             :         case FN_DELETE_BACK_SENT:
     867           0 :             rSh.DelToStartOfSentence();
     868           0 :             break;
     869             :         case FN_DELETE_WORD:
     870           0 :             rSh.DelNxtWord();
     871           0 :             break;
     872             :         case FN_DELETE_BACK_WORD:
     873           0 :             rSh.DelPrvWord();
     874           0 :             break;
     875             :         case FN_DELETE_LINE:
     876           0 :             rSh.DelToEndOfLine();
     877           0 :             break;
     878             :         case FN_DELETE_BACK_LINE:
     879           0 :             rSh.DelToStartOfLine();
     880           0 :             break;
     881             :         case FN_DELETE_PARA:
     882           0 :             rSh.DelToEndOfPara();
     883           0 :             break;
     884             :         case FN_DELETE_BACK_PARA:
     885           0 :             rSh.DelToStartOfPara();
     886           0 :             break;
     887             :         case FN_DELETE_WHOLE_LINE:
     888           0 :             rSh.DelLine();
     889           0 :             break;
     890             :         default:
     891             :             OSL_ENSURE(!this, "wrong dispatcher");
     892           0 :             return;
     893             :     }
     894           0 :     rReq.Done();
     895             : }
     896             : 
     897           0 : void SwTextShell::ExecTransliteration( SfxRequest & rReq )
     898             : {
     899             :     using namespace ::com::sun::star::i18n;
     900           0 :     sal_uInt32 nMode = 0;
     901             : 
     902           0 :     switch( rReq.GetSlot() )
     903             :     {
     904             :     case SID_TRANSLITERATE_SENTENCE_CASE:
     905           0 :         nMode = TransliterationModulesExtra::SENTENCE_CASE;
     906           0 :         break;
     907             :     case SID_TRANSLITERATE_TITLE_CASE:
     908           0 :         nMode = TransliterationModulesExtra::TITLE_CASE;
     909           0 :         break;
     910             :     case SID_TRANSLITERATE_TOGGLE_CASE:
     911           0 :         nMode = TransliterationModulesExtra::TOGGLE_CASE;
     912           0 :         break;
     913             :     case SID_TRANSLITERATE_UPPER:
     914           0 :         nMode = TransliterationModules_LOWERCASE_UPPERCASE;
     915           0 :         break;
     916             :     case SID_TRANSLITERATE_LOWER:
     917           0 :         nMode = TransliterationModules_UPPERCASE_LOWERCASE;
     918           0 :         break;
     919             : 
     920             :     case SID_TRANSLITERATE_HALFWIDTH:
     921           0 :         nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
     922           0 :         break;
     923             :     case SID_TRANSLITERATE_FULLWIDTH:
     924           0 :         nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
     925           0 :         break;
     926             : 
     927             :     case SID_TRANSLITERATE_HIRAGANA:
     928           0 :         nMode = TransliterationModules_KATAKANA_HIRAGANA;
     929           0 :         break;
     930             :     case SID_TRANSLITERATE_KATAGANA:
     931           0 :         nMode = TransliterationModules_HIRAGANA_KATAKANA;
     932           0 :         break;
     933             : 
     934             :     default:
     935             :         OSL_ENSURE(!this, "wrong dispatcher");
     936             :     }
     937             : 
     938           0 :     if( nMode )
     939           0 :         GetShell().TransliterateText( nMode );
     940           0 : }
     941             : 
     942           0 : void SwTextShell::ExecRotateTransliteration( SfxRequest & rReq )
     943             : {
     944           0 :     if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
     945           0 :         GetShell().TransliterateText( m_aRotateCase.getNextMode() );
     946           0 : }
     947             : 
     948        1749 : SwTextShell::SwTextShell(SwView &_rView) :
     949        1749 :     SwBaseShell(_rView), pPostItFldMgr( 0 )
     950             : {
     951        1749 :     SetName(OUString("Text"));
     952        1749 :     SetHelpId(SW_TEXTSHELL);
     953        1749 :     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Text));
     954        1749 : }
     955             : 
     956        3494 : SwTextShell::~SwTextShell()
     957             : {
     958        3494 : }
     959             : 
     960           0 : void SwTextShell::InsertSymbol( SfxRequest& rReq )
     961             : {
     962           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
     963           0 :     const SfxPoolItem* pItem = 0;
     964           0 :     if( pArgs )
     965           0 :         pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
     966             : 
     967           0 :     OUString aChars, aFontName;
     968           0 :     if ( pItem )
     969             :     {
     970           0 :         aChars = ((const SfxStringItem*)pItem)->GetValue();
     971           0 :         const SfxPoolItem* pFtItem = NULL;
     972           0 :         pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
     973           0 :         const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
     974           0 :         if ( pFontItem )
     975           0 :             aFontName = pFontItem->GetValue();
     976             :     }
     977             : 
     978           0 :     SwWrtShell &rSh = GetShell();
     979           0 :     SfxItemSet aSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT,
     980             :                                 RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
     981             :                                 RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT,
     982           0 :                                 0 );
     983           0 :     rSh.GetCurAttr( aSet );
     984           0 :     sal_uInt16 nScript = rSh.GetScriptType();
     985             : 
     986           0 :     SvxFontItem aFont( RES_CHRATR_FONT );
     987             :     {
     988           0 :         SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
     989           0 :         aSetItem.GetItemSet().Put( aSet, false );
     990           0 :         const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
     991           0 :         if( pI )
     992           0 :             aFont = *(SvxFontItem*)pI;
     993             :         else
     994             :             aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
     995             :                         RES_CHRATR_FONT,
     996           0 :                         GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
     997           0 :         if (aFontName.isEmpty())
     998           0 :             aFontName = aFont.GetFamilyName();
     999             :     }
    1000             : 
    1001           0 :     Font aNewFont(aFontName, Size(1,1)); // Size only because CTOR.
    1002           0 :     if( aChars.isEmpty() )
    1003             :     {
    1004             :         // Set selected font as default.
    1005           0 :         SfxAllItemSet aAllSet( rSh.GetAttrPool() );
    1006           0 :         aAllSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
    1007             : 
    1008           0 :         SwViewOption aOpt(*GetShell().GetViewOptions());
    1009           0 :         OUString sSymbolFont = aOpt.GetSymbolFont();
    1010           0 :         if( aFontName.isEmpty() && !sSymbolFont.isEmpty() )
    1011           0 :             aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
    1012             :         else
    1013           0 :             aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont.GetFamilyName() ) );
    1014             : 
    1015           0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    1016           0 :         SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aAllSet,
    1017           0 :             GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
    1018           0 :         if( RET_OK == pDlg->Execute() )
    1019             :         {
    1020           0 :             SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, false );
    1021           0 :             SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, false );
    1022           0 :             if ( pFontItem )
    1023             :             {
    1024           0 :                 aNewFont.SetName( pFontItem->GetFamilyName() );
    1025           0 :                 aNewFont.SetStyleName( pFontItem->GetStyleName() );
    1026           0 :                 aNewFont.SetCharSet( pFontItem->GetCharSet() );
    1027           0 :                 aNewFont.SetPitch( pFontItem->GetPitch() );
    1028             :             }
    1029             : 
    1030           0 :             if ( pCItem )
    1031             :             {
    1032           0 :                 aChars  = pCItem->GetValue();
    1033           0 :                 aOpt.SetSymbolFont(aNewFont.GetName());
    1034           0 :                 SW_MOD()->ApplyUsrPref(aOpt, &GetView());
    1035             :             }
    1036             :         }
    1037             : 
    1038           0 :         delete pDlg;
    1039             :     }
    1040             : 
    1041           0 :     if( !aChars.isEmpty() )
    1042             :     {
    1043           0 :         rSh.StartAllAction();
    1044             : 
    1045             :         // Delete selected content.
    1046           0 :         SwRewriter aRewriter;
    1047           0 :         aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_SPECIALCHAR));
    1048             : 
    1049           0 :         rSh.StartUndo( UNDO_INSERT, &aRewriter );
    1050           0 :         if ( rSh.HasSelection() )
    1051             :         {
    1052           0 :             rSh.DelRight();
    1053           0 :             aSet.ClearItem();
    1054           0 :             rSh.GetCurAttr( aSet );
    1055             : 
    1056           0 :             SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
    1057           0 :             aSetItem.GetItemSet().Put( aSet, false );
    1058           0 :             const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
    1059           0 :             if( pI )
    1060           0 :                 aFont = *(SvxFontItem*)pI;
    1061             :             else
    1062             :                 aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
    1063             :                             RES_CHRATR_FONT,
    1064           0 :                             GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
    1065             :         }
    1066             : 
    1067             :         // Insert character.
    1068           0 :         rSh.Insert( aChars );
    1069             : 
    1070             :         // #108876# a font attribute has to be set always due to a guessed script type
    1071           0 :         if( !aNewFont.GetName().isEmpty() )
    1072             :         {
    1073           0 :             SvxFontItem aNewFontItem( aFont );
    1074           0 :             aNewFontItem.SetFamilyName( aNewFont.GetName());
    1075           0 :             aNewFontItem.SetFamily(  aNewFont.GetFamily());
    1076           0 :             aNewFontItem.SetPitch(   aNewFont.GetPitch());
    1077           0 :             aNewFontItem.SetCharSet( aNewFont.GetCharSet() );
    1078             : 
    1079           0 :             SfxItemSet aRestoreSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT,
    1080             :                                                RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
    1081           0 :                                                RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT, 0 );
    1082             : 
    1083           0 :             nScript = g_pBreakIt->GetAllScriptsOfText( aChars );
    1084           0 :             if( SCRIPTTYPE_LATIN & nScript )
    1085             :             {
    1086           0 :                 aRestoreSet.Put( aSet.Get( RES_CHRATR_FONT, true ) );
    1087           0 :                 aSet.Put( aNewFontItem, RES_CHRATR_FONT);
    1088             :             }
    1089           0 :             if( SCRIPTTYPE_ASIAN & nScript )
    1090             :             {
    1091           0 :                 aRestoreSet.Put( aSet.Get( RES_CHRATR_CJK_FONT, true ) );
    1092           0 :                 aSet.Put( aNewFontItem, RES_CHRATR_CJK_FONT );
    1093             :             }
    1094           0 :             if( SCRIPTTYPE_COMPLEX & nScript )
    1095             :             {
    1096           0 :                 aRestoreSet.Put( aSet.Get( RES_CHRATR_CTL_FONT, true ) );
    1097           0 :                 aSet.Put( aNewFontItem, RES_CHRATR_CTL_FONT );
    1098             :             }
    1099             : 
    1100           0 :             rSh.SetMark();
    1101           0 :             rSh.ExtendSelection( sal_False, aChars.getLength() );
    1102           0 :             rSh.SetAttrSet( aSet, nsSetAttrMode::SETATTR_DONTEXPAND | nsSetAttrMode::SETATTR_NOFORMATATTR );
    1103           0 :             if( !rSh.IsCrsrPtAtEnd() )
    1104           0 :                 rSh.SwapPam();
    1105             : 
    1106           0 :             rSh.ClearMark();
    1107             : 
    1108             :             // #i75891#
    1109             :             // SETATTR_DONTEXPAND does not work if there are already hard attributes.
    1110             :             // Therefore we have to restore the font attributes.
    1111           0 :             rSh.SetMark();
    1112           0 :             rSh.SetAttrSet( aRestoreSet );
    1113           0 :             rSh.ClearMark();
    1114             : 
    1115           0 :             rSh.UpdateAttr();
    1116           0 :             aFont = aNewFontItem;
    1117             :         }
    1118             : 
    1119           0 :         rSh.EndAllAction();
    1120           0 :         rSh.EndUndo();
    1121             : 
    1122           0 :         if ( !aChars.isEmpty() )
    1123             :         {
    1124           0 :             rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), aChars ) );
    1125           0 :             rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aNewFont.GetName() ) );
    1126           0 :             rReq.Done();
    1127           0 :         }
    1128           0 :     }
    1129         111 : }
    1130             : 
    1131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10