LCOV - code coverage report
Current view: top level - sw/source/core/uibase/shells - txtattr.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 106 380 27.9 %
Date: 2014-04-11 Functions: 3 7 42.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <hintids.hxx>
      21             : 
      22             : #include <vcl/msgbox.hxx>
      23             : #include <svl/whiter.hxx>
      24             : #include <svl/stritem.hxx>
      25             : #include <svl/itemiter.hxx>
      26             : #include <svl/ctloptions.hxx>
      27             : #include <swmodule.hxx>
      28             : #include <sfx2/bindings.hxx>
      29             : #include <sfx2/request.hxx>
      30             : #include <editeng/fhgtitem.hxx>
      31             : #include <editeng/adjustitem.hxx>
      32             : #include <editeng/lspcitem.hxx>
      33             : #include <editeng/lrspitem.hxx>
      34             : #include <editeng/udlnitem.hxx>
      35             : #include <editeng/escapementitem.hxx>
      36             : #include <sfx2/htmlmode.hxx>
      37             : #include <editeng/scripttypeitem.hxx>
      38             : #include <editeng/frmdiritem.hxx>
      39             : #include "paratr.hxx"
      40             : 
      41             : #include <fmtinfmt.hxx>
      42             : #include <docsh.hxx>
      43             : #include <wrtsh.hxx>
      44             : #include <view.hxx>
      45             : #include <viewopt.hxx>
      46             : #include <uitool.hxx>
      47             : #include <textsh.hxx>
      48             : #include <num.hxx>
      49             : #include <swundo.hxx>
      50             : #include <fmtcol.hxx>
      51             : 
      52             : #include <cmdid.h>
      53             : #include <globals.h>
      54             : #include <shells.hrc>
      55             : #include <SwStyleNameMapper.hxx>
      56             : #include "swabstdlg.hxx"
      57             : #include "chrdlg.hrc"
      58             : const sal_uInt32 nFontInc = 40;      // 2pt
      59             : const sal_uInt32 nFontMaxSz = 19998; // 999.9pt
      60             : 
      61           0 : void SwTextShell::ExecCharAttr(SfxRequest &rReq)
      62             : {
      63           0 :     SwWrtShell &rSh = GetShell();
      64           0 :     const SfxItemSet  *pArgs   = rReq.GetArgs();
      65           0 :           int          eState = STATE_TOGGLE;
      66           0 :     sal_uInt16 nWhich = rReq.GetSlot();
      67             : 
      68           0 :     if(pArgs )
      69             :     {
      70             :         const SfxPoolItem* pItem;
      71           0 :         pArgs->GetItemState(nWhich, false, &pItem);
      72             :         eState =  ((const SfxBoolItem &) pArgs->
      73           0 :                                 Get( nWhich )).GetValue() ? STATE_ON : STATE_OFF;
      74             :     }
      75             : 
      76           0 :     SfxItemSet aSet( GetPool(), RES_CHRATR_BEGIN, RES_CHRATR_END-1 );
      77           0 :     if (STATE_TOGGLE == eState)
      78           0 :         rSh.GetCurAttr( aSet );
      79             : 
      80           0 :     switch ( nWhich )
      81             :     {
      82             :         case FN_SET_SUB_SCRIPT:
      83             :         case FN_SET_SUPER_SCRIPT:
      84             :         {
      85           0 :             SvxEscapement eEscape = SVX_ESCAPEMENT_SUBSCRIPT;
      86           0 :             switch (eState)
      87             :             {
      88             :             case STATE_TOGGLE:
      89             :             {
      90             :                 short nTmpEsc = ((const SvxEscapementItem&)
      91           0 :                             aSet.Get( RES_CHRATR_ESCAPEMENT )).GetEsc();
      92             :                 eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
      93             :                                 SVX_ESCAPEMENT_SUPERSCRIPT:
      94           0 :                                 SVX_ESCAPEMENT_SUBSCRIPT;
      95           0 :                 if( (nWhich == FN_SET_SUB_SCRIPT && nTmpEsc < 0) ||
      96           0 :                             (nWhich == FN_SET_SUPER_SCRIPT && nTmpEsc > 0) )
      97           0 :                     eEscape = SVX_ESCAPEMENT_OFF;
      98             : 
      99           0 :                 SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
     100           0 :                 if( nWhich == FN_SET_SUB_SCRIPT )
     101             :                     rBind.SetState( SfxBoolItem( FN_SET_SUPER_SCRIPT,
     102           0 :                                                                     false ) );
     103             :                 else
     104             :                     rBind.SetState( SfxBoolItem( FN_SET_SUB_SCRIPT,
     105           0 :                                                                     false ) );
     106             : 
     107             :             }
     108           0 :             break;
     109             :             case STATE_ON:
     110             :                 eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
     111             :                                 SVX_ESCAPEMENT_SUPERSCRIPT:
     112           0 :                                 SVX_ESCAPEMENT_SUBSCRIPT;
     113           0 :                 break;
     114             :             case STATE_OFF:
     115           0 :                 eEscape = SVX_ESCAPEMENT_OFF;
     116           0 :                 break;
     117             :             }
     118           0 :             SvxEscapementItem aEscape( eEscape, RES_CHRATR_ESCAPEMENT );
     119           0 :             if(eEscape == SVX_ESCAPEMENT_SUPERSCRIPT)
     120           0 :                 aEscape.GetEsc() = DFLT_ESC_AUTO_SUPER;
     121           0 :             else if(eEscape == SVX_ESCAPEMENT_SUBSCRIPT)
     122           0 :                 aEscape.GetEsc() = DFLT_ESC_AUTO_SUB;
     123           0 :             rSh.SetAttrItem( aEscape );
     124           0 :             rReq.AppendItem( aEscape );
     125           0 :             rReq.Done();
     126             :         }
     127           0 :         break;
     128             : 
     129             :         case FN_UPDATE_STYLE_BY_EXAMPLE:
     130           0 :             rSh.QuickUpdateStyle();
     131           0 :             rReq.Done();
     132           0 :             break;
     133             :         case FN_UNDERLINE_DOUBLE:
     134             :         {
     135             :             FontUnderline eUnderline =  ((const SvxUnderlineItem&)
     136           0 :                             aSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
     137           0 :             switch( eState )
     138             :             {
     139             :                 case STATE_TOGGLE:
     140             :                     eUnderline = eUnderline == UNDERLINE_DOUBLE ?
     141             :                         UNDERLINE_NONE :
     142           0 :                             UNDERLINE_DOUBLE;
     143           0 :                 break;
     144             :                 case STATE_ON:
     145           0 :                     eUnderline = UNDERLINE_DOUBLE;
     146           0 :                 break;
     147             :                 case STATE_OFF:
     148           0 :                     eUnderline = UNDERLINE_NONE;
     149           0 :                 break;
     150             :             }
     151           0 :             SvxUnderlineItem aUnderline(eUnderline, RES_CHRATR_UNDERLINE );
     152           0 :             rSh.SetAttrItem( aUnderline );
     153           0 :             rReq.AppendItem( aUnderline );
     154           0 :             rReq.Done();
     155             :         }
     156           0 :         break;
     157             :         case FN_REMOVE_DIRECT_CHAR_FORMATS:
     158           0 :             if( !rSh.HasReadonlySel() && rSh.IsEndPara())
     159           0 :                 rSh.DontExpandFmt();
     160           0 :         break;
     161             :         default:
     162             :             OSL_FAIL("wrong  dispatcher");
     163           0 :             return;
     164           0 :     }
     165             : }
     166             : 
     167           0 : void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq)
     168             : {
     169           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     170           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     171           0 :     bool bArgs = pArgs != 0 && pArgs->Count() > 0;
     172           0 :     SwWrtShell& rWrtSh = GetShell();
     173           0 :     SwTxtFmtColl* pColl = 0;
     174             : 
     175             :     // Is only set if the whole paragraph is selected and AutoUpdateFmt is set.
     176           0 :     if (rWrtSh.HasSelection() && rWrtSh.IsSelFullPara())
     177             :     {
     178           0 :         pColl = rWrtSh.GetCurTxtFmtColl();
     179           0 :         if ( pColl && !pColl->IsAutoUpdateFmt() )
     180           0 :             pColl = 0;
     181             :     }
     182           0 :     SfxItemPool& rPool = GetPool();
     183           0 :     sal_uInt16 nWhich = rPool.GetWhich( nSlot );
     184           0 :     switch (nSlot)
     185             :     {
     186             :         case FN_TXTATR_INET:
     187             :         // Special treatment of the PoolId of the SwFmtInetFmt
     188           0 :         if(bArgs)
     189             :         {
     190           0 :             const SfxPoolItem& rItem = pArgs->Get( nWhich );
     191             : 
     192           0 :             SwFmtINetFmt aINetFmt( (const SwFmtINetFmt&) rItem );
     193           0 :             if ( USHRT_MAX == aINetFmt.GetVisitedFmtId() )
     194             :             {
     195             :                 OSL_ENSURE( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected visited character format ID at hyperlink attribute" );
     196             :                 aINetFmt.SetVisitedFmtAndId(
     197           0 :                         aINetFmt.GetVisitedFmt(),
     198           0 :                         SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetVisitedFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ) );
     199             :             }
     200           0 :             if ( USHRT_MAX == aINetFmt.GetINetFmtId() )
     201             :             {
     202             :                 OSL_ENSURE( false, "<SwTextShell::ExecCharAttrArgs(..)> - unexpected unvisited character format ID at hyperlink attribute" );
     203             :                 aINetFmt.SetINetFmtAndId(
     204           0 :                         aINetFmt.GetINetFmt(),
     205           0 :                         SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetINetFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ) );
     206             :             }
     207             : 
     208           0 :             if ( pColl )
     209           0 :                 pColl->SetFmtAttr( aINetFmt );
     210             :             else
     211           0 :                 rWrtSh.SetAttrItem( aINetFmt );
     212           0 :             rReq.Done();
     213             :         }
     214           0 :         break;
     215             : 
     216             :         case FN_GROW_FONT_SIZE:
     217             :         case FN_SHRINK_FONT_SIZE:
     218             :         {
     219           0 :             SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool );
     220           0 :             rWrtSh.GetCurAttr( aSetItem.GetItemSet() );
     221           0 :             SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() );
     222             : 
     223           0 :             sal_uInt16 nScriptTypes = rWrtSh.GetScriptType();
     224             : 
     225             :             const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
     226           0 :                                         aSetItem.GetItemOfScript( nScriptTypes ) ) );
     227             : 
     228           0 :             if (pSize)
     229             :             {
     230           0 :                 SvxFontHeightItem aSize(*pSize);
     231             : 
     232           0 :                 sal_uInt32 nSize = aSize.GetHeight();
     233             : 
     234           0 :                 if ( nSlot == FN_GROW_FONT_SIZE && ( nSize += nFontInc ) > nFontMaxSz )
     235           0 :                     nSize = nFontMaxSz;
     236           0 :                 else if ( nSlot == FN_SHRINK_FONT_SIZE && ( nSize -= nFontInc ) < nFontInc )
     237           0 :                     nSize = nFontInc;
     238             : 
     239           0 :                 aSize.SetHeight( nSize );
     240           0 :                 aSetItem.PutItemForScriptType( nScriptTypes, aSize );
     241           0 :                 aAttrSet.Put( aSetItem.GetItemSet() );
     242             : 
     243           0 :                 if( pColl )
     244           0 :                     pColl->SetFmtAttr( aAttrSet );
     245             :                 else
     246           0 :                     rWrtSh.SetAttrSet( aAttrSet );
     247             :             }
     248             : 
     249           0 :             rReq.Done();
     250             :         }
     251           0 :         break;
     252             : 
     253             :         default:
     254             :             OSL_FAIL("wrong  dispatcher");
     255           0 :             return;
     256             :     }
     257             : }
     258             : 
     259           0 : void SwTextShell::ExecParaAttr(SfxRequest &rReq)
     260             : {
     261             :     SvxAdjust eAdjst;
     262             :     sal_uInt8 ePropL;
     263           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     264             : 
     265             :     // Get both attributes immediately isn't more expensive!!
     266           0 :     SfxItemSet aSet( GetPool(),
     267             :         RES_PARATR_LINESPACING, RES_PARATR_ADJUST,
     268             :         RES_FRAMEDIR, RES_FRAMEDIR,
     269           0 :         0 );
     270             : 
     271           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     272           0 :     switch (nSlot)
     273             :     {
     274             :         case SID_ATTR_PARA_ADJUST:
     275             :         {
     276           0 :             if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_PARATR_ADJUST) )
     277             :             {
     278           0 :                 const SvxAdjustItem& rAdj = (const SvxAdjustItem&) pArgs->Get(RES_PARATR_ADJUST);
     279           0 :                 SvxAdjustItem aAdj( rAdj.GetAdjust(), RES_PARATR_ADJUST );
     280           0 :                 if ( rAdj.GetAdjust() == SVX_ADJUST_BLOCK )
     281             :                 {
     282           0 :                     aAdj.SetLastBlock( rAdj.GetLastBlock() );
     283           0 :                     aAdj.SetOneWord( rAdj.GetOneWord() );
     284             :                 }
     285             : 
     286           0 :                 aSet.Put(aAdj);
     287             :             }
     288             :         }
     289           0 :         break;
     290           0 :         case SID_ATTR_PARA_ADJUST_LEFT:     eAdjst =  SVX_ADJUST_LEFT;      goto SET_ADJUST;
     291           0 :         case SID_ATTR_PARA_ADJUST_RIGHT:    eAdjst =  SVX_ADJUST_RIGHT;     goto SET_ADJUST;
     292           0 :         case SID_ATTR_PARA_ADJUST_CENTER:   eAdjst =  SVX_ADJUST_CENTER;    goto SET_ADJUST;
     293           0 :         case SID_ATTR_PARA_ADJUST_BLOCK:    eAdjst =  SVX_ADJUST_BLOCK;     goto SET_ADJUST;
     294             : SET_ADJUST:
     295             :         {
     296           0 :             aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST));
     297           0 :             rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), true ) );
     298             :         }
     299           0 :         break;
     300             : 
     301             :         case SID_ATTR_PARA_LINESPACE:
     302           0 :             if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) ))
     303             :             {
     304             :                 SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pArgs->Get(
     305           0 :                                                             GetPool().GetWhich(nSlot));
     306           0 :                 aSet.Put( aLineSpace );
     307             :             }
     308           0 :         break;
     309           0 :         case SID_ATTR_PARA_LINESPACE_10:    ePropL = 100;   goto SET_LINESPACE;
     310           0 :         case SID_ATTR_PARA_LINESPACE_15:    ePropL = 150;   goto SET_LINESPACE;
     311           0 :         case SID_ATTR_PARA_LINESPACE_20:    ePropL = 200;   goto SET_LINESPACE;
     312             : 
     313             : SET_LINESPACE:
     314             :         {
     315             : 
     316           0 :             SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
     317           0 :             aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
     318           0 :             if( 100 == ePropL )
     319           0 :                 aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
     320             :             else
     321           0 :                 aLineSpacing.SetPropLineSpace(ePropL);
     322           0 :             aSet.Put( aLineSpacing );
     323             :         }
     324           0 :         break;
     325             : 
     326             :         case SID_ATTR_PARA_LEFT_TO_RIGHT :
     327             :         case SID_ATTR_PARA_RIGHT_TO_LEFT :
     328             :         {
     329           0 :             SfxItemSet aAdjustSet( GetPool(),
     330           0 :                     RES_PARATR_ADJUST, RES_PARATR_ADJUST );
     331           0 :             GetShell().GetCurAttr(aAdjustSet);
     332           0 :             bool bChgAdjust = false;
     333           0 :             SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, false);
     334           0 :             if(eAdjustState  >= SFX_ITEM_DEFAULT)
     335             :             {
     336             :                 int eAdjust = (int)(( const SvxAdjustItem& )
     337           0 :                         aAdjustSet.Get(RES_PARATR_ADJUST)).GetAdjust();
     338           0 :                 bChgAdjust = (SVX_ADJUST_LEFT  == eAdjust  &&  SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) ||
     339           0 :                              (SVX_ADJUST_RIGHT == eAdjust  &&  SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot);
     340             :             }
     341             :             else
     342           0 :                 bChgAdjust = true;
     343             : 
     344             :             SvxFrameDirection eFrmDirection =
     345             :                     (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
     346           0 :                         FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
     347           0 :             aSet.Put( SvxFrameDirectionItem( eFrmDirection, RES_FRAMEDIR ) );
     348             : 
     349           0 :             if (bChgAdjust)
     350             :             {
     351             :                 SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
     352           0 :                         SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT;
     353           0 :                 SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST );
     354           0 :                 aSet.Put( aAdjust );
     355           0 :                 aAdjust.SetWhich(SID_ATTR_PARA_ADJUST);
     356           0 :                 GetView().GetViewFrame()->GetBindings().SetState( aAdjust );
     357             :                 // Toggle numbering alignment
     358           0 :                 const SwNumRule* pCurRule = GetShell().GetNumRuleAtCurrCrsrPos();
     359           0 :                 if( pCurRule )
     360             :                 {
     361           0 :                     SvxNumRule aRule = pCurRule->MakeSvxNumRule();
     362             : 
     363           0 :                     for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++)
     364             :                     {
     365           0 :                         SvxNumberFormat aFmt(aRule.GetLevel(i));
     366           0 :                         if(SVX_ADJUST_LEFT == aFmt.GetNumAdjust())
     367           0 :                             aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
     368             : 
     369           0 :                         else if(SVX_ADJUST_RIGHT == aFmt.GetNumAdjust())
     370           0 :                             aFmt.SetNumAdjust( SVX_ADJUST_LEFT );
     371             : 
     372           0 :                         aRule.SetLevel(i, aFmt, aRule.Get(i) != 0);
     373           0 :                     }
     374             :                     SwNumRule aSetRule( pCurRule->GetName(),
     375           0 :                                         pCurRule->Get( 0 ).GetPositionAndSpaceMode() );
     376           0 :                     aSetRule.SetSvxRule( aRule, GetShell().GetDoc());
     377           0 :                     aSetRule.SetAutoRule( sal_True );
     378             :                     // no start or continuation of a list - list style is only changed
     379           0 :                     GetShell().SetCurNumRule( aSetRule, false );
     380           0 :                 }
     381           0 :             }
     382             :         }
     383           0 :         break;
     384             : 
     385             :         default:
     386             :             OSL_FAIL("wrong  dispatcher");
     387           0 :             return;
     388             :     }
     389           0 :     SwWrtShell& rWrtSh = GetShell();
     390           0 :     SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
     391           0 :     if(pColl && pColl->IsAutoUpdateFmt())
     392             :     {
     393           0 :         rWrtSh.AutoUpdatePara(pColl, aSet);
     394             :     }
     395             :     else
     396           0 :         rWrtSh.SetAttrSet( aSet );
     397           0 :     rReq.Done();
     398             : }
     399             : 
     400           0 : void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq)
     401             : {
     402           0 :     SwWrtShell &rSh = GetShell();
     403           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
     404           0 :     const SfxPoolItem *pItem = 0;
     405             : 
     406           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     407           0 :     if(pArgs)
     408           0 :         pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
     409           0 :     switch ( nSlot )
     410             :     {
     411             :         case FN_DROP_CHAR_STYLE_NAME:
     412           0 :             if( pItem )
     413             :             {
     414           0 :                 OUString sCharStyleName = ((const SfxStringItem*)pItem)->GetValue();
     415           0 :                 SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, 0L);
     416           0 :                 rSh.GetCurAttr(aSet);
     417           0 :                 SwFmtDrop aDropItem((const SwFmtDrop&)aSet.Get(RES_PARATR_DROP));
     418           0 :                 SwCharFmt* pFmt = 0;
     419           0 :                 if(!sCharStyleName.isEmpty())
     420           0 :                     pFmt = rSh.FindCharFmtByName( sCharStyleName );
     421           0 :                 aDropItem.SetCharFmt( pFmt );
     422           0 :                 aSet.Put(aDropItem);
     423           0 :                 rSh.SetAttrSet(aSet);
     424             :             }
     425           0 :         break;
     426             :         case FN_FORMAT_DROPCAPS:
     427             :         {
     428           0 :             if(pItem)
     429             :             {
     430           0 :                 rSh.SetAttrItem(*pItem);
     431           0 :                 rReq.Done();
     432             :             }
     433             :             else
     434             :             {
     435           0 :                 SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP,
     436           0 :                                            HINT_END, HINT_END, 0);
     437           0 :                 rSh.GetCurAttr(aSet);
     438           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     439             :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     440             : 
     441           0 :                 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aSet,
     442           0 :                     rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), DLG_SWDROPCAPS );
     443             :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     444           0 :                 if (pDlg->Execute() == RET_OK)
     445             :                 {
     446           0 :                     rSh.StartAction();
     447           0 :                     rSh.StartUndo( UNDO_START );
     448           0 :                     if ( SFX_ITEM_SET == aSet.GetItemState(HINT_END,false,&pItem) )
     449             :                     {
     450           0 :                         if ( !((SfxStringItem*)pItem)->GetValue().isEmpty() )
     451           0 :                             rSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue());
     452             :                     }
     453           0 :                     rSh.SetAttrSet(*pDlg->GetOutputItemSet());
     454           0 :                     rSh.StartUndo( UNDO_END );
     455           0 :                     rSh.EndAction();
     456           0 :                     rReq.Done(*pDlg->GetOutputItemSet());
     457             :                 }
     458           0 :                 delete pDlg;
     459             :             }
     460             :         }
     461           0 :          break;
     462             :         case SID_ATTR_PARA_PAGEBREAK:
     463           0 :             if(pItem)
     464             :             {
     465           0 :                 rSh.SetAttrItem( *pItem );
     466           0 :                 rReq.Done();
     467             :             }
     468           0 :         break;
     469             :         case SID_ATTR_PARA_MODEL:
     470             :         {
     471           0 :             if(pItem)
     472             :             {
     473           0 :                 SfxItemSet aCoreSet( GetPool(),
     474             :                     RES_PAGEDESC,   RES_PAGEDESC,
     475           0 :                     SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, 0);
     476           0 :                 aCoreSet.Put(*pItem);
     477           0 :                 SfxToSwPageDescAttr( rSh, aCoreSet);
     478           0 :                 rSh.SetAttrSet(aCoreSet);
     479           0 :                 rReq.Done();
     480             :             }
     481             :         }
     482           0 :         break;
     483             : 
     484             :         default:
     485             :             OSL_FAIL("wrong  dispatcher");
     486           0 :             return;
     487             :     }
     488             : }
     489             : 
     490        7446 : void SwTextShell::GetAttrState(SfxItemSet &rSet)
     491             : {
     492        7446 :     SwWrtShell &rSh = GetShell();
     493        7446 :     SfxItemPool& rPool = GetPool();
     494        7446 :     SfxItemSet aCoreSet(rPool, aTxtFmtCollSetRange);
     495        7446 :     rSh.GetCurAttr(aCoreSet); // Request *all* text attributes from the core.
     496             : 
     497       14892 :     SfxWhichIter aIter(rSet);
     498        7446 :     sal_uInt16 nSlot = aIter.FirstWhich();
     499        7446 :     sal_Bool bFlag = sal_False;
     500       14892 :     SfxBoolItem aFlagItem;
     501        7446 :     const SfxPoolItem* pItem = 0;
     502        7446 :     int eAdjust = -1;   // Illegal value to recognize DONTCARE.
     503        7446 :     SfxItemState eState = aCoreSet.GetItemState(RES_PARATR_ADJUST, false, &pItem);
     504             : 
     505        7446 :     if( SFX_ITEM_DEFAULT == eState )
     506        7443 :         pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST);
     507        7446 :     if( SFX_ITEM_DEFAULT <= eState )
     508        7444 :         eAdjust = (int)(( SvxAdjustItem* ) pItem)->GetAdjust();
     509             : 
     510        7446 :     short nEsc = 0;
     511        7446 :     eState =  aCoreSet.GetItemState(RES_CHRATR_ESCAPEMENT, false, &pItem);
     512        7446 :     if( SFX_ITEM_DEFAULT == eState )
     513        7441 :         pItem = &rPool.GetDefaultItem(RES_CHRATR_ESCAPEMENT);
     514        7446 :     if( eState >= SFX_ITEM_DEFAULT )
     515        7446 :         nEsc = ((SvxEscapementItem* )pItem)->GetEsc();
     516             : 
     517        7446 :     sal_uInt16 nLineSpace = 0;
     518        7446 :     eState =  aCoreSet.GetItemState(RES_PARATR_LINESPACING, false, &pItem);
     519        7446 :     if( SFX_ITEM_DEFAULT == eState )
     520        7445 :         pItem = &rPool.GetDefaultItem(RES_PARATR_LINESPACING);
     521       14892 :     if( SFX_ITEM_DEFAULT <= eState &&
     522        7446 :             ((SvxLineSpacingItem* )pItem)->GetLineSpaceRule() == SVX_LINE_SPACE_AUTO )
     523             :     {
     524        7446 :         if(SVX_INTER_LINE_SPACE_OFF ==
     525        7446 :                     ((SvxLineSpacingItem* )pItem)->GetInterLineSpaceRule())
     526        7445 :             nLineSpace = 100;
     527             :         else
     528           1 :             nLineSpace = ((SvxLineSpacingItem* )pItem)->GetPropLineSpace();
     529             :     }
     530             : 
     531       26569 :     while (nSlot)
     532             :     {
     533       11677 :         switch(nSlot)
     534             :         {
     535             :             case FN_SET_SUPER_SCRIPT:
     536         669 :                     bFlag = 0 < nEsc;
     537         669 :                 break;
     538             :             case FN_SET_SUB_SCRIPT:
     539         669 :                     bFlag = 0 > nEsc;
     540         669 :                 break;
     541             :             case SID_ATTR_PARA_ADJUST_LEFT:
     542         669 :                 if (eAdjust == -1)
     543             :                 {
     544           2 :                     rSet.InvalidateItem( nSlot );
     545           2 :                     nSlot = 0;
     546             :                 }
     547             :                 else
     548         667 :                     bFlag = SVX_ADJUST_LEFT == eAdjust;
     549         669 :                 break;
     550             :             case SID_ATTR_PARA_ADJUST_RIGHT:
     551         669 :                 if (eAdjust == -1)
     552             :                 {
     553           2 :                     rSet.InvalidateItem( nSlot );
     554           2 :                     nSlot = 0;
     555             :                 }
     556             :                 else
     557         667 :                     bFlag = SVX_ADJUST_RIGHT == eAdjust;
     558         669 :                 break;
     559             :             case SID_ATTR_PARA_ADJUST_CENTER:
     560         669 :                 if (eAdjust == -1)
     561             :                 {
     562           2 :                     rSet.InvalidateItem( nSlot );
     563           2 :                     nSlot = 0;
     564             :                 }
     565             :                 else
     566         667 :                     bFlag = SVX_ADJUST_CENTER == eAdjust;
     567         669 :                 break;
     568             :             case SID_ATTR_PARA_ADJUST_BLOCK:
     569             :             {
     570         669 :                 if (eAdjust == -1)
     571             :                 {
     572           2 :                     rSet.InvalidateItem( nSlot );
     573           2 :                     nSlot = 0;
     574             :                 }
     575             :                 else
     576             :                 {
     577         667 :                     bFlag = SVX_ADJUST_BLOCK == eAdjust;
     578         667 :                     sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
     579         667 :                     if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & HTMLMODE_FULL_STYLES ))
     580             :                     {
     581           1 :                         rSet.DisableItem( nSlot );
     582           1 :                         nSlot = 0;
     583             :                     }
     584             :                 }
     585             :             }
     586         669 :             break;
     587             :             case SID_ATTR_PARA_LINESPACE_10:
     588         669 :                 bFlag = nLineSpace == 100;
     589         669 :             break;
     590             :             case SID_ATTR_PARA_LINESPACE_15:
     591         669 :                 bFlag = nLineSpace == 150;
     592         669 :             break;
     593             :             case SID_ATTR_PARA_LINESPACE_20:
     594         669 :                 bFlag = nLineSpace == 200;
     595         669 :             break;
     596             :             case FN_GROW_FONT_SIZE:
     597             :             case FN_SHRINK_FONT_SIZE:
     598             :             {
     599             :                 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT,
     600        1338 :                                             *rSet.GetPool() );
     601        1338 :                 aSetItem.GetItemSet().Put( aCoreSet, false );
     602             :                 const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>(
     603        1338 :                                             aSetItem.GetItemOfScript( rSh.GetScriptType() ) ) );
     604             : 
     605        1338 :                 if( !pSize )
     606           0 :                     rSet.DisableItem( nSlot );
     607             :                 else
     608             :                 {
     609        1338 :                     sal_uInt32 nSize = pSize->GetHeight();
     610        1338 :                     if( nSize == nFontMaxSz )
     611           0 :                         rSet.DisableItem( FN_GROW_FONT_SIZE );
     612        1338 :                     else if( nSize == nFontInc )
     613           0 :                         rSet.DisableItem( FN_SHRINK_FONT_SIZE );
     614             :                 }
     615        1338 :                 nSlot = 0;
     616             :             }
     617        1338 :             break;
     618             :             case FN_UNDERLINE_DOUBLE:
     619             :             {
     620           0 :                 eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE);
     621           0 :                 if( eState >= SFX_ITEM_DEFAULT )
     622             :                 {
     623             :                     FontUnderline eUnderline =  ((const SvxUnderlineItem&)
     624           0 :                             aCoreSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
     625           0 :                     rSet.Put(SfxBoolItem(nSlot, eUnderline == UNDERLINE_DOUBLE));
     626             :                 }
     627             :                 else
     628           0 :                     rSet.InvalidateItem(nSlot);
     629           0 :                 nSlot = 0;
     630             :             }
     631           0 :             break;
     632             :             case SID_ATTR_PARA_ADJUST:
     633           0 :                 if (eAdjust == -1)
     634           0 :                     rSet.InvalidateItem( nSlot );
     635             :                 else
     636           0 :                     rSet.Put(SvxAdjustItem((SvxAdjust)eAdjust, SID_ATTR_PARA_ADJUST ));
     637           0 :                 nSlot = 0;
     638           0 :             break;
     639             :             case SID_ATTR_PARA_LRSPACE:
     640             :             {
     641         309 :                 eState = aCoreSet.GetItemState(RES_LR_SPACE);
     642         309 :                 if( eState >= SFX_ITEM_DEFAULT )
     643             :                 {
     644         309 :                     SvxLRSpaceItem aLR = ( (const SvxLRSpaceItem&) aCoreSet.Get( RES_LR_SPACE ) );
     645         309 :                     aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
     646         309 :                     rSet.Put(aLR);
     647             :                 }
     648             :                 else
     649           0 :                     rSet.InvalidateItem(nSlot);
     650         309 :                 nSlot = 0;
     651             :             }
     652         309 :             break;
     653             : 
     654             :             case SID_ATTR_PARA_LEFT_TO_RIGHT :
     655             :             case SID_ATTR_PARA_RIGHT_TO_LEFT :
     656             :             {
     657        2156 :                 if ( !SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
     658             :                 {
     659           0 :                     rSet.DisableItem( nSlot );
     660           0 :                     nSlot = 0;
     661             :                 }
     662             :                 else
     663             :                 {
     664             :                     // is the item set?
     665        2156 :                     sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
     666        4312 :                     if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) &&
     667        2156 :                     aCoreSet.GetItemState( RES_FRAMEDIR, false ) >= SFX_ITEM_DEFAULT)
     668             :                     {
     669             :                         SvxFrameDirection eFrmDir = (SvxFrameDirection)
     670        2156 :                                 ((const SvxFrameDirectionItem& )aCoreSet.Get(RES_FRAMEDIR)).GetValue();
     671        2156 :                         if (FRMDIR_ENVIRONMENT == eFrmDir)
     672             :                         {
     673        2156 :                             eFrmDir = rSh.IsInRightToLeftText() ?
     674        2156 :                                     FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP;
     675             :                         }
     676        1078 :                         bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot &&
     677        4312 :                                             FRMDIR_HORI_LEFT_TOP == eFrmDir) ||
     678        1078 :                                 (SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot &&
     679        2156 :                                             FRMDIR_HORI_RIGHT_TOP == eFrmDir);
     680             :                     }
     681             :                     else
     682             :                     {
     683           0 :                         rSet.InvalidateItem(nSlot);
     684           0 :                         nSlot = 0;
     685             :                     }
     686             :                 }
     687             :             }
     688        2156 :             break;
     689             : 
     690             :             case SID_ATTR_CHAR_LANGUAGE:
     691             :             case SID_ATTR_CHAR_KERNING:
     692             :             case RES_PARATR_DROP:
     693             :             {
     694             : #if OSL_DEBUG_LEVEL > 1
     695             :                 const SfxPoolItem& rItem = aCoreSet.Get(GetPool().GetWhich(nSlot), true);
     696             :                 rSet.Put(rItem);
     697             : #else
     698           0 :                 rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot), true));
     699             : #endif
     700           0 :                 nSlot = 0;
     701             :             }
     702           0 :             break;
     703             :             case SID_ATTR_PARA_MODEL:
     704             :             {
     705           0 :                 SfxItemSet aTemp(GetPool(),
     706             :                         RES_PAGEDESC,RES_PAGEDESC,
     707             :                         SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL,
     708           0 :                         0L);
     709           0 :                 aTemp.Put(aCoreSet);
     710           0 :                 ::SwToSfxPageDescAttr(aTemp);
     711           0 :                 rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL));
     712           0 :                 nSlot = 0;
     713             :             }
     714           0 :             break;
     715             :             case RES_TXTATR_INETFMT:
     716             :             {
     717           0 :                 SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
     718           0 :                 rSh.GetCurAttr(aSet);
     719           0 :                 const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, true);
     720           0 :                 rSet.Put(rItem);
     721           0 :                 nSlot = 0;
     722             :             }
     723           0 :             break;
     724             : 
     725             :             default:
     726             :             // Do nothing
     727        1853 :             nSlot = 0;
     728        1853 :             break;
     729             : 
     730             :         }
     731       11677 :         if( nSlot )
     732             :         {
     733        8168 :             aFlagItem.SetWhich( nSlot );
     734        8168 :             aFlagItem.SetValue( bFlag );
     735        8168 :             rSet.Put( aFlagItem );
     736             :         }
     737       11677 :         nSlot = aIter.NextWhich();
     738             :     }
     739             : 
     740       14892 :     rSet.Put(aCoreSet,false);
     741        7557 : }
     742             : 
     743             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10