LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/shells - annotsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 843 0.7 %
Date: 2012-12-17 Functions: 6 33 18.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10