merge the formfield patch from ooo-build
[ooovba.git] / forms / source / component / FormsCollection.cxx
blob2a8b37e30ed214412e1aa6ebf667cd892a2aca32
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FormsCollection.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_forms.hxx"
34 #include "FormsCollection.hxx"
35 #include "services.hxx"
36 #include <comphelper/sequence.hxx>
37 #include <tools/debug.hxx>
38 #include <com/sun/star/form/XForm.hpp>
39 #include <rtl/logfile.hxx>
41 //.........................................................................
42 namespace frm
44 //.........................................................................
45 using namespace ::com::sun::star::lang;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::form;
48 using namespace ::com::sun::star::container;
49 using namespace ::com::sun::star::util;
51 //------------------------------------------------------------------
52 DBG_NAME(OFormsCollection)
53 //------------------------------------------------------------------
54 InterfaceRef SAL_CALL OFormsCollection_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
56 return *(new OFormsCollection(_rxFactory));
59 //------------------------------------------------------------------------------
60 ::rtl::OUString SAL_CALL OFormsCollection::getServiceName() throw(RuntimeException)
62 return FRM_SUN_FORMS_COLLECTION;
65 //------------------------------------------------------------------------------
66 Sequence< sal_Int8 > SAL_CALL OFormsCollection::getImplementationId( ) throw(RuntimeException)
68 return OImplementationIds::getImplementationId(getTypes());
71 //------------------------------------------------------------------------------
72 Sequence<Type> SAL_CALL OFormsCollection::getTypes() throw(RuntimeException)
74 return concatSequences(OInterfaceContainer::getTypes(), FormsCollectionComponentBase::getTypes(), OFormsCollection_BASE::getTypes());
77 //------------------------------------------------------------------
78 OFormsCollection::OFormsCollection(const Reference<XMultiServiceFactory>& _rxFactory)
79 :FormsCollectionComponentBase( m_aMutex )
80 ,OInterfaceContainer( _rxFactory, m_aMutex, XForm::static_type() )
81 ,OFormsCollection_BASE()
83 DBG_CTOR(OFormsCollection, NULL);
86 //------------------------------------------------------------------------------
87 OFormsCollection::OFormsCollection( const OFormsCollection& _cloneSource )
88 :FormsCollectionComponentBase( m_aMutex )
89 ,OInterfaceContainer( m_aMutex, _cloneSource )
90 ,OFormsCollection_BASE()
92 DBG_CTOR( OFormsCollection, NULL );
95 //------------------------------------------------------------------------------
96 OFormsCollection::~OFormsCollection()
98 DBG_DTOR(OFormsCollection, NULL);
99 if (!FormsCollectionComponentBase::rBHelper.bDisposed)
101 acquire();
102 dispose();
106 //------------------------------------------------------------------------------
107 Any SAL_CALL OFormsCollection::queryAggregation(const Type& _rType) throw(RuntimeException)
109 Any aReturn = OFormsCollection_BASE::queryInterface(_rType);
110 if (!aReturn.hasValue())
112 aReturn = OInterfaceContainer::queryInterface(_rType);
114 if (!aReturn.hasValue())
115 aReturn = FormsCollectionComponentBase::queryAggregation(_rType);
118 return aReturn;
121 //------------------------------------------------------------------------------
122 ::rtl::OUString SAL_CALL OFormsCollection::getImplementationName() throw(RuntimeException)
124 return ::rtl::OUString::createFromAscii("com.sun.star.comp.forms.OFormsCollection");
127 //------------------------------------------------------------------------------
128 sal_Bool SAL_CALL OFormsCollection::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
130 Sequence<rtl::OUString> aSupported = getSupportedServiceNames();
131 const rtl::OUString* pSupported = aSupported.getConstArray();
132 for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported)
133 if (pSupported->equals(_rServiceName))
134 return sal_True;
135 return sal_False;
138 //------------------------------------------------------------------------------
139 StringSequence SAL_CALL OFormsCollection::getSupportedServiceNames() throw(RuntimeException)
141 StringSequence aReturn(2);
143 aReturn.getArray()[0] = FRM_SUN_FORMS_COLLECTION;
144 aReturn.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponents");
146 return aReturn;
149 // XCloneable
150 //------------------------------------------------------------------------------
151 Reference< XCloneable > SAL_CALL OFormsCollection::createClone( ) throw (RuntimeException)
153 OFormsCollection* pClone = new OFormsCollection( *this );
154 osl_incrementInterlockedCount( &pClone->m_refCount );
155 pClone->clonedFrom( *this );
156 osl_decrementInterlockedCount( &pClone->m_refCount );
157 return pClone;
160 // OComponentHelper
161 //------------------------------------------------------------------------------
162 void OFormsCollection::disposing()
165 RTL_LOGFILE_CONTEXT( aLogger, "forms::OFormsCollection::disposing" );
166 OInterfaceContainer::disposing();
168 FormsCollectionComponentBase::disposing();
169 m_xParent = NULL;
172 //XChild
173 //------------------------------------------------------------------------------
174 void OFormsCollection::setParent(const InterfaceRef& Parent) throw( NoSupportException, RuntimeException )
176 ::osl::MutexGuard aGuard( m_aMutex );
177 m_xParent = Parent;
180 //------------------------------------------------------------------------------
181 InterfaceRef OFormsCollection::getParent() throw( RuntimeException )
183 return m_xParent;
186 //.........................................................................
187 } // namespace frm
188 //.........................................................................