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>
30 #include <comphelper/serviceinfohelper.hxx>
32 #include <osl/mutex.hxx>
33 #include <vcl/svapp.hxx>
35 #include <cppuhelper/basemutex.hxx>
36 #include <cppuhelper/compbase6.hxx>
37 #include <cppuhelper/implbase7.hxx>
38 #include <cppuhelper/interfacecontainer.h>
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>
52 // -----------------------------------------------------------------------------
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
);
78 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw(RuntimeException
);
79 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw(RuntimeException
);
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
);
88 virtual OUString SAL_CALL
getName() throw (RuntimeException
);
89 virtual void SAL_CALL
setName( const OUString
& aName
) throw (RuntimeException
);
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
);
97 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType() throw(RuntimeException
);
98 virtual sal_Bool SAL_CALL
hasElements() throw(RuntimeException
);
101 virtual sal_Int32 SAL_CALL
getCount() throw(RuntimeException
) ;
102 virtual Any SAL_CALL
getByIndex( sal_Int32 Index
) throw(IndexOutOfBoundsException
, WrappedTargetException
, RuntimeException
);
105 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const Any
& aElement
) throw(IllegalArgumentException
, NoSuchElementException
, WrappedTargetException
, RuntimeException
);
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
);
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
);
115 void notifyModifyListener();
117 // this function is called upon disposing the component
118 virtual void SAL_CALL
disposing();
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
);
133 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw(RuntimeException
);
134 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw(RuntimeException
);
137 virtual OUString SAL_CALL
getName( ) throw (RuntimeException
);
138 virtual void SAL_CALL
setName( const OUString
& aName
) throw (RuntimeException
);
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
);
146 virtual Type SAL_CALL
getElementType() throw(RuntimeException
);
147 virtual sal_Bool SAL_CALL
hasElements() throw(RuntimeException
);
150 virtual sal_Int32 SAL_CALL
getCount() throw(RuntimeException
) ;
151 virtual Any SAL_CALL
getByIndex( sal_Int32 Index
) throw(IndexOutOfBoundsException
, WrappedTargetException
, RuntimeException
);
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
);
158 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const Any
& aElement
) throw(IllegalArgumentException
, NoSuchElementException
, WrappedTargetException
, RuntimeException
);
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
);
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
);
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
);
178 TableDesignStyleVector maDesigns
;
181 //------------------------------------------------------------------------
183 //------------------------------------------------------------------------
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
);
212 // ----------------------------------------------------------
214 // ----------------------------------------------------------
216 OUString SAL_CALL
TableDesignStyle::getImplementationName() throw(RuntimeException
)
218 return OUString("TableDesignStyle");
221 // ----------------------------------------------------------
223 sal_Bool SAL_CALL
TableDesignStyle::supportsService( const OUString
& ServiceName
) throw(RuntimeException
)
225 return comphelper::ServiceInfoHelper::supportsService( ServiceName
, getSupportedServiceNames() );
228 // ----------------------------------------------------------
230 Sequence
< OUString
> SAL_CALL
TableDesignStyle::getSupportedServiceNames() throw(RuntimeException
)
232 OUString
aServiceName("com.sun.star.style.Style");
233 Sequence
< OUString
> aSeq( &aServiceName
, 1 );
237 // ----------------------------------------------------------
239 // ----------------------------------------------------------
241 sal_Bool SAL_CALL
TableDesignStyle::isUserDefined() throw (RuntimeException
)
246 // ----------------------------------------------------------
248 sal_Bool SAL_CALL
TableDesignStyle::isInUse() throw (RuntimeException
)
250 ClearableMutexGuard
aGuard( rBHelper
.rMutex
);
251 OInterfaceContainerHelper
* pContainer
= rBHelper
.getContainer( XModifyListener::static_type() );
254 Sequence
< Reference
< XInterface
> > aListener( pContainer
->getElements() );
257 sal_Int32 nIndex
= aListener
.getLength();
258 while( --nIndex
>= 0 )
260 TableDesignUser
* pUser
= dynamic_cast< TableDesignUser
* >( aListener
[nIndex
].get() );
261 if( pUser
&& pUser
->isInUse() )
268 // ----------------------------------------------------------
270 OUString SAL_CALL
TableDesignStyle::getParentStyle() throw (RuntimeException
)
275 // ----------------------------------------------------------
277 void SAL_CALL
TableDesignStyle::setParentStyle( const OUString
& ) throw (NoSuchElementException
, RuntimeException
)
281 // ----------------------------------------------------------
283 // ----------------------------------------------------------
285 OUString SAL_CALL
TableDesignStyle::getName() throw (RuntimeException
)
290 // ----------------------------------------------------------
292 void SAL_CALL
TableDesignStyle::setName( const OUString
& rName
) throw (RuntimeException
)
297 // ----------------------------------------------------------
299 // ----------------------------------------------------------
301 Any SAL_CALL
TableDesignStyle::getByName( const OUString
& rName
) throw(NoSuchElementException
, WrappedTargetException
, RuntimeException
)
303 SolarMutexGuard aGuard
;
305 const CellStyleNameMap
& rMap
= getCellStyleNameMap();
307 CellStyleNameMap::const_iterator iter
= rMap
.find( rName
);
308 if( iter
== rMap
.end() )
309 throw NoSuchElementException();
311 return Any( maCellStyles
[(*iter
).second
] );
314 // ----------------------------------------------------------
316 Sequence
< OUString
> SAL_CALL
TableDesignStyle::getElementNames() throw(RuntimeException
)
318 SolarMutexGuard aGuard
;
320 const CellStyleNameMap
& rMap
= getCellStyleNameMap();
321 Sequence
< OUString
> aRet( rMap
.size() );
322 OUString
* pName
= aRet
.getArray();
324 CellStyleNameMap::const_iterator iter
= rMap
.begin();
325 while( iter
!= rMap
.end() )
326 *pName
++ = (*iter
++).first
;
331 // ----------------------------------------------------------
333 sal_Bool SAL_CALL
TableDesignStyle::hasByName( const OUString
& rName
) throw(RuntimeException
)
335 SolarMutexGuard aGuard
;
337 const CellStyleNameMap
& rMap
= getCellStyleNameMap();
339 CellStyleNameMap::const_iterator iter
= rMap
.find( rName
);
340 return ( iter
!= rMap
.end() ) ? sal_True
: sal_False
;
343 // ----------------------------------------------------------
345 // ----------------------------------------------------------
347 Type SAL_CALL
TableDesignStyle::getElementType() throw(RuntimeException
)
349 return XStyle::static_type();
352 // ----------------------------------------------------------
354 sal_Bool SAL_CALL
TableDesignStyle::hasElements() throw(RuntimeException
)
359 // ----------------------------------------------------------
361 // ----------------------------------------------------------
363 sal_Int32 SAL_CALL
TableDesignStyle::getCount() throw(RuntimeException
)
368 // ----------------------------------------------------------
370 Any SAL_CALL
TableDesignStyle::getByIndex( sal_Int32 Index
) throw(IndexOutOfBoundsException
, WrappedTargetException
, RuntimeException
)
372 SolarMutexGuard aGuard
;
374 if( (Index
< 0) || (Index
>= style_count
) )
375 throw IndexOutOfBoundsException();
377 return Any( maCellStyles
[Index
] );
380 // ----------------------------------------------------------
382 // ----------------------------------------------------------
384 void SAL_CALL
TableDesignStyle::replaceByName( const OUString
& rName
, const Any
& aElement
) throw(IllegalArgumentException
, NoSuchElementException
, WrappedTargetException
, RuntimeException
)
386 SolarMutexGuard aGuard
;
388 const CellStyleNameMap
& rMap
= getCellStyleNameMap();
389 CellStyleNameMap::const_iterator iter
= rMap
.find( rName
);
390 if( iter
== rMap
.end() )
391 throw NoSuchElementException();
394 Reference
< XStyle
> xNewStyle
;
395 if( !(aElement
>>= xNewStyle
) )
396 throw IllegalArgumentException();
398 const sal_Int32 nIndex
= (*iter
).second
;
400 Reference
< XStyle
> xOldStyle( maCellStyles
[nIndex
] );
402 if( xNewStyle
!= xOldStyle
)
404 Reference
< XModifyListener
> xListener( this );
406 // end listening to old style, if possible
407 Reference
< XModifyBroadcaster
> xOldBroadcaster( xOldStyle
, UNO_QUERY
);
408 if( xOldBroadcaster
.is() )
409 xOldBroadcaster
->removeModifyListener( xListener
);
411 // start listening to new style, if possible
412 Reference
< XModifyBroadcaster
> xNewBroadcaster( xNewStyle
, UNO_QUERY
);
413 if( xNewBroadcaster
.is() )
414 xNewBroadcaster
->addModifyListener( xListener
);
416 maCellStyles
[nIndex
] = xNewStyle
;
420 // ----------------------------------------------------------
422 // ----------------------------------------------------------
424 void SAL_CALL
TableDesignStyle::disposing()
426 for( sal_Int32 nIndex
= 0; nIndex
< style_count
; nIndex
++ )
427 maCellStyles
[nIndex
].clear();
430 //------------------------------------------------------------------------
431 // XModifyBroadcaster
432 //------------------------------------------------------------------------
434 void SAL_CALL
TableDesignStyle::addModifyListener( const Reference
< XModifyListener
>& xListener
) throw (RuntimeException
)
436 ClearableMutexGuard
aGuard( rBHelper
.rMutex
);
437 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
440 EventObject
aEvt( static_cast< OWeakObject
* >( this ) );
441 xListener
->disposing( aEvt
);
445 rBHelper
.addListener( XModifyListener::static_type(), xListener
);
449 //------------------------------------------------------------------------
451 void SAL_CALL
TableDesignStyle::removeModifyListener( const Reference
< XModifyListener
>& xListener
) throw (RuntimeException
)
453 rBHelper
.removeListener( XModifyListener::static_type(), xListener
);
456 //------------------------------------------------------------------------
458 void TableDesignStyle::notifyModifyListener()
460 MutexGuard
aGuard( rBHelper
.rMutex
);
462 OInterfaceContainerHelper
* pContainer
= rBHelper
.getContainer( XModifyListener::static_type() );
465 EventObject
aEvt( static_cast< OWeakObject
* >( this ) );
466 pContainer
->forEach
<XModifyListener
>( boost::bind( &XModifyListener::modified
, _1
, boost::cref( aEvt
) ) );
470 //------------------------------------------------------------------------
472 //------------------------------------------------------------------------
474 // if we get a modify hint from a style, notify all registered XModifyListener
475 void SAL_CALL
TableDesignStyle::modified( const ::com::sun::star::lang::EventObject
& ) throw (::com::sun::star::uno::RuntimeException
)
477 notifyModifyListener();
480 //------------------------------------------------------------------------
482 void SAL_CALL
TableDesignStyle::disposing( const ::com::sun::star::lang::EventObject
& ) throw (::com::sun::star::uno::RuntimeException
)
486 //------------------------------------------------------------------------
488 //------------------------------------------------------------------------
490 // ----------------------------------------------------------
492 // ----------------------------------------------------------
494 OUString SAL_CALL
TableDesignFamily::getImplementationName() throw(RuntimeException
)
496 return OUString("TableDesignFamily");
499 // ----------------------------------------------------------
501 sal_Bool SAL_CALL
TableDesignFamily::supportsService( const OUString
& ServiceName
) throw(RuntimeException
)
503 return comphelper::ServiceInfoHelper::supportsService( ServiceName
, getSupportedServiceNames() );
506 // ----------------------------------------------------------
508 Sequence
< OUString
> SAL_CALL
TableDesignFamily::getSupportedServiceNames() throw(RuntimeException
)
510 OUString
aServiceName("com.sun.star.style.StyleFamily");
511 Sequence
< OUString
> aSeq( &aServiceName
, 1 );
515 // ----------------------------------------------------------
517 // ----------------------------------------------------------
519 OUString SAL_CALL
TableDesignFamily::getName() throw (RuntimeException
)
521 return OUString( "table" );
524 // ----------------------------------------------------------
526 void SAL_CALL
TableDesignFamily::setName( const OUString
& ) throw (RuntimeException
)
530 // ----------------------------------------------------------
532 // ----------------------------------------------------------
534 Any SAL_CALL
TableDesignFamily::getByName( const OUString
& rName
) throw(NoSuchElementException
, WrappedTargetException
, RuntimeException
)
536 SolarMutexGuard aGuard
;
538 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
539 for( TableDesignStyleVector::const_iterator
iter( maDesigns
.begin() );
540 iter
!= aEnd
; ++iter
)
542 if( (*iter
)->getName() == rName
)
543 return Any( (*iter
) );
546 throw NoSuchElementException();
549 // ----------------------------------------------------------
551 Sequence
< OUString
> SAL_CALL
TableDesignFamily::getElementNames() throw(RuntimeException
)
553 SolarMutexGuard aGuard
;
555 Sequence
< OUString
> aRet( maDesigns
.size() );
556 OUString
* pNames
= aRet
.getArray();
558 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
559 for( TableDesignStyleVector::const_iterator
iter( maDesigns
.begin() );
560 iter
!= aEnd
; ++iter
)
561 *pNames
++ = (*iter
)->getName();
566 // ----------------------------------------------------------
568 sal_Bool SAL_CALL
TableDesignFamily::hasByName( const OUString
& aName
) throw(RuntimeException
)
570 SolarMutexGuard aGuard
;
572 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
573 for( TableDesignStyleVector::const_iterator
iter( maDesigns
.begin() );
574 iter
!= aEnd
; ++iter
)
575 if( (*iter
)->getName() == aName
)
581 // ----------------------------------------------------------
583 // ----------------------------------------------------------
585 Type SAL_CALL
TableDesignFamily::getElementType() throw(RuntimeException
)
587 return XStyle::static_type();
590 // ----------------------------------------------------------
592 sal_Bool SAL_CALL
TableDesignFamily::hasElements() throw(RuntimeException
)
594 SolarMutexGuard aGuard
;
596 return maDesigns
.empty() ? sal_False
: sal_True
;
599 // ----------------------------------------------------------
601 // ----------------------------------------------------------
603 sal_Int32 SAL_CALL
TableDesignFamily::getCount() throw(RuntimeException
)
605 SolarMutexGuard aGuard
;
607 return sal::static_int_cast
< sal_Int32
>( maDesigns
.size() );
610 // ----------------------------------------------------------
612 Any SAL_CALL
TableDesignFamily::getByIndex( sal_Int32 Index
) throw(IndexOutOfBoundsException
, WrappedTargetException
, RuntimeException
)
614 SolarMutexGuard aGuard
;
616 if( (Index
>= 0) && (Index
< sal::static_int_cast
< sal_Int32
>( maDesigns
.size() ) ) )
617 return Any( maDesigns
[Index
] );
619 throw IndexOutOfBoundsException();
622 // ----------------------------------------------------------
624 // ----------------------------------------------------------
626 void SAL_CALL
TableDesignFamily::insertByName( const OUString
& rName
, const Any
& rElement
) throw(IllegalArgumentException
, ElementExistException
, WrappedTargetException
, RuntimeException
)
628 SolarMutexGuard aGuard
;
630 Reference
< XStyle
> xStyle( rElement
, UNO_QUERY
);
632 throw IllegalArgumentException();
634 xStyle
->setName( rName
);
635 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
636 for( TableDesignStyleVector::const_iterator
iter( maDesigns
.begin() );
637 iter
!= aEnd
; ++iter
)
638 if( (*iter
)->getName() == rName
)
639 throw ElementExistException();
641 maDesigns
.push_back( xStyle
);
644 // ----------------------------------------------------------
646 void SAL_CALL
TableDesignFamily::removeByName( const OUString
& rName
) throw(NoSuchElementException
, WrappedTargetException
, RuntimeException
)
648 SolarMutexGuard aGuard
;
650 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
651 for( TableDesignStyleVector::iterator
iter( maDesigns
.begin() );
652 iter
!= aEnd
; ++iter
)
654 if( (*iter
)->getName() == rName
)
656 maDesigns
.erase( iter
);
662 throw NoSuchElementException();
665 // ----------------------------------------------------------
667 // ----------------------------------------------------------
669 void SAL_CALL
TableDesignFamily::replaceByName( const OUString
& rName
, const Any
& aElement
) throw(IllegalArgumentException
, NoSuchElementException
, WrappedTargetException
, RuntimeException
)
671 SolarMutexGuard aGuard
;
673 Reference
< XStyle
> xStyle( aElement
, UNO_QUERY
);
675 throw IllegalArgumentException();
677 const TableDesignStyleVector::const_iterator
aEnd( maDesigns
.end() );
678 for( TableDesignStyleVector::iterator
iter( maDesigns
.begin() );
679 iter
!= aEnd
; ++iter
)
681 if( (*iter
)->getName() == rName
)
684 xStyle
->setName( rName
);
689 throw NoSuchElementException();
692 // ----------------------------------------------------------
693 // XSingleServiceFactory
694 // ----------------------------------------------------------
696 Reference
< XInterface
> SAL_CALL
TableDesignFamily::createInstance() throw(Exception
, RuntimeException
)
698 SolarMutexGuard aGuard
;
700 return Reference
< XInterface
>( static_cast< XStyle
* >( new TableDesignStyle
) );
703 // ----------------------------------------------------------
705 Reference
< XInterface
> SAL_CALL
TableDesignFamily::createInstanceWithArguments( const Sequence
< Any
>& ) throw(Exception
, RuntimeException
)
707 return createInstance();
710 // ----------------------------------------------------------
712 // ----------------------------------------------------------
714 void SAL_CALL
TableDesignFamily::dispose( ) throw (RuntimeException
)
716 TableDesignStyleVector aDesigns
;
717 aDesigns
.swap( maDesigns
);
719 for( TableDesignStyleVector::iterator
iter( aDesigns
.begin() ); iter
!= aDesigns
.end(); ++iter
)
721 Reference
< XComponent
> xComp( (*iter
), UNO_QUERY
);
727 // ----------------------------------------------------------
729 void SAL_CALL
TableDesignFamily::addEventListener( const Reference
< XEventListener
>& ) throw (RuntimeException
)
733 // ----------------------------------------------------------
735 void SAL_CALL
TableDesignFamily::removeEventListener( const Reference
< XEventListener
>& ) throw (RuntimeException
)
739 // ----------------------------------------------------------
741 // ----------------------------------------------------------
743 Reference
<XPropertySetInfo
> TableDesignFamily::getPropertySetInfo() throw (RuntimeException
)
745 OSL_FAIL( "###unexpected!" );
746 return Reference
<XPropertySetInfo
>();
749 // ----------------------------------------------------------
751 void TableDesignFamily::setPropertyValue( const OUString
& , const Any
& ) throw (UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
)
753 OSL_FAIL( "###unexpected!" );
756 // ----------------------------------------------------------
758 Any
TableDesignFamily::getPropertyValue( const OUString
& PropertyName
) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
760 if ( PropertyName
== "DisplayName" )
762 OUString
sDisplayName( SVX_RESSTR( RID_SVXSTR_STYLEFAMILY_TABLEDESIGN
) );
763 return Any( sDisplayName
);
767 throw UnknownPropertyException( OUString("unknown property: ") + PropertyName
, static_cast<OWeakObject
*>(this) );
771 // ----------------------------------------------------------
773 void TableDesignFamily::addPropertyChangeListener( const OUString
& , const Reference
<XPropertyChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
775 OSL_FAIL( "###unexpected!" );
778 // ----------------------------------------------------------
780 void TableDesignFamily::removePropertyChangeListener( const OUString
& , const Reference
<XPropertyChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
782 OSL_FAIL( "###unexpected!" );
785 // ----------------------------------------------------------
787 void TableDesignFamily::addVetoableChangeListener( const OUString
& , const Reference
<XVetoableChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
789 OSL_FAIL( "###unexpected!" );
792 // ----------------------------------------------------------
794 void TableDesignFamily::removeVetoableChangeListener( const OUString
& , const Reference
<XVetoableChangeListener
>& ) throw (UnknownPropertyException
, WrappedTargetException
, RuntimeException
)
796 OSL_FAIL( "###unexpected!" );
799 // --------------------------------------------------------------------
802 SVX_DLLPUBLIC Reference
< XNameAccess
> CreateTableDesignFamily()
804 return new TableDesignFamily();
809 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */