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

Generated by: LCOV version 1.10