bump product version to 4.1.6.2
[LibreOffice.git] / forms / source / component / FormsCollection.cxx
blob1da85ce08828967de3461b440cf10fafb9c30629
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "FormsCollection.hxx"
22 #include "services.hxx"
23 #include <comphelper/sequence.hxx>
24 #include <tools/debug.hxx>
25 #include <com/sun/star/form/XForm.hpp>
26 #include <rtl/logfile.hxx>
28 //.........................................................................
29 namespace frm
31 //.........................................................................
32 using namespace ::com::sun::star::lang;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::form;
35 using namespace ::com::sun::star::container;
36 using namespace ::com::sun::star::util;
38 //------------------------------------------------------------------
39 DBG_NAME(OFormsCollection)
40 //------------------------------------------------------------------
41 InterfaceRef SAL_CALL OFormsCollection_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
43 return *(new OFormsCollection(_rxFactory));
46 //------------------------------------------------------------------------------
47 OUString SAL_CALL OFormsCollection::getServiceName() throw(RuntimeException)
49 return OUString("com.sun.star.form.Forms");
52 //------------------------------------------------------------------------------
53 Sequence< sal_Int8 > SAL_CALL OFormsCollection::getImplementationId( ) throw(RuntimeException)
55 return OImplementationIds::getImplementationId(getTypes());
58 //------------------------------------------------------------------------------
59 Sequence<Type> SAL_CALL OFormsCollection::getTypes() throw(RuntimeException)
61 return concatSequences(OInterfaceContainer::getTypes(), FormsCollectionComponentBase::getTypes(), OFormsCollection_BASE::getTypes());
64 //------------------------------------------------------------------
65 OFormsCollection::OFormsCollection(const Reference<XMultiServiceFactory>& _rxFactory)
66 :FormsCollectionComponentBase( m_aMutex )
67 ,OInterfaceContainer( _rxFactory, m_aMutex, XForm::static_type() )
68 ,OFormsCollection_BASE()
70 DBG_CTOR(OFormsCollection, NULL);
73 //------------------------------------------------------------------------------
74 OFormsCollection::OFormsCollection( const OFormsCollection& _cloneSource )
75 :FormsCollectionComponentBase( m_aMutex )
76 ,OInterfaceContainer( m_aMutex, _cloneSource )
77 ,OFormsCollection_BASE()
79 DBG_CTOR( OFormsCollection, NULL );
82 //------------------------------------------------------------------------------
83 OFormsCollection::~OFormsCollection()
85 DBG_DTOR(OFormsCollection, NULL);
86 if (!FormsCollectionComponentBase::rBHelper.bDisposed)
88 acquire();
89 dispose();
93 //------------------------------------------------------------------------------
94 Any SAL_CALL OFormsCollection::queryAggregation(const Type& _rType) throw(RuntimeException)
96 Any aReturn = OFormsCollection_BASE::queryInterface(_rType);
97 if (!aReturn.hasValue())
99 aReturn = OInterfaceContainer::queryInterface(_rType);
101 if (!aReturn.hasValue())
102 aReturn = FormsCollectionComponentBase::queryAggregation(_rType);
105 return aReturn;
108 //------------------------------------------------------------------------------
109 OUString SAL_CALL OFormsCollection::getImplementationName() throw(RuntimeException)
111 return OUString("com.sun.star.comp.forms.OFormsCollection");
114 //------------------------------------------------------------------------------
115 sal_Bool SAL_CALL OFormsCollection::supportsService( const OUString& _rServiceName ) throw(RuntimeException)
117 Sequence<OUString> aSupported = getSupportedServiceNames();
118 const OUString* pSupported = aSupported.getConstArray();
119 for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported)
120 if (pSupported->equals(_rServiceName))
121 return sal_True;
122 return sal_False;
125 //------------------------------------------------------------------------------
126 StringSequence SAL_CALL OFormsCollection::getSupportedServiceNames() throw(RuntimeException)
128 StringSequence aReturn(2);
130 aReturn.getArray()[0] = OUString("com.sun.star.form.Forms");
131 aReturn.getArray()[1] = OUString("com.sun.star.form.FormComponents");
133 return aReturn;
136 // XCloneable
137 //------------------------------------------------------------------------------
138 Reference< XCloneable > SAL_CALL OFormsCollection::createClone( ) throw (RuntimeException)
140 OFormsCollection* pClone = new OFormsCollection( *this );
141 osl_atomic_increment( &pClone->m_refCount );
142 pClone->clonedFrom( *this );
143 osl_atomic_decrement( &pClone->m_refCount );
144 return static_cast<OInterfaceContainer*>(pClone);
147 // OComponentHelper
148 //------------------------------------------------------------------------------
149 void OFormsCollection::disposing()
152 RTL_LOGFILE_CONTEXT( aLogger, "forms::OFormsCollection::disposing" );
153 OInterfaceContainer::disposing();
155 FormsCollectionComponentBase::disposing();
156 m_xParent = NULL;
159 //XChild
160 //------------------------------------------------------------------------------
161 void OFormsCollection::setParent(const InterfaceRef& Parent) throw( NoSupportException, RuntimeException )
163 ::osl::MutexGuard aGuard( m_aMutex );
164 m_xParent = Parent;
167 //------------------------------------------------------------------------------
168 InterfaceRef OFormsCollection::getParent() throw( RuntimeException )
170 return m_xParent;
173 //.........................................................................
174 } // namespace frm
175 //.........................................................................
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */