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

Generated by: LCOV version 1.10