LCOV - code coverage report
Current view: top level - forms/source/richtext - richtextmodel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 246 272 90.4 %
Date: 2012-08-25 Functions: 32 37 86.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 213 421 50.6 %

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

Generated by: LCOV version 1.10