LCOV - code coverage report
Current view: top level - libreoffice/forms/source/richtext - specialdispatchers.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 66 0.0 %
Date: 2012-12-27 Functions: 0 12 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 "specialdispatchers.hxx"
      21             : #include <editeng/editeng.hxx>
      22             : #include <editeng/editview.hxx>
      23             : #include <svx/svxids.hrc>
      24             : #define ITEMID_SCRIPTSPACE          SID_ATTR_PARA_SCRIPTSPACE
      25             : #include <editeng/scriptspaceitem.hxx>
      26             : 
      27             : //........................................................................
      28             : namespace frm
      29             : {
      30             : //........................................................................
      31             : 
      32             :     using namespace ::com::sun::star::uno;
      33             :     using namespace ::com::sun::star::lang;
      34             :     using namespace ::com::sun::star::util;
      35             :     using namespace ::com::sun::star::frame;
      36             :     using namespace ::com::sun::star::beans;
      37             : 
      38             :     //====================================================================
      39             :     //= OSelectAllDispatcher
      40             :     //====================================================================
      41             :     //--------------------------------------------------------------------
      42           0 :     OSelectAllDispatcher::OSelectAllDispatcher( EditView& _rView, const URL&  _rURL )
      43           0 :         :ORichTextFeatureDispatcher( _rView, _rURL )
      44             :     {
      45           0 :     }
      46             : 
      47             :     //--------------------------------------------------------------------
      48           0 :     OSelectAllDispatcher::~OSelectAllDispatcher( )
      49             :     {
      50           0 :         if ( !isDisposed() )
      51             :         {
      52           0 :             acquire();
      53           0 :             dispose();
      54             :         }
      55           0 :     }
      56             : 
      57             :     //--------------------------------------------------------------------
      58           0 :     void SAL_CALL OSelectAllDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ ) throw (RuntimeException)
      59             :     {
      60           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      61             :         OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OSelectAllDispatcher::dispatch: invalid URL!" );
      62             :         (void)_rURL;
      63             : 
      64           0 :         checkDisposed();
      65             : 
      66           0 :         EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
      67             :         OSL_ENSURE( pEngine, "OSelectAllDispatcher::dispatch: no edit engine - but not yet disposed?" );
      68           0 :         if ( !pEngine )
      69           0 :             return;
      70             : 
      71           0 :         sal_uInt16 nParagraphs = pEngine->GetParagraphCount();
      72           0 :         if ( nParagraphs )
      73             :         {
      74           0 :             sal_uInt16 nLastParaNumber = nParagraphs - 1;
      75           0 :             xub_StrLen nParaLen = pEngine->GetTextLen( nLastParaNumber );
      76           0 :             getEditView()->SetSelection( ESelection( 0, 0, nLastParaNumber, nParaLen ) );
      77           0 :         }
      78             :     }
      79             : 
      80             :     //--------------------------------------------------------------------
      81           0 :     FeatureStateEvent OSelectAllDispatcher::buildStatusEvent() const
      82             :     {
      83           0 :         FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
      84           0 :         aEvent.IsEnabled = sal_True;
      85           0 :         return aEvent;
      86             :     }
      87             : 
      88             :     //====================================================================
      89             :     //= OParagraphDirectionDispatcher
      90             :     //====================================================================
      91             :     //--------------------------------------------------------------------
      92           0 :     OParagraphDirectionDispatcher::OParagraphDirectionDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL,
      93             :             IMultiAttributeDispatcher* _pMasterDispatcher )
      94           0 :         :OAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
      95             :     {
      96           0 :     }
      97             : 
      98             :     //--------------------------------------------------------------------
      99           0 :     FeatureStateEvent OParagraphDirectionDispatcher::buildStatusEvent() const
     100             :     {
     101           0 :         FeatureStateEvent aEvent( OAttributeDispatcher::buildStatusEvent() );
     102             : 
     103           0 :         EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
     104             :         OSL_ENSURE( pEngine, "OParagraphDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
     105           0 :         if ( pEngine && pEngine->IsVertical() )
     106           0 :             aEvent.IsEnabled = sal_False;
     107             : 
     108           0 :         return aEvent;
     109             :     }
     110             : 
     111             :     //====================================================================
     112             :     //= OTextDirectionDispatcher
     113             :     //====================================================================
     114             :     //--------------------------------------------------------------------
     115           0 :     OTextDirectionDispatcher::OTextDirectionDispatcher( EditView& _rView, const URL& _rURL )
     116           0 :         :ORichTextFeatureDispatcher( _rView, _rURL )
     117             :     {
     118           0 :     }
     119             : 
     120             :     //--------------------------------------------------------------------
     121           0 :     void SAL_CALL OTextDirectionDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ ) throw (RuntimeException)
     122             :     {
     123           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     124             :         OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OTextDirectionDispatcher::dispatch: invalid URL!" );
     125             :         (void)_rURL;
     126             : 
     127           0 :         checkDisposed();
     128             : 
     129           0 :         EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
     130             :         OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
     131           0 :         if ( !pEngine )
     132           0 :             return;
     133             : 
     134           0 :         pEngine->SetVertical( !pEngine->IsVertical() );
     135             :     }
     136             : 
     137             :     //--------------------------------------------------------------------
     138           0 :     FeatureStateEvent OTextDirectionDispatcher::buildStatusEvent() const
     139             :     {
     140           0 :         FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
     141             : 
     142           0 :         EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
     143             :         OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
     144             : 
     145           0 :         aEvent.IsEnabled = sal_True;
     146           0 :         aEvent.State <<= (sal_Bool)( pEngine && pEngine->IsVertical() );
     147             : 
     148           0 :         return aEvent;
     149             :     }
     150             : 
     151             :     //====================================================================
     152             :     //= OAsianFontLayoutDispatcher
     153             :     //====================================================================
     154             :     //--------------------------------------------------------------------
     155           0 :     OAsianFontLayoutDispatcher::OAsianFontLayoutDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL, IMultiAttributeDispatcher* _pMasterDispatcher )
     156           0 :         :OParametrizedAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
     157             :     {
     158           0 :     }
     159             : 
     160             :     //--------------------------------------------------------------------
     161           0 :     const SfxPoolItem* OAsianFontLayoutDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
     162             :     {
     163             :         // look for the "Enable" parameter
     164           0 :         const PropertyValue* pLookup = _rArguments.getConstArray();
     165           0 :         const PropertyValue* pLookupEnd = _rArguments.getConstArray() + _rArguments.getLength();
     166           0 :         while ( pLookup != pLookupEnd )
     167             :         {
     168           0 :             if ( pLookup->Name == "Enable" )
     169           0 :                 break;
     170           0 :             ++pLookup;
     171             :         }
     172           0 :         if ( pLookup != pLookupEnd )
     173             :         {
     174           0 :             sal_Bool bEnable = sal_True;
     175           0 :             OSL_VERIFY( pLookup->Value >>= bEnable );
     176           0 :             if ( m_nAttributeId == SID_ATTR_PARA_SCRIPTSPACE )
     177           0 :                 return new SvxScriptSpaceItem( bEnable, (WhichId)m_nAttributeId );
     178           0 :             return new SfxBoolItem( (WhichId)m_nAttributeId, bEnable );
     179             :         }
     180             : 
     181             :         OSL_FAIL( "OAsianFontLayoutDispatcher::convertDispatchArgsToItem: did not find the one and only argument!" );
     182           0 :         return NULL;
     183             :     }
     184             : 
     185             : //........................................................................
     186             : }   // namespace frm
     187             : //........................................................................
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10