LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/shells - drwtxtsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 403 1.7 %
Date: 2012-12-17 Functions: 6 31 19.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <hintids.hxx>
      22             : #include <i18npool/lang.h>
      23             : #include <svl/slstitm.hxx>
      24             : #include <svl/cjkoptions.hxx>
      25             : #include <editeng/fontitem.hxx>
      26             : #include <editeng/langitem.hxx>
      27             : #include <svx/svdview.hxx>
      28             : #include <vcl/msgbox.hxx>
      29             : #include <sfx2/viewfrm.hxx>
      30             : #include <sfx2/objface.hxx>
      31             : #include <svx/svdotext.hxx>
      32             : #include <svx/xftsfit.hxx>
      33             : #include <editeng/editeng.hxx>
      34             : #include <editeng/editview.hxx>
      35             : #include <editeng/eeitem.hxx>
      36             : #include <editeng/scripttypeitem.hxx>
      37             : #include <sfx2/bindings.hxx>
      38             : #include <svx/fontwork.hxx>
      39             : #include <sfx2/request.hxx>
      40             : #include <svl/whiter.hxx>
      41             : #include <editeng/outliner.hxx>
      42             : #include <editeng/editstat.hxx>
      43             : #include <svx/svdoutl.hxx>
      44             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      45             : #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
      46             : #include <com/sun/star/i18n/TextConversionOption.hpp>
      47             : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      48             : #include <com/sun/star/lang/XInitialization.hpp>
      49             : #include <swtypes.hxx>
      50             : #include <view.hxx>
      51             : #include <wrtsh.hxx>
      52             : #include <viewopt.hxx>
      53             : #include <initui.hxx>               // fuer SpellPointer
      54             : #include <drwtxtsh.hxx>
      55             : #include <swundo.hxx>
      56             : #include <breakit.hxx>
      57             : 
      58             : #include <cmdid.h>
      59             : #include <helpid.h>
      60             : #include <globals.hrc>
      61             : #include <shells.hrc>
      62             : 
      63             : #define SwDrawTextShell
      64             : #include <sfx2/msg.hxx>
      65             : #include <swslots.hxx>
      66             : #include <popup.hrc>
      67             : #include <uitool.hxx>
      68             : #include <wview.hxx>
      69             : #include <swmodule.hxx>
      70             : 
      71             : #include <svx/xtable.hxx>
      72             : #include <svx/svxdlg.hxx>
      73             : #include <svx/dialogs.hrc>
      74             : 
      75             : #include <cppuhelper/bootstrap.hxx>
      76             : 
      77             : #include "swabstdlg.hxx"
      78             : #include "misc.hrc"
      79             : 
      80             : using namespace ::com::sun::star;
      81             : using namespace ::com::sun::star::uno;
      82             : using namespace ::com::sun::star::beans;
      83             : using namespace ::com::sun::star::i18n;
      84             : 
      85         144 : SFX_IMPL_INTERFACE(SwDrawTextShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT))
      86             : {
      87          24 :     SFX_POPUPMENU_REGISTRATION(SW_RES(MN_DRWTXT_POPUPMENU));
      88          24 :     SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_DRAW_TEXT_TOOLBOX));
      89          24 :     SFX_CHILDWINDOW_REGISTRATION(SvxFontWorkChildWindow::GetChildWindowId());
      90          24 : }
      91             : 
      92           8 : TYPEINIT1(SwDrawTextShell,SfxShell)
      93             : 
      94           0 : void SwDrawTextShell::Init()
      95             : {
      96           0 :     SwWrtShell &rSh = GetShell();
      97           0 :     pSdrView = rSh.GetDrawView();
      98           0 :     SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
      99             :     //#97471# mouse click _and_ key input at the same time
     100           0 :     if( !pOutliner )
     101           0 :         return ;
     102           0 :     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
     103           0 :     sal_uLong nCtrl = pOutliner->GetControlWord();
     104           0 :     nCtrl |= EE_CNTRL_AUTOCORRECT;
     105             : 
     106           0 :     SetUndoManager(&pOutliner->GetUndoManager());
     107             : 
     108             :     // jetzt versuchen wir mal ein AutoSpell
     109             : 
     110           0 :     const SwViewOption* pVOpt = rSh.GetViewOptions();
     111           0 :     if(pVOpt->IsOnlineSpell())
     112             :     {
     113           0 :         nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS;
     114             :     }
     115             :     else
     116           0 :         nCtrl &= ~(EE_CNTRL_ONLINESPELLING);
     117             : 
     118           0 :     pOutliner->SetControlWord(nCtrl);
     119           0 :     pOLV->ShowCursor();
     120             : }
     121             : 
     122           0 : SwDrawTextShell::SwDrawTextShell(SwView &rV) :
     123             :     SfxShell(&rV),
     124           0 :     rView(rV)
     125             : {
     126           0 :     SwWrtShell &rSh = GetShell();
     127           0 :     SetPool(rSh.GetAttrPool().GetSecondaryPool());
     128             : 
     129           0 :     Init();
     130             : 
     131           0 :     rSh.NoEdit(sal_True);
     132           0 :     SetName(rtl::OUString("ObjectText"));
     133           0 :     SetHelpId(SW_DRWTXTSHELL);
     134           0 : }
     135             : 
     136           0 : SwDrawTextShell::~SwDrawTextShell()
     137             : {
     138           0 :     if ( GetView().GetCurShell() == this )
     139           0 :         rView.ResetSubShell();
     140           0 : }
     141             : 
     142           0 : SwWrtShell& SwDrawTextShell::GetShell()
     143             : {
     144           0 :     return rView.GetWrtShell();
     145             : }
     146             : 
     147             : /*--------------------------------------------------------------------
     148             :     Beschreibung:   Slots mit dieser Statusmethode disablen
     149             :  --------------------------------------------------------------------*/
     150           0 : void SwDrawTextShell::StateDisableItems( SfxItemSet &rSet )
     151             : {
     152           0 :     SfxWhichIter aIter(rSet);
     153           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     154             : 
     155           0 :     while (nWhich)
     156             :     {
     157           0 :         rSet.DisableItem( nWhich );
     158           0 :         nWhich = aIter.NextWhich();
     159           0 :     }
     160           0 : }
     161             : 
     162             : /*************************************************************************
     163             : |*
     164             : |* Attribute setzen
     165             : |*
     166             : \************************************************************************/
     167           0 : void SwDrawTextShell::SetAttrToMarked(const SfxItemSet& rAttr)
     168             : {
     169           0 :     Rectangle aNullRect;
     170           0 :     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
     171           0 :     Rectangle aOutRect = pOLV->GetOutputArea();
     172             : 
     173           0 :     if (aNullRect != aOutRect)
     174             :     {
     175           0 :         GetShell().GetDrawView()->SetAttributes(rAttr);
     176             : //      Init();
     177             :     }
     178           0 : }
     179             : 
     180           0 : sal_Bool SwDrawTextShell::IsTextEdit()
     181             : {
     182           0 :     return pSdrView->IsTextEdit();
     183             : }
     184             : 
     185           0 : void SwDrawTextShell::ExecFontWork(SfxRequest& rReq)
     186             : {
     187           0 :     SwWrtShell &rSh = GetShell();
     188           0 :     FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
     189           0 :     SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
     190           0 :     SfxViewFrame* pVFrame = GetView().GetViewFrame();
     191           0 :     if ( rReq.GetArgs() )
     192             :     {
     193           0 :         pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
     194           0 :                                 ((const SfxBoolItem&) (rReq.GetArgs()->
     195           0 :                                 Get(SID_FONTWORK))).GetValue());
     196             :     }
     197             :     else
     198           0 :         pVFrame->ToggleChildWindow(SvxFontWorkChildWindow::GetChildWindowId());
     199             : 
     200           0 :     pVFrame->GetBindings().Invalidate(SID_FONTWORK);
     201           0 : }
     202             : 
     203           0 : void SwDrawTextShell::StateFontWork(SfxItemSet& rSet)
     204             : {
     205           0 :     const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
     206           0 :     rSet.Put(SfxBoolItem(SID_FONTWORK, GetView().GetViewFrame()->HasChildWindow(nId)));
     207           0 : }
     208             : 
     209             : /*************************************************************************
     210             : |*
     211             : |* SfxRequests fuer FontWork bearbeiten
     212             : |*
     213             : \************************************************************************/
     214           0 : void SwDrawTextShell::ExecFormText(SfxRequest& rReq)
     215             : {
     216           0 :     SwWrtShell &rSh = GetShell();
     217           0 :     SdrView* pDrView = rSh.GetDrawView();
     218             : 
     219           0 :     const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     220             : 
     221           0 :     if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
     222             :     {
     223           0 :         const SfxItemSet& rSet = *rReq.GetArgs();
     224             :         const SfxPoolItem* pItem;
     225             : 
     226             :         //ask for the ViewFrame here - "this" may not be valid any longer!
     227           0 :         SfxViewFrame* pVFrame = GetView().GetViewFrame();
     228           0 :         if ( pDrView->IsTextEdit() )
     229             :         {
     230             :             //#111733# Sometimes SdrEndTextEdit() initiates the change in selection and
     231             :             // 'this' is not valid anymore
     232           0 :             SwView& rTempView = GetView();
     233           0 :             pDrView->SdrEndTextEdit(sal_True);
     234             :             //this removes the current shell from the dispatcher stack!!
     235           0 :             rTempView.AttrChangedNotify(&rSh);
     236             :         }
     237             : 
     238           0 :         if ( rSet.GetItemState(XATTR_FORMTXTSTDFORM, sal_True, &pItem) ==
     239             :              SFX_ITEM_SET &&
     240           0 :             ((const XFormTextStdFormItem*) pItem)->GetValue() != XFTFORM_NONE )
     241             :         {
     242             : 
     243           0 :             const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
     244             :             SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)(
     245           0 :                     pVFrame->GetChildWindow(nId)->GetWindow());
     246             : 
     247           0 :             pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(),
     248           0 :                                     rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(),
     249             :                                    ((const XFormTextStdFormItem*) pItem)->
     250           0 :                                    GetValue());
     251             :         }
     252             :         else
     253           0 :             pDrView->SetAttributes(rSet);
     254             :     }
     255             : 
     256           0 : }
     257             : 
     258             : /*************************************************************************
     259             : |*
     260             : |* Statuswerte fuer FontWork zurueckgeben
     261             : |*
     262             : \************************************************************************/
     263           0 : void SwDrawTextShell::GetFormTextState(SfxItemSet& rSet)
     264             : {
     265           0 :     SwWrtShell &rSh = GetShell();
     266           0 :     SdrView* pDrView = rSh.GetDrawView();
     267           0 :     const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
     268           0 :     const SdrObject* pObj = NULL;
     269           0 :     SvxFontWorkDialog* pDlg = NULL;
     270             : 
     271           0 :     const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
     272             : 
     273           0 :     SfxViewFrame* pVFrame = GetView().GetViewFrame();
     274           0 :     if ( pVFrame->HasChildWindow(nId) )
     275           0 :         pDlg = (SvxFontWorkDialog*)(pVFrame->GetChildWindow(nId)->GetWindow());
     276             : 
     277           0 :     if ( rMarkList.GetMarkCount() == 1 )
     278           0 :         pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     279             : 
     280           0 :     if ( pObj == NULL || !pObj->ISA(SdrTextObj) ||
     281           0 :         !((SdrTextObj*) pObj)->HasText() )
     282             :     {
     283             : #define XATTR_ANZ 12
     284             :         static const sal_uInt16 nXAttr[ XATTR_ANZ ] =
     285             :         {   XATTR_FORMTXTSTYLE, XATTR_FORMTXTADJUST, XATTR_FORMTXTDISTANCE,
     286             :             XATTR_FORMTXTSTART, XATTR_FORMTXTMIRROR, XATTR_FORMTXTSTDFORM,
     287             :             XATTR_FORMTXTHIDEFORM, XATTR_FORMTXTOUTLINE, XATTR_FORMTXTSHADOW,
     288             :             XATTR_FORMTXTSHDWCOLOR, XATTR_FORMTXTSHDWXVAL, XATTR_FORMTXTSHDWYVAL
     289             :         };
     290           0 :         for( sal_uInt16 i = 0; i < XATTR_ANZ; )
     291           0 :             rSet.DisableItem( nXAttr[ i++ ] );
     292             :     }
     293             :     else
     294             :     {
     295           0 :         if ( pDlg )
     296           0 :             pDlg->SetColorList(XColorList::GetStdColorList());
     297             : 
     298           0 :         pDrView->GetAttributes( rSet );
     299             :     }
     300           0 : }
     301             : 
     302           0 : void SwDrawTextShell::ExecDrawLingu(SfxRequest &rReq)
     303             : {
     304           0 :     SwWrtShell &rSh = GetShell();
     305           0 :     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
     306           0 :     if( rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() )
     307             :     {
     308           0 :         switch(rReq.GetSlot())
     309             :         {
     310             :         case SID_THESAURUS:
     311           0 :             pOLV->StartThesaurus();
     312           0 :             break;
     313             : 
     314             :         case SID_HANGUL_HANJA_CONVERSION:
     315             :             pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
     316           0 :                     i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True, sal_False );
     317           0 :             break;
     318             : 
     319             :         case SID_CHINESE_CONVERSION:
     320             :             {
     321             :                 //open ChineseTranslationDialog
     322             :                 Reference< XComponentContext > xContext(
     323           0 :                     ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
     324           0 :                 if(xContext.is())
     325             :                 {
     326           0 :                     Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
     327           0 :                     if(xMCF.is())
     328             :                     {
     329             :                         Reference< ui::dialogs::XExecutableDialog > xDialog(
     330           0 :                                 xMCF->createInstanceWithContext(
     331             :                                     rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.linguistic2.ChineseTranslationDialog"))
     332           0 :                                     , xContext), UNO_QUERY);
     333           0 :                         Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
     334           0 :                         if( xInit.is() )
     335             :                         {
     336             :                             //  initialize dialog
     337           0 :                             Reference< awt::XWindow > xDialogParentWindow(0);
     338           0 :                             Sequence<Any> aSeq(1);
     339           0 :                             Any* pArray = aSeq.getArray();
     340           0 :                             PropertyValue aParam;
     341           0 :                             aParam.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow"));
     342           0 :                             aParam.Value <<= makeAny(xDialogParentWindow);
     343           0 :                             pArray[0] <<= makeAny(aParam);
     344           0 :                             xInit->initialize( aSeq );
     345             : 
     346             :                             //execute dialog
     347           0 :                             sal_Int16 nDialogRet = xDialog->execute();
     348           0 :                             if( RET_OK == nDialogRet )
     349             :                             {
     350             :                                 //get some parameters from the dialog
     351           0 :                                 sal_Bool bToSimplified = sal_True;
     352           0 :                                 sal_Bool bUseVariants = sal_True;
     353           0 :                                 sal_Bool bCommonTerms = sal_True;
     354           0 :                                 Reference< beans::XPropertySet >  xProp( xDialog, UNO_QUERY );
     355           0 :                                 if( xProp.is() )
     356             :                                 {
     357             :                                     try
     358             :                                     {
     359           0 :                                         xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified;
     360           0 :                                         xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants;
     361           0 :                                         xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms;
     362             :                                     }
     363           0 :                                     catch (const Exception&)
     364             :                                     {
     365             :                                     }
     366             :                                 }
     367             : 
     368             :                                 //execute translation
     369           0 :                                 sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
     370           0 :                                 sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
     371           0 :                                 sal_Int32 nOptions    = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
     372           0 :                                 if( !bCommonTerms )
     373           0 :                                     nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
     374             : 
     375           0 :                                 Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT,
     376           0 :                                             nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
     377             : 
     378           0 :                                 pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False, sal_False );
     379           0 :                             }
     380             :                         }
     381           0 :                         Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
     382           0 :                         if( xComponent.is() )
     383           0 :                             xComponent->dispose();
     384           0 :                     }
     385           0 :                 }
     386             :             }
     387           0 :             break;
     388             : 
     389             :         default:
     390             :             OSL_ENSURE(!this, "unexpected slot-id");
     391             :         }
     392             :     }
     393           0 : }
     394             : 
     395           0 : void SwDrawTextShell::ExecDraw(SfxRequest &rReq)
     396             : {
     397           0 :     SwWrtShell &rSh = GetShell();
     398           0 :     pSdrView = rSh.GetDrawView();
     399           0 :     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
     400             : 
     401           0 :     switch (rReq.GetSlot())
     402             :     {
     403             :         case FN_INSERT_SOFT_HYPHEN:
     404             :         case FN_INSERT_HARDHYPHEN:
     405             :         case FN_INSERT_HARD_SPACE:
     406             :         case SID_INSERT_RLM :
     407             :         case SID_INSERT_LRM :
     408             :         case SID_INSERT_ZWNBSP :
     409             :         case SID_INSERT_ZWSP:
     410             :         {
     411           0 :             sal_Unicode cIns = 0;
     412           0 :             switch(rReq.GetSlot())
     413             :             {
     414           0 :                 case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
     415           0 :                 case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break;
     416           0 :                 case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break;
     417           0 :                 case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
     418           0 :                 case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
     419           0 :                 case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
     420           0 :                 case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
     421             :             }
     422           0 :             pOLV->InsertText( rtl::OUString(cIns));
     423           0 :             rReq.Done();
     424             :         }
     425           0 :         break;
     426             :         case SID_CHARMAP:
     427             :     {  // Sonderzeichen einfuegen
     428           0 :             InsertSymbol(rReq);
     429           0 :             break;
     430             :     }
     431             :           case FN_INSERT_STRING:
     432             :                 {
     433           0 :             const SfxItemSet *pNewAttrs = rReq.GetArgs();
     434           0 :                         sal_uInt16 nSlot = rReq.GetSlot();
     435           0 :             const SfxPoolItem* pItem = 0;
     436           0 :                         if(pNewAttrs)
     437             :             {
     438           0 :                                 pNewAttrs->GetItemState(nSlot, sal_False, &pItem );
     439           0 :                              pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue());
     440             :             }
     441             :                         break;
     442             :                 }
     443             : 
     444             :         case SID_SELECTALL:
     445             :         {
     446           0 :             SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
     447           0 :             if(pOutliner)
     448             :             {
     449           0 :                 sal_uLong nParaCount = pOutliner->GetParagraphCount();
     450           0 :                 if (nParaCount > 0)
     451           0 :                     pOLV->SelectRange(0L, sal_uInt16(nParaCount) );
     452             :             }
     453             :         }
     454           0 :         break;
     455             : 
     456             :         case FN_FORMAT_RESET:   // delete hard text attributes
     457             :         {
     458           0 :             pOLV->RemoveAttribsKeepLanguages( true );
     459           0 :             pOLV->GetEditView().GetEditEngine()->RemoveFields(sal_True);
     460           0 :             rReq.Done();
     461             :         }
     462           0 :         break;
     463             : 
     464             :         case FN_ESCAPE:
     465           0 :             if (pSdrView->IsTextEdit())
     466             :             {
     467             :                 // Shellwechsel!
     468           0 :                 rSh.EndTextEdit();
     469           0 :                 SwView& rTempView = rSh.GetView();
     470           0 :                 rTempView.ExitDraw();
     471           0 :                 rSh.Edit();
     472           0 :                 rTempView.AttrChangedNotify(&rSh);
     473           0 :                 return;
     474             :             }
     475           0 :             break;
     476             :         case FN_DRAWTEXT_ATTR_DLG:
     477             :             {
     478           0 :                 SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool() );
     479           0 :                 pSdrView->GetAttributes( aNewAttr );
     480           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     481           0 :                 if ( pFact )
     482             :                 {
     483             :                     SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog(
     484           0 :                                 &(GetView().GetViewFrame()->GetWindow()),
     485           0 :                                 &aNewAttr, pSdrView );
     486           0 :                     sal_uInt16 nResult = pDlg->Execute();
     487             : 
     488           0 :                     if (nResult == RET_OK)
     489             :                     {
     490           0 :                         if (pSdrView->AreObjectsMarked())
     491             :                         {
     492           0 :                             pSdrView->SetAttributes(*pDlg->GetOutputItemSet());
     493           0 :                             rReq.Done(*(pDlg->GetOutputItemSet()));
     494             :                         }
     495             :                     }
     496             : 
     497           0 :                     delete( pDlg );
     498           0 :                 }
     499             :             }
     500           0 :             break;
     501             : 
     502             :         default:
     503             :             OSL_ENSURE(!this, "unexpected slot-id");
     504           0 :             return;
     505             :     }
     506             : 
     507           0 :     GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
     508             : 
     509           0 :     if (IsTextEdit() && pOLV->GetOutliner()->IsModified())
     510           0 :         rSh.SetModified();
     511             : }
     512             : 
     513             : /*--------------------------------------------------------------------
     514             :     Beschreibung:   Undo ausfuehren
     515             :  --------------------------------------------------------------------*/
     516           0 : void SwDrawTextShell::ExecUndo(SfxRequest &rReq)
     517             : {
     518           0 :     if( IsTextEdit() )
     519             :     {
     520           0 :         sal_Bool bCallBase = sal_True;
     521           0 :         const SfxItemSet* pArgs = rReq.GetArgs();
     522           0 :         if( pArgs )
     523             :         {
     524           0 :             sal_uInt16 nId = rReq.GetSlot(), nCnt = 1;
     525             :             const SfxPoolItem* pItem;
     526           0 :             switch( nId )
     527             :             {
     528             :             case SID_UNDO:
     529             :             case SID_REDO:
     530           0 :                 if( SFX_ITEM_SET == pArgs->GetItemState( nId, sal_False, &pItem ) &&
     531           0 :                     1 < (nCnt = ((SfxUInt16Item*)pItem)->GetValue()) )
     532             :                 {
     533             :                     // then we make by ourself.
     534           0 :                     ::svl::IUndoManager* pUndoManager = GetUndoManager();
     535           0 :                     if( pUndoManager )
     536             :                     {
     537           0 :                         if( SID_UNDO == nId )
     538           0 :                             while( nCnt-- )
     539           0 :                                 pUndoManager->Undo();
     540             :                         else
     541           0 :                             while( nCnt-- )
     542           0 :                                 pUndoManager->Redo();
     543             :                     }
     544           0 :                     bCallBase = sal_False;
     545           0 :                     GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
     546             :                 }
     547           0 :                 break;
     548             :             }
     549             :         }
     550           0 :         if( bCallBase )
     551             :         {
     552           0 :             SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame();
     553           0 :             pSfxViewFrame->ExecuteSlot(rReq, pSfxViewFrame->GetInterface());
     554             :         }
     555             :     }
     556           0 : }
     557             : 
     558             : /*--------------------------------------------------------------------
     559             :     Beschreibung:   Zustand Undo
     560             :  --------------------------------------------------------------------*/
     561           0 : void SwDrawTextShell::StateUndo(SfxItemSet &rSet)
     562             : {
     563           0 :     if ( !IsTextEdit() )
     564           0 :         return;
     565             : 
     566           0 :     SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame();
     567           0 :     SfxWhichIter aIter(rSet);
     568           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     569           0 :     while( nWhich )
     570             :     {
     571           0 :         switch ( nWhich )
     572             :         {
     573             :         case SID_GETUNDOSTRINGS:
     574             :         case SID_GETREDOSTRINGS:
     575             :             {
     576           0 :                 ::svl::IUndoManager* pUndoManager = GetUndoManager();
     577           0 :                 if( pUndoManager )
     578             :                 {
     579             :                     rtl::OUString (::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const;
     580             : 
     581             :                     sal_uInt16 nCount;
     582           0 :                     if( SID_GETUNDOSTRINGS == nWhich )
     583             :                     {
     584           0 :                         nCount = pUndoManager->GetUndoActionCount();
     585           0 :                         fnGetComment = &::svl::IUndoManager::GetUndoActionComment;
     586             :                     }
     587             :                     else
     588             :                     {
     589           0 :                         nCount = pUndoManager->GetRedoActionCount();
     590           0 :                         fnGetComment = &::svl::IUndoManager::GetRedoActionComment;
     591             :                     }
     592           0 :                     if( nCount )
     593             :                     {
     594           0 :                         String sList;
     595           0 :                         for( sal_uInt16 n = 0; n < nCount; ++n )
     596           0 :                             ( sList += (pUndoManager->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) )
     597           0 :                                     += '\n';
     598             : 
     599           0 :                         SfxStringListItem aItem( nWhich );
     600           0 :                         aItem.SetString( sList );
     601           0 :                         rSet.Put( aItem );
     602             :                     }
     603             :                 }
     604             :                 else
     605           0 :                     rSet.DisableItem( nWhich );
     606             :             }
     607           0 :             break;
     608             : 
     609             :         default:
     610             :             pSfxViewFrame->GetSlotState( nWhich,
     611           0 :                                     pSfxViewFrame->GetInterface(), &rSet );
     612             :         }
     613             : 
     614           0 :         nWhich = aIter.NextWhich();
     615           0 :     }
     616             : }
     617             : 
     618           0 : void SwDrawTextShell::ExecTransliteration( SfxRequest & rReq )
     619             : {
     620           0 :     if (!pSdrView)
     621           0 :         return;
     622             : 
     623             :     using namespace i18n;
     624             : 
     625           0 :     sal_uInt32 nMode = 0;
     626             : 
     627           0 :     switch( rReq.GetSlot() )
     628             :     {
     629             :     case SID_TRANSLITERATE_SENTENCE_CASE:
     630           0 :         nMode = TransliterationModulesExtra::SENTENCE_CASE;
     631           0 :         break;
     632             :     case SID_TRANSLITERATE_TITLE_CASE:
     633           0 :         nMode = TransliterationModulesExtra::TITLE_CASE;
     634           0 :         break;
     635             :     case SID_TRANSLITERATE_TOGGLE_CASE:
     636           0 :         nMode = TransliterationModulesExtra::TOGGLE_CASE;
     637           0 :         break;
     638             :     case SID_TRANSLITERATE_UPPER:
     639           0 :         nMode = TransliterationModules_LOWERCASE_UPPERCASE;
     640           0 :         break;
     641             :     case SID_TRANSLITERATE_LOWER:
     642           0 :         nMode = TransliterationModules_UPPERCASE_LOWERCASE;
     643           0 :         break;
     644             : 
     645             :     case SID_TRANSLITERATE_HALFWIDTH:
     646           0 :         nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
     647           0 :         break;
     648             :     case SID_TRANSLITERATE_FULLWIDTH:
     649           0 :         nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
     650           0 :         break;
     651             : 
     652             :     case SID_TRANSLITERATE_HIRAGANA:
     653           0 :         nMode = TransliterationModules_KATAKANA_HIRAGANA;
     654           0 :         break;
     655             :     case SID_TRANSLITERATE_KATAGANA:
     656           0 :         nMode = TransliterationModules_HIRAGANA_KATAKANA;
     657           0 :         break;
     658             : 
     659             :     default:
     660             :         OSL_ENSURE(!this, "wrong dispatcher");
     661             :     }
     662             : 
     663           0 :     if( nMode )
     664             :     {
     665           0 :         OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
     666             : 
     667           0 :         if (!pOLV)
     668           0 :             return;
     669             : 
     670           0 :         pOLV->TransliterateText( nMode );
     671             :     }
     672             : }
     673             : 
     674           0 : void SwDrawTextShell::ExecRotateTransliteration( SfxRequest & rReq )
     675             : {
     676           0 :     if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
     677             :     {
     678           0 :         if (!pSdrView)
     679           0 :             return;
     680             : 
     681           0 :         OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
     682             : 
     683           0 :         if (!pOLV)
     684           0 :             return;
     685             : 
     686           0 :         pOLV->TransliterateText( m_aRotateCase.getNextMode() );
     687             :     }
     688             : }
     689             : 
     690             : /*--------------------------------------------------------------------
     691             :     Beschreibung:   Sonderzeichen einfuegen (siehe SDraw: FUBULLET.CXX)
     692             :  --------------------------------------------------------------------*/
     693           0 : void SwDrawTextShell::InsertSymbol(SfxRequest& rReq)
     694             : {
     695           0 :     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
     696           0 :     if(!pOLV)
     697           0 :         return;
     698           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
     699           0 :     const SfxPoolItem* pItem = 0;
     700           0 :     if( pArgs )
     701           0 :         pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem);
     702             : 
     703           0 :     String sSym;
     704           0 :     String sFontName;
     705           0 :     if ( pItem )
     706             :     {
     707           0 :         sSym = ((const SfxStringItem*)pItem)->GetValue();
     708           0 :         const SfxPoolItem* pFtItem = NULL;
     709           0 :         pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem);
     710           0 :         const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
     711           0 :         if ( pFontItem )
     712           0 :             sFontName = pFontItem->GetValue();
     713             :     }
     714             : 
     715           0 :     SfxItemSet aSet(pOLV->GetAttribs());
     716           0 :     sal_uInt16 nScript = pOLV->GetSelectedScriptType();
     717           0 :     SvxFontItem aSetDlgFont( RES_CHRATR_FONT );
     718             :     {
     719           0 :         SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
     720           0 :         aSetItem.GetItemSet().Put( aSet, sal_False );
     721           0 :         const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
     722           0 :         if( pI )
     723           0 :             aSetDlgFont = *(SvxFontItem*)pI;
     724             :         else
     725             :             aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
     726             :                         SID_ATTR_CHAR_FONT,
     727           0 :                         GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
     728           0 :         if (!sFontName.Len())
     729           0 :             sFontName = aSetDlgFont.GetFamilyName();
     730             :     }
     731             : 
     732           0 :     Font aFont(sFontName, Size(1,1));
     733           0 :     if(!sSym.Len())
     734             :     {
     735           0 :         SfxAllItemSet aAllSet( GetPool() );
     736           0 :         aAllSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) );
     737             : 
     738           0 :         SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions());
     739           0 :         String sSymbolFont = aOpt.GetSymbolFont();
     740           0 :         if( sSymbolFont.Len() )
     741           0 :             aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
     742             :         else
     743           0 :             aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) );
     744             : 
     745             :         // Wenn Zeichen selektiert ist kann es angezeigt werden
     746           0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     747             :         SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet,
     748           0 :             rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
     749           0 :         sal_uInt16 nResult = pDlg->Execute();
     750           0 :         if( nResult == RET_OK )
     751             :         {
     752           0 :             SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, sal_False );
     753           0 :             SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False );
     754           0 :             if ( pFontItem )
     755             :             {
     756           0 :                 aFont.SetName( pFontItem->GetFamilyName() );
     757           0 :                 aFont.SetStyleName( pFontItem->GetStyleName() );
     758           0 :                 aFont.SetCharSet( pFontItem->GetCharSet() );
     759           0 :                 aFont.SetPitch( pFontItem->GetPitch() );
     760             :             }
     761             : 
     762           0 :             if ( pCItem )
     763             :             {
     764           0 :                 sSym  = pCItem->GetValue();
     765           0 :                 aOpt.SetSymbolFont(aFont.GetName());
     766           0 :                 SW_MOD()->ApplyUsrPref(aOpt, &rView);
     767             :             }
     768             :         }
     769             : 
     770           0 :         delete( pDlg );
     771             :     }
     772             : 
     773           0 :     if( sSym.Len() )
     774             :     {
     775             :         // nicht flackern
     776           0 :         pOLV->HideCursor();
     777           0 :         SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
     778           0 :         pOutliner->SetUpdateMode(sal_False);
     779             : 
     780           0 :         SfxItemSet aOldSet( pOLV->GetAttribs() );
     781           0 :         SfxItemSet aFontSet( *aOldSet.GetPool(),
     782             :                             EE_CHAR_FONTINFO, EE_CHAR_FONTINFO,
     783             :                             EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK,
     784             :                             EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL,
     785           0 :                             0 );
     786           0 :         aFontSet.Set( aOldSet );
     787             : 
     788             :         // String einfuegen
     789           0 :         pOLV->InsertText( sSym );
     790             : 
     791             :         // attributieren (Font setzen)
     792           0 :         SfxItemSet aFontAttribSet( *aFontSet.GetPool(), aFontSet.GetRanges() );
     793           0 :         SvxFontItem aFontItem (aFont.GetFamily(),    aFont.GetName(),
     794           0 :                                 aFont.GetStyleName(), aFont.GetPitch(),
     795           0 :                                 aFont.GetCharSet(),
     796           0 :                                 EE_CHAR_FONTINFO );
     797           0 :         nScript = pBreakIt->GetAllScriptsOfText( sSym );
     798           0 :         if( SCRIPTTYPE_LATIN & nScript )
     799           0 :             aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO );
     800           0 :         if( SCRIPTTYPE_ASIAN & nScript )
     801           0 :             aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CJK );
     802           0 :         if( SCRIPTTYPE_COMPLEX & nScript )
     803           0 :             aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CTL );
     804           0 :         pOLV->SetAttribs(aFontAttribSet);
     805             : 
     806             :         // Selektion loeschen
     807           0 :         ESelection aSel(pOLV->GetSelection());
     808           0 :         aSel.nStartPara = aSel.nEndPara;
     809           0 :         aSel.nStartPos = aSel.nEndPos;
     810           0 :         pOLV->SetSelection(aSel);
     811             : 
     812             :         // Alten Font restaurieren
     813           0 :         pOLV->SetAttribs( aFontSet );
     814             : 
     815             :         // ab jetzt wieder anzeigen
     816           0 :         pOutliner->SetUpdateMode(sal_True);
     817           0 :         pOLV->ShowCursor();
     818             : 
     819           0 :         rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) );
     820           0 :         if(aFont.GetName().Len())
     821           0 :             rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) );
     822           0 :         rReq.Done();
     823           0 :     }
     824             : }
     825             : 
     826           0 : ::svl::IUndoManager* SwDrawTextShell::GetUndoManager()
     827             : {
     828           0 :     SwWrtShell &rSh = GetShell();
     829           0 :     pSdrView = rSh.GetDrawView();
     830           0 :     SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
     831           0 :     return &pOutliner->GetUndoManager();
     832          72 : }
     833             : 
     834             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10