LCOV - code coverage report
Current view: top level - libreoffice/forms/source/richtext - rtattributehandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 194 0.0 %
Date: 2012-12-27 Functions: 0 37 0.0 %
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 "rtattributehandler.hxx"
      21             : 
      22             : #include <svx/svxids.hrc>
      23             : #include <editeng/eeitem.hxx>
      24             : #include <svl/itemset.hxx>
      25             : #include <svl/itempool.hxx>
      26             : #include <tools/mapunit.hxx>
      27             : #include <vcl/mapmod.hxx>
      28             : #include <vcl/outdev.hxx>
      29             : 
      30             : #define ITEMID_ADJUST       EE_PARA_JUST
      31             : #include <editeng/adjitem.hxx>
      32             : #define ITEMID_WEIGHT       EE_CHAR_WEIGHT
      33             : #include <editeng/wghtitem.hxx>
      34             : #define ITEMID_ESCAPEMENT   EE_CHAR_ESCAPEMENT
      35             : #include <editeng/escpitem.hxx>
      36             : #define ITEMID_LINESPACING  EE_PARA_SBL
      37             : #include <editeng/lspcitem.hxx>
      38             : #define ITEMID_FONTHEIGHT   EE_CHAR_FONTHEIGHT
      39             : #include <editeng/fhgtitem.hxx>
      40             : #define ITEMID_FRAMEDIR     EE_PARA_WRITINGDIR
      41             : #include <editeng/frmdiritem.hxx>
      42             : #include <editeng/scripttypeitem.hxx>
      43             : 
      44             : //........................................................................
      45             : namespace frm
      46             : {
      47             : //........................................................................
      48             :     //====================================================================
      49             :     //= ReferenceBase
      50             :     //====================================================================
      51             :     //--------------------------------------------------------------------
      52           0 :     oslInterlockedCount SAL_CALL ReferenceBase::acquire()
      53             :     {
      54           0 :         return osl_atomic_increment( &m_refCount );
      55             :     }
      56             : 
      57             :     //--------------------------------------------------------------------
      58           0 :     oslInterlockedCount SAL_CALL ReferenceBase::release()
      59             :     {
      60           0 :         return osl_atomic_decrement( &m_refCount );
      61             :     }
      62             : 
      63             :     //--------------------------------------------------------------------
      64           0 :     ReferenceBase::~ReferenceBase()
      65             :     {
      66           0 :     }
      67             : 
      68             :     //====================================================================
      69             :     //= AttributeHandler
      70             :     //====================================================================
      71             :     //--------------------------------------------------------------------
      72           0 :     AttributeHandler::AttributeHandler( AttributeId _nAttributeId, WhichId _nWhichId )
      73             :         :m_nAttribute( _nAttributeId )
      74           0 :         ,m_nWhich    ( _nWhichId     )
      75             :     {
      76           0 :     }
      77             : 
      78             :     //--------------------------------------------------------------------
      79           0 :     AttributeHandler::~AttributeHandler()
      80             :     {
      81           0 :     }
      82             : 
      83             :     //--------------------------------------------------------------------
      84           0 :     oslInterlockedCount SAL_CALL AttributeHandler::acquire()
      85             :     {
      86           0 :         return ReferenceBase::acquire();
      87             :     }
      88             : 
      89             :     //--------------------------------------------------------------------
      90           0 :     oslInterlockedCount SAL_CALL AttributeHandler::release()
      91             :     {
      92           0 :         return ReferenceBase::release();
      93             :     }
      94             : 
      95             :     //--------------------------------------------------------------------
      96           0 :     AttributeId AttributeHandler::getAttributeId( ) const
      97             :     {
      98           0 :         return getAttribute();
      99             :     }
     100             : 
     101             :     //--------------------------------------------------------------------
     102           0 :     AttributeCheckState AttributeHandler::implGetCheckState( const SfxPoolItem& /*_rItem*/ ) const
     103             :     {
     104             :         OSL_FAIL( "AttributeHandler::implGetCheckState: not to be called!" );
     105           0 :         return eIndetermined;
     106             :     }
     107             : 
     108             :     //--------------------------------------------------------------------
     109           0 :     void AttributeHandler::putItemForScript( SfxItemSet& _rAttribs, const SfxPoolItem& _rItem, ScriptType _nForScriptType ) const
     110             :     {
     111           0 :         SvxScriptSetItem aSetItem( (WhichId)getAttributeId(), *_rAttribs.GetPool() );
     112           0 :         aSetItem.PutItemForScriptType( _nForScriptType, _rItem );
     113           0 :         _rAttribs.Put( aSetItem.GetItemSet(), sal_False );
     114           0 :     }
     115             : 
     116             :     //--------------------------------------------------------------------
     117           0 :     AttributeCheckState AttributeHandler::getCheckState( const SfxItemSet& _rAttribs ) const
     118             :     {
     119           0 :         AttributeCheckState eSimpleState( eIndetermined );
     120           0 :         const SfxPoolItem* pItem = _rAttribs.GetItem( getWhich() );
     121           0 :         if ( pItem )
     122           0 :             eSimpleState = implGetCheckState( *pItem );
     123           0 :         return eSimpleState;
     124             :     }
     125             : 
     126             :     //--------------------------------------------------------------------
     127           0 :     AttributeState AttributeHandler::getState( const SfxItemSet& _rAttribs ) const
     128             :     {
     129           0 :         AttributeState aState( eIndetermined );
     130           0 :         aState.eSimpleState = getCheckState( _rAttribs );
     131           0 :         return aState;
     132             :     }
     133             : 
     134             :     //====================================================================
     135             :     //= AttributeHandlerFactory
     136             :     //====================================================================
     137             :     //--------------------------------------------------------------------
     138             :     namespace
     139             :     {
     140           0 :         static WhichId lcl_implGetWhich( const SfxItemPool& _rPool, AttributeId _nAttributeId )
     141             :         {
     142           0 :             WhichId nWhich = 0;
     143           0 :             switch ( _nAttributeId )
     144             :             {
     145           0 :             case SID_ATTR_CHAR_LATIN_FONTHEIGHT:nWhich = EE_CHAR_FONTHEIGHT;break;
     146           0 :             case SID_ATTR_CHAR_LATIN_FONT:      nWhich = EE_CHAR_FONTINFO;  break;
     147           0 :             case SID_ATTR_CHAR_LATIN_LANGUAGE:  nWhich = EE_CHAR_LANGUAGE;  break;
     148           0 :             case SID_ATTR_CHAR_LATIN_POSTURE:   nWhich = EE_CHAR_ITALIC;    break;
     149           0 :             case SID_ATTR_CHAR_LATIN_WEIGHT:    nWhich = EE_CHAR_WEIGHT;    break;
     150             : 
     151             :             default:
     152           0 :                 nWhich = _rPool.GetWhich( (SfxSlotId)_nAttributeId );
     153             :             }
     154           0 :             return nWhich;
     155             :         }
     156             :     }
     157             :     //--------------------------------------------------------------------
     158           0 :     ::rtl::Reference< IAttributeHandler > AttributeHandlerFactory::getHandlerFor( AttributeId _nAttributeId, const SfxItemPool& _rEditEnginePool )
     159             :     {
     160           0 :         ::rtl::Reference< IAttributeHandler > pReturn;
     161           0 :         switch ( _nAttributeId )
     162             :         {
     163             :         case SID_ATTR_PARA_ADJUST_LEFT  :
     164             :         case SID_ATTR_PARA_ADJUST_CENTER:
     165             :         case SID_ATTR_PARA_ADJUST_RIGHT :
     166             :         case SID_ATTR_PARA_ADJUST_BLOCK :
     167           0 :             pReturn = new ParaAlignmentHandler( _nAttributeId );
     168           0 :             break;
     169             : 
     170             :         case SID_ATTR_PARA_LINESPACE_10:
     171             :         case SID_ATTR_PARA_LINESPACE_15:
     172             :         case SID_ATTR_PARA_LINESPACE_20:
     173           0 :             pReturn = new LineSpacingHandler( _nAttributeId );
     174           0 :             break;
     175             : 
     176             :         case SID_SET_SUPER_SCRIPT:
     177             :         case SID_SET_SUB_SCRIPT:
     178           0 :             pReturn = new EscapementHandler( _nAttributeId );
     179           0 :             break;
     180             : 
     181             :         case SID_ATTR_CHAR_FONTHEIGHT:
     182             :         case SID_ATTR_CHAR_CTL_FONTHEIGHT:
     183             :         case SID_ATTR_CHAR_CJK_FONTHEIGHT:
     184             :         case SID_ATTR_CHAR_LATIN_FONTHEIGHT:
     185           0 :             pReturn = new FontSizeHandler( _nAttributeId, lcl_implGetWhich( _rEditEnginePool, _nAttributeId ) );
     186           0 :             break;
     187             : 
     188             :         case SID_ATTR_PARA_LEFT_TO_RIGHT:
     189             :         case SID_ATTR_PARA_RIGHT_TO_LEFT:
     190           0 :             pReturn = new ParagraphDirectionHandler( _nAttributeId );
     191           0 :             break;
     192             : 
     193             :         case SID_ATTR_PARA_HANGPUNCTUATION:
     194             :         case SID_ATTR_PARA_FORBIDDEN_RULES:
     195             :         case SID_ATTR_PARA_SCRIPTSPACE:
     196           0 :             pReturn = new BooleanHandler( _nAttributeId, lcl_implGetWhich( _rEditEnginePool, _nAttributeId ) );
     197           0 :             break;
     198             : 
     199             :         default:
     200           0 :             pReturn = new SlotHandler( (SfxSlotId)_nAttributeId, lcl_implGetWhich( _rEditEnginePool, _nAttributeId ) );
     201           0 :             break;
     202             : 
     203             :         }
     204             : 
     205           0 :         return pReturn;
     206             :     }
     207             : 
     208             :     //====================================================================
     209             :     //= ParaAlignmentHandler
     210             :     //====================================================================
     211             :     //--------------------------------------------------------------------
     212           0 :     ParaAlignmentHandler::ParaAlignmentHandler( AttributeId _nAttributeId )
     213             :         :AttributeHandler( _nAttributeId, EE_PARA_JUST )
     214           0 :         ,m_eAdjust( SVX_ADJUST_CENTER )
     215             :     {
     216           0 :         switch ( getAttribute() )
     217             :         {
     218           0 :             case SID_ATTR_PARA_ADJUST_LEFT  : m_eAdjust = SVX_ADJUST_LEFT;    break;
     219           0 :             case SID_ATTR_PARA_ADJUST_CENTER: m_eAdjust = SVX_ADJUST_CENTER;  break;
     220           0 :             case SID_ATTR_PARA_ADJUST_RIGHT : m_eAdjust = SVX_ADJUST_RIGHT;   break;
     221           0 :             case SID_ATTR_PARA_ADJUST_BLOCK : m_eAdjust = SVX_ADJUST_BLOCK;   break;
     222             :             default:
     223             :                 OSL_FAIL( "ParaAlignmentHandler::ParaAlignmentHandler: invalid slot!" );
     224           0 :                 break;
     225             :         }
     226           0 :     }
     227             : 
     228             :     //--------------------------------------------------------------------
     229           0 :     AttributeCheckState ParaAlignmentHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
     230             :     {
     231             :         OSL_ENSURE( _rItem.ISA( SvxAdjustItem ), "ParaAlignmentHandler::implGetCheckState: invalid pool item!" );
     232           0 :         SvxAdjust eAdjust = static_cast< const SvxAdjustItem& >( _rItem ).GetAdjust();
     233           0 :         return ( eAdjust == m_eAdjust ) ? eChecked : eUnchecked;
     234             :     }
     235             : 
     236             :     //--------------------------------------------------------------------
     237           0 :     void ParaAlignmentHandler::executeAttribute( const SfxItemSet& /*_rCurrentAttribs*/, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType /*_nForScriptType*/ ) const
     238             :     {
     239             :         OSL_ENSURE( !_pAdditionalArg, "ParaAlignmentHandler::executeAttribute: this is a simple toggle attribute - no args possible!" );
     240             :         (void)_pAdditionalArg;
     241           0 :         _rNewAttribs.Put( SvxAdjustItem( m_eAdjust, getWhich() ) );
     242           0 :     }
     243             : 
     244             :     //====================================================================
     245             :     //= LineSpacingHandler
     246             :     //====================================================================
     247             :     //--------------------------------------------------------------------
     248           0 :     LineSpacingHandler::LineSpacingHandler( AttributeId _nAttributeId )
     249             :         :AttributeHandler( _nAttributeId, EE_PARA_SBL )
     250           0 :         ,m_nLineSpace( 100 )
     251             :     {
     252           0 :         switch ( getAttribute() )
     253             :         {
     254           0 :             case SID_ATTR_PARA_LINESPACE_10: m_nLineSpace = 100; break;
     255           0 :             case SID_ATTR_PARA_LINESPACE_15: m_nLineSpace = 150; break;
     256           0 :             case SID_ATTR_PARA_LINESPACE_20: m_nLineSpace = 200; break;
     257             :             default:
     258             :                 OSL_FAIL( "LineSpacingHandler::LineSpacingHandler: invalid slot!" );
     259           0 :                 break;
     260             :         }
     261           0 :     }
     262             : 
     263             :     //--------------------------------------------------------------------
     264           0 :     AttributeCheckState LineSpacingHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
     265             :     {
     266             :         OSL_ENSURE( _rItem.ISA( SvxLineSpacingItem ), "LineSpacingHandler::implGetCheckState: invalid pool item!" );
     267           0 :         sal_uInt16 nLineSpace = static_cast< const SvxLineSpacingItem& >( _rItem ).GetPropLineSpace();
     268           0 :         return ( nLineSpace == m_nLineSpace ) ? eChecked : eUnchecked;
     269             :     }
     270             : 
     271             :     //--------------------------------------------------------------------
     272           0 :     void LineSpacingHandler::executeAttribute( const SfxItemSet& /*_rCurrentAttribs*/, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType /*_nForScriptType*/ ) const
     273             :     {
     274             :         OSL_ENSURE( !_pAdditionalArg, "LineSpacingHandler::executeAttribute: this is a simple toggle attribute - no args possible!" );
     275             :         (void)_pAdditionalArg;
     276             : 
     277           0 :         SvxLineSpacingItem aLineSpacing( m_nLineSpace, getWhich() );
     278           0 :         aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
     279           0 :         if ( 100 == m_nLineSpace )
     280           0 :             aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
     281             :         else
     282           0 :             aLineSpacing.SetPropLineSpace( (sal_uInt8)m_nLineSpace );
     283             : 
     284           0 :         _rNewAttribs.Put( aLineSpacing );
     285           0 :     }
     286             : 
     287             :     //====================================================================
     288             :     //= EscapementHandler
     289             :     //====================================================================
     290             :     //--------------------------------------------------------------------
     291           0 :     EscapementHandler::EscapementHandler( AttributeId _nAttributeId )
     292             :         :AttributeHandler( _nAttributeId, EE_CHAR_ESCAPEMENT )
     293           0 :         ,m_eEscapement( SVX_ESCAPEMENT_OFF )
     294             :     {
     295           0 :         switch ( getAttribute() )
     296             :         {
     297           0 :             case SID_SET_SUPER_SCRIPT   : m_eEscapement = SVX_ESCAPEMENT_SUPERSCRIPT; break;
     298           0 :             case SID_SET_SUB_SCRIPT     : m_eEscapement = SVX_ESCAPEMENT_SUBSCRIPT;   break;
     299             :             default:
     300             :                 OSL_FAIL( "EscapementHandler::EscapementHandler: invalid slot!" );
     301           0 :                 break;
     302             :         }
     303           0 :     }
     304             : 
     305             :     //--------------------------------------------------------------------
     306           0 :     AttributeCheckState EscapementHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
     307             :     {
     308             :         OSL_ENSURE( _rItem.ISA( SvxEscapementItem ), "EscapementHandler::getState: invalid pool item!" );
     309           0 :         SvxEscapement eEscapement = static_cast< const SvxEscapementItem& >( _rItem ).GetEscapement();
     310           0 :         return ( eEscapement == m_eEscapement ) ? eChecked : eUnchecked;
     311             :     }
     312             : 
     313             :     //--------------------------------------------------------------------
     314           0 :     void EscapementHandler::executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType /*_nForScriptType*/ ) const
     315             :     {
     316             :         OSL_ENSURE( !_pAdditionalArg, "EscapementHandler::executeAttribute: this is a simple toggle attribute - no args possible!" );
     317             :             // well, in theory we could allow an SvxEscapementItem here, but this is not needed
     318             :         (void)_pAdditionalArg;
     319             : 
     320           0 :         bool bIsChecked = getCheckState( _rCurrentAttribs ) == eChecked;
     321           0 :         _rNewAttribs.Put( SvxEscapementItem( bIsChecked ? SVX_ESCAPEMENT_OFF : m_eEscapement, getWhich() ) );
     322           0 :     }
     323             : 
     324             :     //====================================================================
     325             :     //= SlotHandler
     326             :     //====================================================================
     327             :     //--------------------------------------------------------------------
     328           0 :     SlotHandler::SlotHandler( AttributeId _nAttributeId, WhichId _nWhichId )
     329             :         :AttributeHandler( _nAttributeId, _nWhichId )
     330           0 :         ,m_bScriptDependent( false )
     331             :     {
     332             :         m_bScriptDependent = ( SID_ATTR_CHAR_WEIGHT == _nAttributeId )
     333             :                          ||  ( SID_ATTR_CHAR_POSTURE == _nAttributeId )
     334           0 :                          ||  ( SID_ATTR_CHAR_FONT == _nAttributeId );
     335           0 :     }
     336             : 
     337             :     //--------------------------------------------------------------------
     338           0 :     AttributeState SlotHandler::getState( const SfxItemSet& _rAttribs ) const
     339             :     {
     340           0 :         AttributeState aState( eIndetermined );
     341             : 
     342           0 :         const SfxPoolItem* pItem = _rAttribs.GetItem( getWhich() );
     343           0 :         if ( pItem )
     344           0 :             aState.setItem( pItem->Clone() );
     345             : 
     346           0 :         return aState;
     347             :     }
     348             : 
     349             :     //--------------------------------------------------------------------
     350           0 :     void SlotHandler::executeAttribute( const SfxItemSet& /*_rCurrentAttribs*/, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const
     351             :     {
     352           0 :         if ( _pAdditionalArg )
     353             :         {
     354           0 :             SfxPoolItem* pCorrectWich = _pAdditionalArg->Clone();
     355           0 :             pCorrectWich->SetWhich( getWhich() );
     356             : 
     357           0 :             if ( m_bScriptDependent )
     358           0 :                 putItemForScript( _rNewAttribs, *pCorrectWich, _nForScriptType );
     359             :             else
     360           0 :                 _rNewAttribs.Put( *pCorrectWich );
     361           0 :             DELETEZ( pCorrectWich );
     362             :         }
     363             :         else
     364             :             OSL_FAIL( "SlotHandler::executeAttribute: need attributes to do something!" );
     365           0 :     }
     366             : 
     367             :     //====================================================================
     368             :     //= FontSizeHandler
     369             :     //====================================================================
     370             :     //--------------------------------------------------------------------
     371           0 :     FontSizeHandler::FontSizeHandler( AttributeId _nAttributeId, WhichId _nWhichId )
     372           0 :         :AttributeHandler( _nAttributeId, _nWhichId )
     373             :     {
     374             :         OSL_ENSURE( ( _nAttributeId == SID_ATTR_CHAR_FONTHEIGHT ) || ( _nAttributeId == SID_ATTR_CHAR_CTL_FONTHEIGHT )
     375             :             || ( _nAttributeId == SID_ATTR_CHAR_CJK_FONTHEIGHT ) || ( _nAttributeId == SID_ATTR_CHAR_LATIN_FONTHEIGHT ),
     376             :             "FontSizeHandler::FontSizeHandler: invalid attribute id!" );
     377           0 :     }
     378             : 
     379             :     //--------------------------------------------------------------------
     380           0 :     AttributeState FontSizeHandler::getState( const SfxItemSet& _rAttribs ) const
     381             :     {
     382           0 :         AttributeState aState( eIndetermined );
     383             : 
     384           0 :         const SfxPoolItem* pItem = _rAttribs.GetItem( getWhich() );
     385           0 :         const SvxFontHeightItem* pFontHeightItem = PTR_CAST( SvxFontHeightItem, pItem );
     386             :         OSL_ENSURE( pFontHeightItem || !pItem, "FontSizeHandler::getState: invalid item!" );
     387           0 :         if ( pFontHeightItem )
     388             :         {
     389             :             // by definition, the item should have the unit twip
     390           0 :             sal_uLong nHeight = pFontHeightItem->GetHeight();
     391           0 :             if ( _rAttribs.GetPool()->GetMetric( getWhich() ) != SFX_MAPUNIT_TWIP )
     392             :             {
     393             :                 nHeight = OutputDevice::LogicToLogic(
     394             :                     Size( 0, nHeight ),
     395           0 :                     MapMode( (MapUnit)( _rAttribs.GetPool()->GetMetric( getWhich() ) ) ),
     396             :                     MapMode( MAP_TWIP )
     397           0 :                 ).Height();
     398             :             }
     399             : 
     400           0 :             SvxFontHeightItem* pNewItem = new SvxFontHeightItem( nHeight, 100, getWhich() );
     401           0 :             pNewItem->SetProp( pFontHeightItem->GetProp(), pFontHeightItem->GetPropUnit() );
     402           0 :             aState.setItem( pNewItem );
     403             :         }
     404             : 
     405           0 :         return aState;
     406             :     }
     407             : 
     408             :     //--------------------------------------------------------------------
     409           0 :     void FontSizeHandler::executeAttribute( const SfxItemSet& /*_rCurrentAttribs*/, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const
     410             :     {
     411           0 :         const SvxFontHeightItem* pFontHeightItem = PTR_CAST( SvxFontHeightItem, _pAdditionalArg );
     412             :         OSL_ENSURE( pFontHeightItem, "FontSizeHandler::executeAttribute: need a FontHeightItem!" );
     413             : 
     414           0 :         if ( pFontHeightItem )
     415             :         {
     416             :             // corect measurement units
     417           0 :             SfxMapUnit eItemMapUnit = pFontHeightItem->GetPropUnit(); (void)eItemMapUnit;
     418           0 :             sal_uLong nHeight = pFontHeightItem->GetHeight();
     419           0 :             if ( _rNewAttribs.GetPool()->GetMetric( getWhich() ) != SFX_MAPUNIT_TWIP )
     420             :             {
     421             :                 nHeight = OutputDevice::LogicToLogic(
     422             :                     Size( 0, nHeight ),
     423             :                     MapMode( (MapUnit)( SFX_MAPUNIT_TWIP ) ),
     424           0 :                     MapMode( (MapUnit)( _rNewAttribs.GetPool()->GetMetric( getWhich() ) ) )
     425           0 :                 ).Height();
     426             :             }
     427             : 
     428           0 :             SvxFontHeightItem aNewItem( nHeight, 100, getWhich() );
     429           0 :             aNewItem.SetProp( pFontHeightItem->GetProp(), pFontHeightItem->GetPropUnit() );
     430             : 
     431           0 :             if ( ( getAttributeId() == SID_ATTR_CHAR_FONTHEIGHT ) && _nForScriptType )
     432           0 :                 putItemForScript( _rNewAttribs, aNewItem, _nForScriptType );
     433             :             else
     434           0 :                 _rNewAttribs.Put( aNewItem );
     435             :         }
     436           0 :     }
     437             : 
     438             :     //====================================================================
     439             :     //= ParagraphDirectionHandler
     440             :     //====================================================================
     441             :     //--------------------------------------------------------------------
     442           0 :     ParagraphDirectionHandler::ParagraphDirectionHandler( AttributeId _nAttributeId )
     443             :         :AttributeHandler( _nAttributeId, EE_PARA_WRITINGDIR )
     444             :         ,m_eParagraphDirection( FRMDIR_HORI_LEFT_TOP )
     445             :         ,m_eDefaultAdjustment( SVX_ADJUST_RIGHT )
     446           0 :         ,m_eOppositeDefaultAdjustment( SVX_ADJUST_LEFT )
     447             :     {
     448           0 :         switch ( getAttributeId() )
     449             :         {
     450           0 :             case SID_ATTR_PARA_LEFT_TO_RIGHT: m_eParagraphDirection = FRMDIR_HORI_LEFT_TOP; m_eDefaultAdjustment = SVX_ADJUST_LEFT; break;
     451           0 :             case SID_ATTR_PARA_RIGHT_TO_LEFT: m_eParagraphDirection = FRMDIR_HORI_RIGHT_TOP; m_eDefaultAdjustment = SVX_ADJUST_RIGHT; break;
     452             :             default:
     453             :                 OSL_FAIL( "ParagraphDirectionHandler::ParagraphDirectionHandler: invalid attribute id!" );
     454             :         }
     455             : 
     456           0 :         if ( SVX_ADJUST_RIGHT == m_eDefaultAdjustment )
     457           0 :             m_eOppositeDefaultAdjustment = SVX_ADJUST_LEFT;
     458             :         else
     459           0 :             m_eOppositeDefaultAdjustment = SVX_ADJUST_RIGHT;
     460           0 :     }
     461             : 
     462             :     //--------------------------------------------------------------------
     463           0 :     AttributeCheckState ParagraphDirectionHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
     464             :     {
     465             :         OSL_ENSURE( _rItem.ISA( SvxFrameDirectionItem ), "ParagraphDirectionHandler::implGetCheckState: invalid pool item!" );
     466           0 :         SvxFrameDirection eDirection = static_cast< SvxFrameDirection >( static_cast< const SvxFrameDirectionItem& >( _rItem ).GetValue() );
     467           0 :         return ( eDirection == m_eParagraphDirection ) ? eChecked : eUnchecked;
     468             :     }
     469             : 
     470             :     //--------------------------------------------------------------------
     471           0 :     void ParagraphDirectionHandler::executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* /*_pAdditionalArg*/, ScriptType /*_nForScriptType*/ ) const
     472             :     {
     473           0 :         _rNewAttribs.Put( SvxFrameDirectionItem( m_eParagraphDirection, getWhich() ) );
     474             : 
     475             :         // if the current adjustment of the was the default adjustment for the *previous* text direction,
     476             :         // then we toggle the adjustment, too
     477           0 :         SvxAdjust eCurrentAdjustment = SVX_ADJUST_LEFT;
     478           0 :         const SfxPoolItem* pCurrentAdjustment = NULL;
     479           0 :         if ( SFX_ITEM_ON == _rCurrentAttribs.GetItemState( EE_PARA_JUST, sal_True, &pCurrentAdjustment ) )
     480           0 :             eCurrentAdjustment = static_cast< const SvxAdjustItem* >( pCurrentAdjustment )->GetAdjust();
     481             : 
     482           0 :         if ( eCurrentAdjustment == m_eOppositeDefaultAdjustment )
     483           0 :             _rNewAttribs.Put( SvxAdjustItem( m_eDefaultAdjustment, EE_PARA_JUST ) );
     484           0 :     }
     485             : 
     486             :     //====================================================================
     487             :     //= BooleanHandler
     488             :     //====================================================================
     489             :     //--------------------------------------------------------------------
     490           0 :     BooleanHandler::BooleanHandler( AttributeId _nAttributeId, WhichId _nWhichId )
     491           0 :         :AttributeHandler( _nAttributeId, _nWhichId )
     492             :     {
     493           0 :     }
     494             : 
     495             :     //--------------------------------------------------------------------
     496           0 :     AttributeCheckState BooleanHandler::implGetCheckState( const SfxPoolItem& _rItem ) const
     497             :     {
     498             :         OSL_ENSURE( _rItem.ISA( SfxBoolItem ), "BooleanHandler::implGetCheckState: invalid item!" );
     499           0 :         if ( _rItem.ISA( SfxBoolItem ) )
     500           0 :             return static_cast< const SfxBoolItem& >( _rItem ).GetValue() ? eChecked : eUnchecked;
     501             : 
     502           0 :         return eIndetermined;
     503             :     }
     504             : 
     505             :     //--------------------------------------------------------------------
     506           0 :     void BooleanHandler::executeAttribute( const SfxItemSet& /*_rCurrentAttribs*/, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType /*_nForScriptType*/ ) const
     507             :     {
     508             :         OSL_ENSURE( _pAdditionalArg && _pAdditionalArg->ISA( SfxBoolItem ), "BooleanHandler::executeAttribute: invalid argument!" );
     509           0 :         if ( _pAdditionalArg )
     510             :         {
     511           0 :             SfxPoolItem* pCorrectWich = _pAdditionalArg->Clone();
     512           0 :             pCorrectWich->SetWhich( getWhich() );
     513           0 :             _rNewAttribs.Put( *pCorrectWich );
     514           0 :             DELETEZ( pCorrectWich );
     515             :         }
     516           0 :     }
     517             : 
     518             : //........................................................................
     519             : }   // namespace frm
     520             : //........................................................................
     521             : 
     522             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10