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