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

Generated by: LCOV version 1.10