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

Generated by: LCOV version 1.10