LCOV - code coverage report
Current view: top level - forms/source/richtext - parametrizedattributedispatcher.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 42 0.0 %
Date: 2014-04-14 Functions: 0 7 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 "parametrizedattributedispatcher.hxx"
      21             : #include <editeng/editview.hxx>
      22             : #include <svl/itemset.hxx>
      23             : #include <svl/itempool.hxx>
      24             : 
      25             : #include <svx/svxids.hrc>
      26             : #include <sfx2/sfxuno.hxx>
      27             : #include <com/sun/star/uno/Sequence.hxx>
      28             : #include <com/sun/star/beans/PropertyValue.hpp>
      29             : 
      30             : 
      31             : namespace frm
      32             : {
      33             : 
      34             : 
      35             :     using namespace ::com::sun::star::uno;
      36             :     using namespace ::com::sun::star::frame;
      37             :     using namespace ::com::sun::star::lang;
      38             :     using namespace ::com::sun::star::util;
      39             :     using namespace ::com::sun::star::beans;
      40             : 
      41             : 
      42             :     //= OParametrizedAttributeDispatcher
      43             : 
      44             : 
      45           0 :     OParametrizedAttributeDispatcher::OParametrizedAttributeDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL, IMultiAttributeDispatcher* _pMasterDispatcher )
      46           0 :         :OAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
      47             :     {
      48           0 :     }
      49             : 
      50             : 
      51           0 :     OParametrizedAttributeDispatcher::~OParametrizedAttributeDispatcher()
      52             :     {
      53           0 :         acquire();
      54           0 :         dispose();
      55           0 :     }
      56             : 
      57             : 
      58             :     namespace
      59             :     {
      60           0 :         static SfxSlotId lcl_normalizeLatinScriptSlotId( SfxSlotId _nSlotId )
      61             :         {
      62           0 :             switch ( _nSlotId )
      63             :             {
      64           0 :             case SID_ATTR_CHAR_LATIN_FONT:      return SID_ATTR_CHAR_FONT;
      65           0 :             case SID_ATTR_CHAR_LATIN_LANGUAGE:  return SID_ATTR_CHAR_LANGUAGE;
      66           0 :             case SID_ATTR_CHAR_LATIN_POSTURE:   return SID_ATTR_CHAR_POSTURE;
      67           0 :             case SID_ATTR_CHAR_LATIN_WEIGHT:    return SID_ATTR_CHAR_WEIGHT;
      68           0 :             case SID_ATTR_CHAR_LATIN_FONTHEIGHT:return SID_ATTR_CHAR_FONTHEIGHT;
      69             :             }
      70           0 :             return _nSlotId;
      71             :         }
      72             :     }
      73             : 
      74             : 
      75           0 :     void OParametrizedAttributeDispatcher::fillFeatureEventFromAttributeState( FeatureStateEvent& _rEvent, const AttributeState& _rState ) const
      76             :     {
      77             :         OSL_ENSURE( getEditView(), "OParametrizedAttributeDispatcher::notifyState: already disposed!" );
      78           0 :         if ( !getEditView() )
      79           0 :             return;
      80             : 
      81           0 :         SfxItemSet aEmptySet( const_cast< EditView* >( getEditView() )->GetEmptyItemSet() );
      82           0 :         Sequence< PropertyValue > aUnoStateDescription;
      83           0 :         if ( _rState.getItem() )
      84             :         {
      85           0 :             aEmptySet.Put( *_rState.getItem() );
      86           0 :             SfxSlotId nSlotId = aEmptySet.GetPool()->GetSlotId( _rState.getItem()->Which() );
      87           0 :             TransformItems( nSlotId, aEmptySet, aUnoStateDescription );
      88           0 :             _rEvent.State <<= aUnoStateDescription;
      89             :         }
      90             :         else
      91           0 :             OAttributeDispatcher::fillFeatureEventFromAttributeState( _rEvent, _rState );
      92             :     }
      93             : 
      94             : 
      95           0 :     const SfxPoolItem* OParametrizedAttributeDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
      96             :     {
      97             :         // get the real slot id. This may differ from our attribute id: for instance, both
      98             :         // SID_ATTR_CHAR_HEIGHT and SID_ATTR_CHAR_LATIN_HEIGHT are mapped to the same which id
      99           0 :         SfxSlotId nSlotId = lcl_normalizeLatinScriptSlotId( (SfxSlotId)m_nAttributeId );
     100             : 
     101           0 :         SfxAllItemSet aParameterSet( getEditView()->GetEmptyItemSet() );
     102           0 :         TransformParameters( nSlotId, _rArguments, aParameterSet );
     103             : 
     104           0 :         const SfxPoolItem* pArgument = NULL;
     105           0 :         if ( aParameterSet.Count() )
     106             :         {
     107             :             OSL_ENSURE( aParameterSet.Count() == 1, "OParametrizedAttributeDispatcher::convertDispatchArgsToItem: Arguments which form more than 1 item? How this?" );
     108           0 :             WhichId nAttributeWhich = aParameterSet.GetPool()->GetWhich( nSlotId );
     109           0 :             pArgument = aParameterSet.GetItem( nAttributeWhich );
     110             :             OSL_ENSURE( pArgument, "OParametrizedAttributeDispatcher::convertDispatchArgsToItem: suspicious: there were arguments, but they're not for my slot!" );
     111             :         }
     112             : 
     113           0 :         return pArgument;
     114             :     }
     115             : 
     116             : 
     117           0 :     void SAL_CALL OParametrizedAttributeDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (RuntimeException, std::exception)
     118             :     {
     119           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     120             :         OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OParametrizedAttributeDispatcher::dispatch: invalid URL!" );
     121             :         (void)_rURL;
     122           0 :         if ( m_pMasterDispatcher )
     123             :         {
     124           0 :             const SfxPoolItem* pConvertedArgument = convertDispatchArgsToItem( _rArguments );
     125           0 :             m_pMasterDispatcher->executeAttribute( m_nAttributeId, pConvertedArgument );
     126           0 :         }
     127           0 :     }
     128             : 
     129             : 
     130             : }   // namespace frm
     131             : 
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10