1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include "FormsCollection.hxx"
21 #include <services.hxx>
22 #include <comphelper/sequence.hxx>
23 #include <cppuhelper/supportsservice.hxx>
24 #include <sal/log.hxx>
25 #include <com/sun/star/form/XForm.hpp>
26 
27 using namespace frm;
28 using namespace ::com::sun::star::lang;
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::form;
31 using namespace ::com::sun::star::container;
32 using namespace ::com::sun::star::util;
33 
getServiceName()34 OUString SAL_CALL OFormsCollection::getServiceName()
35 {
36     return "com.sun.star.form.Forms";
37 }
38 
getImplementationId()39 Sequence< sal_Int8 > SAL_CALL OFormsCollection::getImplementationId(  )
40 {
41     return css::uno::Sequence<sal_Int8>();
42 }
43 
getTypes()44 Sequence<Type> SAL_CALL OFormsCollection::getTypes()
45 {
46     return concatSequences(OInterfaceContainer::getTypes(), ::cppu::OComponentHelper::getTypes(), OFormsCollection_BASE::getTypes());
47 }
48 
OFormsCollection(const Reference<XComponentContext> & _rxFactory)49 OFormsCollection::OFormsCollection(const Reference<XComponentContext>& _rxFactory)
50     : ::cppu::OComponentHelper( m_aMutex )
51     ,OInterfaceContainer( _rxFactory, m_aMutex, cppu::UnoType<XForm>::get() )
52     ,OFormsCollection_BASE()
53 {
54 }
55 
OFormsCollection(const OFormsCollection & _cloneSource)56 OFormsCollection::OFormsCollection( const OFormsCollection& _cloneSource )
57     : ::cppu::OComponentHelper( m_aMutex )
58     ,OInterfaceContainer( m_aMutex, _cloneSource )
59     ,OFormsCollection_BASE()
60 {
61 }
62 
~OFormsCollection()63 OFormsCollection::~OFormsCollection()
64 {
65     if (!::cppu::OComponentHelper::rBHelper.bDisposed)
66     {
67         acquire();
68         dispose();
69     }
70 }
71 
queryAggregation(const Type & _rType)72 Any SAL_CALL OFormsCollection::queryAggregation(const Type& _rType)
73 {
74     Any aReturn = OFormsCollection_BASE::queryInterface(_rType);
75     if (!aReturn.hasValue())
76     {
77         aReturn = OInterfaceContainer::queryInterface(_rType);
78 
79         if (!aReturn.hasValue())
80             aReturn = ::cppu::OComponentHelper::queryAggregation(_rType);
81     }
82 
83     return aReturn;
84 }
85 
getImplementationName()86 OUString SAL_CALL OFormsCollection::getImplementationName()
87 {
88     return "com.sun.star.form.OFormsCollection";
89 }
90 
supportsService(const OUString & _rServiceName)91 sal_Bool SAL_CALL OFormsCollection::supportsService( const OUString& _rServiceName )
92 {
93     return cppu::supportsService(this, _rServiceName);
94 }
95 
getSupportedServiceNames()96 css::uno::Sequence<OUString> SAL_CALL OFormsCollection::getSupportedServiceNames()
97 {
98     return { "com.sun.star.form.Forms", "com.sun.star.form.FormComponents" };
99 }
100 
101 // XCloneable
createClone()102 Reference< XCloneable > SAL_CALL OFormsCollection::createClone(  )
103 {
104     OFormsCollection* pClone = new OFormsCollection( *this );
105     osl_atomic_increment( &pClone->m_refCount );
106     pClone->clonedFrom( *this );
107     osl_atomic_decrement( &pClone->m_refCount );
108     return static_cast<OInterfaceContainer*>(pClone);
109 }
110 
111 // OComponentHelper
112 
disposing()113 void OFormsCollection::disposing()
114 {
115     {
116         SAL_INFO( "forms.component", "forms::OFormsCollection::disposing" );
117         OInterfaceContainer::disposing();
118     }
119     ::cppu::OComponentHelper::disposing();
120     m_xParent = nullptr;
121 }
122 
123 //XChild
124 
setParent(const css::uno::Reference<css::uno::XInterface> & Parent)125 void OFormsCollection::setParent(const css::uno::Reference<css::uno::XInterface>& Parent)
126 {
127     ::osl::MutexGuard aGuard( m_aMutex );
128     m_xParent = Parent;
129 }
130 
getParent()131 css::uno::Reference<css::uno::XInterface>  OFormsCollection::getParent()
132 {
133     return m_xParent;
134 }
135 
136 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_form_OFormsCollection_get_implementation(css::uno::XComponentContext * context,css::uno::Sequence<css::uno::Any> const &)137 com_sun_star_form_OFormsCollection_get_implementation(css::uno::XComponentContext* context,
138         css::uno::Sequence<css::uno::Any> const &)
139 {
140     return cppu::acquire(new frm::OFormsCollection(context));
141 }
142 
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
144