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
;
181 TableDesignStyle::TableDesignStyle()
182 : TableDesignStyleBase(m_aMutex
)
186 const CellStyleNameMap
& TableDesignStyle::getCellStyleNameMap()
188 static CellStyleNameMap aMap
;
191 CellStyleNameMap aNewMap
;
192 aNewMap
[ OUString( "first-row" ) ] = first_row_style
;
193 aNewMap
[ OUString( "last-row" ) ] = last_row_style
;
194 aNewMap
[ OUString( "first-column" ) ] = first_column_style
;
195 aNewMap
[ OUString( "last-column" ) ] = last_column_style
;
196 aNewMap
[ OUString( "body" ) ] = body_style
;
197 aNewMap
[ OUString( "even-rows" ) ] = even_rows_style
;
198 aNewMap
[ OUString( "odd-rows" ) ] = odd_rows_style
;
199 aNewMap
[ OUString( "even-columns" ) ] = even_columns_style
;
200 aNewMap
[ OUString( "odd-columns" ) ] = odd_columns_style
;
201 aNewMap
[ OUString( "background" ) ] = background_style
;
202 aMap
.swap( aNewMap
);
209 OUString SAL_CALL
TableDesignStyle::getImplementationName() throw(RuntimeException
, std::exception
)
211 return OUString("TableDesignStyle");
214 sal_Bool SAL_CALL
TableDesignStyle::supportsService( const OUString
& ServiceName
) throw(RuntimeException
, std::exception
)
216 return cppu::supportsService( this, ServiceName
);
219 Sequence
< OUString
> SAL_CALL
TableDesignStyle::getSupportedServiceNames() throw(RuntimeException
, std::exception
)
221 OUString
aServiceName("com.sun.star.style.Style");
222 Sequence
< OUString
> aSeq( &aServiceName
, 1 );
227 sal_Bool SAL_CALL
TableDesignStyle::isUserDefined() throw (RuntimeException
, std::exception
)
232 sal_Bool SAL_CALL
TableDesignStyle::isInUse() throw (RuntimeException
, std::exception
)
234 ClearableMutexGuard
aGuard( rBHelper
.rMutex
);
235 OInterfaceContainerHelper
* pContainer
= rBHelper
.getContainer( cppu::UnoType
<XModifyListener
>::get() );
238 Sequence
< Reference
< XInterface
> > aListener( pContainer
->getElements() );
241 sal_Int32 nIndex
= aListener
.getLength();
242 while( --nIndex
>= 0 )
244 TableDesignUser
* pUser
= dynamic_cast< TableDesignUser
* >( aListener
[nIndex
].get() );
245 if( pUser
&& pUser
->isInUse() )
254 OUString SAL_CALL
TableDesignStyle::getParentStyle() throw (RuntimeException
, std::exception
)
261 void SAL_CALL
TableDesignStyle::setParentStyle( const OUString
& ) throw (NoSuchElementException
, RuntimeException
, std::exception
)
269 OUString SAL_CALL
TableDesignStyle::getName() throw (RuntimeException
, std::exception
)
276 void SAL_CALL
TableDesignStyle::setName( const OUString
& rName
) throw (RuntimeException
, std::exception
)
285 Any SAL_CALL
TableDesignStyle::getByName( const OUString
& rName
) throw(NoSuchElementException
, WrappedTargetException
, RuntimeException
, std::exception
)
287 SolarMutexGuard aGuard
;
289 const CellStyleNameMap
& rMap
= getCellStyleNameMap();
291 CellStyleNameMap::const_iterator iter
= rMap
.find( rName
);
292 if( iter
== rMap
.end() )
293 throw NoSuchElementException();
295 return Any( maCellStyles
[(*iter
).second
] );
300 Sequence
< OUString
> SAL_CALL
TableDesignStyle::getElementNames() throw(RuntimeException
, std::exception
)
302 SolarMutexGuard aGuard
;
304 const CellStyleNameMap
& rMap
= getCellStyleNameMap();
305 Sequence
< OUString
> aRet( rMap
.size() );
306 OUString
* pName
= aRet
.getArray();
308 CellStyleNameMap::const_iterator iter
= rMap
.begin();
309 while( iter
!= rMap
.end() )
310 *pName
++ = (*iter
++).first
;
317 sal_Bool SAL_CALL
TableDesignStyle::hasByName( const OUString
& rName
) throw(RuntimeException
, std::exception
)
319 SolarMutexGuard aGuard
;
321 const CellStyleNameMap
& rMap
= getCellStyleNameMap();
323 CellStyleNameMap::const_iterator iter
= rMap
.find( rName
);
324 return ( iter
!= rMap
.end() ) ? sal_True
: sal_False
;
331 Type SAL_CALL
TableDesignStyle::getElementType() throw(RuntimeException
, std::exception
)
333 return cppu::UnoType
<XStyle
>::get();
338 sal_Bool SAL_CALL
TableDesignStyle::hasElements() throw(RuntimeException
, std::exception
)
347 sal_Int32 SAL_CALL
TableDesignStyle::getCount() throw(RuntimeException
, std::exception
)
354 Any SAL_CALL
TableDesignStyle::getByIndex( sal_Int32 Index
) throw(IndexOutOfBoundsException
, WrappedTargetException
, RuntimeException
, std::exception
)
356 SolarMutexGuard aGuard
;
358 if( (Index
< 0) || (Index
>= style_count
) )
359 throw IndexOutOfBoundsException();
361 return Any( maCellStyles
[Index
] );
368 void SAL_CALL
TableDesignStyle::replaceByName( const OUString
& rName
, const Any
& aElement
) throw(IllegalArgumentException
, NoSuchElementException
, WrappedTargetException
, RuntimeException
, std::exception
)
370 SolarMutexGuard aGuard
;
372 const CellStyleNameMap
& rMap
= getCellStyleNameMap();
373 CellStyleNameMap::const_iterator iter
= rMap
.find( rName
);
374 if( iter
== rMap
.end() )
375 throw NoSuchElementException();
378 Reference
< XStyle
> xNewStyle
;
379 if( !(aElement
>>= xNewStyle
) )
380 throw IllegalArgumentException();
382 const sal_Int32 nIndex
= (*iter
).second
;
384 Reference
< XStyle
> xOldStyle( maCellStyles
[nIndex
] );
386 if( xNewStyle
!= xOldStyle
)
388 Reference
< XModifyListener
> xListener( this );
390 // end listening to old style, if possible
391 Reference
< XModifyBroadcaster
> xOldBroadcaster( xOldStyle
, UNO_QUERY
);
392 if( xOldBroadcaster
.is() )
393 xOldBroadcaster
->removeModifyListener( xListener
);
395 // start listening to new style, if possible
396 Reference
< XModifyBroadcaster
> xNewBroadcaster( xNewStyle
, UNO_QUERY
);
397 if( xNewBroadcaster
.is() )
398 xNewBroadcaster
->addModifyListener( xListener
);
400 maCellStyles
[nIndex
] = xNewStyle
;
408 void SAL_CALL
TableDesignStyle::disposing()
410 for( sal_Int32 nIndex
= 0; nIndex
< style_count
; nIndex
++ )
411 maCellStyles
[nIndex
].clear();
415 // XModifyBroadcaster
418 void SAL_CALL
TableDesignStyle::addModifyListener( const Reference
< XModifyListener
>& xListener
) throw (RuntimeException
, std::exception
)
420 ClearableMutexGuard
aGuard( rBHelper
.rMutex
);
421 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
424 EventObject
aEvt( static_cast< OWeakObject
* >( this ) );
425 xListener
->disposing( aEvt
);
429 rBHelper
.addListener( cppu::UnoType
<XModifyListener
>::get(), xListener
);
435 void SAL_CALL
TableDesignStyle::removeModifyListener( const Reference
< XModifyListener
>& xListener
) throw (RuntimeException
, std::exception
)
437 rBHelper
.removeListener( cppu::UnoType
<XModifyListener
>::get(), xListener
);
442 void TableDesignStyle::notifyModifyListener()
444 MutexGuard
aGuard( rBHelper
.rMutex
);
446 OInterfaceContainerHelper
* pContainer
= rBHelper
.getContainer( cppu::UnoType
<XModifyListener
>::get() );
449 EventObject
aEvt( static_cast< OWeakObject
* >( this ) );
450 pContainer
->forEach
<XModifyListener
>( boost::bind( &XModifyListener::modified
, _1
, boost::cref( aEvt
) ) );
458 // if we get a modify hint from a style, notify all registered XModifyListener
459 void SAL_CALL
TableDesignStyle::modified( const ::com::sun::star::lang::EventObject
& ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
461 notifyModifyListener();
466 void SAL_CALL
TableDesignStyle::disposing( const ::com::sun::star::lang::EventObject
& ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
476 OUString SAL_CALL
TableDesignFamily::getImplementationName() throw(RuntimeException
, std::exception
)
478 return OUString("TableDesignFamily");
481 sal_Bool SAL_CALL
TableDesignFamily::supportsService( const OUString
& ServiceName
) throw(RuntimeException
, std::exception
)
483 return cppu::supportsService( this, ServiceName
);
486 Sequence
< OUString
> SAL_CALL
TableDesignFamily::getSupportedServiceNames() throw(RuntimeException
, std::exception
)
488 OUString
aServiceName("com.sun.star.style.StyleFamily");
489 Sequence
< OUString
> aSeq( &aServiceName
, 1 );
494 OUString SAL_CALL
TableDesignFamily::getName() throw (RuntimeException
, std::exception
)
496 return OUString( "table" );
499 void SAL_CALL
TableDesignFamily::setName( const OUString
& ) throw (RuntimeException
, std::exception
)
504 Any SAL_CALL
TableDesignFamily::getByName( const OUString
& rName
) throw(NoSuchElementException
, WrappedTargetException
, RuntimeException
, std::exception
)
506 SolarMutexGuard aGuard
;
508 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
509 for( TableDesignStyleVector::const_iterator
iter( maDesigns
.begin() );
510 iter
!= aEnd
; ++iter
)
512 if( (*iter
)->getName() == rName
)
513 return Any( (*iter
) );
516 throw NoSuchElementException();
521 Sequence
< OUString
> SAL_CALL
TableDesignFamily::getElementNames() throw(RuntimeException
, std::exception
)
523 SolarMutexGuard aGuard
;
525 Sequence
< OUString
> aRet( maDesigns
.size() );
526 OUString
* pNames
= aRet
.getArray();
528 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
529 for( TableDesignStyleVector::const_iterator
iter( maDesigns
.begin() );
530 iter
!= aEnd
; ++iter
)
531 *pNames
++ = (*iter
)->getName();
538 sal_Bool SAL_CALL
TableDesignFamily::hasByName( const OUString
& aName
) throw(RuntimeException
, std::exception
)
540 SolarMutexGuard aGuard
;
542 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
543 for( TableDesignStyleVector::const_iterator
iter( maDesigns
.begin() );
544 iter
!= aEnd
; ++iter
)
545 if( (*iter
)->getName() == aName
)
555 Type SAL_CALL
TableDesignFamily::getElementType() throw(RuntimeException
, std::exception
)
557 return cppu::UnoType
<XStyle
>::get();
562 sal_Bool SAL_CALL
TableDesignFamily::hasElements() throw(RuntimeException
, std::exception
)
564 SolarMutexGuard aGuard
;
566 return maDesigns
.empty() ? sal_False
: sal_True
;
573 sal_Int32 SAL_CALL
TableDesignFamily::getCount() throw(RuntimeException
, std::exception
)
575 SolarMutexGuard aGuard
;
577 return sal::static_int_cast
< sal_Int32
>( maDesigns
.size() );
582 Any SAL_CALL
TableDesignFamily::getByIndex( sal_Int32 Index
) throw(IndexOutOfBoundsException
, WrappedTargetException
, RuntimeException
, std::exception
)
584 SolarMutexGuard aGuard
;
586 if( (Index
>= 0) && (Index
< sal::static_int_cast
< sal_Int32
>( maDesigns
.size() ) ) )
587 return Any( maDesigns
[Index
] );
589 throw IndexOutOfBoundsException();
596 void SAL_CALL
TableDesignFamily::insertByName( const OUString
& rName
, const Any
& rElement
) throw(IllegalArgumentException
, ElementExistException
, WrappedTargetException
, RuntimeException
, std::exception
)
598 SolarMutexGuard aGuard
;
600 Reference
< XStyle
> xStyle( rElement
, UNO_QUERY
);
602 throw IllegalArgumentException();
604 xStyle
->setName( rName
);
605 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
606 for( TableDesignStyleVector::const_iterator
iter( maDesigns
.begin() );
607 iter
!= aEnd
; ++iter
)
608 if( (*iter
)->getName() == rName
)
609 throw ElementExistException();
611 maDesigns
.push_back( xStyle
);
616 void SAL_CALL
TableDesignFamily::removeByName( const OUString
& rName
) throw(NoSuchElementException
, WrappedTargetException
, RuntimeException
, std::exception
)
618 SolarMutexGuard aGuard
;
620 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
621 for( TableDesignStyleVector::iterator
iter( maDesigns
.begin() );
622 iter
!= aEnd
; ++iter
)
624 if( (*iter
)->getName() == rName
)
626 maDesigns
.erase( iter
);
632 throw NoSuchElementException();
639 void SAL_CALL
TableDesignFamily::replaceByName( const OUString
& rName
, const Any
& aElement
) throw(IllegalArgumentException
, NoSuchElementException
, WrappedTargetException
, RuntimeException
, std::exception
)
641 SolarMutexGuard aGuard
;
643 Reference
< XStyle
> xStyle( aElement
, UNO_QUERY
);
645 throw IllegalArgumentException();
647 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
648 for( TableDesignStyleVector::iterator
iter( maDesigns
.begin() );
649 iter
!= aEnd
; ++iter
)
651 if( (*iter
)->getName() == rName
)
654 xStyle
->setName( rName
);
659 throw NoSuchElementException();
663 // XSingleServiceFactory
666 Reference
< XInterface
> SAL_CALL
TableDesignFamily::createInstance() throw(Exception
, RuntimeException
, std::exception
)
668 SolarMutexGuard aGuard
;
670 return Reference
< XInterface
>( static_cast< XStyle
* >( new TableDesignStyle
) );
675 Reference
< XInterface
> SAL_CALL
TableDesignFamily::createInstanceWithArguments( const Sequence
< Any
>& ) throw(Exception
, RuntimeException
, std::exception
)
677 return createInstance();
684 void SAL_CALL
TableDesignFamily::dispose( ) throw (RuntimeException
, std::exception
)
686 TableDesignStyleVector aDesigns
;
687 aDesigns
.swap( maDesigns
);
689 for( TableDesignStyleVector::iterator
iter( aDesigns
.begin() ); iter
!= aDesigns
.end(); ++iter
)
691 Reference
< XComponent
> xComp( (*iter
), UNO_QUERY
);
699 void SAL_CALL
TableDesignFamily::addEventListener( const Reference
< XEventListener
>& ) throw (RuntimeException
, std::exception
)
705 void SAL_CALL
TableDesignFamily::removeEventListener( const Reference
< XEventListener
>& ) throw (RuntimeException
, std::exception
)
713 Reference
<XPropertySetInfo
> TableDesignFamily::getPropertySetInfo() throw (RuntimeException
, std::exception
)
715 OSL_FAIL( "###unexpected!" );
716 return Reference
<XPropertySetInfo
>();
721 void TableDesignFamily::setPropertyValue( const OUString
& , const Any
& ) throw (UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
, std::exception
)
723 OSL_FAIL( "###unexpected!" );
728 Any
TableDesignFamily::getPropertyValue( const OUString
& PropertyName
) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
730 if ( PropertyName
== "DisplayName" )
732 OUString
sDisplayName( SVX_RESSTR( RID_SVXSTR_STYLEFAMILY_TABLEDESIGN
) );
733 return Any( sDisplayName
);
737 throw UnknownPropertyException( "unknown property: " + PropertyName
, static_cast<OWeakObject
*>(this) );
743 void TableDesignFamily::addPropertyChangeListener( const OUString
& , const Reference
<XPropertyChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
745 OSL_FAIL( "###unexpected!" );
750 void TableDesignFamily::removePropertyChangeListener( const OUString
& , const Reference
<XPropertyChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
752 OSL_FAIL( "###unexpected!" );
757 void TableDesignFamily::addVetoableChangeListener( const OUString
& , const Reference
<XVetoableChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
759 OSL_FAIL( "###unexpected!" );
764 void TableDesignFamily::removeVetoableChangeListener( const OUString
& , const Reference
<XVetoableChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
, std::exception
)
766 OSL_FAIL( "###unexpected!" );
772 Reference
< XNameAccess
> CreateTableDesignFamily()
774 return new TableDesignFamily();
779 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */