LCOV - code coverage report
Current view: top level - sw/source/core/uibase/shells - drwtxtsh.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 7 449 1.6 %
Date: 2014-04-11 Functions: 6 32 18.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10