1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
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
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
;
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
;
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
;
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
;
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
;
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
;
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
;
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();
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
>
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
;
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
;
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
;
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
;
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
;
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
;
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
;
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
;
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
;
185 TableDesignStyle::TableDesignStyle()
186 : TableDesignStyleBase(m_aMutex
)
190 const CellStyleNameMap
& TableDesignStyle::getCellStyleNameMap()
192 static CellStyleNameMap aMap
;
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
);
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 );
231 sal_Bool SAL_CALL
TableDesignStyle::isUserDefined() throw (RuntimeException
, std::exception
)
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() );
242 Sequence
< Reference
< XInterface
> > aListener( pContainer
->getElements() );
245 sal_Int32 nIndex
= aListener
.getLength();
246 while( --nIndex
>= 0 )
248 TableDesignUser
* pUser
= dynamic_cast< TableDesignUser
* >( aListener
[nIndex
].get() );
249 if( pUser
&& pUser
->isInUse() )
258 OUString SAL_CALL
TableDesignStyle::getParentStyle() throw (RuntimeException
, std::exception
)
265 void SAL_CALL
TableDesignStyle::setParentStyle( const OUString
& ) throw (NoSuchElementException
, RuntimeException
, std::exception
)
273 OUString SAL_CALL
TableDesignStyle::getName() throw (RuntimeException
, std::exception
)
280 void SAL_CALL
TableDesignStyle::setName( const OUString
& rName
) throw (RuntimeException
, std::exception
)
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
;
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
;
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
)
351 sal_Int32 SAL_CALL
TableDesignStyle::getCount() throw(RuntimeException
, std::exception
)
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
] );
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
;
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
)
428 EventObject
aEvt( static_cast< OWeakObject
* >( this ) );
429 xListener
->disposing( aEvt
);
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() );
453 EventObject
aEvt( static_cast< OWeakObject
* >( this ) );
454 pContainer
->forEach
<XModifyListener
>( boost::bind( &XModifyListener::modified
, _1
, boost::cref( aEvt
) ) );
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
)
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 );
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
)
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();
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
)
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
;
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();
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
);
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
);
636 throw NoSuchElementException();
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
);
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
)
658 xStyle
->setName( rName
);
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();
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
);
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
)
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
);
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: */