LCOV - code coverage report
Current view: top level - chart2/source/model/main - FormattedString.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 75 0.0 %
Date: 2014-04-14 Functions: 0 31 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "FormattedString.hxx"
      21             : #include "ContainerHelper.hxx"
      22             : 
      23             : #include "CharacterProperties.hxx"
      24             : #include "PropertyHelper.hxx"
      25             : #include "macros.hxx"
      26             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      27             : 
      28             : using namespace ::com::sun::star;
      29             : 
      30             : using ::com::sun::star::beans::Property;
      31             : using ::com::sun::star::uno::Sequence;
      32             : using ::com::sun::star::uno::Reference;
      33             : using ::com::sun::star::uno::Any;
      34             : using ::osl::MutexGuard;
      35             : 
      36             : namespace
      37             : {
      38             : 
      39             : struct StaticFormattedStringDefaults_Initializer
      40             : {
      41           0 :     ::chart::tPropertyValueMap* operator()()
      42             :     {
      43           0 :         static ::chart::tPropertyValueMap aStaticDefaults;
      44           0 :         lcl_AddDefaultsToMap( aStaticDefaults );
      45           0 :         return &aStaticDefaults;
      46             :     }
      47             : private:
      48           0 :     void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
      49             :     {
      50           0 :         ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
      51           0 :     }
      52             : };
      53             : 
      54             : struct StaticFormattedStringDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticFormattedStringDefaults_Initializer >
      55             : {
      56             : };
      57             : 
      58             : struct StaticFormattedStringInfoHelper_Initializer
      59             : {
      60           0 :     ::cppu::OPropertyArrayHelper* operator()()
      61             :     {
      62           0 :         static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
      63           0 :         return &aPropHelper;
      64             :     }
      65             : 
      66             : private:
      67           0 :     Sequence< Property > lcl_GetPropertySequence()
      68             :     {
      69           0 :         ::std::vector< ::com::sun::star::beans::Property > aProperties;
      70           0 :         ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
      71             : 
      72             :         ::std::sort( aProperties.begin(), aProperties.end(),
      73           0 :                      ::chart::PropertyNameLess() );
      74             : 
      75           0 :         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
      76             :     }
      77             : 
      78             : };
      79             : 
      80             : struct StaticFormattedStringInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticFormattedStringInfoHelper_Initializer >
      81             : {
      82             : };
      83             : 
      84             : struct StaticFormattedStringInfo_Initializer
      85             : {
      86           0 :     uno::Reference< beans::XPropertySetInfo >* operator()()
      87             :     {
      88             :         static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
      89           0 :             ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticFormattedStringInfoHelper::get() ) );
      90           0 :         return &xPropertySetInfo;
      91             :     }
      92             : };
      93             : 
      94             : struct StaticFormattedStringInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticFormattedStringInfo_Initializer >
      95             : {
      96             : };
      97             : 
      98             : } // anonymous namespace
      99             : 
     100             : namespace chart
     101             : {
     102             : 
     103           0 : FormattedString::FormattedString(
     104             :         uno::Reference< uno::XComponentContext > const & /* xContext */ ) :
     105             :         ::property::OPropertySet( m_aMutex ),
     106             :     m_aString(),
     107           0 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     108           0 : {}
     109             : 
     110           0 : FormattedString::FormattedString( const FormattedString & rOther ) :
     111             :         MutexContainer(),
     112             :         impl::FormattedString_Base(),
     113             :         ::property::OPropertySet( rOther, m_aMutex ),
     114             :     m_aString( rOther.m_aString ),
     115           0 :     m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
     116           0 : {}
     117             : 
     118           0 : FormattedString::~FormattedString()
     119           0 : {}
     120             : 
     121             : // ____ XCloneable ____
     122           0 : uno::Reference< util::XCloneable > SAL_CALL FormattedString::createClone()
     123             :     throw (uno::RuntimeException, std::exception)
     124             : {
     125           0 :     return uno::Reference< util::XCloneable >( new FormattedString( *this ));
     126             : }
     127             : 
     128             : // ____ XFormattedString ____
     129           0 : OUString SAL_CALL FormattedString::getString()
     130             :     throw (uno::RuntimeException, std::exception)
     131             : {
     132           0 :     MutexGuard aGuard( GetMutex());
     133           0 :     return m_aString;
     134             : }
     135             : 
     136           0 : void SAL_CALL FormattedString::setString( const OUString& String )
     137             :     throw (uno::RuntimeException, std::exception)
     138             : {
     139             :     {
     140           0 :         MutexGuard aGuard( GetMutex());
     141           0 :         m_aString = String;
     142             :     }
     143             :     //don't keep the mutex locked while calling out
     144           0 :     fireModifyEvent();
     145             : 
     146           0 : }
     147             : 
     148             : // ____ XModifyBroadcaster ____
     149           0 : void SAL_CALL FormattedString::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     150             :     throw (uno::RuntimeException, std::exception)
     151             : {
     152             :     try
     153             :     {
     154           0 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     155           0 :         xBroadcaster->addModifyListener( aListener );
     156             :     }
     157           0 :     catch( const uno::Exception & ex )
     158             :     {
     159             :         ASSERT_EXCEPTION( ex );
     160             :     }
     161           0 : }
     162             : 
     163           0 : void SAL_CALL FormattedString::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
     164             :     throw (uno::RuntimeException, std::exception)
     165             : {
     166             :     try
     167             :     {
     168           0 :         uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
     169           0 :         xBroadcaster->removeModifyListener( aListener );
     170             :     }
     171           0 :     catch( const uno::Exception & ex )
     172             :     {
     173             :         ASSERT_EXCEPTION( ex );
     174             :     }
     175           0 : }
     176             : 
     177             : // ____ XModifyListener ____
     178           0 : void SAL_CALL FormattedString::modified( const lang::EventObject& aEvent )
     179             :     throw (uno::RuntimeException, std::exception)
     180             : {
     181           0 :     m_xModifyEventForwarder->modified( aEvent );
     182           0 : }
     183             : 
     184             : // ____ XEventListener (base of XModifyListener) ____
     185           0 : void SAL_CALL FormattedString::disposing( const lang::EventObject& /* Source */ )
     186             :     throw (uno::RuntimeException, std::exception)
     187             : {
     188             :     // nothing
     189           0 : }
     190             : 
     191             : // ____ OPropertySet ____
     192           0 : void FormattedString::firePropertyChangeEvent()
     193             : {
     194           0 :     fireModifyEvent();
     195           0 : }
     196             : 
     197           0 : void FormattedString::fireModifyEvent()
     198             : {
     199           0 :     m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
     200           0 : }
     201             : 
     202           0 : Sequence< OUString > FormattedString::getSupportedServiceNames_Static()
     203             : {
     204           0 :     Sequence< OUString > aServices( 2 );
     205             : 
     206           0 :     aServices[ 0 ] = "com.sun.star.chart2.FormattedString";
     207           0 :     aServices[ 1 ] = "com.sun.star.beans.PropertySet";
     208           0 :     return aServices;
     209             : }
     210             : 
     211             : // ____ OPropertySet ____
     212           0 : uno::Any FormattedString::GetDefaultValue( sal_Int32 nHandle ) const
     213             :     throw(beans::UnknownPropertyException)
     214             : {
     215           0 :     const tPropertyValueMap& rStaticDefaults = *StaticFormattedStringDefaults::get();
     216           0 :     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     217           0 :     if( aFound == rStaticDefaults.end() )
     218           0 :         return uno::Any();
     219           0 :     return (*aFound).second;
     220             : }
     221             : 
     222             : // ____ OPropertySet ____
     223           0 : ::cppu::IPropertyArrayHelper & SAL_CALL FormattedString::getInfoHelper()
     224             : {
     225           0 :     return *StaticFormattedStringInfoHelper::get();
     226             : }
     227             : 
     228             : // ____ XPropertySet ____
     229           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL FormattedString::getPropertySetInfo()
     230             :     throw (uno::RuntimeException, std::exception)
     231             : {
     232           0 :     return *StaticFormattedStringInfo::get();
     233             : }
     234             : 
     235             : using impl::FormattedString_Base;
     236             : 
     237           0 : IMPLEMENT_FORWARD_XINTERFACE2( FormattedString, FormattedString_Base, ::property::OPropertySet )
     238           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( FormattedString, FormattedString_Base, ::property::OPropertySet )
     239             : 
     240             : // do this in derived classes!
     241             : 
     242             : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
     243           0 : APPHELPER_XSERVICEINFO_IMPL( FormattedString,
     244             :                              OUString("com.sun.star.comp.chart.FormattedString") );
     245             : 
     246             : } //  namespace chart
     247             : 
     248             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10