LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/shells - annotsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 895 0.7 %
Date: 2013-07-09 Functions: 6 33 18.2 %
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             : 
      23             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      24             : #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
      25             : #include <com/sun/star/i18n/TextConversionOption.hpp>
      26             : #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
      27             : #include <com/sun/star/lang/XInitialization.hpp>
      28             : 
      29             : #include <tools/shl.hxx>
      30             : #include <i18nlangtag/mslangid.hxx>
      31             : #include <sfx2/objface.hxx>
      32             : #include <sfx2/viewfrm.hxx>
      33             : #include <sfx2/bindings.hxx>
      34             : #include <sfx2/dispatch.hxx>
      35             : #include <sfx2/request.hxx>
      36             : #include <editeng/spltitem.hxx>
      37             : #include <editeng/lrspitem.hxx>
      38             : #include <editeng/ulspitem.hxx>
      39             : #include <editeng/orphitem.hxx>
      40             : #include <editeng/formatbreakitem.hxx>
      41             : #include <editeng/widwitem.hxx>
      42             : #include <editeng/kernitem.hxx>
      43             : #include <editeng/escapementitem.hxx>
      44             : #include <editeng/lspcitem.hxx>
      45             : #include <editeng/adjustitem.hxx>
      46             : #include <editeng/crossedoutitem.hxx>
      47             : #include <editeng/shdditem.hxx>
      48             : #include <editeng/hyphenzoneitem.hxx>
      49             : #include <editeng/udlnitem.hxx>
      50             : #include <editeng/fontitem.hxx>
      51             : #include <editeng/fhgtitem.hxx>
      52             : #include <svx/clipfmtitem.hxx>
      53             : #include <svl/stritem.hxx>
      54             : #include <svl/slstitm.hxx>
      55             : #include <editeng/colritem.hxx>
      56             : #include <editeng/wghtitem.hxx>
      57             : #include <editeng/contouritem.hxx>
      58             : #include <editeng/postitem.hxx>
      59             : #include <editeng/frmdiritem.hxx>
      60             : #include <svx/svdoutl.hxx>
      61             : #include <svl/whiter.hxx>
      62             : #include <svl/cjkoptions.hxx>
      63             : #include <svl/ctloptions.hxx>
      64             : #include <unotools/useroptions.hxx>
      65             : #include <vcl/msgbox.hxx>
      66             : #include <editeng/flditem.hxx>
      67             : #include <editeng/editstat.hxx>
      68             : #include <svx/hlnkitem.hxx>
      69             : #include <sfx2/htmlmode.hxx>
      70             : #include <editeng/langitem.hxx>
      71             : #include <editeng/unolingu.hxx>
      72             : #include <editeng/scripttypeitem.hxx>
      73             : #include <editeng/writingmodeitem.hxx>
      74             : #include <swundo.hxx>
      75             : #include <doc.hxx>
      76             : #include <viewopt.hxx>
      77             : #include <wrtsh.hxx>
      78             : #include <uitool.hxx>
      79             : #include <popup.hrc>
      80             : #include <pardlg.hxx>
      81             : #include <swdtflvr.hxx>
      82             : #include <drwtxtsh.hxx>
      83             : #include <swmodule.hxx>
      84             : #include <initui.hxx>
      85             : #include <edtwin.hxx>
      86             : #include <swwait.hxx>
      87             : #include <docstat.hxx>
      88             : 
      89             : #include <cmdid.h>
      90             : #include <globals.hrc>
      91             : #include <shells.hrc>
      92             : #include <breakit.hxx>
      93             : #include "annotsh.hxx"
      94             : #include "view.hxx"
      95             : #include <PostItMgr.hxx>
      96             : #include <SidebarWin.hxx>
      97             : 
      98             : #include "swtypes.hxx"
      99             : 
     100             : #include <svx/svxdlg.hxx>
     101             : #include <svx/dialogs.hrc>
     102             : 
     103             : #include <svx/svxids.hrc>
     104             : #include <sfx2/sidebar/EnumContext.hxx>
     105             : #include <svl/itempool.hxx>
     106             : #include <editeng/outliner.hxx>
     107             : #include <editeng/editeng.hxx>
     108             : #include <editeng/editview.hxx>
     109             : 
     110             : #include <svl/languageoptions.hxx>
     111             : #include <svtools/langtab.hxx>
     112             : 
     113             : #include <docsh.hxx>
     114             : #include <svl/undo.hxx>
     115             : #include "swabstdlg.hxx"
     116             : #include "chrdlg.hrc"
     117             : #include "misc.hrc"
     118             : #include <app.hrc>
     119             : 
     120             : #include <comphelper/processfactory.hxx>
     121             : #include <comphelper/string.hxx>
     122             : #include <cppuhelper/bootstrap.hxx>
     123             : 
     124             : #include <langhelper.hxx>
     125             : 
     126             : #include <wordcountdialog.hxx>
     127             : #include <tools/diagnose_ex.h>
     128             : 
     129             : using namespace ::com::sun::star;
     130             : using namespace ::com::sun::star::uno;
     131             : using namespace ::com::sun::star::beans;
     132             : using namespace ::com::sun::star::i18n;
     133             : 
     134             : #define SwAnnotationShell
     135             : 
     136             : #include <sfx2/msg.hxx>
     137             : #include <swslots.hxx>
     138             : 
     139         165 : SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT))
     140             : {
     141          33 :     SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
     142          33 :     SFX_POPUPMENU_REGISTRATION(SW_RES(MN_ANNOTATION_POPUPMENU));
     143          33 : }
     144             : 
     145         645 : TYPEINIT1(SwAnnotationShell,SfxShell)
     146             : 
     147           0 : SwAnnotationShell::SwAnnotationShell( SwView& r )
     148           0 : : rView(r)
     149             : {
     150           0 :     SwWrtShell &rSh = rView.GetWrtShell();
     151           0 :     SetPool(rSh.GetAttrPool().GetSecondaryPool());
     152           0 :     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Annotation));
     153           0 : }
     154             : 
     155           0 : SwAnnotationShell::~SwAnnotationShell()
     156             : {
     157           0 : }
     158             : 
     159           0 : ::svl::IUndoManager* SwAnnotationShell::GetUndoManager()
     160             : {
     161           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
     162           0 :     if ( !pPostItMgr ||
     163           0 :          !pPostItMgr->HasActiveSidebarWin() )
     164             :     {
     165             :         OSL_ENSURE(pPostItMgr,"PostItMgr::Layout(): We are looping forever");
     166           0 :         return 0;
     167             :     }
     168           0 :     return &pPostItMgr->GetActiveSidebarWin()->GetOutlinerView()->GetOutliner()->GetUndoManager();
     169             : }
     170             : 
     171           0 : void SwAnnotationShell::Exec( SfxRequest &rReq )
     172             : {
     173             :     //TODO: clean this up!!!!
     174           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
     175           0 :     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
     176           0 :         return;
     177             : 
     178           0 :     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
     179           0 :     SfxItemSet aEditAttr(pOLV->GetAttribs());
     180           0 :     SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
     181             : 
     182           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     183           0 :     sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
     184           0 :     const SfxItemSet *pNewAttrs = rReq.GetArgs();
     185           0 :     sal_uInt16 nEEWhich = 0;
     186           0 :     switch (nSlot)
     187             :     {
     188             :         case SID_ATTR_PARA_LRSPACE:
     189             :             {
     190             :                 SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)rReq.
     191           0 :                                         GetArgs()->Get(nSlot));
     192           0 :                 aParaMargin.SetWhich( EE_PARA_LRSPACE );
     193             : 
     194           0 :                 aNewAttr.Put(aParaMargin);
     195           0 :                 rReq.Done();
     196           0 :                 break;
     197             :             }
     198             :         case SID_ATTR_PARA_LINESPACE:
     199             :             {
     200             :                 SvxLineSpacingItem aParaMargin = (const SvxLineSpacingItem&)pNewAttrs->Get(
     201           0 :                                                             GetPool().GetWhich(nSlot));
     202           0 :                 aParaMargin.SetWhich( EE_PARA_SBL );
     203             : 
     204           0 :                 aNewAttr.Put(aParaMargin);
     205           0 :                 rReq.Done();
     206           0 :                 break;
     207             :             }
     208             :         case SID_ATTR_PARA_ULSPACE:
     209             :             {
     210             :                 SvxULSpaceItem aULSpace = (const SvxULSpaceItem&)pNewAttrs->Get(
     211           0 :                     GetPool().GetWhich(nSlot));
     212           0 :                 aULSpace.SetWhich( EE_PARA_ULSPACE );
     213           0 :                 aNewAttr.Put( aULSpace );
     214           0 :                 rReq.Done();
     215             :             }
     216           0 :             break;
     217             :         case SID_ATTR_CHAR_FONT:
     218             :         case SID_ATTR_CHAR_FONTHEIGHT:
     219             :         case SID_ATTR_CHAR_WEIGHT:
     220             :         case SID_ATTR_CHAR_POSTURE:
     221             :             {
     222           0 :                 SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool();
     223           0 :                 if( !pSecondPool )
     224           0 :                     pSecondPool = aEditAttr.GetPool();
     225           0 :                 SvxScriptSetItem aSetItem( nSlot, *pSecondPool );
     226           0 :                 aSetItem.PutItemForScriptType( pOLV->GetSelectedScriptType(), pNewAttrs->Get( nWhich ));
     227           0 :                 aNewAttr.Put( aSetItem.GetItemSet() );
     228           0 :                 rReq.Done();
     229           0 :                 break;
     230             :             }
     231           0 :         case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
     232             :         case SID_ATTR_CHAR_UNDERLINE:
     233             :         {
     234           0 :             if( rReq.GetArgs() )
     235             :             {
     236           0 :                 SFX_REQUEST_ARG( rReq, pItem, SvxUnderlineItem, SID_ATTR_CHAR_UNDERLINE , sal_False );
     237           0 :                 if (pItem)
     238             :                 {
     239           0 :                     aNewAttr.Put(*pItem);
     240             :                 }
     241             :                 else
     242             :                 {
     243           0 :                     FontUnderline eFU = ( (const SvxUnderlineItem&) aEditAttr.Get( EE_CHAR_UNDERLINE ) ).GetLineStyle();
     244           0 :                     aNewAttr.Put( SvxUnderlineItem( eFU != UNDERLINE_NONE ?UNDERLINE_NONE : UNDERLINE_SINGLE,  EE_CHAR_UNDERLINE ) );
     245             :                 }
     246             :             }
     247           0 :             break;
     248             :         }
     249             :         case SID_ATTR_CHAR_OVERLINE:
     250             :         {
     251           0 :              FontUnderline eFO = ((const SvxOverlineItem&)aEditAttr.Get(EE_CHAR_OVERLINE)).GetLineStyle();
     252           0 :             aNewAttr.Put(SvxOverlineItem(eFO == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_OVERLINE));
     253           0 :             break;
     254             :         }
     255           0 :         case SID_ATTR_CHAR_CONTOUR:     nEEWhich = EE_CHAR_OUTLINE; break;
     256           0 :         case SID_ATTR_CHAR_SHADOWED:    nEEWhich = EE_CHAR_SHADOW; break;
     257           0 :         case SID_ATTR_CHAR_STRIKEOUT:   nEEWhich = EE_CHAR_STRIKEOUT; break;
     258           0 :         case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
     259           0 :         case SID_ATTR_CHAR_RELIEF      : nEEWhich = EE_CHAR_RELIEF;  break;
     260           0 :         case SID_ATTR_CHAR_LANGUAGE    : nEEWhich = EE_CHAR_LANGUAGE;break;
     261           0 :         case SID_ATTR_CHAR_KERNING     : nEEWhich = EE_CHAR_KERNING; break;
     262           0 :         case SID_ATTR_CHAR_SCALEWIDTH:   nEEWhich = EE_CHAR_FONTWIDTH; break;
     263           0 :         case SID_ATTR_CHAR_AUTOKERN  :   nEEWhich = EE_CHAR_PAIRKERNING; break;
     264           0 :         case SID_ATTR_CHAR_ESCAPEMENT:   nEEWhich = EE_CHAR_ESCAPEMENT; break;
     265             :         case SID_ATTR_PARA_ADJUST_LEFT:
     266           0 :             aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST));
     267           0 :         break;
     268             :         case SID_ATTR_PARA_ADJUST_CENTER:
     269           0 :             aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
     270           0 :         break;
     271             :         case SID_ATTR_PARA_ADJUST_RIGHT:
     272           0 :             aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST));
     273           0 :         break;
     274             :         case SID_ATTR_PARA_ADJUST_BLOCK:
     275           0 :             aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST));
     276           0 :         break;
     277             : 
     278             :         case SID_ATTR_PARA_LINESPACE_10:
     279             :         {
     280           0 :             SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_LINE, EE_PARA_SBL);
     281           0 :             aItem.SetPropLineSpace(100);
     282           0 :             aNewAttr.Put(aItem);
     283             :         }
     284           0 :         break;
     285             :         case SID_ATTR_PARA_LINESPACE_15:
     286             :         {
     287           0 :             SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL);
     288           0 :             aItem.SetPropLineSpace(150);
     289           0 :             aNewAttr.Put(aItem);
     290             :         }
     291           0 :         break;
     292             :         case SID_ATTR_PARA_LINESPACE_20:
     293             :         {
     294           0 :             SvxLineSpacingItem aItem(SVX_LINESPACE_TWO_LINES, EE_PARA_SBL);
     295           0 :             aItem.SetPropLineSpace(200);
     296           0 :             aNewAttr.Put(aItem);
     297             :         }
     298           0 :         break;
     299             :         case SID_SELECTALL:
     300             :         {
     301           0 :             Outliner * pOutliner = pOLV->GetOutliner();
     302           0 :             if(pOutliner)
     303             :             {
     304           0 :                 sal_Int32 nParaCount = pOutliner->GetParagraphCount();
     305           0 :                 if (nParaCount > 0)
     306           0 :                     pOLV->SelectRange(0L, nParaCount );
     307             :             }
     308           0 :             break;
     309             :         }
     310             :         case FN_FORMAT_RESET:
     311             :         {
     312           0 :             pPostItMgr->GetActiveSidebarWin()->ResetAttributes();
     313           0 :             rReq.Done();
     314           0 :             break;
     315             :         }
     316             :         case FN_SET_SUPER_SCRIPT:
     317             :         {
     318           0 :             SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
     319             :             SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
     320           0 :                             aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
     321             : 
     322           0 :             if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
     323           0 :                 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
     324             :             else
     325           0 :                 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
     326           0 :             aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
     327             :         }
     328           0 :         break;
     329             :         case FN_SET_SUB_SCRIPT:
     330             :         {
     331           0 :             SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
     332             :             SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
     333           0 :                             aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
     334             : 
     335           0 :             if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
     336           0 :                 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
     337             :             else
     338           0 :                 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
     339           0 :             aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
     340             :         }
     341           0 :         break;
     342             :         case SID_HYPERLINK_SETLINK:
     343             :         {
     344           0 :             const SfxPoolItem* pItem = 0;
     345           0 :             if(pNewAttrs)
     346           0 :                 pNewAttrs->GetItemState(nSlot, sal_False, &pItem);
     347             : 
     348           0 :             if(pItem)
     349             :             {
     350           0 :                 const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
     351           0 :                 SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT);
     352           0 :                 aFld.SetTargetFrame(rHLinkItem.GetTargetFrame());
     353             : 
     354           0 :                 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
     355             : 
     356           0 :                 if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField))
     357             :                 {
     358             :                     // Select the field so that it will be deleted during insert
     359           0 :                     ESelection aSel = pOLV->GetSelection();
     360           0 :                     aSel.nEndPos++;
     361           0 :                     pOLV->SetSelection(aSel);
     362             :                 }
     363           0 :                 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
     364           0 :                     pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD));
     365             :             }
     366           0 :             break;
     367             :         }
     368             :         case FN_INSERT_SOFT_HYPHEN:
     369             :         case FN_INSERT_HARDHYPHEN:
     370             :         case FN_INSERT_HARD_SPACE:
     371             :         case SID_INSERT_RLM :
     372             :         case SID_INSERT_LRM :
     373             :         case SID_INSERT_ZWNBSP :
     374             :         case SID_INSERT_ZWSP:
     375             :         {
     376           0 :             sal_Unicode cIns = 0;
     377           0 :             switch(rReq.GetSlot())
     378             :             {
     379           0 :                 case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
     380           0 :                 case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break;
     381           0 :                 case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break;
     382           0 :                 case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
     383           0 :                 case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
     384           0 :                 case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
     385           0 :                 case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
     386             :             }
     387           0 :             pOLV->InsertText( OUString(cIns));
     388           0 :             rReq.Done();
     389           0 :             break;
     390             :         }
     391             :         case SID_CHARMAP:
     392             :         {
     393           0 :             if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
     394           0 :                 InsertSymbol(rReq);
     395           0 :             break;
     396             :         }
     397             :             case FN_INSERT_STRING:
     398             :                 {
     399           0 :             const SfxPoolItem* pItem = 0;
     400           0 :             if(pNewAttrs)
     401           0 :                 pNewAttrs->GetItemState(nSlot, sal_False, &pItem );
     402           0 :                         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
     403           0 :                                 pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue());
     404           0 :                         break;
     405             :                 }
     406             : 
     407             :         case FN_FORMAT_FOOTNOTE_DLG:
     408             :         {
     409           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     410             :             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     411             : 
     412           0 :             VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(rView.GetWindow(), rView.GetWrtShell());
     413             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     414           0 :             pDlg->Execute();
     415           0 :             delete pDlg;
     416           0 :             break;
     417             :         }
     418             :         case FN_NUMBERING_OUTLINE_DLG:
     419             :         {
     420           0 :             SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
     421           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     422             :             OSL_ENSURE(pFact, "Dialogdiet fail!");
     423             :             SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
     424           0 :                                                         rView.GetWindow(), &aTmp, rView.GetWrtShell());
     425             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     426           0 :             pDlg->Execute();
     427           0 :             delete pDlg;
     428           0 :             rReq.Done();
     429             :         }
     430           0 :         break;
     431             :         case SID_OPEN_XML_FILTERSETTINGS:
     432             :         {
     433             :             try
     434             :             {
     435           0 :                 uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
     436           0 :                 xDialog->execute();
     437             :             }
     438           0 :             catch (const uno::Exception&)
     439             :             {
     440             :                 DBG_UNHANDLED_EXCEPTION();
     441             :             }
     442           0 :             rReq.Ignore ();
     443             :         }
     444           0 :         break;
     445             :         case FN_WORDCOUNT_DIALOG:
     446             :         {
     447           0 :             SfxViewFrame* pVFrame = rView.GetViewFrame();
     448           0 :             if (pVFrame != NULL)
     449             :             {
     450           0 :                 pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
     451           0 :                 Invalidate(rReq.GetSlot());
     452             : 
     453           0 :                 SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
     454           0 :                 if (pWrdCnt)
     455           0 :                     pWrdCnt->UpdateCounts();
     456             :             }
     457             :         }
     458           0 :         break;
     459             :         case SID_CHAR_DLG_EFFECT:
     460             :         case SID_CHAR_DLG:
     461             :         {
     462           0 :             const SfxItemSet* pArgs = rReq.GetArgs();
     463             : 
     464           0 :             if( !pArgs )
     465             :             {
     466             :                 /* mod
     467             :                 SwView* pView = &GetView();
     468             :                 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
     469             :                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
     470             :                 */
     471           0 :                 SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END);
     472             : 
     473             :                 // util::Language does not exist in the EditEngine! Therefore not included in the set.
     474             : 
     475           0 :                 aDlgAttr.Put( aEditAttr );
     476           0 :                 aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) );
     477             : 
     478           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     479             :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     480             : 
     481           0 :                 SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( rView.GetWindow(), rView, aDlgAttr, 0, sal_True );
     482             :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     483           0 :                 if (nSlot == SID_CHAR_DLG_EFFECT)
     484             :                 {
     485           0 :                     pDlg->SetCurPageId(TP_CHAR_EXT);
     486             :                 }
     487           0 :                 sal_uInt16 nRet = pDlg->Execute();
     488           0 :                 if(RET_OK == nRet )
     489             :                 {
     490           0 :                     rReq.Done( *( pDlg->GetOutputItemSet() ) );
     491           0 :                     aNewAttr.Put(*pDlg->GetOutputItemSet());
     492             :                 }
     493           0 :                 delete( pDlg );
     494           0 :                 if(RET_OK != nRet)
     495           0 :                     return ;
     496             :             }
     497             :             else
     498           0 :                 aNewAttr.Put(*pArgs);
     499           0 :         break;
     500             :         }
     501             :         case SID_PARA_DLG:
     502             :         {
     503           0 :             const SfxItemSet* pArgs = rReq.GetArgs();
     504             : 
     505           0 :             if (!pArgs)
     506             :             {
     507             :                 /* mod todo ???
     508             :                 SwView* pView = &GetView();
     509             :                 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
     510             :                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
     511             :                 */
     512           0 :                 SfxItemSet aDlgAttr(GetPool(),
     513             :                                     EE_ITEMS_START, EE_ITEMS_END,
     514             :                                     SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
     515             :                                     SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT,
     516             :                                     SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS,
     517             :                                     SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS,
     518           0 :                                     0);
     519             : 
     520           0 :                 aDlgAttr.Put(aEditAttr);
     521             : 
     522             : 
     523           0 :                 aDlgAttr.Put( SvxHyphenZoneItem( sal_False, RES_PARATR_HYPHENZONE) );
     524           0 :                 aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) );
     525           0 :                 aDlgAttr.Put( SvxFmtSplitItem( sal_True, RES_PARATR_SPLIT ) );
     526           0 :                 aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
     527           0 :                 aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
     528             : 
     529             : 
     530           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     531             :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     532             : 
     533           0 :                 SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( rView.GetWindow(), rView, aDlgAttr,DLG_STD, DLG_PARA, 0, sal_True );
     534             :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     535           0 :                 sal_uInt16 nRet = pDlg->Execute();
     536           0 :                 if(RET_OK == nRet)
     537             :                 {
     538           0 :                     rReq.Done( *( pDlg->GetOutputItemSet() ) );
     539           0 :                     aNewAttr.Put(*pDlg->GetOutputItemSet());
     540             :                 }
     541           0 :                 delete( pDlg );
     542           0 :                 if(RET_OK != nRet)
     543           0 :                     return;
     544             :             }
     545             :             else
     546           0 :                 aNewAttr.Put(*pArgs);
     547           0 :             break;
     548             :         }
     549             : 
     550             :         case SID_AUTOSPELL_CHECK:
     551             :         {
     552           0 :             rView.ExecuteSlot(rReq);
     553           0 :             break;
     554             :         }
     555             :         case SID_ATTR_PARA_LEFT_TO_RIGHT:
     556             :         case SID_ATTR_PARA_RIGHT_TO_LEFT:
     557             :         {
     558           0 :             bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
     559             : 
     560             :             const SfxPoolItem* pPoolItem;
     561           0 :             if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, sal_True, &pPoolItem ) )
     562             :             {
     563           0 :                 if( !( (SfxBoolItem*)pPoolItem)->GetValue() )
     564           0 :                     bLeftToRight = !bLeftToRight;
     565             :             }
     566           0 :             SfxItemSet aAttr( *aNewAttr.GetPool(),
     567             :                         EE_PARA_JUST, EE_PARA_JUST,
     568             :                         EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
     569           0 :                         0 );
     570             : 
     571           0 :             sal_uInt16 nAdjust = SVX_ADJUST_LEFT;
     572           0 :             if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, sal_True, &pPoolItem ) )
     573           0 :                 nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue();
     574             : 
     575           0 :             if( bLeftToRight )
     576             :             {
     577           0 :                 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
     578           0 :                 if( nAdjust == SVX_ADJUST_RIGHT )
     579           0 :                     aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
     580             :             }
     581             :             else
     582             :             {
     583           0 :                 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
     584           0 :                 if( nAdjust == SVX_ADJUST_LEFT )
     585           0 :                     aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
     586             :             }
     587           0 :             pOLV->SetAttribs(aAttr);
     588           0 :             break;
     589             :         }
     590             :     }
     591             : 
     592           0 :     if(nEEWhich && pNewAttrs)
     593           0 :         aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich);
     594             : 
     595           0 :     Rectangle aNullRect;
     596           0 :     Rectangle aOutRect = pOLV->GetOutputArea();
     597           0 :     if (aNullRect != aOutRect)
     598           0 :         pOLV->SetAttribs(aNewAttr);
     599             : 
     600           0 :     rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
     601           0 :     if ( pOLV->GetOutliner()->IsModified() )
     602           0 :         rView.GetWrtShell().SetModified();
     603             : 
     604             : }
     605             : 
     606           0 : void SwAnnotationShell::GetState(SfxItemSet& rSet)
     607             : {
     608             :     //TODO: clean this up!!!
     609             :     // FN_SET_SUPER_SCRIPT
     610             :     //SID_ATTR_PARA_ADJUST
     611             :     //SID_ATTR_PARA_ADJUST_BLOCK
     612             : 
     613           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
     614           0 :     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
     615           0 :         return;
     616             : 
     617           0 :     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
     618           0 :     SfxItemSet aEditAttr(pOLV->GetAttribs());
     619             : 
     620           0 :     SfxWhichIter aIter(rSet);
     621           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     622           0 :     while(nWhich)
     623             :     {
     624           0 :         sal_uInt16 nEEWhich = 0;
     625           0 :         sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
     626           0 :         switch( nSlotId )
     627             :         {
     628             :             case SID_ATTR_PARA_LRSPACE:
     629             :             {
     630           0 :                 SfxItemState eState = aEditAttr.GetItemState( EE_PARA_LRSPACE );
     631           0 :                 if( eState >= SFX_ITEM_DEFAULT )
     632             :                 {
     633           0 :                     SvxLRSpaceItem aLR = ( (const SvxLRSpaceItem&) aEditAttr.Get( EE_PARA_LRSPACE ) );
     634           0 :                     aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
     635           0 :                     rSet.Put(aLR);
     636             :                 }
     637             :                 else
     638           0 :                     rSet.InvalidateItem(nSlotId);
     639             :             }
     640           0 :             break;
     641             :             case SID_ATTR_PARA_LINESPACE:
     642             :             {
     643           0 :                 SfxItemState eState = aEditAttr.GetItemState( EE_PARA_SBL );
     644           0 :                 if( eState >= SFX_ITEM_DEFAULT )
     645             :                 {
     646           0 :                     SvxLineSpacingItem aLR = ( (const SvxLineSpacingItem&) aEditAttr.Get( EE_PARA_SBL ) );
     647           0 :                     rSet.Put(aLR);
     648             :                 }
     649             :                 else
     650           0 :                     rSet.InvalidateItem(nSlotId);
     651             :             }
     652           0 :             break;
     653             :             case SID_ATTR_PARA_ULSPACE:
     654             :                 {
     655           0 :                     SfxItemState eState = aEditAttr.GetItemState( EE_PARA_ULSPACE );
     656           0 :                     if( eState >= SFX_ITEM_DEFAULT )
     657             :                     {
     658           0 :                         SvxULSpaceItem aULSpace = (const SvxULSpaceItem&) aEditAttr.Get( EE_PARA_ULSPACE );
     659           0 :                         aULSpace.SetWhich(SID_ATTR_PARA_ULSPACE);
     660           0 :                         rSet.Put(aULSpace);
     661             :                     }
     662             :                     else
     663           0 :                         rSet.InvalidateItem(nSlotId);
     664             :                 }
     665           0 :                     break;
     666             :             case SID_ATTR_CHAR_FONT:
     667             :             case SID_ATTR_CHAR_FONTHEIGHT:
     668             :             case SID_ATTR_CHAR_WEIGHT:
     669             :             case SID_ATTR_CHAR_POSTURE:
     670             :                 {
     671           0 :                     if ( pOLV )
     672             :                     {
     673           0 :                         sal_uInt16 nScriptType = pOLV->GetSelectedScriptType();
     674           0 :                         SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool();
     675           0 :                         if( !pSecondPool )
     676           0 :                             pSecondPool = aEditAttr.GetPool();
     677           0 :                         SvxScriptSetItem aSetItem( nSlotId, *pSecondPool );
     678           0 :                         aSetItem.GetItemSet().Put( aEditAttr, sal_False );
     679           0 :                         const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
     680           0 :                         if( pI )
     681           0 :                             rSet.Put( *pI, nWhich );
     682             :                         else
     683           0 :                             rSet.InvalidateItem( nWhich );
     684             :                     }
     685             :                     else
     686           0 :                         rSet.InvalidateItem( nWhich );
     687             :                 }
     688           0 :                 break;
     689           0 :             case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
     690           0 :             case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
     691           0 :             case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break;
     692           0 :             case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
     693           0 :             case SID_ATTR_CHAR_SHADOWED:  nEEWhich = EE_CHAR_SHADOW;break;
     694           0 :             case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
     695           0 :             case SID_ATTR_CHAR_LANGUAGE    : nEEWhich = EE_CHAR_LANGUAGE;break;
     696           0 :             case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT;break;
     697           0 :             case SID_ATTR_CHAR_KERNING:  nEEWhich = EE_CHAR_KERNING;break;
     698             :             case FN_SET_SUPER_SCRIPT:
     699             :             case FN_SET_SUB_SCRIPT:
     700             :             {
     701           0 :                 sal_uInt16 nEsc = 0;
     702           0 :                 const SfxPoolItem *pEscItem = 0;
     703           0 :                 if (nWhich==FN_SET_SUPER_SCRIPT)
     704           0 :                     nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
     705             :                 else
     706           0 :                     nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
     707             : 
     708           0 :                 if( !pEscItem )
     709           0 :                     pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT );
     710             : 
     711           0 :                 if( nEsc == ((const SvxEscapementItem*)pEscItem)->GetEnumValue() )
     712           0 :                     rSet.Put( SfxBoolItem( nWhich, sal_True ));
     713             :                 else
     714           0 :                     rSet.InvalidateItem( nWhich );
     715           0 :                 break;
     716             :             }
     717             :             case SID_ATTR_PARA_ADJUST_LEFT:
     718             :             case SID_ATTR_PARA_ADJUST_RIGHT:
     719             :             case SID_ATTR_PARA_ADJUST_CENTER:
     720             :             case SID_ATTR_PARA_ADJUST_BLOCK:
     721             :                 {
     722           0 :                     const SfxPoolItem *pAdjust = 0;
     723           0 :                     int eAdjust = 0;
     724             : 
     725           0 :                     if (nWhich==SID_ATTR_PARA_ADJUST_LEFT)
     726           0 :                         eAdjust = SVX_ADJUST_LEFT;
     727           0 :                     else if (nWhich==SID_ATTR_PARA_ADJUST_RIGHT)
     728           0 :                         eAdjust = SVX_ADJUST_RIGHT;
     729           0 :                     else if (nWhich==SID_ATTR_PARA_ADJUST_CENTER)
     730           0 :                         eAdjust = SVX_ADJUST_CENTER;
     731           0 :                     else if (nWhich==SID_ATTR_PARA_ADJUST_BLOCK)
     732           0 :                         eAdjust = SVX_ADJUST_BLOCK;
     733             : 
     734           0 :                     if( !pAdjust )
     735           0 :                         aEditAttr.GetItemState( EE_PARA_JUST, sal_False, &pAdjust);
     736             : 
     737           0 :                     if( !pAdjust || IsInvalidItem( pAdjust ))
     738           0 :                         rSet.InvalidateItem( nSlotId ), nSlotId = 0;
     739             :                     else
     740             :                     {
     741           0 :                         if ( eAdjust == ((const SvxAdjustItem*)pAdjust)->GetAdjust())
     742           0 :                             rSet.Put( SfxBoolItem( nWhich, sal_True ));
     743             :                         else
     744           0 :                             rSet.InvalidateItem( nWhich );
     745             :                     }
     746           0 :                     break;
     747             :                 }
     748             :             case SID_ATTR_PARA_LINESPACE_10:
     749             :             case SID_ATTR_PARA_LINESPACE_15:
     750             :             case SID_ATTR_PARA_LINESPACE_20:
     751             :                 {
     752           0 :                     const SfxPoolItem *pLSpace = 0;
     753           0 :                     int nLSpace = 0;
     754             : 
     755           0 :                     if (nWhich==SID_ATTR_PARA_LINESPACE_10)
     756           0 :                         nLSpace = 100;
     757           0 :                     else if (nWhich==SID_ATTR_PARA_LINESPACE_15)
     758           0 :                         nLSpace = 150;
     759           0 :                     else if (nWhich==SID_ATTR_PARA_LINESPACE_20)
     760           0 :                         nLSpace = 200;
     761             : 
     762           0 :                     if( !pLSpace )
     763           0 :                         aEditAttr.GetItemState( EE_PARA_SBL, sal_False, &pLSpace );
     764             : 
     765           0 :                     if( !pLSpace || IsInvalidItem( pLSpace ))
     766           0 :                         rSet.InvalidateItem( nSlotId ), nSlotId = 0;
     767             :                     else
     768             :                     {
     769           0 :                         if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)->GetPropLineSpace() )
     770           0 :                             rSet.Put( SfxBoolItem( nWhich, sal_True ));
     771             :                         else
     772           0 :                             rSet.InvalidateItem( nWhich );
     773             :                     }
     774           0 :                     break;
     775             :                 }
     776             :             case SID_AUTOSPELL_CHECK:
     777             :             {
     778           0 :                 const SfxPoolItem* pState = rView.GetSlotState(nWhich);
     779           0 :                 if (pState)
     780           0 :                     rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue()));
     781             :                 else
     782           0 :                     rSet.DisableItem( nWhich );
     783           0 :                 break;
     784             :             }
     785             :             case SID_ATTR_PARA_LEFT_TO_RIGHT:
     786             :             case SID_ATTR_PARA_RIGHT_TO_LEFT:
     787             :             {
     788           0 :                 if ( !SvtLanguageOptions().IsCTLFontEnabled() )
     789           0 :                     rSet.DisableItem( nWhich );
     790             :                 else
     791             :                 {
     792           0 :                     if(pOLV->GetOutliner() && pOLV->GetOutliner()->IsVertical())
     793           0 :                         rSet.DisableItem( nWhich );
     794             :                     else
     795             :                     {
     796           0 :                         sal_Bool bFlag = sal_False;
     797           0 :                         switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() )
     798             :                         {
     799             :                             case FRMDIR_HORI_LEFT_TOP:
     800             :                             {
     801           0 :                                 bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
     802           0 :                                 rSet.Put( SfxBoolItem( nWhich, bFlag ));
     803           0 :                                 break;
     804             :                             }
     805             :                             case FRMDIR_HORI_RIGHT_TOP:
     806             :                             {
     807           0 :                                 bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
     808           0 :                                 rSet.Put( SfxBoolItem( nWhich, bFlag ));
     809           0 :                                 break;
     810             :                             }
     811             :                         }
     812             :                     }
     813             :                 }
     814             :             }
     815           0 :             break;
     816             :             case SID_INSERT_RLM :
     817             :             case SID_INSERT_LRM :
     818             :             case SID_INSERT_ZWNBSP :
     819             :             case SID_INSERT_ZWSP:
     820             :             {
     821           0 :                 SvtCTLOptions aCTLOptions;
     822           0 :                 sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled();
     823           0 :                 rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled );
     824           0 :                 if(!bEnabled)
     825           0 :                     rSet.DisableItem(nWhich);
     826             :             }
     827           0 :             break;
     828             :             default:
     829           0 :                 rSet.InvalidateItem( nWhich );
     830           0 :                 break;
     831             :         }
     832             : 
     833           0 :         if(nEEWhich)
     834             :         {
     835           0 :             rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich);
     836           0 :         if(nEEWhich == EE_CHAR_KERNING)
     837             :         {
     838           0 :             SfxItemState eState = aEditAttr.GetItemState( EE_CHAR_KERNING, sal_True );
     839           0 :             if ( eState == SFX_ITEM_DONTCARE )
     840             :             {
     841           0 :                 rSet.InvalidateItem(EE_CHAR_KERNING);
     842             :             }
     843             :         }
     844             :         }
     845             : 
     846           0 :         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
     847           0 :             rSet.DisableItem( nWhich );
     848             : 
     849           0 :         nWhich = aIter.NextWhich();
     850           0 :     }
     851             : }
     852             : 
     853           0 : void SwAnnotationShell::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
     854             : {
     855           0 :     rView.ExecSearch(rReq,bNoMessage);
     856           0 : }
     857             : 
     858           0 : void SwAnnotationShell::StateSearch(SfxItemSet &rSet)
     859             : {
     860           0 :     rView.StateSearch(rSet);
     861           0 : }
     862             : 
     863           0 : void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq)
     864             : {
     865           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
     866           0 :     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
     867           0 :         return;
     868             : 
     869           0 :     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
     870           0 :     SfxItemSet aEditAttr(pOLV->GetAttribs());
     871           0 :     SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
     872             : 
     873           0 :     long aOldHeight = pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight();
     874           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     875           0 :     switch (nSlot)
     876             :     {
     877             :         case SID_CUT:
     878           0 :             if ( (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) && pOLV->HasSelection() )
     879           0 :                 pOLV->Cut();
     880           0 :             break;
     881             :         case SID_COPY:
     882           0 :             if( pOLV->HasSelection() )
     883           0 :                 pOLV->Copy();
     884           0 :             break;
     885             :         case SID_PASTE:
     886           0 :             if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
     887           0 :                 pOLV->Paste();
     888           0 :             break;
     889             :         case SID_PASTE_SPECIAL:
     890             :         {
     891           0 :             if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
     892             :             {
     893           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     894           0 :                 SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( &rView.GetEditWin() );
     895             : 
     896           0 :                 pDlg->Insert( SOT_FORMAT_STRING, aEmptyStr );
     897           0 :                 pDlg->Insert( SOT_FORMAT_RTF,    aEmptyStr );
     898             : 
     899           0 :                 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) );
     900             : 
     901           0 :                 sal_uLong nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
     902             : 
     903           0 :                 if (nFormat > 0)
     904             :                 {
     905           0 :                     if (nFormat == SOT_FORMAT_STRING)
     906           0 :                         pOLV->Paste();
     907             :                     else
     908           0 :                         pOLV->PasteSpecial();
     909             :                 }
     910           0 :                 delete pDlg;
     911             :             }
     912           0 :             break;
     913             :         }
     914             :         case SID_CLIPBOARD_FORMAT_ITEMS:
     915             :         {
     916           0 :             sal_uLong nFormat = 0;
     917             :             const SfxPoolItem* pItem;
     918           0 :             if ( rReq.GetArgs() && rReq.GetArgs()->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
     919           0 :                                     pItem->ISA(SfxUInt32Item) )
     920             :             {
     921           0 :                 nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
     922             :             }
     923             : 
     924           0 :             if ( nFormat )
     925             :             {
     926           0 :                 if (SOT_FORMAT_STRING == nFormat)
     927           0 :                     pOLV->Paste();
     928             :                 else
     929           0 :                     pOLV->PasteSpecial();
     930             :             }
     931           0 :             break;
     932             :         }
     933             :     }
     934           0 :     pPostItMgr->GetActiveSidebarWin()->ResizeIfNeccessary(aOldHeight,pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight());
     935             : }
     936             : 
     937           0 : void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet)
     938             : {
     939           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
     940           0 :     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
     941           0 :         return;
     942           0 :     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
     943             : 
     944           0 :     TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) );
     945           0 :     bool bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
     946           0 :     bPastePossible = bPastePossible &&  (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED);
     947             : 
     948           0 :     SfxWhichIter aIter(rSet);
     949           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     950             : 
     951           0 :     while(nWhich)
     952             :     {
     953           0 :         switch(nWhich)
     954             :         {
     955             :             case SID_CUT:
     956             :             {
     957           0 :                 if ( (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) || !pOLV->HasSelection() )
     958           0 :                     rSet.DisableItem( nWhich );
     959             :             }
     960             :             case SID_COPY:
     961             :             {
     962           0 :                 if( !pOLV->HasSelection() )
     963           0 :                     rSet.DisableItem( nWhich );
     964           0 :                 break;
     965             :             }
     966             :             case SID_PASTE:
     967             :             case SID_PASTE_SPECIAL:
     968             :                 {
     969           0 :                     if( !bPastePossible )
     970           0 :                         rSet.DisableItem( nWhich );
     971           0 :                     break;
     972             :                 }
     973             :             case SID_CLIPBOARD_FORMAT_ITEMS:
     974             :                 {
     975           0 :                     if ( bPastePossible )
     976             :                     {
     977           0 :                         SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
     978           0 :                         if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
     979           0 :                             aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
     980           0 :                         aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
     981           0 :                         rSet.Put( aFormats );
     982             :                     }
     983             :                     else
     984           0 :                         rSet.DisableItem( nWhich );
     985           0 :                     break;
     986             :                 }
     987             :         }
     988           0 :         nWhich = aIter.NextWhich();
     989           0 :     }
     990             : }
     991             : 
     992           0 : void SwAnnotationShell::StateStatusLine(SfxItemSet &rSet)
     993             : {
     994           0 :     SfxWhichIter aIter( rSet );
     995           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     996             : 
     997           0 :     while( nWhich )
     998             :     {
     999           0 :         switch( nWhich )
    1000             :         {
    1001             :             case FN_STAT_SELMODE:
    1002             :             {
    1003           0 :                 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
    1004           0 :                 rSet.DisableItem( nWhich );
    1005           0 :                 break;
    1006             :             }
    1007             :             case FN_STAT_TEMPLATE:
    1008             :             {
    1009           0 :                 rSet.DisableItem( nWhich );
    1010           0 :                 break;
    1011             :             }
    1012             :         }
    1013           0 :         nWhich = aIter.NextWhich();
    1014           0 :     }
    1015           0 : }
    1016             : 
    1017           0 : void SwAnnotationShell::StateInsert(SfxItemSet &rSet)
    1018             : {
    1019           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
    1020           0 :     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
    1021           0 :         return;
    1022             : 
    1023           0 :     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
    1024           0 :     SfxWhichIter aIter(rSet);
    1025           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
    1026             : 
    1027           0 :     while(nWhich)
    1028             :     {
    1029           0 :         switch(nWhich)
    1030             :         {
    1031             :             case SID_HYPERLINK_GETLINK:
    1032             :                 {
    1033           0 :                     SvxHyperlinkItem aHLinkItem;
    1034           0 :                     aHLinkItem.SetInsertMode(HLINK_FIELD);
    1035             : 
    1036           0 :                     const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
    1037             : 
    1038           0 :                     if (pFieldItem)
    1039             :                     {
    1040           0 :                         const SvxFieldData* pField = pFieldItem->GetField();
    1041             : 
    1042           0 :                         if (pField->ISA(SvxURLField))
    1043             :                         {
    1044           0 :                             aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
    1045           0 :                             aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
    1046           0 :                             aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
    1047             :                         }
    1048             :                     }
    1049             :                     else
    1050             :                     {
    1051           0 :                         String sSel(pOLV->GetSelected());
    1052           0 :                         sSel.Erase(255);
    1053           0 :                         aHLinkItem.SetName(comphelper::string::stripEnd(sSel, ' '));
    1054             :                     }
    1055             : 
    1056           0 :                     sal_uInt16 nHtmlMode = ::GetHtmlMode(rView.GetDocShell());
    1057           0 :                     aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
    1058           0 :                         ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
    1059             : 
    1060           0 :                     rSet.Put(aHLinkItem);
    1061             :                 }
    1062           0 :                 break;
    1063             :         }
    1064             : 
    1065           0 :         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
    1066           0 :             rSet.DisableItem( nWhich );
    1067             : 
    1068           0 :         nWhich = aIter.NextWhich();
    1069           0 :     }
    1070             : }
    1071             : 
    1072             : 
    1073           0 : void SwAnnotationShell::NoteExec(SfxRequest &rReq)
    1074             : {
    1075           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
    1076           0 :     if ( !pPostItMgr )
    1077           0 :         return;
    1078             : 
    1079           0 :     sal_uInt16 nSlot = rReq.GetSlot();
    1080           0 :     switch (nSlot)
    1081             :     {
    1082             :         case FN_REPLY:
    1083             :         case FN_POSTIT:
    1084             :         case FN_DELETE_COMMENT:
    1085           0 :             if ( pPostItMgr->HasActiveSidebarWin() )
    1086           0 :                 pPostItMgr->GetActiveSidebarWin()->ExecuteCommand(nSlot);
    1087           0 :             break;
    1088             :         case FN_DELETE_ALL_NOTES:
    1089           0 :             pPostItMgr->Delete();
    1090           0 :             break;
    1091             :         case FN_DELETE_NOTE_AUTHOR:
    1092             :         {
    1093           0 :             SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, sal_False);
    1094           0 :             if ( pItem )
    1095           0 :                 pPostItMgr->Delete( pItem->GetValue() );
    1096           0 :             break;
    1097             :         }
    1098             :         case FN_HIDE_NOTE:
    1099           0 :             break;
    1100             :         case FN_HIDE_ALL_NOTES:
    1101           0 :             pPostItMgr->Hide();
    1102           0 :             break;
    1103             :         case FN_HIDE_NOTE_AUTHOR:
    1104             :         {
    1105           0 :             SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, sal_False);
    1106           0 :             if ( pItem )
    1107           0 :                 pPostItMgr->Hide( pItem->GetValue() );
    1108             :         }
    1109             :     }
    1110             : }
    1111             : 
    1112           0 : void SwAnnotationShell::GetNoteState(SfxItemSet &rSet)
    1113             : {
    1114           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
    1115           0 :     SfxWhichIter aIter(rSet);
    1116           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
    1117           0 :     while(nWhich)
    1118             :     {
    1119           0 :         sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
    1120           0 :         switch( nSlotId )
    1121             :         {
    1122             :             case FN_POSTIT:
    1123             :             case FN_DELETE_NOTE_AUTHOR:
    1124             :             case FN_DELETE_ALL_NOTES:
    1125             :             case FN_HIDE_NOTE:
    1126             :             case FN_HIDE_NOTE_AUTHOR:
    1127             :             case FN_HIDE_ALL_NOTES:
    1128             :             case FN_DELETE_COMMENT:
    1129             :             {
    1130           0 :                 if ( !pPostItMgr ||
    1131           0 :                      !pPostItMgr->HasActiveAnnotationWin() )
    1132             :                 {
    1133           0 :                     rSet.DisableItem(nWhich);
    1134             :                 }
    1135           0 :                 break;
    1136             :             }
    1137             :             case FN_REPLY:
    1138             :             {
    1139           0 :                 if ( !pPostItMgr ||
    1140           0 :                      !pPostItMgr->HasActiveAnnotationWin() )
    1141             :                 {
    1142           0 :                     rSet.DisableItem(nWhich);
    1143             :                 }
    1144             :                 else
    1145             :                 {
    1146           0 :                     SvtUserOptions aUserOpt;
    1147           0 :                     String sAuthor;
    1148           0 :                     if( !(sAuthor = aUserOpt.GetFullName()).Len())
    1149           0 :                             if( !(sAuthor = aUserOpt.GetID()).Len() )
    1150           0 :                         sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR ));
    1151           0 :                     if (sAuthor == pPostItMgr->GetActiveSidebarWin()->GetAuthor())
    1152           0 :                         rSet.DisableItem(nWhich);
    1153             :                 }
    1154           0 :                 break;
    1155             :             }
    1156             :             default:
    1157           0 :                 rSet.InvalidateItem( nWhich );
    1158           0 :                 break;
    1159             :         }
    1160             : 
    1161           0 :         if (pPostItMgr->HasActiveSidebarWin())
    1162             :         {
    1163           0 :             if ( (pPostItMgr->GetActiveSidebarWin()->IsProtected()) &&
    1164           0 :                     ( (nSlotId==FN_DELETE_COMMENT) || (nSlotId==FN_REPLY) ) )
    1165           0 :                 rSet.DisableItem( nWhich );
    1166             :         }
    1167           0 :         nWhich = aIter.NextWhich();
    1168           0 :     }
    1169           0 : }
    1170             : 
    1171           0 : void SwAnnotationShell::ExecLingu(SfxRequest &rReq)
    1172             : {
    1173           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
    1174           0 :     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
    1175           0 :         return;
    1176             : 
    1177           0 :     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
    1178           0 :     SfxItemSet aEditAttr(pOLV->GetAttribs());
    1179           0 :     sal_uInt16 nSlot = rReq.GetSlot();
    1180           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    1181           0 :     bool bRestoreSelection = false;
    1182           0 :     ESelection aOldSelection;
    1183             : 
    1184           0 :     switch (nSlot)
    1185             :     {
    1186             :         case SID_LANGUAGE_STATUS:
    1187             :         {
    1188           0 :             aOldSelection = pOLV->GetSelection();
    1189           0 :             if (!pOLV->GetEditView().HasSelection())
    1190             :             {
    1191           0 :                 bRestoreSelection   = true;
    1192           0 :                 pOLV->GetEditView().SelectCurrentWord();
    1193             :             }
    1194             : 
    1195           0 :             bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,rView,rSh);
    1196           0 :             break;
    1197             :         }
    1198             :         case SID_THES:
    1199             :         {
    1200           0 :             String aReplaceText;
    1201           0 :             SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False );
    1202           0 :             if (pItem2)
    1203           0 :                 aReplaceText = pItem2->GetValue();
    1204           0 :             if (aReplaceText.Len() > 0)
    1205           0 :                 ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
    1206           0 :             break;
    1207             :         }
    1208             :         case SID_THESAURUS:
    1209             :         {
    1210           0 :             pOLV->StartThesaurus();
    1211           0 :             break;
    1212             :         }
    1213             :         case SID_HANGUL_HANJA_CONVERSION:
    1214             :             pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
    1215           0 :                     i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True, sal_False );
    1216           0 :             break;
    1217             : 
    1218             :         case SID_CHINESE_CONVERSION:
    1219             :         {
    1220             :                 //open ChineseTranslationDialog
    1221             :                 Reference< XComponentContext > xContext(
    1222           0 :                     ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
    1223           0 :                 if(xContext.is())
    1224             :                 {
    1225           0 :                     Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
    1226           0 :                     if(xMCF.is())
    1227             :                     {
    1228             :                         Reference< ui::dialogs::XExecutableDialog > xDialog(
    1229           0 :                                 xMCF->createInstanceWithContext(
    1230             :                                     OUString("com.sun.star.linguistic2.ChineseTranslationDialog")
    1231           0 :                                     , xContext), UNO_QUERY);
    1232           0 :                         Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
    1233           0 :                         if( xInit.is() )
    1234             :                         {
    1235             :                             //  initialize dialog
    1236           0 :                             Reference< awt::XWindow > xDialogParentWindow(0);
    1237           0 :                             Sequence<Any> aSeq(1);
    1238           0 :                             Any* pArray = aSeq.getArray();
    1239           0 :                             PropertyValue aParam;
    1240           0 :                             aParam.Name = OUString("ParentWindow");
    1241           0 :                             aParam.Value <<= makeAny(xDialogParentWindow);
    1242           0 :                             pArray[0] <<= makeAny(aParam);
    1243           0 :                             xInit->initialize( aSeq );
    1244             : 
    1245             :                             //execute dialog
    1246           0 :                             sal_Int16 nDialogRet = xDialog->execute();
    1247           0 :                             if( RET_OK == nDialogRet )
    1248             :                             {
    1249             :                                 //get some parameters from the dialog
    1250           0 :                                 sal_Bool bToSimplified = sal_True;
    1251           0 :                                 sal_Bool bUseVariants = sal_True;
    1252           0 :                                 sal_Bool bCommonTerms = sal_True;
    1253           0 :                                 Reference< beans::XPropertySet >  xProp( xDialog, UNO_QUERY );
    1254           0 :                                 if( xProp.is() )
    1255             :                                 {
    1256             :                                     try
    1257             :                                     {
    1258           0 :                                         xProp->getPropertyValue( "IsDirectionToSimplified" ) >>= bToSimplified;
    1259           0 :                                         xProp->getPropertyValue( "IsUseCharacterVariants" ) >>= bUseVariants;
    1260           0 :                                         xProp->getPropertyValue( "IsTranslateCommonTerms" ) >>= bCommonTerms;
    1261             :                                     }
    1262           0 :                                     catch (const Exception&)
    1263             :                                     {
    1264             :                                     }
    1265             :                                 }
    1266             : 
    1267             :                                 //execute translation
    1268           0 :                                 sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
    1269           0 :                                 sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
    1270           0 :                                 sal_Int32 nOptions    = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
    1271           0 :                                 if( !bCommonTerms )
    1272           0 :                                     nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
    1273             : 
    1274           0 :                                 Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT,
    1275           0 :                                             nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
    1276             : 
    1277           0 :                                 pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False, sal_False );
    1278           0 :                             }
    1279             :                         }
    1280           0 :                         Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
    1281           0 :                         if( xComponent.is() )
    1282           0 :                             xComponent->dispose();
    1283           0 :                     }
    1284           0 :                 }
    1285             :             }
    1286           0 :             break;
    1287             :     }
    1288             : 
    1289           0 :     if (bRestoreSelection)
    1290             :     {
    1291             :         // restore selection
    1292           0 :         pOLV->GetEditView().SetSelection( aOldSelection );
    1293           0 :     }
    1294             : }
    1295             : 
    1296           0 : void SwAnnotationShell::GetLinguState(SfxItemSet &rSet)
    1297             : {
    1298           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
    1299           0 :     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
    1300           0 :         return;
    1301             : 
    1302           0 :     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
    1303           0 :     SfxItemSet aEditAttr(pOLV->GetAttribs());
    1304             : 
    1305           0 :     SfxWhichIter aIter(rSet);
    1306           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
    1307           0 :     while(nWhich)
    1308             :     {
    1309           0 :         switch (nWhich)
    1310             :         {
    1311             :             case SID_LANGUAGE_STATUS:
    1312             :             {
    1313           0 :                 SwLangHelper::GetLanguageStatus(pOLV,rSet);
    1314           0 :                 break;
    1315             :             }
    1316             : 
    1317             :             case SID_THES:
    1318             :             {
    1319           0 :                 String          aStatusVal;
    1320           0 :                 LanguageType    nLang = LANGUAGE_NONE;
    1321           0 :                 bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() );
    1322           0 :                 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
    1323             : 
    1324             :                 // disable "Thesaurus" context menu entry if there is nothing to look up
    1325           0 :                 uno::Reference< linguistic2::XThesaurus >  xThes( ::GetThesaurus() );
    1326           0 :                 if (!bIsLookUpWord ||
    1327           0 :                     !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( LanguageTag( nLang ).getLocale() ))
    1328           0 :                     rSet.DisableItem( SID_THES );
    1329           0 :                 break;
    1330             :             }
    1331             : 
    1332             :             // disable "Thesaurus" if the language is not supported
    1333             :             case SID_THESAURUS:
    1334             :             {
    1335           0 :                 const SfxPoolItem &rItem = rView.GetWrtShell().GetDoc()->GetDefault(
    1336             :                             GetWhichOfScript( RES_CHRATR_LANGUAGE,
    1337           0 :                             GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage())) );
    1338             :                 LanguageType nLang = ((const SvxLanguageItem &)
    1339           0 :                                                         rItem).GetLanguage();
    1340           0 :                 uno::Reference< linguistic2::XThesaurus >  xThes( ::GetThesaurus() );
    1341           0 :                 if (!xThes.is() || nLang == LANGUAGE_NONE ||
    1342           0 :                     !xThes->hasLocale( LanguageTag( nLang ).getLocale() ))
    1343           0 :                     rSet.DisableItem( SID_THESAURUS );
    1344             :             }
    1345           0 :             break;
    1346             :             case SID_HANGUL_HANJA_CONVERSION:
    1347             :             case SID_CHINESE_CONVERSION:
    1348             :             {
    1349           0 :                 if (!SvtCJKOptions().IsAnyEnabled())
    1350             :                 {
    1351           0 :                     rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
    1352           0 :                     rSet.DisableItem(nWhich);
    1353             :                 }
    1354             :                 else
    1355           0 :                     rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
    1356             :             }
    1357           0 :             break;
    1358             :         }
    1359             : 
    1360           0 :         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
    1361           0 :             rSet.DisableItem( nWhich );
    1362             : 
    1363           0 :         nWhich = aIter.NextWhich();
    1364           0 :     }
    1365             : }
    1366             : 
    1367           0 : void SwAnnotationShell::ExecTransliteration(SfxRequest &rReq)
    1368             : {
    1369           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
    1370           0 :     if (!pPostItMgr || !pPostItMgr->HasActiveSidebarWin())
    1371           0 :         return;
    1372             : 
    1373           0 :     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
    1374             : 
    1375           0 :     if (!pOLV)
    1376           0 :         return;
    1377             : 
    1378             :     using namespace ::com::sun::star::i18n;
    1379             : 
    1380           0 :     sal_uInt32 nMode = 0;
    1381             : 
    1382           0 :     switch( rReq.GetSlot() )
    1383             :     {
    1384             :         case SID_TRANSLITERATE_SENTENCE_CASE:
    1385           0 :             nMode = TransliterationModulesExtra::SENTENCE_CASE;
    1386           0 :             break;
    1387             :         case SID_TRANSLITERATE_TITLE_CASE:
    1388           0 :             nMode = TransliterationModulesExtra::TITLE_CASE;
    1389           0 :             break;
    1390             :         case SID_TRANSLITERATE_TOGGLE_CASE:
    1391           0 :             nMode = TransliterationModulesExtra::TOGGLE_CASE;
    1392           0 :             break;
    1393             :         case SID_TRANSLITERATE_UPPER:
    1394           0 :             nMode = TransliterationModules_LOWERCASE_UPPERCASE;
    1395           0 :             break;
    1396             :         case SID_TRANSLITERATE_LOWER:
    1397           0 :             nMode = TransliterationModules_UPPERCASE_LOWERCASE;
    1398           0 :             break;
    1399             :         case SID_TRANSLITERATE_HALFWIDTH:
    1400           0 :             nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
    1401           0 :             break;
    1402             :         case SID_TRANSLITERATE_FULLWIDTH:
    1403           0 :             nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
    1404           0 :             break;
    1405             :         case SID_TRANSLITERATE_HIRAGANA:
    1406           0 :             nMode = TransliterationModules_KATAKANA_HIRAGANA;
    1407           0 :             break;
    1408             :         case SID_TRANSLITERATE_KATAGANA:
    1409           0 :             nMode = TransliterationModules_HIRAGANA_KATAKANA;
    1410           0 :             break;
    1411             : 
    1412             :         default:
    1413             :             OSL_ENSURE(!this, "wrong dispatcher");
    1414             :     }
    1415             : 
    1416           0 :     if( nMode )
    1417           0 :         pOLV->TransliterateText( nMode );
    1418             : }
    1419             : 
    1420           0 : void SwAnnotationShell::ExecRotateTransliteration( SfxRequest & rReq )
    1421             : {
    1422           0 :     if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
    1423             :     {
    1424           0 :         SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
    1425           0 :         if (!pPostItMgr || !pPostItMgr->HasActiveSidebarWin())
    1426           0 :             return;
    1427             : 
    1428           0 :         OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
    1429             : 
    1430           0 :         if (!pOLV)
    1431           0 :             return;
    1432             : 
    1433           0 :         pOLV->TransliterateText(m_aRotateCase.getNextMode());
    1434             :     }
    1435             : }
    1436             : 
    1437           0 : void SwAnnotationShell::ExecUndo(SfxRequest &rReq)
    1438             : {
    1439           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
    1440           0 :     ::svl::IUndoManager* pUndoManager = GetUndoManager();
    1441           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    1442             : 
    1443           0 :     long aOldHeight = rView.GetPostItMgr()->HasActiveSidebarWin()
    1444           0 :                       ? rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight()
    1445           0 :                       : 0;
    1446             : 
    1447           0 :     sal_uInt16 nId = rReq.GetSlot();
    1448           0 :     sal_uInt16 nCnt = 1;
    1449           0 :     const SfxPoolItem* pItem=0;
    1450           0 :     if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, sal_False, &pItem ) )
    1451           0 :         nCnt = ((SfxUInt16Item*)pItem)->GetValue();
    1452           0 :     switch( nId )
    1453             :     {
    1454             :         case SID_UNDO:
    1455             :         {
    1456           0 :             if ( pUndoManager )
    1457             :             {
    1458           0 :                 sal_uInt16 nCount = pUndoManager->GetUndoActionCount();
    1459           0 :                 sal_uInt16 nSteps = nCnt;
    1460           0 :                 if ( nCount < nCnt )
    1461             :                 {
    1462           0 :                     nCnt = nCnt - nCount;
    1463           0 :                     nSteps = nCount;
    1464             :                 }
    1465             :                 else
    1466           0 :                     nCnt = 0;
    1467             : 
    1468           0 :                 while( nSteps-- )
    1469           0 :                     pUndoManager->Undo();
    1470             :             }
    1471             : 
    1472           0 :             if ( nCnt )
    1473           0 :                 rSh.Do( SwWrtShell::UNDO, nCnt );
    1474             : 
    1475           0 :             break;
    1476             :         }
    1477             : 
    1478             :         case SID_REDO:
    1479             :         {
    1480           0 :             if ( pUndoManager )
    1481             :             {
    1482           0 :                 sal_uInt16 nCount = pUndoManager->GetRedoActionCount();
    1483           0 :                 sal_uInt16 nSteps = nCnt;
    1484           0 :                 if ( nCount < nCnt )
    1485             :                 {
    1486           0 :                     nCnt = nCnt - nCount;
    1487           0 :                     nSteps = nCount;
    1488             :                 }
    1489             :                 else
    1490           0 :                     nCnt = 0;
    1491             : 
    1492           0 :                 while( nSteps-- )
    1493           0 :                     pUndoManager->Redo();
    1494             :             }
    1495             : 
    1496           0 :             if ( nCnt )
    1497           0 :                 rSh.Do( SwWrtShell::REDO, nCnt );
    1498             : 
    1499           0 :             break;
    1500             :         }
    1501             :     }
    1502             : 
    1503           0 :     rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
    1504             : 
    1505           0 :     if (rView.GetPostItMgr()->HasActiveSidebarWin())
    1506           0 :         rView.GetPostItMgr()->GetActiveSidebarWin()->ResizeIfNeccessary(aOldHeight,rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight());
    1507           0 : }
    1508             : 
    1509           0 : void SwAnnotationShell::StateUndo(SfxItemSet &rSet)
    1510             : {
    1511           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
    1512           0 :     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
    1513           0 :         return;
    1514             : 
    1515           0 :     SfxWhichIter aIter(rSet);
    1516           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
    1517           0 :     ::svl::IUndoManager* pUndoManager = GetUndoManager();
    1518           0 :     SfxViewFrame *pSfxViewFrame = rView.GetViewFrame();
    1519           0 :     SwWrtShell &rSh = rView.GetWrtShell();
    1520             : 
    1521           0 :     while( nWhich )
    1522             :     {
    1523           0 :         switch ( nWhich )
    1524             :         {
    1525             :         case SID_UNDO:
    1526             :             {
    1527           0 :                 sal_uInt16 nCount = pUndoManager->GetUndoActionCount();
    1528           0 :                 if ( nCount )
    1529           0 :                     pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
    1530           0 :                 else if (rSh.GetLastUndoInfo(0, 0))
    1531             :                 {
    1532           0 :                     rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) );
    1533             :                 }
    1534             :                 else
    1535           0 :                     rSet.DisableItem(nWhich);
    1536           0 :                 break;
    1537             :             }
    1538             :         case SID_REDO:
    1539             :             {
    1540           0 :                 sal_uInt16 nCount = pUndoManager->GetRedoActionCount();
    1541           0 :                 if ( nCount )
    1542           0 :                     pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
    1543           0 :                 else if (rSh.GetFirstRedoInfo(0))
    1544             :                 {
    1545           0 :                     rSet.Put(SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::REDO)) );
    1546             :                 }
    1547             :                 else
    1548           0 :                     rSet.DisableItem(nWhich);
    1549           0 :                 break;
    1550             :             }
    1551             :         case SID_GETUNDOSTRINGS:
    1552             :         case SID_GETREDOSTRINGS:
    1553             :             {
    1554           0 :                 if( pUndoManager )
    1555             :                 {
    1556             :                     OUString (::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const;
    1557             : 
    1558             :                     sal_uInt16 nCount;
    1559           0 :                     if( SID_GETUNDOSTRINGS == nWhich )
    1560             :                     {
    1561           0 :                         nCount = pUndoManager->GetUndoActionCount();
    1562           0 :                         fnGetComment = &::svl::IUndoManager::GetUndoActionComment;
    1563             :                     }
    1564             :                     else
    1565             :                     {
    1566           0 :                         nCount = pUndoManager->GetRedoActionCount();
    1567           0 :                         fnGetComment = &::svl::IUndoManager::GetRedoActionComment;
    1568             :                     }
    1569             : 
    1570           0 :                     OUString sList;
    1571           0 :                     if( nCount )
    1572             :                     {
    1573           0 :                         for( sal_uInt16 n = 0; n < nCount; ++n )
    1574           0 :                             sList += (pUndoManager->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) + "\n";
    1575             :                     }
    1576             : 
    1577           0 :                     SfxStringListItem aItem( nWhich );
    1578           0 :                     if ((nWhich == SID_GETUNDOSTRINGS) &&
    1579           0 :                         rSh.GetLastUndoInfo(0, 0))
    1580             :                     {
    1581           0 :                         rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
    1582             :                     }
    1583           0 :                     else if ((nWhich == SID_GETREDOSTRINGS) &&
    1584           0 :                              (rSh.GetFirstRedoInfo(0)))
    1585             :                     {
    1586           0 :                         rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
    1587             :                     }
    1588             : 
    1589           0 :                     sList += aItem.GetString();
    1590           0 :                     aItem.SetString( sList );
    1591           0 :                     rSet.Put( aItem );
    1592             :                 }
    1593             :                 else
    1594           0 :                     rSet.DisableItem( nWhich );
    1595             :             }
    1596           0 :             break;
    1597             : 
    1598             :         default:
    1599             :             {
    1600           0 :                 pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
    1601           0 :                 break;
    1602             :             }
    1603             : 
    1604             :         }
    1605             : 
    1606           0 :         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
    1607           0 :             rSet.DisableItem( nWhich );
    1608             : 
    1609           0 :         nWhich = aIter.NextWhich();
    1610           0 :     }
    1611             : }
    1612             : 
    1613           0 : void SwAnnotationShell::StateDisableItems( SfxItemSet &rSet )
    1614             : {
    1615           0 :     SfxWhichIter aIter(rSet);
    1616           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
    1617           0 :     while (nWhich)
    1618             :     {
    1619           0 :         rSet.DisableItem( nWhich );
    1620           0 :         nWhich = aIter.NextWhich();
    1621           0 :     }
    1622           0 : }
    1623             : 
    1624           0 : void SwAnnotationShell::InsertSymbol(SfxRequest& rReq)
    1625             : {
    1626           0 :     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
    1627           0 :     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
    1628           0 :         return;
    1629             : 
    1630           0 :     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
    1631             : 
    1632           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
    1633           0 :     const SfxPoolItem* pItem = 0;
    1634           0 :     if( pArgs )
    1635           0 :         pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem);
    1636             : 
    1637           0 :     String sSym;
    1638           0 :     String sFontName;
    1639           0 :     if ( pItem )
    1640             :     {
    1641           0 :         sSym = ((const SfxStringItem*)pItem)->GetValue();
    1642           0 :         const SfxPoolItem* pFtItem = NULL;
    1643           0 :         pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem);
    1644           0 :         const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
    1645           0 :         if ( pFontItem )
    1646           0 :             sFontName = pFontItem->GetValue();
    1647             :     }
    1648             : 
    1649           0 :     SfxItemSet aSet(pOLV->GetAttribs());
    1650           0 :     sal_uInt16 nScript = pOLV->GetSelectedScriptType();
    1651           0 :     SvxFontItem aSetDlgFont( RES_CHRATR_FONT );
    1652             :     {
    1653           0 :         SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
    1654           0 :         aSetItem.GetItemSet().Put( aSet, sal_False );
    1655           0 :         const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
    1656           0 :         if( pI )
    1657           0 :             aSetDlgFont = *(SvxFontItem*)pI;
    1658             :         else
    1659             :             aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
    1660             :                         SID_ATTR_CHAR_FONT,
    1661           0 :                         GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
    1662           0 :         if (!sFontName.Len())
    1663           0 :             sFontName = aSetDlgFont.GetFamilyName();
    1664             :     }
    1665             : 
    1666           0 :     Font aFont(sFontName, Size(1,1));
    1667           0 :     if( !sSym.Len() )
    1668             :     {
    1669           0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    1670             : 
    1671           0 :         SfxAllItemSet aAllSet( GetPool() );
    1672           0 :         aAllSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) );
    1673             : 
    1674           0 :         SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions());
    1675           0 :         String sSymbolFont = aOpt.GetSymbolFont();
    1676           0 :         if( sSymbolFont.Len() )
    1677           0 :             aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
    1678             :         else
    1679           0 :             aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) );
    1680             : 
    1681             :         // If character is selected then it can be shown.
    1682             :         SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet,
    1683           0 :             rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
    1684             : 
    1685           0 :         sal_uInt16 nResult = pDlg->Execute();
    1686           0 :         if( nResult == RET_OK )
    1687             :         {
    1688           0 :             SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, sal_False );
    1689           0 :             SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False );
    1690           0 :             if ( pFontItem )
    1691             :             {
    1692           0 :                 aFont.SetName( pFontItem->GetFamilyName() );
    1693           0 :                 aFont.SetStyleName( pFontItem->GetStyleName() );
    1694           0 :                 aFont.SetCharSet( pFontItem->GetCharSet() );
    1695           0 :                 aFont.SetPitch( pFontItem->GetPitch() );
    1696             :             }
    1697             : 
    1698           0 :             if ( pCItem )
    1699             :             {
    1700           0 :                 sSym  = pCItem->GetValue();
    1701           0 :                 aOpt.SetSymbolFont(aFont.GetName());
    1702           0 :                 SW_MOD()->ApplyUsrPref(aOpt, &rView);
    1703             :             }
    1704             :         }
    1705             : 
    1706           0 :         delete( pDlg );
    1707             :     }
    1708             : 
    1709           0 :     if( sSym.Len() )
    1710             :     {
    1711             :         // do not flicker
    1712           0 :         pOLV->HideCursor();
    1713           0 :         Outliner * pOutliner = pOLV->GetOutliner();
    1714           0 :         pOutliner->SetUpdateMode(sal_False);
    1715             : 
    1716           0 :         SfxItemSet aOldSet( pOLV->GetAttribs() );
    1717           0 :         SfxItemSet aFontSet( *aOldSet.GetPool(),
    1718             :                             EE_CHAR_FONTINFO, EE_CHAR_FONTINFO,
    1719             :                             EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK,
    1720             :                             EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL,
    1721           0 :                             0 );
    1722           0 :         aFontSet.Set( aOldSet );
    1723             : 
    1724             :         // Insert string
    1725           0 :         pOLV->InsertText( sSym);
    1726             : 
    1727             :         // Attributing (set font)
    1728           0 :         SfxItemSet aSetFont( *aFontSet.GetPool(), aFontSet.GetRanges() );
    1729           0 :         SvxFontItem aFontItem (aFont.GetFamily(),    aFont.GetName(),
    1730           0 :                                 aFont.GetStyleName(), aFont.GetPitch(),
    1731           0 :                                 aFont.GetCharSet(),
    1732           0 :                                 EE_CHAR_FONTINFO );
    1733           0 :         sal_uInt16 nScriptBreak = g_pBreakIt->GetAllScriptsOfText( sSym );
    1734           0 :         if( SCRIPTTYPE_LATIN & nScriptBreak )
    1735           0 :             aSetFont.Put( aFontItem, EE_CHAR_FONTINFO );
    1736           0 :         if( SCRIPTTYPE_ASIAN & nScriptBreak )
    1737           0 :             aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CJK );
    1738           0 :         if( SCRIPTTYPE_COMPLEX & nScriptBreak )
    1739           0 :             aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CTL );
    1740           0 :         pOLV->SetAttribs(aSetFont);
    1741             : 
    1742             :         // Erase selection
    1743           0 :         ESelection aSel(pOLV->GetSelection());
    1744           0 :         aSel.nStartPara = aSel.nEndPara;
    1745           0 :         aSel.nStartPos = aSel.nEndPos;
    1746           0 :         pOLV->SetSelection(aSel);
    1747             : 
    1748             :         // Restore old font
    1749           0 :         pOLV->SetAttribs( aFontSet );
    1750             : 
    1751             :         // From now on show it again
    1752           0 :         pOutliner->SetUpdateMode(sal_True);
    1753           0 :         pOLV->ShowCursor();
    1754             : 
    1755           0 :         rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) );
    1756           0 :         if(aFont.GetName().Len())
    1757           0 :             rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) );
    1758           0 :         rReq.Done();
    1759           0 :     }
    1760          99 : }
    1761             : 
    1762             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10