LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/forms/source/richtext - richtextmodel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 248 274 90.5 %
Date: 2013-07-09 Functions: 34 39 87.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "richtextmodel.hxx"
      21             : #include "richtextengine.hxx"
      22             : #include "richtextunowrapper.hxx"
      23             : 
      24             : #include <com/sun/star/awt/LineEndFormat.hpp>
      25             : #include <com/sun/star/text/WritingMode2.hpp>
      26             : #include <com/sun/star/style/VerticalAlignment.hpp>
      27             : 
      28             : #include <cppuhelper/typeprovider.hxx>
      29             : #include <comphelper/guarding.hxx>
      30             : #include <toolkit/awt/vclxdevice.hxx>
      31             : #include <toolkit/helper/vclunohelper.hxx>
      32             : #include <editeng/editstat.hxx>
      33             : #include <vcl/outdev.hxx>
      34             : #include <vcl/svapp.hxx>
      35             : 
      36             : //--------------------------------------------------------------------------
      37          15 : extern "C" void SAL_CALL createRegistryInfo_ORichTextModel()
      38             : {
      39          15 :     static ::frm::OMultiInstanceAutoRegistration< ::frm::ORichTextModel >   aRegisterModel;
      40          15 : }
      41             : 
      42             : //........................................................................
      43             : namespace frm
      44             : {
      45             : //........................................................................
      46             : 
      47             :     using namespace ::com::sun::star::uno;
      48             :     using namespace ::com::sun::star::awt;
      49             :     using namespace ::com::sun::star::lang;
      50             :     using namespace ::com::sun::star::io;
      51             :     using namespace ::com::sun::star::beans;
      52             :     using namespace ::com::sun::star::form;
      53             :     using namespace ::com::sun::star::util;
      54             :     using namespace ::com::sun::star::style;
      55             : 
      56             :     namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
      57             : 
      58             :     //====================================================================
      59             :     //= ORichTextModel
      60             :     //====================================================================
      61             :     DBG_NAME( ORichTextModel )
      62             :     //--------------------------------------------------------------------
      63         103 :     ORichTextModel::ORichTextModel( const Reference< XComponentContext >& _rxFactory )
      64             :         :OControlModel       ( _rxFactory, OUString() )
      65             :         ,FontControlModel    ( true                          )
      66             :         ,m_pEngine           ( RichTextEngine::Create()      )
      67             :         ,m_bSettingEngineText( false                         )
      68         103 :         ,m_aModifyListeners  ( m_aMutex                      )
      69             :     {
      70             :         DBG_CTOR( ORichTextModel, NULL );
      71         103 :         m_nClassId = FormComponentType::TEXTFIELD;
      72             : 
      73         103 :         getPropertyDefaultByHandle( PROPERTY_ID_DEFAULTCONTROL          ) >>= m_sDefaultControl;
      74         103 :         getPropertyDefaultByHandle( PROPERTY_ID_BORDER                  ) >>= m_nBorder;
      75         103 :         getPropertyDefaultByHandle( PROPERTY_ID_ENABLED                 ) >>= m_bEnabled;
      76         103 :         getPropertyDefaultByHandle( PROPERTY_ID_ENABLEVISIBLE           ) >>= m_bEnableVisible;
      77         103 :         getPropertyDefaultByHandle( PROPERTY_ID_HARDLINEBREAKS          ) >>= m_bHardLineBreaks;
      78         103 :         getPropertyDefaultByHandle( PROPERTY_ID_HSCROLL                 ) >>= m_bHScroll;
      79         103 :         getPropertyDefaultByHandle( PROPERTY_ID_VSCROLL                 ) >>= m_bVScroll;
      80         103 :         getPropertyDefaultByHandle( PROPERTY_ID_READONLY                ) >>= m_bReadonly;
      81         103 :         getPropertyDefaultByHandle( PROPERTY_ID_PRINTABLE               ) >>= m_bPrintable;
      82         103 :         getPropertyDefaultByHandle( PROPERTY_ID_ALIGN                   ) >>= m_aAlign;
      83         103 :         getPropertyDefaultByHandle( PROPERTY_ID_ECHO_CHAR               ) >>= m_nEchoChar;
      84         103 :         getPropertyDefaultByHandle( PROPERTY_ID_MAXTEXTLEN              ) >>= m_nMaxTextLength;
      85         103 :         getPropertyDefaultByHandle( PROPERTY_ID_MULTILINE               ) >>= m_bMultiLine;
      86         103 :         getPropertyDefaultByHandle( PROPERTY_ID_RICH_TEXT               ) >>= m_bReallyActAsRichText;
      87         103 :         getPropertyDefaultByHandle( PROPERTY_ID_HIDEINACTIVESELECTION   ) >>= m_bHideInactiveSelection;
      88         103 :         getPropertyDefaultByHandle( PROPERTY_ID_LINEEND_FORMAT          ) >>= m_nLineEndFormat;
      89         103 :         getPropertyDefaultByHandle( PROPERTY_ID_WRITING_MODE            ) >>= m_nTextWritingMode;
      90         103 :         getPropertyDefaultByHandle( PROPERTY_ID_CONTEXT_WRITING_MODE    ) >>= m_nContextWritingMode;
      91             : 
      92         103 :         implInit();
      93         103 :     }
      94             : 
      95             :     //------------------------------------------------------------------
      96           2 :     ORichTextModel::ORichTextModel( const ORichTextModel* _pOriginal, const Reference< XComponentContext >& _rxFactory )
      97             :         :OControlModel       ( _pOriginal, _rxFactory, sal_False )
      98             :         ,FontControlModel    ( _pOriginal                        )
      99             :         ,m_pEngine           ( NULL                              )
     100             :         ,m_bSettingEngineText( false                             )
     101           2 :         ,m_aModifyListeners  ( m_aMutex                          )
     102             :     {
     103             :         DBG_CTOR( ORichTextModel, NULL );
     104             : 
     105           2 :         m_aTabStop               = _pOriginal->m_aTabStop;
     106           2 :         m_aBackgroundColor       = _pOriginal->m_aBackgroundColor;
     107           2 :         m_aBorderColor           = _pOriginal->m_aBorderColor;
     108           2 :         m_aVerticalAlignment     = _pOriginal->m_aVerticalAlignment;
     109           2 :         m_sDefaultControl        = _pOriginal->m_sDefaultControl;
     110           2 :         m_sHelpText              = _pOriginal->m_sHelpText;
     111           2 :         m_sHelpURL               = _pOriginal->m_sHelpURL;
     112           2 :         m_nBorder                = _pOriginal->m_nBorder;
     113           2 :         m_bEnabled               = _pOriginal->m_bEnabled;
     114           2 :         m_bEnableVisible         = _pOriginal->m_bEnableVisible;
     115           2 :         m_bHardLineBreaks        = _pOriginal->m_bHardLineBreaks;
     116           2 :         m_bHScroll               = _pOriginal->m_bHScroll;
     117           2 :         m_bVScroll               = _pOriginal->m_bVScroll;
     118           2 :         m_bReadonly              = _pOriginal->m_bReadonly;
     119           2 :         m_bPrintable             = _pOriginal->m_bPrintable;
     120           2 :         m_bReallyActAsRichText   = _pOriginal->m_bReallyActAsRichText;
     121           2 :         m_bHideInactiveSelection = _pOriginal->m_bHideInactiveSelection;
     122           2 :         m_nLineEndFormat         = _pOriginal->m_nLineEndFormat;
     123           2 :         m_nTextWritingMode       = _pOriginal->m_nTextWritingMode;
     124           2 :         m_nContextWritingMode    = _pOriginal->m_nContextWritingMode;
     125             : 
     126           2 :         m_aAlign               = _pOriginal->m_aAlign;
     127           2 :         m_nEchoChar            = _pOriginal->m_nEchoChar;
     128           2 :         m_nMaxTextLength       = _pOriginal->m_nMaxTextLength;
     129           2 :         m_bMultiLine           = _pOriginal->m_bMultiLine;
     130             : 
     131           2 :         m_pEngine.reset(_pOriginal->m_pEngine->Clone());
     132           2 :         m_sLastKnownEngineText = m_pEngine->GetText();
     133             : 
     134           2 :         implInit();
     135           2 :     }
     136             : 
     137             :     //------------------------------------------------------------------
     138         105 :     void ORichTextModel::implInit()
     139             :     {
     140             :         OSL_ENSURE( m_pEngine.get(), "ORichTextModel::implInit: where's the engine?" );
     141         105 :         if ( m_pEngine.get() )
     142             :         {
     143         105 :             m_pEngine->SetModifyHdl( LINK( this, ORichTextModel, OnEngineContentModified ) );
     144             : 
     145         105 :             sal_uLong nEngineControlWord = m_pEngine->GetControlWord();
     146         105 :             nEngineControlWord = nEngineControlWord & ~EE_CNTRL_AUTOPAGESIZE;
     147         105 :             m_pEngine->SetControlWord( nEngineControlWord );
     148             : 
     149         105 :             VCLXDevice* pUnoRefDevice = new VCLXDevice;
     150         105 :             pUnoRefDevice->SetOutputDevice( m_pEngine->GetRefDevice() );
     151         105 :             m_xReferenceDevice = pUnoRefDevice;
     152             :         }
     153             : 
     154         105 :         implDoAggregation();
     155         105 :         implRegisterProperties();
     156         105 :     }
     157             : 
     158             :     //------------------------------------------------------------------
     159         105 :     void ORichTextModel::implDoAggregation()
     160             :     {
     161         105 :         increment( m_refCount );
     162             : 
     163             :         {
     164         105 :             m_xAggregate = new ORichTextUnoWrapper( *m_pEngine, this );
     165         105 :             setAggregation( m_xAggregate );
     166         105 :             doSetDelegator();
     167             :         }
     168             : 
     169         105 :         decrement( m_refCount );
     170         105 :     }
     171             : 
     172             :     //------------------------------------------------------------------
     173         105 :     void ORichTextModel::implRegisterProperties()
     174             :     {
     175         105 :         REGISTER_PROP_2( DEFAULTCONTROL,        m_sDefaultControl,          BOUND, MAYBEDEFAULT );
     176         105 :         REGISTER_PROP_2( HELPTEXT,              m_sHelpText,                BOUND, MAYBEDEFAULT );
     177         105 :         REGISTER_PROP_2( HELPURL,               m_sHelpURL,                 BOUND, MAYBEDEFAULT );
     178         105 :         REGISTER_PROP_2( ENABLED,               m_bEnabled,                 BOUND, MAYBEDEFAULT );
     179         105 :         REGISTER_PROP_2( ENABLEVISIBLE,               m_bEnableVisible,                 BOUND, MAYBEDEFAULT );
     180         105 :         REGISTER_PROP_2( BORDER,                m_nBorder,                  BOUND, MAYBEDEFAULT );
     181         105 :         REGISTER_PROP_2( HARDLINEBREAKS,        m_bHardLineBreaks,          BOUND, MAYBEDEFAULT );
     182         105 :         REGISTER_PROP_2( HSCROLL,               m_bHScroll,                 BOUND, MAYBEDEFAULT );
     183         105 :         REGISTER_PROP_2( VSCROLL,               m_bVScroll,                 BOUND, MAYBEDEFAULT );
     184         105 :         REGISTER_PROP_2( READONLY,              m_bReadonly,                BOUND, MAYBEDEFAULT );
     185         105 :         REGISTER_PROP_2( PRINTABLE,             m_bPrintable,               BOUND, MAYBEDEFAULT );
     186         105 :         REGISTER_PROP_2( REFERENCE_DEVICE,      m_xReferenceDevice,         BOUND, TRANSIENT    );
     187         105 :         REGISTER_PROP_2( RICH_TEXT,             m_bReallyActAsRichText,     BOUND, MAYBEDEFAULT );
     188         105 :         REGISTER_PROP_2( HIDEINACTIVESELECTION, m_bHideInactiveSelection,   BOUND, MAYBEDEFAULT );
     189             : 
     190         105 :         REGISTER_VOID_PROP_2( TABSTOP,          m_aTabStop,             sal_Bool,           BOUND, MAYBEDEFAULT );
     191         105 :         REGISTER_VOID_PROP_2( BACKGROUNDCOLOR,  m_aBackgroundColor,     sal_Int32,          BOUND, MAYBEDEFAULT );
     192         105 :         REGISTER_VOID_PROP_2( BORDERCOLOR,      m_aBorderColor,         sal_Int32,          BOUND, MAYBEDEFAULT );
     193         105 :         REGISTER_VOID_PROP_2( VERTICAL_ALIGN,   m_aVerticalAlignment,   VerticalAlignment,  BOUND, MAYBEDEFAULT );
     194             : 
     195             :         // properties which exist only for compatibility with the css.swt.UnoControlEditModel,
     196             :         // since we replace the default implementation for this service
     197         105 :         REGISTER_PROP_2( ECHO_CHAR,             m_nEchoChar,            BOUND, MAYBEDEFAULT );
     198         105 :         REGISTER_PROP_2( MAXTEXTLEN,            m_nMaxTextLength,       BOUND, MAYBEDEFAULT );
     199         105 :         REGISTER_PROP_2( MULTILINE,             m_bMultiLine,           BOUND, MAYBEDEFAULT );
     200         105 :         REGISTER_PROP_2( TEXT,                  m_sLastKnownEngineText, BOUND, MAYBEDEFAULT );
     201         105 :         REGISTER_PROP_2( LINEEND_FORMAT,        m_nLineEndFormat,       BOUND, MAYBEDEFAULT );
     202         105 :         REGISTER_PROP_2( WRITING_MODE,          m_nTextWritingMode,     BOUND, MAYBEDEFAULT );
     203         105 :         REGISTER_PROP_3( CONTEXT_WRITING_MODE,  m_nContextWritingMode,  BOUND, MAYBEDEFAULT, TRANSIENT );
     204             : 
     205         105 :         REGISTER_VOID_PROP_2( ALIGN,        m_aAlign,           sal_Int16, BOUND, MAYBEDEFAULT );
     206         105 :     }
     207             : 
     208             :     //--------------------------------------------------------------------
     209         291 :     ORichTextModel::~ORichTextModel( )
     210             :     {
     211          97 :         if ( !OComponentHelper::rBHelper.bDisposed )
     212             :         {
     213           0 :             acquire();
     214           0 :             dispose();
     215             :         }
     216          97 :         if ( m_pEngine.get() )
     217             :         {
     218          97 :             SolarMutexGuard g;
     219          97 :             SfxItemPool* pPool = m_pEngine->getPool();
     220          97 :             m_pEngine.reset();
     221          97 :             SfxItemPool::Free(pPool);
     222             :         }
     223             : 
     224             : 
     225             :         DBG_DTOR( ORichTextModel, NULL );
     226         194 :     }
     227             : 
     228             :     //------------------------------------------------------------------
     229       13512 :     Any SAL_CALL ORichTextModel::queryAggregation( const Type& _rType ) throw ( RuntimeException )
     230             :     {
     231       13512 :         Any aReturn = ORichTextModel_BASE::queryInterface( _rType );
     232             : 
     233       13512 :         if ( !aReturn.hasValue() )
     234        1672 :             aReturn = OControlModel::queryAggregation( _rType );
     235             : 
     236       13512 :         return aReturn;
     237             :     }
     238             : 
     239             :     //------------------------------------------------------------------
     240           2 :     IMPLEMENT_FORWARD_XTYPEPROVIDER2( ORichTextModel, OControlModel, ORichTextModel_BASE )
     241             : 
     242             :     //--------------------------------------------------------------------
     243         252 :     IMPLEMENT_SERVICE_REGISTRATION_8( ORichTextModel, OControlModel,
     244             :         FRM_SUN_COMPONENT_RICHTEXTCONTROL,
     245             :         OUString( "com.sun.star.text.TextRange" ),
     246             :         OUString( "com.sun.star.style.CharacterProperties" ),
     247             :         OUString( "com.sun.star.style.ParagraphProperties" ),
     248             :         OUString( "com.sun.star.style.CharacterPropertiesAsian" ),
     249             :         OUString( "com.sun.star.style.CharacterPropertiesComplex" ),
     250             :         OUString( "com.sun.star.style.ParagraphPropertiesAsian" ),
     251             :         OUString( "com.sun.star.style.ParagraphPropertiesComplex" )
     252             :     )
     253             : 
     254             :     //------------------------------------------------------------------------------
     255           2 :     IMPLEMENT_DEFAULT_CLONING( ORichTextModel )
     256             : 
     257             :     //------------------------------------------------------------------------------
     258          97 :     void SAL_CALL ORichTextModel::disposing()
     259             :     {
     260          97 :         m_aModifyListeners.disposeAndClear( EventObject( *this ) );
     261          97 :         OControlModel::disposing();
     262          97 :     }
     263             : 
     264             :     //------------------------------------------------------------------------------
     265             :     namespace
     266             :     {
     267         210 :         void lcl_removeProperty( Sequence< Property >& _rSeq, const OUString& _rPropertyName )
     268             :         {
     269         210 :             Property* pLoop = _rSeq.getArray();
     270         210 :             Property* pEnd = _rSeq.getArray() + _rSeq.getLength();
     271        7140 :             while ( pLoop != pEnd )
     272             :             {
     273        6930 :                 if ( pLoop->Name == _rPropertyName )
     274             :                 {
     275         210 :                     ::std::copy( pLoop + 1, pEnd, pLoop );
     276         210 :                     _rSeq.realloc( _rSeq.getLength() - 1 );
     277         210 :                     break;
     278             :                 }
     279        6720 :                 ++pLoop;
     280             :             }
     281         210 :         }
     282             :     }
     283             :     //------------------------------------------------------------------------------
     284         105 :     void ORichTextModel::describeFixedProperties( Sequence< Property >& _rProps ) const
     285             :     {
     286         105 :         BEGIN_DESCRIBE_PROPERTIES( 1, OControlModel )
     287         105 :             DECL_PROP2( TABINDEX,       sal_Int16,  BOUND,    MAYBEDEFAULT );
     288             :         END_DESCRIBE_PROPERTIES();
     289             : 
     290             :         // properties which the OPropertyContainerHelper is responsible for
     291         105 :         Sequence< Property > aContainedProperties;
     292         105 :         describeProperties( aContainedProperties );
     293             : 
     294             :         // properties which the FontControlModel is responsible for
     295         210 :         Sequence< Property > aFontProperties;
     296         105 :         describeFontRelatedProperties( aFontProperties );
     297             : 
     298         210 :         _rProps = concatSequences( aContainedProperties, aFontProperties, _rProps );
     299         105 :     }
     300             : 
     301             :     //------------------------------------------------------------------------------
     302         105 :     void ORichTextModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const
     303             :     {
     304         105 :         OControlModel::describeAggregateProperties( _rAggregateProps );
     305             : 
     306             :         // our aggregate (the SvxUnoText) declares a FontDescriptor property, as does
     307             :         // our FormControlFont base class. We remove it from the base class' sequence
     308             :         // here, and later on care for both instances being in sync
     309         105 :         lcl_removeProperty( _rAggregateProps, PROPERTY_FONT );
     310             : 
     311             :         // similar, the WritingMode property is declared in our aggregate, too, but we override
     312             :         // it, since the aggregate does no proper PropertyState handling.
     313         105 :         lcl_removeProperty( _rAggregateProps, PROPERTY_WRITING_MODE );
     314         105 :     }
     315             : 
     316             :     //--------------------------------------------------------------------
     317        6312 :     void SAL_CALL ORichTextModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
     318             :     {
     319        6312 :         if ( isRegisteredProperty( _nHandle ) )
     320             :         {
     321        4221 :             OPropertyContainerHelper::getFastPropertyValue( _rValue, _nHandle );
     322             :         }
     323        2091 :         else if ( isFontRelatedProperty( _nHandle ) )
     324             :         {
     325        2091 :             FontControlModel::getFastPropertyValue( _rValue, _nHandle );
     326             :         }
     327             :         else
     328             :         {
     329           0 :             OControlModel::getFastPropertyValue( _rValue, _nHandle );
     330             :         }
     331        6312 :     }
     332             : 
     333             :     //--------------------------------------------------------------------
     334        1564 :     sal_Bool SAL_CALL ORichTextModel::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue ) throw( IllegalArgumentException )
     335             :     {
     336        1564 :         sal_Bool bModified = sal_False;
     337             : 
     338        1564 :         if ( isRegisteredProperty( _nHandle ) )
     339             :         {
     340        1343 :             bModified = OPropertyContainerHelper::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
     341             :         }
     342         221 :         else if ( isFontRelatedProperty( _nHandle ) )
     343             :         {
     344         221 :             bModified = FontControlModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
     345             :         }
     346             :         else
     347             :         {
     348           0 :             bModified = OControlModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
     349             :         }
     350             : 
     351        1563 :         return bModified;
     352             :     }
     353             : 
     354             :     //--------------------------------------------------------------------
     355         499 :     void SAL_CALL ORichTextModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception)
     356             :     {
     357         499 :         if ( isRegisteredProperty( _nHandle ) )
     358             :         {
     359         432 :             OPropertyContainerHelper::setFastPropertyValue( _nHandle, _rValue );
     360             : 
     361         432 :             switch ( _nHandle )
     362             :             {
     363             :             case PROPERTY_ID_REFERENCE_DEVICE:
     364             :             {
     365             :             #if OSL_DEBUG_LEVEL > 0
     366             :                 MapMode aOldMapMode = m_pEngine->GetRefDevice()->GetMapMode();
     367             :             #endif
     368             : 
     369          38 :                 OutputDevice* pRefDevice = VCLUnoHelper::GetOutputDevice( m_xReferenceDevice );
     370             :                 OSL_ENSURE( pRefDevice, "ORichTextModel::setFastPropertyValue_NoBroadcast: empty reference device?" );
     371          38 :                 m_pEngine->SetRefDevice( pRefDevice );
     372             : 
     373             :             #if OSL_DEBUG_LEVEL > 0
     374             :                 MapMode aNewMapMode = m_pEngine->GetRefDevice()->GetMapMode();
     375             :                 OSL_ENSURE( aNewMapMode.GetMapUnit() == aOldMapMode.GetMapUnit(),
     376             :                     "ORichTextModel::setFastPropertyValue_NoBroadcast: You should not tamper with the MapUnit of the ref device!" );
     377             :                 // if this assertion here is triggered, then we would need to adjust all
     378             :                 // items in all text portions in all paragraphs in the attributes of the EditEngine,
     379             :                 // as long as they are MapUnit-dependent. This holds at least for the FontSize.
     380             :             #endif
     381             :             }
     382          38 :             break;
     383             : 
     384             :             case PROPERTY_ID_TEXT:
     385             :             {
     386          41 :                 MutexRelease aReleaseMutex( m_aMutex );
     387          41 :                 impl_smlock_setEngineText( m_sLastKnownEngineText );
     388             :             }
     389          41 :             break;
     390             :             }   // switch ( _nHandle )
     391             :         }
     392          67 :         else if ( isFontRelatedProperty( _nHandle ) )
     393             :         {
     394          67 :             FontDescriptor aOldFont( getFont() );
     395             : 
     396          67 :             FontControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
     397             : 
     398          67 :             if ( isFontAggregateProperty( _nHandle ) )
     399          49 :                 firePropertyChange( PROPERTY_ID_FONT, makeAny( getFont() ), makeAny( aOldFont ) );
     400             :         }
     401             :         else
     402             :         {
     403           0 :             switch ( _nHandle )
     404             :             {
     405             :             case PROPERTY_ID_WRITING_MODE:
     406             :             {
     407             :                 // forward to our aggregate, so the EditEngine knows about it
     408           0 :                 if ( m_xAggregateSet.is() )
     409           0 :                     m_xAggregateSet->setPropertyValue(
     410           0 :                         OUString( "WritingMode" ), _rValue );
     411             :             }
     412           0 :             break;
     413             : 
     414             :             default:
     415           0 :                 OControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
     416           0 :                 break;
     417             :             }
     418             :         }
     419         499 :     }
     420             : 
     421             :     //--------------------------------------------------------------------
     422        1858 :     Any ORichTextModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const
     423             :     {
     424        1858 :         Any aDefault;
     425             : 
     426        1858 :         switch ( _nHandle )
     427             :         {
     428             :         case PROPERTY_ID_WRITING_MODE:
     429             :         case PROPERTY_ID_CONTEXT_WRITING_MODE:
     430         206 :             aDefault <<= WritingMode2::CONTEXT;
     431         206 :             break;
     432             : 
     433             :         case PROPERTY_ID_LINEEND_FORMAT:
     434         103 :             aDefault <<= (sal_Int16)LineEndFormat::LINE_FEED;
     435         103 :             break;
     436             : 
     437             :         case PROPERTY_ID_ECHO_CHAR:
     438             :         case PROPERTY_ID_ALIGN:
     439             :         case PROPERTY_ID_MAXTEXTLEN:
     440         313 :             aDefault <<= (sal_Int16)0;
     441         313 :             break;
     442             : 
     443             :         case PROPERTY_ID_TABSTOP:
     444             :         case PROPERTY_ID_BACKGROUNDCOLOR:
     445             :         case PROPERTY_ID_BORDERCOLOR:
     446             :         case PROPERTY_ID_VERTICAL_ALIGN:
     447             :             /* void */
     448           0 :             break;
     449             : 
     450             :         case PROPERTY_ID_ENABLED:
     451             :         case PROPERTY_ID_ENABLEVISIBLE:
     452             :         case PROPERTY_ID_PRINTABLE:
     453             :         case PROPERTY_ID_HIDEINACTIVESELECTION:
     454         412 :             aDefault <<= (sal_Bool)sal_True;
     455         412 :             break;
     456             : 
     457             :         case PROPERTY_ID_HARDLINEBREAKS:
     458             :         case PROPERTY_ID_HSCROLL:
     459             :         case PROPERTY_ID_VSCROLL:
     460             :         case PROPERTY_ID_READONLY:
     461             :         case PROPERTY_ID_MULTILINE:
     462             :         case PROPERTY_ID_RICH_TEXT:
     463         618 :             aDefault <<= (sal_Bool)sal_False;
     464         618 :             break;
     465             : 
     466             :         case PROPERTY_ID_DEFAULTCONTROL:
     467         103 :             aDefault <<= (OUString)FRM_SUN_CONTROL_RICHTEXTCONTROL;
     468         103 :             break;
     469             : 
     470             :         case PROPERTY_ID_HELPTEXT:
     471             :         case PROPERTY_ID_HELPURL:
     472             :         case PROPERTY_ID_TEXT:
     473           0 :             aDefault <<= OUString();
     474           0 :             break;
     475             : 
     476             :         case PROPERTY_ID_BORDER:
     477         103 :             aDefault <<= (sal_Int16)1;
     478         103 :             break;
     479             : 
     480             :         default:
     481           0 :             if ( isFontRelatedProperty( _nHandle ) )
     482           0 :                 aDefault = FontControlModel::getPropertyDefaultByHandle( _nHandle );
     483             :             else
     484           0 :                 aDefault = OControlModel::getPropertyDefaultByHandle( _nHandle );
     485             :         }
     486             : 
     487        1858 :         return aDefault;
     488             :     }
     489             : 
     490             :     //--------------------------------------------------------------------
     491          41 :     void ORichTextModel::impl_smlock_setEngineText( const OUString& _rText )
     492             :     {
     493          41 :         if ( m_pEngine.get() )
     494             :         {
     495          41 :             SolarMutexGuard aSolarGuard;
     496          41 :             m_bSettingEngineText = true;
     497          41 :             m_pEngine->SetText( _rText );
     498          41 :             m_bSettingEngineText = false;
     499             :         }
     500          41 :     }
     501             : 
     502             :     //--------------------------------------------------------------------
     503           0 :     OUString SAL_CALL ORichTextModel::getServiceName() throw ( RuntimeException)
     504             :     {
     505           0 :         return OUString(FRM_SUN_COMPONENT_RICHTEXTCONTROL);
     506             :     }
     507             : 
     508             :     //--------------------------------------------------------------------
     509           0 :     void SAL_CALL ORichTextModel::write(const Reference< XObjectOutputStream >& _rxOutStream) throw ( IOException, RuntimeException)
     510             :     {
     511           0 :         OControlModel::write( _rxOutStream );
     512             :         // TODO: place your code here
     513           0 :     }
     514             : 
     515             :     //--------------------------------------------------------------------
     516           0 :     void SAL_CALL ORichTextModel::read(const Reference< XObjectInputStream >& _rxInStream) throw ( IOException, RuntimeException)
     517             :     {
     518           0 :         OControlModel::read( _rxInStream );
     519             :         // TODO: place your code here
     520           0 :     }
     521             : 
     522             :     //--------------------------------------------------------------------
     523          20 :     RichTextEngine* ORichTextModel::getEditEngine( const Reference< XControlModel >& _rxModel )
     524             :     {
     525          20 :         RichTextEngine* pEngine = NULL;
     526             : 
     527          20 :         Reference< XUnoTunnel > xTunnel( _rxModel, UNO_QUERY );
     528             :         OSL_ENSURE( xTunnel.is(), "ORichTextModel::getEditEngine: invalid model!" );
     529          20 :         if ( xTunnel.is() )
     530             :         {
     531             :             try
     532             :             {
     533          20 :                 pEngine = reinterpret_cast< RichTextEngine* >( xTunnel->getSomething( getEditEngineTunnelId() ) );
     534             :             }
     535           0 :             catch( const Exception& )
     536             :             {
     537             :                 OSL_FAIL( "ORichTextModel::getEditEngine: caught an exception!" );
     538             :             }
     539             :         }
     540          20 :         return pEngine;
     541             :     }
     542             : 
     543             :     //--------------------------------------------------------------------
     544          42 :     Sequence< sal_Int8 > ORichTextModel::getEditEngineTunnelId()
     545             :     {
     546             :         static ::cppu::OImplementationId * pId = 0;
     547          42 :         if (! pId)
     548             :         {
     549           1 :             ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     550           1 :             if (! pId)
     551             :             {
     552           1 :                 static ::cppu::OImplementationId aId;
     553           1 :                 pId = &aId;
     554           1 :             }
     555             :         }
     556          42 :         return pId->getImplementationId();
     557             :     }
     558             : 
     559             :     //--------------------------------------------------------------------
     560        1266 :     IMPL_LINK( ORichTextModel, OnEngineContentModified, void*, /*_pNotInterestedIn*/ )
     561             :     {
     562         633 :         if ( !m_bSettingEngineText )
     563             :         {
     564         553 :             m_aModifyListeners.notifyEach( &XModifyListener::modified, EventObject( *this ) );
     565             : 
     566         553 :             potentialTextChange();
     567             :                 // is this a good idea? It may become expensive in case of larger texts,
     568             :                 // and this method here is called for every single changed character ...
     569             :                 // On the other hand, the API *requires* us to notify changes in the "Text"
     570             :                 // property immediately ...
     571             :         }
     572             : 
     573         633 :         return 0L;
     574             :     }
     575             : 
     576             :     //--------------------------------------------------------------------
     577          22 :     sal_Int64 SAL_CALL ORichTextModel::getSomething( const Sequence< sal_Int8 >& _rId ) throw (RuntimeException)
     578             :     {
     579          22 :         Sequence< sal_Int8 > aEditEngineAccessId( getEditEngineTunnelId() );
     580          44 :         if  (   ( _rId.getLength() == aEditEngineAccessId.getLength() )
     581          22 :             &&  ( 0 == memcmp( aEditEngineAccessId.getConstArray(),  _rId.getConstArray(), _rId.getLength() ) )
     582             :             )
     583          20 :             return reinterpret_cast< sal_Int64 >( m_pEngine.get() );
     584             : 
     585           4 :         Reference< XUnoTunnel > xAggTunnel;
     586           2 :         if ( query_aggregation( m_xAggregate, xAggTunnel ) )
     587           2 :             return xAggTunnel->getSomething( _rId );
     588             : 
     589          22 :         return 0;
     590             :     }
     591             : 
     592             :     //--------------------------------------------------------------------
     593          60 :     void SAL_CALL ORichTextModel::addModifyListener( const Reference< XModifyListener >& _rxListener ) throw (RuntimeException)
     594             :     {
     595          60 :         m_aModifyListeners.addInterface( _rxListener );
     596          60 :     }
     597             : 
     598             :     //--------------------------------------------------------------------
     599          58 :     void SAL_CALL ORichTextModel::removeModifyListener( const Reference< XModifyListener >& _rxListener ) throw (RuntimeException)
     600             :     {
     601          58 :         m_aModifyListeners.removeInterface( _rxListener );
     602          58 :     }
     603             : 
     604             :     //--------------------------------------------------------------------
     605         847 :     void ORichTextModel::potentialTextChange( )
     606             :     {
     607         847 :         OUString sCurrentEngineText;
     608         847 :         if ( m_pEngine.get() )
     609         847 :             sCurrentEngineText = m_pEngine->GetText();
     610             : 
     611         847 :         if ( sCurrentEngineText != m_sLastKnownEngineText )
     612             :         {
     613          14 :             sal_Int32 nHandle = PROPERTY_ID_TEXT;
     614          14 :             Any aOldValue; aOldValue <<= m_sLastKnownEngineText;
     615          28 :             Any aNewValue; aNewValue <<= sCurrentEngineText;
     616          14 :             fire( &nHandle, &aNewValue, &aOldValue, 1, sal_False );
     617             : 
     618          28 :             m_sLastKnownEngineText = sCurrentEngineText;
     619         847 :         }
     620         847 :     }
     621             : 
     622             : //........................................................................
     623          72 : } // namespace frm
     624             : //........................................................................
     625             : 
     626             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10