Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / table / tabledesign.cxx
bloba8f6d45fdbb45d1aab5cebb420d7a1948ca4d972
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
31 #include <osl/mutex.hxx>
32 #include <vcl/svapp.hxx>
34 #include <cppuhelper/basemutex.hxx>
35 #include <cppuhelper/compbase6.hxx>
36 #include <cppuhelper/implbase7.hxx>
37 #include <cppuhelper/interfacecontainer.h>
38 #include <cppuhelper/supportsservice.hxx>
40 #include "svx/unoprov.hxx"
41 #include "svx/sdr/table/tabledesign.hxx"
42 #include "svx/dialmgr.hxx"
43 #include "svx/dialogs.hrc"
45 #include "celltypes.hxx"
47 #include <vector>
48 #include <map>
50 #include <boost/bind.hpp>
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;
61 using ::osl::MutexGuard;
62 using ::osl::ClearableMutexGuard;
63 using ::cppu::OInterfaceContainerHelper;
65 namespace sdr { namespace table {
67 typedef std::map< OUString, sal_Int32 > CellStyleNameMap;
69 typedef ::cppu::WeakComponentImplHelper6< XStyle, XNameReplace, XServiceInfo, XIndexAccess, XModifyBroadcaster, XModifyListener > TableDesignStyleBase;
71 class TableDesignStyle : private ::cppu::BaseMutex, public TableDesignStyleBase
73 public:
74 TableDesignStyle();
76 // XServiceInfo
77 virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) SAL_OVERRIDE;
78 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
79 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
81 // XStyle
82 virtual sal_Bool SAL_CALL isUserDefined() throw (RuntimeException, std::exception) SAL_OVERRIDE;
83 virtual sal_Bool SAL_CALL isInUse() throw (RuntimeException, std::exception) SAL_OVERRIDE;
84 virtual OUString SAL_CALL getParentStyle() throw (RuntimeException, std::exception) SAL_OVERRIDE;
85 virtual void SAL_CALL setParentStyle( const OUString& aParentStyle ) throw (NoSuchElementException, RuntimeException, std::exception) SAL_OVERRIDE;
87 // XNamed
88 virtual OUString SAL_CALL getName() throw (RuntimeException, std::exception) SAL_OVERRIDE;
89 virtual void SAL_CALL setName( const OUString& aName ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
91 // XNameAccess
92 virtual Any SAL_CALL getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
93 virtual Sequence< OUString > SAL_CALL getElementNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
94 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
96 // XElementAccess
97 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(RuntimeException, std::exception) SAL_OVERRIDE;
98 virtual sal_Bool SAL_CALL hasElements() throw(RuntimeException, std::exception) SAL_OVERRIDE;
100 // XIndexAccess
101 virtual sal_Int32 SAL_CALL getCount() throw(RuntimeException, std::exception) SAL_OVERRIDE ;
102 virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
104 // XNameReplace
105 virtual void SAL_CALL replaceByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
107 // XModifyBroadcaster
108 virtual void SAL_CALL addModifyListener( const Reference< XModifyListener >& aListener ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
109 virtual void SAL_CALL removeModifyListener( const Reference< XModifyListener >& aListener ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
111 // XModifyListener
112 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 void notifyModifyListener();
117 // this function is called upon disposing the component
118 virtual void SAL_CALL disposing() SAL_OVERRIDE;
120 static const CellStyleNameMap& getCellStyleNameMap();
122 OUString msName;
123 Reference< XStyle > maCellStyles[style_count];
126 typedef std::vector< Reference< XStyle > > TableDesignStyleVector;
128 class TableDesignFamily : public ::cppu::WeakImplHelper7< XNameContainer, XNamed, XIndexAccess, XSingleServiceFactory, XServiceInfo, XComponent, XPropertySet >
130 public:
131 // XServiceInfo
132 virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) SAL_OVERRIDE;
133 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
134 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
136 // XNamed
137 virtual OUString SAL_CALL getName( ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
138 virtual void SAL_CALL setName( const OUString& aName ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
140 // XNameAccess
141 virtual Any SAL_CALL getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
142 virtual Sequence< OUString > SAL_CALL getElementNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
143 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
145 // XElementAccess
146 virtual Type SAL_CALL getElementType() throw(RuntimeException, std::exception) SAL_OVERRIDE;
147 virtual sal_Bool SAL_CALL hasElements() throw(RuntimeException, std::exception) SAL_OVERRIDE;
149 // XIndexAccess
150 virtual sal_Int32 SAL_CALL getCount() throw(RuntimeException, std::exception) SAL_OVERRIDE ;
151 virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
153 // XNameContainer
154 virtual void SAL_CALL insertByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
155 virtual void SAL_CALL removeByName( const OUString& Name ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
157 // XNameReplace
158 virtual void SAL_CALL replaceByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
160 // XSingleServiceFactory
161 virtual Reference< XInterface > SAL_CALL createInstance( ) throw(Exception, RuntimeException, std::exception) SAL_OVERRIDE;
162 virtual Reference< XInterface > SAL_CALL createInstanceWithArguments( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException, std::exception) SAL_OVERRIDE;
164 // XComponent
165 virtual void SAL_CALL dispose( ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
166 virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
167 virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
169 // XPropertySet
170 virtual Reference<XPropertySetInfo> SAL_CALL getPropertySetInfo() throw (RuntimeException, std::exception) SAL_OVERRIDE;
171 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
172 virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
173 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const Reference<XPropertyChangeListener>& xListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
174 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
175 virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const Reference<XVetoableChangeListener>& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
176 virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName,const Reference<XVetoableChangeListener>&aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
178 TableDesignStyleVector maDesigns;
182 // TableDesignStyle
185 TableDesignStyle::TableDesignStyle()
186 : TableDesignStyleBase(m_aMutex)
190 const CellStyleNameMap& TableDesignStyle::getCellStyleNameMap()
192 static CellStyleNameMap aMap;
193 if( aMap.empty() )
195 CellStyleNameMap aNewMap;
196 aNewMap[ OUString( "first-row" ) ] = first_row_style;
197 aNewMap[ OUString( "last-row" ) ] = last_row_style;
198 aNewMap[ OUString( "first-column" ) ] = first_column_style;
199 aNewMap[ OUString( "last-column" ) ] = last_column_style;
200 aNewMap[ OUString( "body" ) ] = body_style;
201 aNewMap[ OUString( "even-rows" ) ] = even_rows_style;
202 aNewMap[ OUString( "odd-rows" ) ] = odd_rows_style;
203 aNewMap[ OUString( "even-columns" ) ] = even_columns_style;
204 aNewMap[ OUString( "odd-columns" ) ] = odd_columns_style;
205 aNewMap[ OUString( "background" ) ] = background_style;
206 aMap.swap( aNewMap );
209 return aMap;
212 // XServiceInfo
213 OUString SAL_CALL TableDesignStyle::getImplementationName() throw(RuntimeException, std::exception)
215 return OUString("TableDesignStyle");
218 sal_Bool SAL_CALL TableDesignStyle::supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception)
220 return cppu::supportsService( this, ServiceName );
223 Sequence< OUString > SAL_CALL TableDesignStyle::getSupportedServiceNames() throw(RuntimeException, std::exception)
225 OUString aServiceName("com.sun.star.style.Style");
226 Sequence< OUString > aSeq( &aServiceName, 1 );
227 return aSeq;
230 // XStyle
231 sal_Bool SAL_CALL TableDesignStyle::isUserDefined() throw (RuntimeException, std::exception)
233 return sal_False;
236 sal_Bool SAL_CALL TableDesignStyle::isInUse() throw (RuntimeException, std::exception)
238 ClearableMutexGuard aGuard( rBHelper.rMutex );
239 OInterfaceContainerHelper * pContainer = rBHelper.getContainer( cppu::UnoType<XModifyListener>::get() );
240 if( pContainer )
242 Sequence< Reference< XInterface > > aListener( pContainer->getElements() );
243 aGuard.clear();
245 sal_Int32 nIndex = aListener.getLength();
246 while( --nIndex >= 0 )
248 TableDesignUser* pUser = dynamic_cast< TableDesignUser* >( aListener[nIndex].get() );
249 if( pUser && pUser->isInUse() )
250 return sal_True;
253 return sal_False;
258 OUString SAL_CALL TableDesignStyle::getParentStyle() throw (RuntimeException, std::exception)
260 return OUString();
265 void SAL_CALL TableDesignStyle::setParentStyle( const OUString& ) throw (NoSuchElementException, RuntimeException, std::exception)
270 // XNamed
273 OUString SAL_CALL TableDesignStyle::getName() throw (RuntimeException, std::exception)
275 return msName;
280 void SAL_CALL TableDesignStyle::setName( const OUString& rName ) throw (RuntimeException, std::exception)
282 msName = rName;
286 // XNameAccess
289 Any SAL_CALL TableDesignStyle::getByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
291 SolarMutexGuard aGuard;
293 const CellStyleNameMap& rMap = getCellStyleNameMap();
295 CellStyleNameMap::const_iterator iter = rMap.find( rName );
296 if( iter == rMap.end() )
297 throw NoSuchElementException();
299 return Any( maCellStyles[(*iter).second] );
304 Sequence< OUString > SAL_CALL TableDesignStyle::getElementNames() throw(RuntimeException, std::exception)
306 SolarMutexGuard aGuard;
308 const CellStyleNameMap& rMap = getCellStyleNameMap();
309 Sequence< OUString > aRet( rMap.size() );
310 OUString* pName = aRet.getArray();
312 CellStyleNameMap::const_iterator iter = rMap.begin();
313 while( iter != rMap.end() )
314 *pName++ = (*iter++).first;
316 return aRet;
321 sal_Bool SAL_CALL TableDesignStyle::hasByName( const OUString& rName ) throw(RuntimeException, std::exception)
323 SolarMutexGuard aGuard;
325 const CellStyleNameMap& rMap = getCellStyleNameMap();
327 CellStyleNameMap::const_iterator iter = rMap.find( rName );
328 return ( iter != rMap.end() ) ? sal_True : sal_False;
332 // XElementAccess
335 Type SAL_CALL TableDesignStyle::getElementType() throw(RuntimeException, std::exception)
337 return cppu::UnoType<XStyle>::get();
342 sal_Bool SAL_CALL TableDesignStyle::hasElements() throw(RuntimeException, std::exception)
344 return sal_True;
348 // XIndexAccess
351 sal_Int32 SAL_CALL TableDesignStyle::getCount() throw(RuntimeException, std::exception)
353 return style_count;
358 Any SAL_CALL TableDesignStyle::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception)
360 SolarMutexGuard aGuard;
362 if( (Index < 0) || (Index >= style_count) )
363 throw IndexOutOfBoundsException();
365 return Any( maCellStyles[Index] );
369 // XNameReplace
372 void SAL_CALL TableDesignStyle::replaceByName( const OUString& rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
374 SolarMutexGuard aGuard;
376 const CellStyleNameMap& rMap = getCellStyleNameMap();
377 CellStyleNameMap::const_iterator iter = rMap.find( rName );
378 if( iter == rMap.end() )
379 throw NoSuchElementException();
382 Reference< XStyle > xNewStyle;
383 if( !(aElement >>= xNewStyle) )
384 throw IllegalArgumentException();
386 const sal_Int32 nIndex = (*iter).second;
388 Reference< XStyle > xOldStyle( maCellStyles[nIndex] );
390 if( xNewStyle != xOldStyle )
392 Reference< XModifyListener > xListener( this );
394 // end listening to old style, if possible
395 Reference< XModifyBroadcaster > xOldBroadcaster( xOldStyle, UNO_QUERY );
396 if( xOldBroadcaster.is() )
397 xOldBroadcaster->removeModifyListener( xListener );
399 // start listening to new style, if possible
400 Reference< XModifyBroadcaster > xNewBroadcaster( xNewStyle, UNO_QUERY );
401 if( xNewBroadcaster.is() )
402 xNewBroadcaster->addModifyListener( xListener );
404 maCellStyles[nIndex] = xNewStyle;
409 // XComponent
412 void SAL_CALL TableDesignStyle::disposing()
414 for( sal_Int32 nIndex = 0; nIndex < style_count; nIndex++ )
415 maCellStyles[nIndex].clear();
419 // XModifyBroadcaster
422 void SAL_CALL TableDesignStyle::addModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException, std::exception)
424 ClearableMutexGuard aGuard( rBHelper.rMutex );
425 if (rBHelper.bDisposed || rBHelper.bInDispose)
427 aGuard.clear();
428 EventObject aEvt( static_cast< OWeakObject * >( this ) );
429 xListener->disposing( aEvt );
431 else
433 rBHelper.addListener( cppu::UnoType<XModifyListener>::get(), xListener );
439 void SAL_CALL TableDesignStyle::removeModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException, std::exception)
441 rBHelper.removeListener( cppu::UnoType<XModifyListener>::get(), xListener );
446 void TableDesignStyle::notifyModifyListener()
448 MutexGuard aGuard( rBHelper.rMutex );
450 OInterfaceContainerHelper * pContainer = rBHelper.getContainer( cppu::UnoType<XModifyListener>::get() );
451 if( pContainer )
453 EventObject aEvt( static_cast< OWeakObject * >( this ) );
454 pContainer->forEach<XModifyListener>( boost::bind( &XModifyListener::modified, _1, boost::cref( aEvt ) ) );
459 // XModifyListener
462 // if we get a modify hint from a style, notify all registered XModifyListener
463 void SAL_CALL TableDesignStyle::modified( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException, std::exception)
465 notifyModifyListener();
470 void SAL_CALL TableDesignStyle::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException, std::exception)
475 // TableStyle
479 // XServiceInfo
480 OUString SAL_CALL TableDesignFamily::getImplementationName() throw(RuntimeException, std::exception)
482 return OUString("TableDesignFamily");
485 sal_Bool SAL_CALL TableDesignFamily::supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception)
487 return cppu::supportsService( this, ServiceName );
490 Sequence< OUString > SAL_CALL TableDesignFamily::getSupportedServiceNames() throw(RuntimeException, std::exception)
492 OUString aServiceName("com.sun.star.style.StyleFamily");
493 Sequence< OUString > aSeq( &aServiceName, 1 );
494 return aSeq;
497 // XNamed
498 OUString SAL_CALL TableDesignFamily::getName() throw (RuntimeException, std::exception)
500 return OUString( "table" );
503 void SAL_CALL TableDesignFamily::setName( const OUString& ) throw (RuntimeException, std::exception)
507 // XNameAccess
508 Any SAL_CALL TableDesignFamily::getByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
510 SolarMutexGuard aGuard;
512 const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
513 for( TableDesignStyleVector::const_iterator iter( maDesigns.begin() );
514 iter != aEnd; ++iter)
516 if( (*iter)->getName() == rName )
517 return Any( (*iter) );
520 throw NoSuchElementException();
525 Sequence< OUString > SAL_CALL TableDesignFamily::getElementNames() throw(RuntimeException, std::exception)
527 SolarMutexGuard aGuard;
529 Sequence< OUString > aRet( maDesigns.size() );
530 OUString* pNames = aRet.getArray();
532 const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
533 for( TableDesignStyleVector::const_iterator iter( maDesigns.begin() );
534 iter != aEnd; ++iter)
535 *pNames++ = (*iter)->getName();
537 return aRet;
542 sal_Bool SAL_CALL TableDesignFamily::hasByName( const OUString& aName ) throw(RuntimeException, std::exception)
544 SolarMutexGuard aGuard;
546 const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
547 for( TableDesignStyleVector::const_iterator iter( maDesigns.begin() );
548 iter != aEnd; ++iter)
549 if( (*iter)->getName() == aName )
550 return sal_True;
552 return sal_False;
556 // XElementAccess
559 Type SAL_CALL TableDesignFamily::getElementType() throw(RuntimeException, std::exception)
561 return cppu::UnoType<XStyle>::get();
566 sal_Bool SAL_CALL TableDesignFamily::hasElements() throw(RuntimeException, std::exception)
568 SolarMutexGuard aGuard;
570 return maDesigns.empty() ? sal_False : sal_True;
574 // XIndexAccess
577 sal_Int32 SAL_CALL TableDesignFamily::getCount() throw(RuntimeException, std::exception)
579 SolarMutexGuard aGuard;
581 return sal::static_int_cast< sal_Int32 >( maDesigns.size() );
586 Any SAL_CALL TableDesignFamily::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception)
588 SolarMutexGuard aGuard;
590 if( (Index >= 0) && (Index < sal::static_int_cast< sal_Int32 >( maDesigns.size() ) ) )
591 return Any( maDesigns[Index] );
593 throw IndexOutOfBoundsException();
597 // XNameContainer
600 void SAL_CALL TableDesignFamily::insertByName( const OUString& rName, const Any& rElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception)
602 SolarMutexGuard aGuard;
604 Reference< XStyle > xStyle( rElement, UNO_QUERY );
605 if( !xStyle.is() )
606 throw IllegalArgumentException();
608 xStyle->setName( rName );
609 const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
610 for( TableDesignStyleVector::const_iterator iter( maDesigns.begin() );
611 iter != aEnd; ++iter)
612 if( (*iter)->getName() == rName )
613 throw ElementExistException();
615 maDesigns.push_back( xStyle );
620 void SAL_CALL TableDesignFamily::removeByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
622 SolarMutexGuard aGuard;
624 const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
625 for( TableDesignStyleVector::iterator iter( maDesigns.begin() );
626 iter != aEnd; ++iter)
628 if( (*iter)->getName() == rName )
630 maDesigns.erase( iter );
631 return;
636 throw NoSuchElementException();
640 // XNameReplace
643 void SAL_CALL TableDesignFamily::replaceByName( const OUString& rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
645 SolarMutexGuard aGuard;
647 Reference< XStyle > xStyle( aElement, UNO_QUERY );
648 if( !xStyle.is() )
649 throw IllegalArgumentException();
651 const TableDesignStyleVector::const_iterator aEnd( maDesigns.end() );
652 for( TableDesignStyleVector::iterator iter( maDesigns.begin() );
653 iter != aEnd; ++iter)
655 if( (*iter)->getName() == rName )
657 (*iter) = xStyle;
658 xStyle->setName( rName );
659 return;
663 throw NoSuchElementException();
667 // XSingleServiceFactory
670 Reference< XInterface > SAL_CALL TableDesignFamily::createInstance() throw(Exception, RuntimeException, std::exception)
672 SolarMutexGuard aGuard;
674 return Reference< XInterface >( static_cast< XStyle* >( new TableDesignStyle ) );
679 Reference< XInterface > SAL_CALL TableDesignFamily::createInstanceWithArguments( const Sequence< Any >& ) throw(Exception, RuntimeException, std::exception)
681 return createInstance();
685 // XComponent
688 void SAL_CALL TableDesignFamily::dispose( ) throw (RuntimeException, std::exception)
690 TableDesignStyleVector aDesigns;
691 aDesigns.swap( maDesigns );
693 for( TableDesignStyleVector::iterator iter( aDesigns.begin() ); iter != aDesigns.end(); ++iter )
695 Reference< XComponent > xComp( (*iter), UNO_QUERY );
696 if( xComp.is() )
697 xComp->dispose();
703 void SAL_CALL TableDesignFamily::addEventListener( const Reference< XEventListener >& ) throw (RuntimeException, std::exception)
709 void SAL_CALL TableDesignFamily::removeEventListener( const Reference< XEventListener >& ) throw (RuntimeException, std::exception)
714 // XPropertySet
717 Reference<XPropertySetInfo> TableDesignFamily::getPropertySetInfo() throw (RuntimeException, std::exception)
719 OSL_FAIL( "###unexpected!" );
720 return Reference<XPropertySetInfo>();
725 void TableDesignFamily::setPropertyValue( const OUString& , const Any& ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
727 OSL_FAIL( "###unexpected!" );
732 Any TableDesignFamily::getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
734 if ( PropertyName == "DisplayName" )
736 OUString sDisplayName( SVX_RESSTR( RID_SVXSTR_STYLEFAMILY_TABLEDESIGN ) );
737 return Any( sDisplayName );
739 else
741 throw UnknownPropertyException( OUString("unknown property: ") + PropertyName, static_cast<OWeakObject *>(this) );
747 void TableDesignFamily::addPropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
749 OSL_FAIL( "###unexpected!" );
754 void TableDesignFamily::removePropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
756 OSL_FAIL( "###unexpected!" );
761 void TableDesignFamily::addVetoableChangeListener( const OUString& , const Reference<XVetoableChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
763 OSL_FAIL( "###unexpected!" );
768 void TableDesignFamily::removeVetoableChangeListener( const OUString& , const Reference<XVetoableChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
770 OSL_FAIL( "###unexpected!" );
776 SVX_DLLPUBLIC Reference< XNameAccess > CreateTableDesignFamily()
778 return new TableDesignFamily();
783 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */