xref: /aoo41x/main/svx/source/table/tabledesign.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/util/XModifyBroadcaster.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/util/XModifyListener.hpp>
40*cdf0e10cSrcweir #include <comphelper/serviceinfohelper.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <osl/mutex.hxx>
43*cdf0e10cSrcweir #include <vos/mutex.hxx>
44*cdf0e10cSrcweir #include <vcl/svapp.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
47*cdf0e10cSrcweir #include <cppuhelper/compbase6.hxx>
48*cdf0e10cSrcweir #include <cppuhelper/implbase7.hxx>
49*cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir #include "svx/unoprov.hxx"
52*cdf0e10cSrcweir #include "svx/sdr/table/tabledesign.hxx"
53*cdf0e10cSrcweir #include "svx/dialmgr.hxx"
54*cdf0e10cSrcweir #include "svx/dialogs.hrc"
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #include "celltypes.hxx"
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir #include <vector>
59*cdf0e10cSrcweir #include <map>
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #include <boost/bind.hpp>
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir // -----------------------------------------------------------------------------
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
66*cdf0e10cSrcweir using namespace ::com::sun::star::style;
67*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
68*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
69*cdf0e10cSrcweir using namespace ::com::sun::star::util;
70*cdf0e10cSrcweir using namespace ::com::sun::star::container;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir using ::rtl::OUString;
73*cdf0e10cSrcweir using ::vos::OGuard;
74*cdf0e10cSrcweir using ::osl::MutexGuard;
75*cdf0e10cSrcweir using ::osl::ClearableMutexGuard;
76*cdf0e10cSrcweir using ::cppu::OInterfaceContainerHelper;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir namespace sdr { namespace table {
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir typedef std::map< OUString, sal_Int32 > CellStyleNameMap;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper6< XStyle, XNameReplace, XServiceInfo, XIndexAccess, XModifyBroadcaster, XModifyListener > TableDesignStyleBase;
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir class TableDesignStyle : private ::cppu::BaseMutex, public TableDesignStyleBase
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir public:
87*cdf0e10cSrcweir 	TableDesignStyle();
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	// XServiceInfo
90*cdf0e10cSrcweir     virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
91*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
92*cdf0e10cSrcweir     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	// XStyle
95*cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL isUserDefined() throw (RuntimeException);
96*cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL isInUse() throw (RuntimeException);
97*cdf0e10cSrcweir     virtual OUString SAL_CALL getParentStyle() throw (RuntimeException);
98*cdf0e10cSrcweir     virtual void SAL_CALL setParentStyle( const OUString& aParentStyle ) throw (NoSuchElementException, RuntimeException);
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	// XNamed
101*cdf0e10cSrcweir     virtual OUString SAL_CALL getName() throw (RuntimeException);
102*cdf0e10cSrcweir     virtual void SAL_CALL setName( const OUString& aName ) throw (RuntimeException);
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	// XNameAccess
105*cdf0e10cSrcweir     virtual Any SAL_CALL getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException);
106*cdf0e10cSrcweir     virtual Sequence< OUString > SAL_CALL getElementNames() throw(RuntimeException);
107*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(RuntimeException);
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	// XElementAccess
110*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(RuntimeException);
111*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasElements() throw(RuntimeException);
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	// XIndexAccess
114*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getCount() throw(RuntimeException) ;
115*cdf0e10cSrcweir     virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	// XNameReplace
118*cdf0e10cSrcweir     virtual void SAL_CALL replaceByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException);
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     // XModifyBroadcaster
121*cdf0e10cSrcweir     virtual void SAL_CALL addModifyListener( const Reference< XModifyListener >& aListener ) throw (RuntimeException);
122*cdf0e10cSrcweir     virtual void SAL_CALL removeModifyListener( const Reference< XModifyListener >& aListener ) throw (RuntimeException);
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     // XModifyListener
125*cdf0e10cSrcweir     virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
126*cdf0e10cSrcweir     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	void notifyModifyListener();
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	// this function is called upon disposing the component
131*cdf0e10cSrcweir 	virtual void SAL_CALL disposing();
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	static const CellStyleNameMap& getCellStyleNameMap();
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	OUString msName;
136*cdf0e10cSrcweir 	Reference< XStyle > maCellStyles[style_count];
137*cdf0e10cSrcweir };
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir typedef std::vector< Reference< XStyle > > TableDesignStyleVector;
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir class TableDesignFamily : public ::cppu::WeakImplHelper7< XNameContainer, XNamed, XIndexAccess, XSingleServiceFactory,  XServiceInfo, XComponent, XPropertySet >
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir public:
144*cdf0e10cSrcweir 	// XServiceInfo
145*cdf0e10cSrcweir     virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
146*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
147*cdf0e10cSrcweir     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	// XNamed
150*cdf0e10cSrcweir     virtual OUString SAL_CALL getName(  ) throw (RuntimeException);
151*cdf0e10cSrcweir     virtual void SAL_CALL setName( const OUString& aName ) throw (RuntimeException);
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 	// XNameAccess
154*cdf0e10cSrcweir     virtual Any SAL_CALL getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException);
155*cdf0e10cSrcweir     virtual Sequence< OUString > SAL_CALL getElementNames() throw(RuntimeException);
156*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(RuntimeException);
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	// XElementAccess
159*cdf0e10cSrcweir     virtual Type SAL_CALL getElementType() throw(RuntimeException);
160*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasElements() throw(RuntimeException);
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	// XIndexAccess
163*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getCount() throw(RuntimeException) ;
164*cdf0e10cSrcweir     virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 	// XNameContainer
167*cdf0e10cSrcweir 	virtual void SAL_CALL insertByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException);
168*cdf0e10cSrcweir 	virtual void SAL_CALL removeByName( const OUString& Name ) throw(NoSuchElementException, WrappedTargetException, RuntimeException);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 	// XNameReplace
171*cdf0e10cSrcweir     virtual void SAL_CALL replaceByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException);
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	// XSingleServiceFactory
174*cdf0e10cSrcweir     virtual Reference< XInterface > SAL_CALL createInstance(  ) throw(Exception, RuntimeException);
175*cdf0e10cSrcweir     virtual Reference< XInterface > SAL_CALL createInstanceWithArguments( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException);
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 	// XComponent
178*cdf0e10cSrcweir     virtual void SAL_CALL dispose(  ) throw (RuntimeException);
179*cdf0e10cSrcweir     virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException);
180*cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException);
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir     // XPropertySet
183*cdf0e10cSrcweir 	virtual Reference<XPropertySetInfo> SAL_CALL getPropertySetInfo() throw (RuntimeException);
184*cdf0e10cSrcweir 	virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException);
185*cdf0e10cSrcweir 	virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException);
186*cdf0e10cSrcweir 	virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const Reference<XPropertyChangeListener>& xListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException);
187*cdf0e10cSrcweir 	virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException);
188*cdf0e10cSrcweir     virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const Reference<XVetoableChangeListener>& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException);
189*cdf0e10cSrcweir     virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName,const Reference<XVetoableChangeListener>&aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 	TableDesignStyleVector	maDesigns;
192*cdf0e10cSrcweir };
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir //------------------------------------------------------------------------
195*cdf0e10cSrcweir // TableDesignStyle
196*cdf0e10cSrcweir //------------------------------------------------------------------------
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir TableDesignStyle::TableDesignStyle()
199*cdf0e10cSrcweir : TableDesignStyleBase(m_aMutex)
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir const CellStyleNameMap& TableDesignStyle::getCellStyleNameMap()
204*cdf0e10cSrcweir {
205*cdf0e10cSrcweir 	static CellStyleNameMap aMap;
206*cdf0e10cSrcweir 	if( aMap.empty() )
207*cdf0e10cSrcweir 	{
208*cdf0e10cSrcweir 		CellStyleNameMap aNewMap;
209*cdf0e10cSrcweir 		aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "first-row" ) ) ] = first_row_style;
210*cdf0e10cSrcweir 		aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "last-row" ) ) ] = last_row_style;
211*cdf0e10cSrcweir 		aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "first-column" ) ) ] = first_column_style;
212*cdf0e10cSrcweir 		aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "last-column" ) ) ] = last_column_style;
213*cdf0e10cSrcweir 		aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "body" ) ) ] = body_style;
214*cdf0e10cSrcweir 		aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "even-rows" ) ) ] = even_rows_style;
215*cdf0e10cSrcweir 		aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "odd-rows" ) ) ] = odd_rows_style;
216*cdf0e10cSrcweir 		aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "even-columns" ) ) ] = even_columns_style;
217*cdf0e10cSrcweir 		aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "odd-columns" ) ) ] = odd_columns_style;
218*cdf0e10cSrcweir 		aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "background" ) ) ] = background_style;
219*cdf0e10cSrcweir 		aMap.swap( aNewMap );
220*cdf0e10cSrcweir 	}
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 	return aMap;
223*cdf0e10cSrcweir }
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir // ----------------------------------------------------------
226*cdf0e10cSrcweir // XServiceInfo
227*cdf0e10cSrcweir // ----------------------------------------------------------
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir OUString SAL_CALL TableDesignStyle::getImplementationName() throw(RuntimeException)
230*cdf0e10cSrcweir {
231*cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM("TableDesignStyle") );
232*cdf0e10cSrcweir }
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir // ----------------------------------------------------------
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir sal_Bool SAL_CALL TableDesignStyle::supportsService( const OUString& ServiceName ) throw(RuntimeException)
237*cdf0e10cSrcweir {
238*cdf0e10cSrcweir 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
239*cdf0e10cSrcweir }
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir // ----------------------------------------------------------
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir Sequence< OUString > SAL_CALL TableDesignStyle::getSupportedServiceNames() throw(RuntimeException)
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir 	OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.Style") );
246*cdf0e10cSrcweir 	Sequence< OUString > aSeq( &aServiceName, 1 );
247*cdf0e10cSrcweir 	return aSeq;
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir // ----------------------------------------------------------
251*cdf0e10cSrcweir // XStyle
252*cdf0e10cSrcweir // ----------------------------------------------------------
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir sal_Bool SAL_CALL TableDesignStyle::isUserDefined() throw (RuntimeException)
255*cdf0e10cSrcweir {
256*cdf0e10cSrcweir 	return sal_False;
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir // ----------------------------------------------------------
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir sal_Bool SAL_CALL TableDesignStyle::isInUse() throw (RuntimeException)
262*cdf0e10cSrcweir {
263*cdf0e10cSrcweir 	ClearableMutexGuard aGuard( rBHelper.rMutex );
264*cdf0e10cSrcweir 	OInterfaceContainerHelper * pContainer = rBHelper.getContainer( XModifyListener::static_type() );
265*cdf0e10cSrcweir 	if( pContainer )
266*cdf0e10cSrcweir 	{
267*cdf0e10cSrcweir 		Sequence< Reference< XInterface > > aListener( pContainer->getElements() );
268*cdf0e10cSrcweir 		aGuard.clear();
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 		sal_Int32 nIndex = aListener.getLength();
271*cdf0e10cSrcweir 		while( --nIndex >= 0 )
272*cdf0e10cSrcweir 		{
273*cdf0e10cSrcweir 			TableDesignUser* pUser = dynamic_cast< TableDesignUser* >( aListener[nIndex].get() );
274*cdf0e10cSrcweir 			if( pUser && pUser->isInUse() )
275*cdf0e10cSrcweir 				return sal_True;
276*cdf0e10cSrcweir 		}
277*cdf0e10cSrcweir 	}
278*cdf0e10cSrcweir 	return sal_False;
279*cdf0e10cSrcweir }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir // ----------------------------------------------------------
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir OUString SAL_CALL TableDesignStyle::getParentStyle() throw (RuntimeException)
284*cdf0e10cSrcweir {
285*cdf0e10cSrcweir 	return OUString();
286*cdf0e10cSrcweir }
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir // ----------------------------------------------------------
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir void SAL_CALL TableDesignStyle::setParentStyle( const OUString& ) throw (NoSuchElementException, RuntimeException)
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir }
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir // ----------------------------------------------------------
295*cdf0e10cSrcweir // XNamed
296*cdf0e10cSrcweir // ----------------------------------------------------------
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir OUString SAL_CALL TableDesignStyle::getName() throw (RuntimeException)
299*cdf0e10cSrcweir {
300*cdf0e10cSrcweir 	return msName;
301*cdf0e10cSrcweir }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir // ----------------------------------------------------------
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir void SAL_CALL TableDesignStyle::setName( const OUString& rName ) throw (RuntimeException)
306*cdf0e10cSrcweir {
307*cdf0e10cSrcweir 	msName = rName;
308*cdf0e10cSrcweir }
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir // ----------------------------------------------------------
311*cdf0e10cSrcweir // XNameAccess
312*cdf0e10cSrcweir // ----------------------------------------------------------
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir Any SAL_CALL TableDesignStyle::getByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir 	const CellStyleNameMap& rMap = getCellStyleNameMap();
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 	CellStyleNameMap::const_iterator iter = rMap.find( rName );
321*cdf0e10cSrcweir 	if( iter == rMap.end() )
322*cdf0e10cSrcweir 		throw NoSuchElementException();
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 	return Any( maCellStyles[(*iter).second] );
325*cdf0e10cSrcweir }
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir // ----------------------------------------------------------
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir Sequence< OUString > SAL_CALL TableDesignStyle::getElementNames() throw(RuntimeException)
330*cdf0e10cSrcweir {
331*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir 	const CellStyleNameMap& rMap = getCellStyleNameMap();
334*cdf0e10cSrcweir 	Sequence< OUString > aRet( rMap.size() );
335*cdf0e10cSrcweir 	OUString* pName = aRet.getArray();
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 	CellStyleNameMap::const_iterator iter = rMap.begin();
338*cdf0e10cSrcweir 	while( iter != rMap.end() )
339*cdf0e10cSrcweir 		*pName++ = (*iter++).first;
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 	return aRet;
342*cdf0e10cSrcweir }
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir // ----------------------------------------------------------
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir sal_Bool SAL_CALL TableDesignStyle::hasByName( const OUString& rName )	throw(RuntimeException)
347*cdf0e10cSrcweir {
348*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 	const CellStyleNameMap& rMap = getCellStyleNameMap();
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir 	CellStyleNameMap::const_iterator iter = rMap.find( rName );
353*cdf0e10cSrcweir 	return ( iter != rMap.end() ) ? sal_True : sal_False;
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir // ----------------------------------------------------------
357*cdf0e10cSrcweir // XElementAccess
358*cdf0e10cSrcweir // ----------------------------------------------------------
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir Type SAL_CALL TableDesignStyle::getElementType() throw(RuntimeException)
361*cdf0e10cSrcweir {
362*cdf0e10cSrcweir 	return XStyle::static_type();
363*cdf0e10cSrcweir }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir // ----------------------------------------------------------
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir sal_Bool SAL_CALL TableDesignStyle::hasElements() throw(RuntimeException)
368*cdf0e10cSrcweir {
369*cdf0e10cSrcweir 	return sal_True;
370*cdf0e10cSrcweir }
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir // ----------------------------------------------------------
373*cdf0e10cSrcweir // XIndexAccess
374*cdf0e10cSrcweir // ----------------------------------------------------------
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir sal_Int32 SAL_CALL TableDesignStyle::getCount() throw(RuntimeException)
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir 	return style_count;
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir // ----------------------------------------------------------
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir Any SAL_CALL TableDesignStyle::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
384*cdf0e10cSrcweir {
385*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 	if( (Index < 0) || (Index >= style_count) )
388*cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir 	return Any( maCellStyles[Index] );
391*cdf0e10cSrcweir }
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir // ----------------------------------------------------------
394*cdf0e10cSrcweir // XNameReplace
395*cdf0e10cSrcweir // ----------------------------------------------------------
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir void SAL_CALL TableDesignStyle::replaceByName( const OUString& rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
398*cdf0e10cSrcweir {
399*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 	const CellStyleNameMap& rMap = getCellStyleNameMap();
402*cdf0e10cSrcweir 	CellStyleNameMap::const_iterator iter = rMap.find( rName );
403*cdf0e10cSrcweir 	if( iter == rMap.end() )
404*cdf0e10cSrcweir 		throw NoSuchElementException();
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 	Reference< XStyle > xNewStyle;
408*cdf0e10cSrcweir 	if( !(aElement >>= xNewStyle) )
409*cdf0e10cSrcweir 		throw IllegalArgumentException();
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 	const sal_Int32 nIndex = (*iter).second;
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir 	Reference< XStyle > xOldStyle( maCellStyles[nIndex] );
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 	if( xNewStyle != xOldStyle )
416*cdf0e10cSrcweir 	{
417*cdf0e10cSrcweir 		Reference< XModifyListener > xListener( this );
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir 		// end listening to old style, if possible
420*cdf0e10cSrcweir 		Reference< XModifyBroadcaster > xOldBroadcaster( xOldStyle, UNO_QUERY );
421*cdf0e10cSrcweir 		if( xOldBroadcaster.is() )
422*cdf0e10cSrcweir 			xOldBroadcaster->removeModifyListener( xListener );
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 		// start listening to new style, if possible
425*cdf0e10cSrcweir 		Reference< XModifyBroadcaster > xNewBroadcaster( xNewStyle, UNO_QUERY );
426*cdf0e10cSrcweir 		if( xNewBroadcaster.is() )
427*cdf0e10cSrcweir 			xNewBroadcaster->addModifyListener( xListener );
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir 		maCellStyles[nIndex] = xNewStyle;
430*cdf0e10cSrcweir 	}
431*cdf0e10cSrcweir }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir // ----------------------------------------------------------
434*cdf0e10cSrcweir // XComponent
435*cdf0e10cSrcweir // ----------------------------------------------------------
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir void SAL_CALL TableDesignStyle::disposing()
438*cdf0e10cSrcweir {
439*cdf0e10cSrcweir 	for( sal_Int32 nIndex = 0; nIndex < style_count; nIndex++ )
440*cdf0e10cSrcweir 		maCellStyles[nIndex].clear();
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir //------------------------------------------------------------------------
444*cdf0e10cSrcweir // XModifyBroadcaster
445*cdf0e10cSrcweir //------------------------------------------------------------------------
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir void SAL_CALL TableDesignStyle::addModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException)
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir 	ClearableMutexGuard aGuard( rBHelper.rMutex );
450*cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
451*cdf0e10cSrcweir 	{
452*cdf0e10cSrcweir 		aGuard.clear();
453*cdf0e10cSrcweir 		EventObject aEvt( static_cast< OWeakObject * >( this ) );
454*cdf0e10cSrcweir 		xListener->disposing( aEvt );
455*cdf0e10cSrcweir 	}
456*cdf0e10cSrcweir 	else
457*cdf0e10cSrcweir 	{
458*cdf0e10cSrcweir 		rBHelper.addListener( XModifyListener::static_type(), xListener );
459*cdf0e10cSrcweir 	}
460*cdf0e10cSrcweir }
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir //------------------------------------------------------------------------
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir void SAL_CALL TableDesignStyle::removeModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException)
465*cdf0e10cSrcweir {
466*cdf0e10cSrcweir 	rBHelper.removeListener( XModifyListener::static_type(), xListener );
467*cdf0e10cSrcweir }
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir //------------------------------------------------------------------------
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir void TableDesignStyle::notifyModifyListener()
472*cdf0e10cSrcweir {
473*cdf0e10cSrcweir 	MutexGuard aGuard( rBHelper.rMutex );
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir 	OInterfaceContainerHelper * pContainer = rBHelper.getContainer( XModifyListener::static_type() );
476*cdf0e10cSrcweir 	if( pContainer )
477*cdf0e10cSrcweir 	{
478*cdf0e10cSrcweir 		EventObject aEvt( static_cast< OWeakObject * >( this ) );
479*cdf0e10cSrcweir 		pContainer->forEach<XModifyListener>( boost::bind( &XModifyListener::modified, _1, boost::cref( aEvt ) ) );
480*cdf0e10cSrcweir 	}
481*cdf0e10cSrcweir }
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir //------------------------------------------------------------------------
484*cdf0e10cSrcweir // XModifyListener
485*cdf0e10cSrcweir //------------------------------------------------------------------------
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir // if we get a modify hint from a style, notify all registered XModifyListener
488*cdf0e10cSrcweir void SAL_CALL TableDesignStyle::modified( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
489*cdf0e10cSrcweir {
490*cdf0e10cSrcweir 	notifyModifyListener();
491*cdf0e10cSrcweir }
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir //------------------------------------------------------------------------
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir void SAL_CALL TableDesignStyle::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
496*cdf0e10cSrcweir {
497*cdf0e10cSrcweir }
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir //------------------------------------------------------------------------
500*cdf0e10cSrcweir // TableStyle
501*cdf0e10cSrcweir //------------------------------------------------------------------------
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir // ----------------------------------------------------------
504*cdf0e10cSrcweir // XServiceInfo
505*cdf0e10cSrcweir // ----------------------------------------------------------
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir OUString SAL_CALL TableDesignFamily::getImplementationName() throw(RuntimeException)
508*cdf0e10cSrcweir {
509*cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM("TableDesignFamily") );
510*cdf0e10cSrcweir }
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir // ----------------------------------------------------------
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir sal_Bool SAL_CALL TableDesignFamily::supportsService( const OUString& ServiceName ) throw(RuntimeException)
515*cdf0e10cSrcweir {
516*cdf0e10cSrcweir 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
517*cdf0e10cSrcweir }
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir // ----------------------------------------------------------
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir Sequence< OUString > SAL_CALL TableDesignFamily::getSupportedServiceNames() throw(RuntimeException)
522*cdf0e10cSrcweir {
523*cdf0e10cSrcweir 	OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.StyleFamily") );
524*cdf0e10cSrcweir 	Sequence< OUString > aSeq( &aServiceName, 1 );
525*cdf0e10cSrcweir 	return aSeq;
526*cdf0e10cSrcweir }
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir // ----------------------------------------------------------
529*cdf0e10cSrcweir // XNamed
530*cdf0e10cSrcweir // ----------------------------------------------------------
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir OUString SAL_CALL TableDesignFamily::getName() throw (RuntimeException)
533*cdf0e10cSrcweir {
534*cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "table" ) );
535*cdf0e10cSrcweir }
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir // ----------------------------------------------------------
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir void SAL_CALL TableDesignFamily::setName( const OUString& ) throw (RuntimeException)
540*cdf0e10cSrcweir {
541*cdf0e10cSrcweir }
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir // ----------------------------------------------------------
544*cdf0e10cSrcweir // XNameAccess
545*cdf0e10cSrcweir // ----------------------------------------------------------
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir Any SAL_CALL TableDesignFamily::getByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
548*cdf0e10cSrcweir {
549*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir 	for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
552*cdf0e10cSrcweir 	{
553*cdf0e10cSrcweir 		if( (*iter)->getName() == rName )
554*cdf0e10cSrcweir 			return Any( (*iter) );
555*cdf0e10cSrcweir 	}
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir 	throw NoSuchElementException();
558*cdf0e10cSrcweir }
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir // ----------------------------------------------------------
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir Sequence< OUString > SAL_CALL TableDesignFamily::getElementNames() throw(RuntimeException)
563*cdf0e10cSrcweir {
564*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir 	Sequence< OUString > aRet( maDesigns.size() );
567*cdf0e10cSrcweir 	OUString* pNames = aRet.getArray();
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir 	for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
570*cdf0e10cSrcweir 		*pNames++ = (*iter)->getName();
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir 	return aRet;
573*cdf0e10cSrcweir }
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir // ----------------------------------------------------------
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir sal_Bool SAL_CALL TableDesignFamily::hasByName( const OUString& aName )	throw(RuntimeException)
578*cdf0e10cSrcweir {
579*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir 	for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
582*cdf0e10cSrcweir 		if( (*iter)->getName() == aName )
583*cdf0e10cSrcweir 			return sal_True;
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 	return sal_False;
586*cdf0e10cSrcweir }
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir // ----------------------------------------------------------
589*cdf0e10cSrcweir // XElementAccess
590*cdf0e10cSrcweir // ----------------------------------------------------------
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir Type SAL_CALL TableDesignFamily::getElementType() throw(RuntimeException)
593*cdf0e10cSrcweir {
594*cdf0e10cSrcweir 	return XStyle::static_type();
595*cdf0e10cSrcweir }
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir // ----------------------------------------------------------
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir sal_Bool SAL_CALL TableDesignFamily::hasElements() throw(RuntimeException)
600*cdf0e10cSrcweir {
601*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 	return maDesigns.empty() ? sal_False : sal_True;
604*cdf0e10cSrcweir }
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir // ----------------------------------------------------------
607*cdf0e10cSrcweir // XIndexAccess
608*cdf0e10cSrcweir // ----------------------------------------------------------
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir sal_Int32 SAL_CALL TableDesignFamily::getCount() throw(RuntimeException)
611*cdf0e10cSrcweir {
612*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 	return sal::static_int_cast< sal_Int32 >( maDesigns.size() );
615*cdf0e10cSrcweir }
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir // ----------------------------------------------------------
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir Any SAL_CALL TableDesignFamily::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
620*cdf0e10cSrcweir {
621*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir 	if( (Index >= 0) && (Index < sal::static_int_cast< sal_Int32 >( maDesigns.size() ) ) )
624*cdf0e10cSrcweir 		return Any( maDesigns[Index] );
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
627*cdf0e10cSrcweir }
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir // ----------------------------------------------------------
630*cdf0e10cSrcweir // XNameContainer
631*cdf0e10cSrcweir // ----------------------------------------------------------
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir void SAL_CALL TableDesignFamily::insertByName( const OUString& rName, const Any& rElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
634*cdf0e10cSrcweir {
635*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir 	Reference< XStyle > xStyle( rElement, UNO_QUERY );
638*cdf0e10cSrcweir 	if( !xStyle.is() )
639*cdf0e10cSrcweir 		throw IllegalArgumentException();
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir 	xStyle->setName( rName );
642*cdf0e10cSrcweir 	for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
643*cdf0e10cSrcweir 		if( (*iter)->getName() == rName )
644*cdf0e10cSrcweir 			throw ElementExistException();
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir 	maDesigns.push_back( xStyle );
647*cdf0e10cSrcweir }
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir // ----------------------------------------------------------
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir void SAL_CALL TableDesignFamily::removeByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
652*cdf0e10cSrcweir {
653*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 	for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
656*cdf0e10cSrcweir 	{
657*cdf0e10cSrcweir 		if( (*iter)->getName() == rName )
658*cdf0e10cSrcweir 		{
659*cdf0e10cSrcweir 			maDesigns.erase( iter );
660*cdf0e10cSrcweir 			return;
661*cdf0e10cSrcweir 		}
662*cdf0e10cSrcweir 	}
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir 	throw NoSuchElementException();
666*cdf0e10cSrcweir }
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir // ----------------------------------------------------------
669*cdf0e10cSrcweir // XNameReplace
670*cdf0e10cSrcweir // ----------------------------------------------------------
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir void SAL_CALL TableDesignFamily::replaceByName( const OUString& rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
673*cdf0e10cSrcweir {
674*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir 	Reference< XStyle > xStyle( aElement, UNO_QUERY );
677*cdf0e10cSrcweir 	if( !xStyle.is() )
678*cdf0e10cSrcweir 		throw IllegalArgumentException();
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir 	for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
681*cdf0e10cSrcweir 	{
682*cdf0e10cSrcweir 		if( (*iter)->getName() == rName )
683*cdf0e10cSrcweir 		{
684*cdf0e10cSrcweir 			(*iter) = xStyle;
685*cdf0e10cSrcweir 			xStyle->setName( rName );
686*cdf0e10cSrcweir 			return;
687*cdf0e10cSrcweir 		}
688*cdf0e10cSrcweir 	}
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir 	throw NoSuchElementException();
691*cdf0e10cSrcweir }
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir // ----------------------------------------------------------
694*cdf0e10cSrcweir // XSingleServiceFactory
695*cdf0e10cSrcweir // ----------------------------------------------------------
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir Reference< XInterface > SAL_CALL TableDesignFamily::createInstance() throw(Exception, RuntimeException)
698*cdf0e10cSrcweir {
699*cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir 	return Reference< XInterface >( static_cast< XStyle* >( new TableDesignStyle ) );
702*cdf0e10cSrcweir }
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir // ----------------------------------------------------------
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir Reference< XInterface > SAL_CALL TableDesignFamily::createInstanceWithArguments( const Sequence< Any >&  ) throw(Exception, RuntimeException)
707*cdf0e10cSrcweir {
708*cdf0e10cSrcweir 	return createInstance();
709*cdf0e10cSrcweir }
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir // ----------------------------------------------------------
712*cdf0e10cSrcweir // XComponent
713*cdf0e10cSrcweir // ----------------------------------------------------------
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir void SAL_CALL TableDesignFamily::dispose(  ) throw (RuntimeException)
716*cdf0e10cSrcweir {
717*cdf0e10cSrcweir 	TableDesignStyleVector aDesigns;
718*cdf0e10cSrcweir 	aDesigns.swap( maDesigns );
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir 	for( TableDesignStyleVector::iterator iter( aDesigns.begin() ); iter != aDesigns.end(); iter++ )
721*cdf0e10cSrcweir 	{
722*cdf0e10cSrcweir 		Reference< XComponent > xComp( (*iter), UNO_QUERY );
723*cdf0e10cSrcweir 		if( xComp.is() )
724*cdf0e10cSrcweir 			xComp->dispose();
725*cdf0e10cSrcweir 	}
726*cdf0e10cSrcweir }
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir // ----------------------------------------------------------
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir void SAL_CALL TableDesignFamily::addEventListener( const Reference< XEventListener >&  ) throw (RuntimeException)
731*cdf0e10cSrcweir {
732*cdf0e10cSrcweir }
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir // ----------------------------------------------------------
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir void SAL_CALL TableDesignFamily::removeEventListener( const Reference< XEventListener >&  ) throw (RuntimeException)
737*cdf0e10cSrcweir {
738*cdf0e10cSrcweir }
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir // ----------------------------------------------------------
741*cdf0e10cSrcweir // XPropertySet
742*cdf0e10cSrcweir // ----------------------------------------------------------
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir Reference<XPropertySetInfo> TableDesignFamily::getPropertySetInfo() throw (RuntimeException)
745*cdf0e10cSrcweir {
746*cdf0e10cSrcweir     OSL_ENSURE( 0, "###unexpected!" );
747*cdf0e10cSrcweir     return Reference<XPropertySetInfo>();
748*cdf0e10cSrcweir }
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir // ----------------------------------------------------------
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir void TableDesignFamily::setPropertyValue( const OUString& , const Any&  ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
753*cdf0e10cSrcweir {
754*cdf0e10cSrcweir     OSL_ENSURE( 0, "###unexpected!" );
755*cdf0e10cSrcweir }
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir // ----------------------------------------------------------
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir Any TableDesignFamily::getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
760*cdf0e10cSrcweir {
761*cdf0e10cSrcweir     if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DisplayName") ))
762*cdf0e10cSrcweir 	{
763*cdf0e10cSrcweir         OUString sDisplayName( SVX_RESSTR( RID_SVXSTR_STYLEFAMILY_TABLEDESIGN ) );
764*cdf0e10cSrcweir 		return Any( sDisplayName );
765*cdf0e10cSrcweir     }
766*cdf0e10cSrcweir     else
767*cdf0e10cSrcweir 	{
768*cdf0e10cSrcweir         throw UnknownPropertyException( OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property: ") ) + PropertyName, static_cast<OWeakObject *>(this) );
769*cdf0e10cSrcweir 	}
770*cdf0e10cSrcweir }
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir // ----------------------------------------------------------
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir void TableDesignFamily::addPropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>&  ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
775*cdf0e10cSrcweir {
776*cdf0e10cSrcweir     OSL_ENSURE( 0, "###unexpected!" );
777*cdf0e10cSrcweir }
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir // ----------------------------------------------------------
780*cdf0e10cSrcweir 
781*cdf0e10cSrcweir void TableDesignFamily::removePropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>&  ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
782*cdf0e10cSrcweir {
783*cdf0e10cSrcweir     OSL_ENSURE( 0, "###unexpected!" );
784*cdf0e10cSrcweir }
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir // ----------------------------------------------------------
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir void TableDesignFamily::addVetoableChangeListener( const OUString& , const Reference<XVetoableChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
789*cdf0e10cSrcweir {
790*cdf0e10cSrcweir     OSL_ENSURE( 0, "###unexpected!" );
791*cdf0e10cSrcweir }
792*cdf0e10cSrcweir 
793*cdf0e10cSrcweir // ----------------------------------------------------------
794*cdf0e10cSrcweir 
795*cdf0e10cSrcweir void TableDesignFamily::removeVetoableChangeListener( const OUString& , const Reference<XVetoableChangeListener>&  ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
796*cdf0e10cSrcweir {
797*cdf0e10cSrcweir     OSL_ENSURE( 0, "###unexpected!" );
798*cdf0e10cSrcweir }
799*cdf0e10cSrcweir 
800*cdf0e10cSrcweir // --------------------------------------------------------------------
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir SVX_DLLPUBLIC Reference< XNameAccess > CreateTableDesignFamily()
804*cdf0e10cSrcweir {
805*cdf0e10cSrcweir 	return new TableDesignFamily();
806*cdf0e10cSrcweir }
807*cdf0e10cSrcweir 
808*cdf0e10cSrcweir } }
809