LCOV - code coverage report
Current view: top level - svx/source/table - tabledesign.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 137 253 54.2 %
Date: 2015-06-13 12:38:46 Functions: 30 60 50.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             : 
      21             : #include <com/sun/star/style/XStyle.hpp>
      22             : #include <com/sun/star/lang/XServiceInfo.hpp>
      23             : #include <com/sun/star/lang/XComponent.hpp>
      24             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      25             : #include <com/sun/star/container/XIndexAccess.hpp>
      26             : #include <com/sun/star/container/XNameContainer.hpp>
      27             : #include <com/sun/star/beans/XPropertySet.hpp>
      28             : #include <com/sun/star/util/XModifyBroadcaster.hpp>
      29             : #include <com/sun/star/util/XModifyListener.hpp>
      30             : 
      31             : #include <osl/mutex.hxx>
      32             : #include <vcl/svapp.hxx>
      33             : 
      34             : #include <cppuhelper/basemutex.hxx>
      35             : #include <cppuhelper/compbase6.hxx>
      36             : #include <cppuhelper/implbase7.hxx>
      37             : #include <cppuhelper/interfacecontainer.h>
      38             : #include <cppuhelper/supportsservice.hxx>
      39             : 
      40             : #include "svx/unoprov.hxx"
      41             : #include "svx/sdr/table/tabledesign.hxx"
      42             : #include "svx/dialmgr.hxx"
      43             : #include "svx/dialogs.hrc"
      44             : 
      45             : #include "celltypes.hxx"
      46             : 
      47             : #include <vector>
      48             : #include <map>
      49             : 
      50             : #include <boost/bind.hpp>
      51             : 
      52             : 
      53             : 
      54             : using namespace ::com::sun::star::uno;
      55             : using namespace ::com::sun::star::style;
      56             : using namespace ::com::sun::star::lang;
      57             : using namespace ::com::sun::star::beans;
      58             : using namespace ::com::sun::star::util;
      59             : using namespace ::com::sun::star::container;
      60             : 
      61             : using ::osl::MutexGuard;
      62             : using ::osl::ClearableMutexGuard;
      63             : using ::cppu::OInterfaceContainerHelper;
      64             : 
      65             : namespace sdr { namespace table {
      66             : 
      67             : typedef std::map< OUString, sal_Int32 > CellStyleNameMap;
      68             : 
      69             : typedef ::cppu::WeakComponentImplHelper6< XStyle, XNameReplace, XServiceInfo, XIndexAccess, XModifyBroadcaster, XModifyListener > TableDesignStyleBase;
      70             : 
      71        5440 : class TableDesignStyle : private ::cppu::BaseMutex, public TableDesignStyleBase
      72             : {
      73             : public:
      74             :     TableDesignStyle();
      75             : 
      76             :     // XServiceInfo
      77             :     virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      78             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
      79             :     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      80             : 
      81             :     // XStyle
      82             :     virtual sal_Bool SAL_CALL isUserDefined() throw (RuntimeException, std::exception) SAL_OVERRIDE;
      83             :     virtual sal_Bool SAL_CALL isInUse() throw (RuntimeException, std::exception) SAL_OVERRIDE;
      84             :     virtual OUString SAL_CALL getParentStyle() throw (RuntimeException, std::exception) SAL_OVERRIDE;
      85             :     virtual void SAL_CALL setParentStyle( const OUString& aParentStyle ) throw (NoSuchElementException, RuntimeException, std::exception) SAL_OVERRIDE;
      86             : 
      87             :     // XNamed
      88             :     virtual OUString SAL_CALL getName() throw (RuntimeException, std::exception) SAL_OVERRIDE;
      89             :     virtual void SAL_CALL setName( const OUString& aName ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
      90             : 
      91             :     // XNameAccess
      92             :     virtual Any SAL_CALL getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
      93             :     virtual Sequence< OUString > SAL_CALL getElementNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      94             :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
      95             : 
      96             :     // XElementAccess
      97             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      98             :     virtual sal_Bool SAL_CALL hasElements() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      99             : 
     100             :     // XIndexAccess
     101             :     virtual sal_Int32 SAL_CALL getCount() throw(RuntimeException, std::exception) SAL_OVERRIDE ;
     102             :     virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     103             : 
     104             :     // XNameReplace
     105             :     virtual void SAL_CALL replaceByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     106             : 
     107             :     // XModifyBroadcaster
     108             :     virtual void SAL_CALL addModifyListener( const Reference< XModifyListener >& aListener ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     109             :     virtual void SAL_CALL removeModifyListener( const Reference< XModifyListener >& aListener ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     110             : 
     111             :     // XModifyListener
     112             :     virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     114             : 
     115             :     void notifyModifyListener();
     116             : 
     117             :     // this function is called upon disposing the component
     118             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     119             : 
     120             :     static const CellStyleNameMap& getCellStyleNameMap();
     121             : 
     122             :     OUString msName;
     123             :     Reference< XStyle > maCellStyles[style_count];
     124             : };
     125             : 
     126             : typedef std::vector< Reference< XStyle > > TableDesignStyleVector;
     127             : 
     128         950 : class TableDesignFamily : public ::cppu::WeakImplHelper7< XNameContainer, XNamed, XIndexAccess, XSingleServiceFactory,  XServiceInfo, XComponent, XPropertySet >
     129             : {
     130             : public:
     131             :     // XServiceInfo
     132             :     virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) SAL_OVERRIDE;
     133             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
     134             :     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
     135             : 
     136             :     // XNamed
     137             :     virtual OUString SAL_CALL getName(  ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     138             :     virtual void SAL_CALL setName( const OUString& aName ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     139             : 
     140             :     // XNameAccess
     141             :     virtual Any SAL_CALL getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     142             :     virtual Sequence< OUString > SAL_CALL getElementNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
     143             :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
     144             : 
     145             :     // XElementAccess
     146             :     virtual Type SAL_CALL getElementType() throw(RuntimeException, std::exception) SAL_OVERRIDE;
     147             :     virtual sal_Bool SAL_CALL hasElements() throw(RuntimeException, std::exception) SAL_OVERRIDE;
     148             : 
     149             :     // XIndexAccess
     150             :     virtual sal_Int32 SAL_CALL getCount() throw(RuntimeException, std::exception) SAL_OVERRIDE ;
     151             :     virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     152             : 
     153             :     // XNameContainer
     154             :     virtual void SAL_CALL insertByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     155             :     virtual void SAL_CALL removeByName( const OUString& Name ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     156             : 
     157             :     // XNameReplace
     158             :     virtual void SAL_CALL replaceByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     159             : 
     160             :     // XSingleServiceFactory
     161             :     virtual Reference< XInterface > SAL_CALL createInstance(  ) throw(Exception, RuntimeException, std::exception) SAL_OVERRIDE;
     162             :     virtual Reference< XInterface > SAL_CALL createInstanceWithArguments( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException, std::exception) SAL_OVERRIDE;
     163             : 
     164             :     // XComponent
     165             :     virtual void SAL_CALL dispose(  ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     166             :     virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     167             :     virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
     168             : 
     169             :     // XPropertySet
     170             :     virtual Reference<XPropertySetInfo> SAL_CALL getPropertySetInfo() throw (RuntimeException, std::exception) SAL_OVERRIDE;
     171             :     virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     172             :     virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     173             :     virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const Reference<XPropertyChangeListener>& xListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     174             :     virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     175             :     virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const Reference<XVetoableChangeListener>& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     176             :     virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName,const Reference<XVetoableChangeListener>&aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
     177             : 
     178             :     TableDesignStyleVector  maDesigns;
     179             : };
     180             : 
     181        2775 : TableDesignStyle::TableDesignStyle()
     182        2775 : : TableDesignStyleBase(m_aMutex)
     183             : {
     184        2775 : }
     185             : 
     186       19425 : const CellStyleNameMap& TableDesignStyle::getCellStyleNameMap()
     187             : {
     188       19425 :     static CellStyleNameMap aMap;
     189       19425 :     if( aMap.empty() )
     190             :     {
     191          19 :         CellStyleNameMap aNewMap;
     192          19 :         aNewMap[ OUString( "first-row" ) ] = first_row_style;
     193          19 :         aNewMap[ OUString( "last-row" ) ] = last_row_style;
     194          19 :         aNewMap[ OUString( "first-column" ) ] = first_column_style;
     195          19 :         aNewMap[ OUString( "last-column" ) ] = last_column_style;
     196          19 :         aNewMap[ OUString( "body" ) ] = body_style;
     197          19 :         aNewMap[ OUString( "even-rows" ) ] = even_rows_style;
     198          19 :         aNewMap[ OUString( "odd-rows" ) ] = odd_rows_style;
     199          19 :         aNewMap[ OUString( "even-columns" ) ] = even_columns_style;
     200          19 :         aNewMap[ OUString( "odd-columns" ) ] = odd_columns_style;
     201          19 :         aNewMap[ OUString( "background" ) ] = background_style;
     202          19 :         aMap.swap( aNewMap );
     203             :     }
     204             : 
     205       19425 :     return aMap;
     206             : }
     207             : 
     208             : // XServiceInfo
     209           0 : OUString SAL_CALL TableDesignStyle::getImplementationName() throw(RuntimeException, std::exception)
     210             : {
     211           0 :     return OUString("TableDesignStyle");
     212             : }
     213             : 
     214           0 : sal_Bool SAL_CALL TableDesignStyle::supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception)
     215             : {
     216           0 :     return cppu::supportsService( this, ServiceName );
     217             : }
     218             : 
     219           0 : Sequence< OUString > SAL_CALL TableDesignStyle::getSupportedServiceNames() throw(RuntimeException, std::exception)
     220             : {
     221           0 :     OUString aServiceName("com.sun.star.style.Style");
     222           0 :     Sequence< OUString > aSeq( &aServiceName, 1 );
     223           0 :     return aSeq;
     224             : }
     225             : 
     226             : // XStyle
     227           0 : sal_Bool SAL_CALL TableDesignStyle::isUserDefined() throw (RuntimeException, std::exception)
     228             : {
     229           0 :     return sal_False;
     230             : }
     231             : 
     232       31203 : sal_Bool SAL_CALL TableDesignStyle::isInUse() throw (RuntimeException, std::exception)
     233             : {
     234       31203 :     ClearableMutexGuard aGuard( rBHelper.rMutex );
     235       31203 :     OInterfaceContainerHelper * pContainer = rBHelper.getContainer( cppu::UnoType<XModifyListener>::get() );
     236       31203 :     if( pContainer )
     237             :     {
     238           0 :         Sequence< Reference< XInterface > > aListener( pContainer->getElements() );
     239           0 :         aGuard.clear();
     240             : 
     241           0 :         sal_Int32 nIndex = aListener.getLength();
     242           0 :         while( --nIndex >= 0 )
     243             :         {
     244           0 :             TableDesignUser* pUser = dynamic_cast< TableDesignUser* >( aListener[nIndex].get() );
     245           0 :             if( pUser && pUser->isInUse() )
     246           0 :                 return sal_True;
     247           0 :         }
     248             :     }
     249       31203 :     return sal_False;
     250             : }
     251             : 
     252             : 
     253             : 
     254           0 : OUString SAL_CALL TableDesignStyle::getParentStyle() throw (RuntimeException, std::exception)
     255             : {
     256           0 :     return OUString();
     257             : }
     258             : 
     259             : 
     260             : 
     261           0 : void SAL_CALL TableDesignStyle::setParentStyle( const OUString& ) throw (NoSuchElementException, RuntimeException, std::exception)
     262             : {
     263           0 : }
     264             : 
     265             : 
     266             : // XNamed
     267             : 
     268             : 
     269       27940 : OUString SAL_CALL TableDesignStyle::getName() throw (RuntimeException, std::exception)
     270             : {
     271       27940 :     return msName;
     272             : }
     273             : 
     274             : 
     275             : 
     276        2775 : void SAL_CALL TableDesignStyle::setName( const OUString& rName ) throw (RuntimeException, std::exception)
     277             : {
     278        2775 :     msName = rName;
     279        2775 : }
     280             : 
     281             : 
     282             : // XNameAccess
     283             : 
     284             : 
     285           0 : Any SAL_CALL TableDesignStyle::getByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
     286             : {
     287           0 :     SolarMutexGuard aGuard;
     288             : 
     289           0 :     const CellStyleNameMap& rMap = getCellStyleNameMap();
     290             : 
     291           0 :     CellStyleNameMap::const_iterator iter = rMap.find( rName );
     292           0 :     if( iter == rMap.end() )
     293           0 :         throw NoSuchElementException();
     294             : 
     295           0 :     return Any( maCellStyles[(*iter).second] );
     296             : }
     297             : 
     298             : 
     299             : 
     300           0 : Sequence< OUString > SAL_CALL TableDesignStyle::getElementNames() throw(RuntimeException, std::exception)
     301             : {
     302           0 :     SolarMutexGuard aGuard;
     303             : 
     304           0 :     const CellStyleNameMap& rMap = getCellStyleNameMap();
     305           0 :     Sequence< OUString > aRet( rMap.size() );
     306           0 :     OUString* pName = aRet.getArray();
     307             : 
     308           0 :     CellStyleNameMap::const_iterator iter = rMap.begin();
     309           0 :     while( iter != rMap.end() )
     310           0 :         *pName++ = (*iter++).first;
     311             : 
     312           0 :     return aRet;
     313             : }
     314             : 
     315             : 
     316             : 
     317           0 : sal_Bool SAL_CALL TableDesignStyle::hasByName( const OUString& rName )  throw(RuntimeException, std::exception)
     318             : {
     319           0 :     SolarMutexGuard aGuard;
     320             : 
     321           0 :     const CellStyleNameMap& rMap = getCellStyleNameMap();
     322             : 
     323           0 :     CellStyleNameMap::const_iterator iter = rMap.find( rName );
     324           0 :     return ( iter != rMap.end() ) ? sal_True : sal_False;
     325             : }
     326             : 
     327             : 
     328             : // XElementAccess
     329             : 
     330             : 
     331           0 : Type SAL_CALL TableDesignStyle::getElementType() throw(RuntimeException, std::exception)
     332             : {
     333           0 :     return cppu::UnoType<XStyle>::get();
     334             : }
     335             : 
     336             : 
     337             : 
     338           0 : sal_Bool SAL_CALL TableDesignStyle::hasElements() throw(RuntimeException, std::exception)
     339             : {
     340           0 :     return sal_True;
     341             : }
     342             : 
     343             : 
     344             : // XIndexAccess
     345             : 
     346             : 
     347           0 : sal_Int32 SAL_CALL TableDesignStyle::getCount() throw(RuntimeException, std::exception)
     348             : {
     349           0 :     return style_count;
     350             : }
     351             : 
     352             : 
     353             : 
     354         120 : Any SAL_CALL TableDesignStyle::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception)
     355             : {
     356         120 :     SolarMutexGuard aGuard;
     357             : 
     358         120 :     if( (Index < 0) || (Index >= style_count) )
     359           0 :         throw IndexOutOfBoundsException();
     360             : 
     361         120 :     return Any( maCellStyles[Index] );
     362             : }
     363             : 
     364             : 
     365             : // XNameReplace
     366             : 
     367             : 
     368       19425 : void SAL_CALL TableDesignStyle::replaceByName( const OUString& rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
     369             : {
     370       19425 :     SolarMutexGuard aGuard;
     371             : 
     372       19425 :     const CellStyleNameMap& rMap = getCellStyleNameMap();
     373       19425 :     CellStyleNameMap::const_iterator iter = rMap.find( rName );
     374       19425 :     if( iter == rMap.end() )
     375           0 :         throw NoSuchElementException();
     376             : 
     377             : 
     378       38850 :     Reference< XStyle > xNewStyle;
     379       19425 :     if( !(aElement >>= xNewStyle) )
     380           0 :         throw IllegalArgumentException();
     381             : 
     382       19425 :     const sal_Int32 nIndex = (*iter).second;
     383             : 
     384       38850 :     Reference< XStyle > xOldStyle( maCellStyles[nIndex] );
     385             : 
     386       19425 :     if( xNewStyle != xOldStyle )
     387             :     {
     388       19425 :         Reference< XModifyListener > xListener( this );
     389             : 
     390             :         // end listening to old style, if possible
     391       38850 :         Reference< XModifyBroadcaster > xOldBroadcaster( xOldStyle, UNO_QUERY );
     392       19425 :         if( xOldBroadcaster.is() )
     393           0 :             xOldBroadcaster->removeModifyListener( xListener );
     394             : 
     395             :         // start listening to new style, if possible
     396       38850 :         Reference< XModifyBroadcaster > xNewBroadcaster( xNewStyle, UNO_QUERY );
     397       19425 :         if( xNewBroadcaster.is() )
     398       19425 :             xNewBroadcaster->addModifyListener( xListener );
     399             : 
     400       38850 :         maCellStyles[nIndex] = xNewStyle;
     401       19425 :     }
     402       19425 : }
     403             : 
     404             : 
     405             : // XComponent
     406             : 
     407             : 
     408        2720 : void SAL_CALL TableDesignStyle::disposing()
     409             : {
     410       29920 :     for( sal_Int32 nIndex = 0; nIndex < style_count; nIndex++ )
     411       27200 :         maCellStyles[nIndex].clear();
     412        2720 : }
     413             : 
     414             : 
     415             : // XModifyBroadcaster
     416             : 
     417             : 
     418           4 : void SAL_CALL TableDesignStyle::addModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException, std::exception)
     419             : {
     420           4 :     ClearableMutexGuard aGuard( rBHelper.rMutex );
     421           4 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     422             :     {
     423           0 :         aGuard.clear();
     424           0 :         EventObject aEvt( static_cast< OWeakObject * >( this ) );
     425           0 :         xListener->disposing( aEvt );
     426             :     }
     427             :     else
     428             :     {
     429           4 :         rBHelper.addListener( cppu::UnoType<XModifyListener>::get(), xListener );
     430           4 :     }
     431           4 : }
     432             : 
     433             : 
     434             : 
     435           4 : void SAL_CALL TableDesignStyle::removeModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException, std::exception)
     436             : {
     437           4 :     rBHelper.removeListener( cppu::UnoType<XModifyListener>::get(), xListener );
     438           4 : }
     439             : 
     440             : 
     441             : 
     442       14812 : void TableDesignStyle::notifyModifyListener()
     443             : {
     444       14812 :     MutexGuard aGuard( rBHelper.rMutex );
     445             : 
     446       14812 :     OInterfaceContainerHelper * pContainer = rBHelper.getContainer( cppu::UnoType<XModifyListener>::get() );
     447       14812 :     if( pContainer )
     448             :     {
     449           0 :         EventObject aEvt( static_cast< OWeakObject * >( this ) );
     450           0 :         pContainer->forEach<XModifyListener>( boost::bind( &XModifyListener::modified, _1, boost::cref( aEvt ) ) );
     451       14812 :     }
     452       14812 : }
     453             : 
     454             : 
     455             : // XModifyListener
     456             : 
     457             : 
     458             : // if we get a modify hint from a style, notify all registered XModifyListener
     459       14812 : void SAL_CALL TableDesignStyle::modified( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     460             : {
     461       14812 :     notifyModifyListener();
     462       14812 : }
     463             : 
     464             : 
     465             : 
     466       19040 : void SAL_CALL TableDesignStyle::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     467             : {
     468       19040 : }
     469             : 
     470             : 
     471             : // TableStyle
     472             : 
     473             : 
     474             : 
     475             : // XServiceInfo
     476           0 : OUString SAL_CALL TableDesignFamily::getImplementationName() throw(RuntimeException, std::exception)
     477             : {
     478           0 :     return OUString("TableDesignFamily");
     479             : }
     480             : 
     481           0 : sal_Bool SAL_CALL TableDesignFamily::supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception)
     482             : {
     483           0 :     return cppu::supportsService( this, ServiceName );
     484             : }
     485             : 
     486           0 : Sequence< OUString > SAL_CALL TableDesignFamily::getSupportedServiceNames() throw(RuntimeException, std::exception)
     487             : {
     488           0 :     OUString aServiceName("com.sun.star.style.StyleFamily");
     489           0 :     Sequence< OUString > aSeq( &aServiceName, 1 );
     490           0 :     return aSeq;
     491             : }
     492             : 
     493             : // XNamed
     494         320 : OUString SAL_CALL TableDesignFamily::getName() throw (RuntimeException, std::exception)
     495             : {
     496         320 :     return OUString( "table" );
     497             : }
     498             : 
     499           0 : void SAL_CALL TableDesignFamily::setName( const OUString& ) throw (RuntimeException, std::exception)
     500             : {
     501           0 : }
     502             : 
     503             : // XNameAccess
     504           4 : Any SAL_CALL TableDesignFamily::getByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
     505             : {
     506           4 :     SolarMutexGuard aGuard;
     507             : 
     508           4 :     const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
     509           8 :     for( TableDesignStyleVector::const_iterator iter( maDesigns.begin() );
     510             :         iter != aEnd; ++iter)
     511             :     {
     512           8 :         if( (*iter)->getName() == rName )
     513           8 :             return Any( (*iter) );
     514             :     }
     515             : 
     516           4 :     throw NoSuchElementException();
     517             : }
     518             : 
     519             : 
     520             : 
     521           0 : Sequence< OUString > SAL_CALL TableDesignFamily::getElementNames() throw(RuntimeException, std::exception)
     522             : {
     523           0 :     SolarMutexGuard aGuard;
     524             : 
     525           0 :     Sequence< OUString > aRet( maDesigns.size() );
     526           0 :     OUString* pNames = aRet.getArray();
     527             : 
     528           0 :     const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
     529           0 :     for( TableDesignStyleVector::const_iterator iter( maDesigns.begin() );
     530             :          iter != aEnd; ++iter)
     531           0 :         *pNames++ = (*iter)->getName();
     532             : 
     533           0 :     return aRet;
     534             : }
     535             : 
     536             : 
     537             : 
     538        2808 : sal_Bool SAL_CALL TableDesignFamily::hasByName( const OUString& aName ) throw(RuntimeException, std::exception)
     539             : {
     540        2808 :     SolarMutexGuard aGuard;
     541             : 
     542        2808 :     const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
     543       16837 :     for( TableDesignStyleVector::const_iterator iter( maDesigns.begin() );
     544             :         iter != aEnd; ++iter)
     545       14065 :         if( (*iter)->getName() == aName )
     546          36 :             return sal_True;
     547             : 
     548        2772 :     return sal_False;
     549             : }
     550             : 
     551             : 
     552             : // XElementAccess
     553             : 
     554             : 
     555           0 : Type SAL_CALL TableDesignFamily::getElementType() throw(RuntimeException, std::exception)
     556             : {
     557           0 :     return cppu::UnoType<XStyle>::get();
     558             : }
     559             : 
     560             : 
     561             : 
     562           0 : sal_Bool SAL_CALL TableDesignFamily::hasElements() throw(RuntimeException, std::exception)
     563             : {
     564           0 :     SolarMutexGuard aGuard;
     565             : 
     566           0 :     return maDesigns.empty() ? sal_False : sal_True;
     567             : }
     568             : 
     569             : 
     570             : // XIndexAccess
     571             : 
     572             : 
     573         180 : sal_Int32 SAL_CALL TableDesignFamily::getCount() throw(RuntimeException, std::exception)
     574             : {
     575         180 :     SolarMutexGuard aGuard;
     576             : 
     577         180 :     return sal::static_int_cast< sal_Int32 >( maDesigns.size() );
     578             : }
     579             : 
     580             : 
     581             : 
     582         165 : Any SAL_CALL TableDesignFamily::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception)
     583             : {
     584         165 :     SolarMutexGuard aGuard;
     585             : 
     586         165 :     if( (Index >= 0) && (Index < sal::static_int_cast< sal_Int32 >( maDesigns.size() ) ) )
     587         330 :         return Any( maDesigns[Index] );
     588             : 
     589           0 :     throw IndexOutOfBoundsException();
     590             : }
     591             : 
     592             : 
     593             : // XNameContainer
     594             : 
     595             : 
     596        2772 : void SAL_CALL TableDesignFamily::insertByName( const OUString& rName, const Any& rElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception)
     597             : {
     598        2772 :     SolarMutexGuard aGuard;
     599             : 
     600        5544 :     Reference< XStyle > xStyle( rElement, UNO_QUERY );
     601        2772 :     if( !xStyle.is() )
     602           0 :         throw IllegalArgumentException();
     603             : 
     604        2772 :     xStyle->setName( rName );
     605        2772 :     const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
     606       16632 :     for( TableDesignStyleVector::const_iterator iter( maDesigns.begin() );
     607             :         iter != aEnd; ++iter)
     608       13860 :         if( (*iter)->getName() == rName )
     609           0 :             throw ElementExistException();
     610             : 
     611        5544 :     maDesigns.push_back( xStyle );
     612        2772 : }
     613             : 
     614             : 
     615             : 
     616           0 : void SAL_CALL TableDesignFamily::removeByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
     617             : {
     618           0 :     SolarMutexGuard aGuard;
     619             : 
     620           0 :     const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
     621           0 :     for( TableDesignStyleVector::iterator iter( maDesigns.begin() );
     622             :         iter != aEnd; ++iter)
     623             :     {
     624           0 :         if( (*iter)->getName() == rName )
     625             :         {
     626           0 :             maDesigns.erase( iter );
     627           0 :             return;
     628             :         }
     629             :     }
     630             : 
     631             : 
     632           0 :     throw NoSuchElementException();
     633             : }
     634             : 
     635             : 
     636             : // XNameReplace
     637             : 
     638             : 
     639           3 : void SAL_CALL TableDesignFamily::replaceByName( const OUString& rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
     640             : {
     641           3 :     SolarMutexGuard aGuard;
     642             : 
     643           6 :     Reference< XStyle > xStyle( aElement, UNO_QUERY );
     644           3 :     if( !xStyle.is() )
     645           0 :         throw IllegalArgumentException();
     646             : 
     647           3 :     const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
     648           7 :     for( TableDesignStyleVector::iterator iter( maDesigns.begin() );
     649             :         iter != aEnd; ++iter)
     650             :     {
     651           7 :         if( (*iter)->getName() == rName )
     652             :         {
     653           3 :             (*iter) = xStyle;
     654           3 :             xStyle->setName( rName );
     655           6 :             return;
     656             :         }
     657             :     }
     658             : 
     659           3 :     throw NoSuchElementException();
     660             : }
     661             : 
     662             : 
     663             : // XSingleServiceFactory
     664             : 
     665             : 
     666        2775 : Reference< XInterface > SAL_CALL TableDesignFamily::createInstance() throw(Exception, RuntimeException, std::exception)
     667             : {
     668        2775 :     SolarMutexGuard aGuard;
     669             : 
     670        2775 :     return Reference< XInterface >( static_cast< XStyle* >( new TableDesignStyle ) );
     671             : }
     672             : 
     673             : 
     674             : 
     675           0 : Reference< XInterface > SAL_CALL TableDesignFamily::createInstanceWithArguments( const Sequence< Any >&  ) throw(Exception, RuntimeException, std::exception)
     676             : {
     677           0 :     return createInstance();
     678             : }
     679             : 
     680             : 
     681             : // XComponent
     682             : 
     683             : 
     684         315 : void SAL_CALL TableDesignFamily::dispose(  ) throw (RuntimeException, std::exception)
     685             : {
     686         315 :     TableDesignStyleVector aDesigns;
     687         315 :     aDesigns.swap( maDesigns );
     688             : 
     689        3032 :     for( TableDesignStyleVector::iterator iter( aDesigns.begin() ); iter != aDesigns.end(); ++iter )
     690             :     {
     691        2717 :         Reference< XComponent > xComp( (*iter), UNO_QUERY );
     692        2717 :         if( xComp.is() )
     693        2717 :             xComp->dispose();
     694        3032 :     }
     695         315 : }
     696             : 
     697             : 
     698             : 
     699           0 : void SAL_CALL TableDesignFamily::addEventListener( const Reference< XEventListener >&  ) throw (RuntimeException, std::exception)
     700             : {
     701           0 : }
     702             : 
     703             : 
     704             : 
     705           0 : void SAL_CALL TableDesignFamily::removeEventListener( const Reference< XEventListener >&  ) throw (RuntimeException, std::exception)
     706             : {
     707           0 : }
     708             : 
     709             : 
     710             : // XPropertySet
     711             : 
     712             : 
     713           0 : Reference<XPropertySetInfo> TableDesignFamily::getPropertySetInfo() throw (RuntimeException, std::exception)
     714             : {
     715             :     OSL_FAIL( "###unexpected!" );
     716           0 :     return Reference<XPropertySetInfo>();
     717             : }
     718             : 
     719             : 
     720             : 
     721           0 : void TableDesignFamily::setPropertyValue( const OUString& , const Any&  ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
     722             : {
     723             :     OSL_FAIL( "###unexpected!" );
     724           0 : }
     725             : 
     726             : 
     727             : 
     728           0 : Any TableDesignFamily::getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     729             : {
     730           0 :     if ( PropertyName == "DisplayName" )
     731             :     {
     732           0 :         OUString sDisplayName( SVX_RESSTR( RID_SVXSTR_STYLEFAMILY_TABLEDESIGN ) );
     733           0 :         return Any( sDisplayName );
     734             :     }
     735             :     else
     736             :     {
     737           0 :         throw UnknownPropertyException( "unknown property: " + PropertyName, static_cast<OWeakObject *>(this) );
     738             :     }
     739             : }
     740             : 
     741             : 
     742             : 
     743           0 : void TableDesignFamily::addPropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>&  ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     744             : {
     745             :     OSL_FAIL( "###unexpected!" );
     746           0 : }
     747             : 
     748             : 
     749             : 
     750           0 : void TableDesignFamily::removePropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>&  ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     751             : {
     752             :     OSL_FAIL( "###unexpected!" );
     753           0 : }
     754             : 
     755             : 
     756             : 
     757           0 : void TableDesignFamily::addVetoableChangeListener( const OUString& , const Reference<XVetoableChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     758             : {
     759             :     OSL_FAIL( "###unexpected!" );
     760           0 : }
     761             : 
     762             : 
     763             : 
     764           0 : void TableDesignFamily::removeVetoableChangeListener( const OUString& , const Reference<XVetoableChangeListener>&  ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
     765             : {
     766             :     OSL_FAIL( "###unexpected!" );
     767           0 : }
     768             : 
     769             : 
     770             : 
     771             : 
     772         320 : Reference< XNameAccess > CreateTableDesignFamily()
     773             : {
     774         320 :     return new TableDesignFamily();
     775             : }
     776             : 
     777         390 : } }
     778             : 
     779             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11