1*24acc546SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*24acc546SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*24acc546SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*24acc546SAndrew Rist * distributed with this work for additional information 6*24acc546SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*24acc546SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*24acc546SAndrew Rist * "License"); you may not use this file except in compliance 9*24acc546SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*24acc546SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*24acc546SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*24acc546SAndrew Rist * software distributed under the License is distributed on an 15*24acc546SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*24acc546SAndrew Rist * KIND, either express or implied. See the License for the 17*24acc546SAndrew Rist * specific language governing permissions and limitations 18*24acc546SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*24acc546SAndrew Rist *************************************************************/ 21*24acc546SAndrew Rist 22*24acc546SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_forms.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "FormsCollection.hxx" 28cdf0e10cSrcweir #include "services.hxx" 29cdf0e10cSrcweir #include <comphelper/sequence.hxx> 30cdf0e10cSrcweir #include <tools/debug.hxx> 31cdf0e10cSrcweir #include <com/sun/star/form/XForm.hpp> 32cdf0e10cSrcweir #include <rtl/logfile.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir //......................................................................... 35cdf0e10cSrcweir namespace frm 36cdf0e10cSrcweir { 37cdf0e10cSrcweir //......................................................................... 38cdf0e10cSrcweir using namespace ::com::sun::star::lang; 39cdf0e10cSrcweir using namespace ::com::sun::star::uno; 40cdf0e10cSrcweir using namespace ::com::sun::star::form; 41cdf0e10cSrcweir using namespace ::com::sun::star::container; 42cdf0e10cSrcweir using namespace ::com::sun::star::util; 43cdf0e10cSrcweir 44cdf0e10cSrcweir //------------------------------------------------------------------ 45cdf0e10cSrcweir DBG_NAME(OFormsCollection) 46cdf0e10cSrcweir //------------------------------------------------------------------ 47cdf0e10cSrcweir InterfaceRef SAL_CALL OFormsCollection_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir return *(new OFormsCollection(_rxFactory)); 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir //------------------------------------------------------------------------------ 53cdf0e10cSrcweir ::rtl::OUString SAL_CALL OFormsCollection::getServiceName() throw(RuntimeException) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir return FRM_SUN_FORMS_COLLECTION; 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir //------------------------------------------------------------------------------ 59cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL OFormsCollection::getImplementationId( ) throw(RuntimeException) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir return OImplementationIds::getImplementationId(getTypes()); 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir //------------------------------------------------------------------------------ 65cdf0e10cSrcweir Sequence<Type> SAL_CALL OFormsCollection::getTypes() throw(RuntimeException) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir return concatSequences(OInterfaceContainer::getTypes(), FormsCollectionComponentBase::getTypes(), OFormsCollection_BASE::getTypes()); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir //------------------------------------------------------------------ 71cdf0e10cSrcweir OFormsCollection::OFormsCollection(const Reference<XMultiServiceFactory>& _rxFactory) 72cdf0e10cSrcweir :FormsCollectionComponentBase( m_aMutex ) 73cdf0e10cSrcweir ,OInterfaceContainer( _rxFactory, m_aMutex, XForm::static_type() ) 74cdf0e10cSrcweir ,OFormsCollection_BASE() 75cdf0e10cSrcweir { 76cdf0e10cSrcweir DBG_CTOR(OFormsCollection, NULL); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir //------------------------------------------------------------------------------ 80cdf0e10cSrcweir OFormsCollection::OFormsCollection( const OFormsCollection& _cloneSource ) 81cdf0e10cSrcweir :FormsCollectionComponentBase( m_aMutex ) 82cdf0e10cSrcweir ,OInterfaceContainer( m_aMutex, _cloneSource ) 83cdf0e10cSrcweir ,OFormsCollection_BASE() 84cdf0e10cSrcweir { 85cdf0e10cSrcweir DBG_CTOR( OFormsCollection, NULL ); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir //------------------------------------------------------------------------------ 89cdf0e10cSrcweir OFormsCollection::~OFormsCollection() 90cdf0e10cSrcweir { 91cdf0e10cSrcweir DBG_DTOR(OFormsCollection, NULL); 92cdf0e10cSrcweir if (!FormsCollectionComponentBase::rBHelper.bDisposed) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir acquire(); 95cdf0e10cSrcweir dispose(); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir //------------------------------------------------------------------------------ 100cdf0e10cSrcweir Any SAL_CALL OFormsCollection::queryAggregation(const Type& _rType) throw(RuntimeException) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir Any aReturn = OFormsCollection_BASE::queryInterface(_rType); 103cdf0e10cSrcweir if (!aReturn.hasValue()) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir aReturn = OInterfaceContainer::queryInterface(_rType); 106cdf0e10cSrcweir 107cdf0e10cSrcweir if (!aReturn.hasValue()) 108cdf0e10cSrcweir aReturn = FormsCollectionComponentBase::queryAggregation(_rType); 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir return aReturn; 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir //------------------------------------------------------------------------------ 115cdf0e10cSrcweir ::rtl::OUString SAL_CALL OFormsCollection::getImplementationName() throw(RuntimeException) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("com.sun.star.comp.forms.OFormsCollection"); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir //------------------------------------------------------------------------------ 121cdf0e10cSrcweir sal_Bool SAL_CALL OFormsCollection::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir Sequence<rtl::OUString> aSupported = getSupportedServiceNames(); 124cdf0e10cSrcweir const rtl::OUString* pSupported = aSupported.getConstArray(); 125cdf0e10cSrcweir for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) 126cdf0e10cSrcweir if (pSupported->equals(_rServiceName)) 127cdf0e10cSrcweir return sal_True; 128cdf0e10cSrcweir return sal_False; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir //------------------------------------------------------------------------------ 132cdf0e10cSrcweir StringSequence SAL_CALL OFormsCollection::getSupportedServiceNames() throw(RuntimeException) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir StringSequence aReturn(2); 135cdf0e10cSrcweir 136cdf0e10cSrcweir aReturn.getArray()[0] = FRM_SUN_FORMS_COLLECTION; 137cdf0e10cSrcweir aReturn.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormComponents"); 138cdf0e10cSrcweir 139cdf0e10cSrcweir return aReturn; 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir // XCloneable 143cdf0e10cSrcweir //------------------------------------------------------------------------------ 144cdf0e10cSrcweir Reference< XCloneable > SAL_CALL OFormsCollection::createClone( ) throw (RuntimeException) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir OFormsCollection* pClone = new OFormsCollection( *this ); 147cdf0e10cSrcweir osl_incrementInterlockedCount( &pClone->m_refCount ); 148cdf0e10cSrcweir pClone->clonedFrom( *this ); 149cdf0e10cSrcweir osl_decrementInterlockedCount( &pClone->m_refCount ); 150cdf0e10cSrcweir return pClone; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir // OComponentHelper 154cdf0e10cSrcweir //------------------------------------------------------------------------------ 155cdf0e10cSrcweir void OFormsCollection::disposing() 156cdf0e10cSrcweir { 157cdf0e10cSrcweir { 158cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLogger, "forms::OFormsCollection::disposing" ); 159cdf0e10cSrcweir OInterfaceContainer::disposing(); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir FormsCollectionComponentBase::disposing(); 162cdf0e10cSrcweir m_xParent = NULL; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir //XChild 166cdf0e10cSrcweir //------------------------------------------------------------------------------ 167cdf0e10cSrcweir void OFormsCollection::setParent(const InterfaceRef& Parent) throw( NoSupportException, RuntimeException ) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 170cdf0e10cSrcweir m_xParent = Parent; 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir //------------------------------------------------------------------------------ 174cdf0e10cSrcweir InterfaceRef OFormsCollection::getParent() throw( RuntimeException ) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir return m_xParent; 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir //......................................................................... 180cdf0e10cSrcweir } // namespace frm 181cdf0e10cSrcweir //......................................................................... 182cdf0e10cSrcweir 183