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_forms.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "FormsCollection.hxx"
32*cdf0e10cSrcweir #include "services.hxx"
33*cdf0e10cSrcweir #include <comphelper/sequence.hxx>
34*cdf0e10cSrcweir #include <tools/debug.hxx>
35*cdf0e10cSrcweir #include <com/sun/star/form/XForm.hpp>
36*cdf0e10cSrcweir #include <rtl/logfile.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir //.........................................................................
39*cdf0e10cSrcweir namespace frm
40*cdf0e10cSrcweir {
41*cdf0e10cSrcweir //.........................................................................
42*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
43*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
44*cdf0e10cSrcweir using namespace ::com::sun::star::form;
45*cdf0e10cSrcweir using namespace ::com::sun::star::container;
46*cdf0e10cSrcweir using namespace ::com::sun::star::util;
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir //------------------------------------------------------------------
49*cdf0e10cSrcweir DBG_NAME(OFormsCollection)
50*cdf0e10cSrcweir //------------------------------------------------------------------
51*cdf0e10cSrcweir InterfaceRef SAL_CALL OFormsCollection_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir 	return *(new OFormsCollection(_rxFactory));
54*cdf0e10cSrcweir }
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir //------------------------------------------------------------------------------
57*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OFormsCollection::getServiceName() throw(RuntimeException)
58*cdf0e10cSrcweir {
59*cdf0e10cSrcweir 	return FRM_SUN_FORMS_COLLECTION;
60*cdf0e10cSrcweir }
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir //------------------------------------------------------------------------------
63*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL OFormsCollection::getImplementationId(  ) throw(RuntimeException)
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir 	return OImplementationIds::getImplementationId(getTypes());
66*cdf0e10cSrcweir }
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir //------------------------------------------------------------------------------
69*cdf0e10cSrcweir Sequence<Type> SAL_CALL OFormsCollection::getTypes() throw(RuntimeException)
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir 	return concatSequences(OInterfaceContainer::getTypes(), FormsCollectionComponentBase::getTypes(), OFormsCollection_BASE::getTypes());
72*cdf0e10cSrcweir }
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir //------------------------------------------------------------------
75*cdf0e10cSrcweir OFormsCollection::OFormsCollection(const Reference<XMultiServiceFactory>& _rxFactory)
76*cdf0e10cSrcweir     :FormsCollectionComponentBase( m_aMutex )
77*cdf0e10cSrcweir     ,OInterfaceContainer( _rxFactory, m_aMutex, XForm::static_type() )
78*cdf0e10cSrcweir     ,OFormsCollection_BASE()
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir 	DBG_CTOR(OFormsCollection, NULL);
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir //------------------------------------------------------------------------------
84*cdf0e10cSrcweir OFormsCollection::OFormsCollection( const OFormsCollection& _cloneSource )
85*cdf0e10cSrcweir     :FormsCollectionComponentBase( m_aMutex )
86*cdf0e10cSrcweir     ,OInterfaceContainer( m_aMutex, _cloneSource )
87*cdf0e10cSrcweir     ,OFormsCollection_BASE()
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir 	DBG_CTOR( OFormsCollection, NULL );
90*cdf0e10cSrcweir }
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir //------------------------------------------------------------------------------
93*cdf0e10cSrcweir OFormsCollection::~OFormsCollection()
94*cdf0e10cSrcweir {
95*cdf0e10cSrcweir 	DBG_DTOR(OFormsCollection, NULL);
96*cdf0e10cSrcweir 	if (!FormsCollectionComponentBase::rBHelper.bDisposed)
97*cdf0e10cSrcweir 	{
98*cdf0e10cSrcweir 		acquire();
99*cdf0e10cSrcweir 		dispose();
100*cdf0e10cSrcweir 	}
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir //------------------------------------------------------------------------------
104*cdf0e10cSrcweir Any SAL_CALL OFormsCollection::queryAggregation(const Type& _rType) throw(RuntimeException)
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir 	Any aReturn = OFormsCollection_BASE::queryInterface(_rType);
107*cdf0e10cSrcweir 	if (!aReturn.hasValue())
108*cdf0e10cSrcweir 	{
109*cdf0e10cSrcweir 		aReturn = OInterfaceContainer::queryInterface(_rType);
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 		if (!aReturn.hasValue())
112*cdf0e10cSrcweir 			aReturn = FormsCollectionComponentBase::queryAggregation(_rType);
113*cdf0e10cSrcweir 	}
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	return aReturn;
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir //------------------------------------------------------------------------------
119*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OFormsCollection::getImplementationName() throw(RuntimeException)
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii("com.sun.star.comp.forms.OFormsCollection");
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir //------------------------------------------------------------------------------
125*cdf0e10cSrcweir sal_Bool SAL_CALL OFormsCollection::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir 	Sequence<rtl::OUString> aSupported = getSupportedServiceNames();
128*cdf0e10cSrcweir 	const rtl::OUString* pSupported = aSupported.getConstArray();
129*cdf0e10cSrcweir 	for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported)
130*cdf0e10cSrcweir 		if (pSupported->equals(_rServiceName))
131*cdf0e10cSrcweir 			return sal_True;
132*cdf0e10cSrcweir 	return sal_False;
133*cdf0e10cSrcweir }
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir //------------------------------------------------------------------------------
136*cdf0e10cSrcweir StringSequence SAL_CALL OFormsCollection::getSupportedServiceNames() throw(RuntimeException)
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir 	StringSequence aReturn(2);
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 	aReturn.getArray()[0] = FRM_SUN_FORMS_COLLECTION;
141*cdf0e10cSrcweir 	aReturn.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponents");
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	return aReturn;
144*cdf0e10cSrcweir }
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir // XCloneable
147*cdf0e10cSrcweir //------------------------------------------------------------------------------
148*cdf0e10cSrcweir Reference< XCloneable > SAL_CALL OFormsCollection::createClone(  ) throw (RuntimeException)
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir     OFormsCollection* pClone = new OFormsCollection( *this );
151*cdf0e10cSrcweir     osl_incrementInterlockedCount( &pClone->m_refCount );
152*cdf0e10cSrcweir     pClone->clonedFrom( *this );
153*cdf0e10cSrcweir     osl_decrementInterlockedCount( &pClone->m_refCount );
154*cdf0e10cSrcweir     return pClone;
155*cdf0e10cSrcweir }
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir // OComponentHelper
158*cdf0e10cSrcweir //------------------------------------------------------------------------------
159*cdf0e10cSrcweir void OFormsCollection::disposing()
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir 	{
162*cdf0e10cSrcweir 		RTL_LOGFILE_CONTEXT( aLogger, "forms::OFormsCollection::disposing" );
163*cdf0e10cSrcweir 		OInterfaceContainer::disposing();
164*cdf0e10cSrcweir 	}
165*cdf0e10cSrcweir 	FormsCollectionComponentBase::disposing();
166*cdf0e10cSrcweir 	m_xParent = NULL;
167*cdf0e10cSrcweir }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir //XChild
170*cdf0e10cSrcweir //------------------------------------------------------------------------------
171*cdf0e10cSrcweir void OFormsCollection::setParent(const InterfaceRef& Parent) throw( NoSupportException, RuntimeException )
172*cdf0e10cSrcweir {
173*cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
174*cdf0e10cSrcweir 	m_xParent = Parent;
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir //------------------------------------------------------------------------------
178*cdf0e10cSrcweir InterfaceRef  OFormsCollection::getParent() throw( RuntimeException )
179*cdf0e10cSrcweir {
180*cdf0e10cSrcweir 	return m_xParent;
181*cdf0e10cSrcweir }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir //.........................................................................
184*cdf0e10cSrcweir }	// namespace frm
185*cdf0e10cSrcweir //.........................................................................
186*cdf0e10cSrcweir 
187