Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <classes/actiontriggercontainer.hxx>
30 : : #include <cppuhelper/typeprovider.hxx>
31 : :
32 : : #include <classes/actiontriggerpropertyset.hxx>
33 : : #include <classes/actiontriggerseparatorpropertyset.hxx>
34 : :
35 : : using namespace cppu;
36 : : using namespace com::sun::star::uno;
37 : : using namespace com::sun::star::lang;
38 : : using namespace com::sun::star::container;
39 : :
40 : : namespace framework
41 : : {
42 : :
43 : 0 : ActionTriggerContainer::ActionTriggerContainer( const Reference< XMultiServiceFactory >& rServiceManager ) :
44 : 0 : PropertySetContainer( rServiceManager )
45 : : {
46 : 0 : }
47 : :
48 : :
49 : 0 : ActionTriggerContainer::~ActionTriggerContainer()
50 : : {
51 [ # # ]: 0 : }
52 : :
53 : : // XInterface
54 : 0 : Any SAL_CALL ActionTriggerContainer::queryInterface( const Type& aType )
55 : : throw ( RuntimeException )
56 : : {
57 : : Any a = ::cppu::queryInterface(
58 : : aType ,
59 : : (static_cast< XMultiServiceFactory* >(this)),
60 [ # # ]: 0 : (static_cast< XServiceInfo* >(this)));
61 : :
62 [ # # ]: 0 : if( a.hasValue() )
63 : : {
64 : 0 : return a;
65 : : }
66 : :
67 [ # # ]: 0 : return PropertySetContainer::queryInterface( aType );
68 : : }
69 : :
70 : 0 : void ActionTriggerContainer::acquire() throw()
71 : : {
72 : 0 : PropertySetContainer::acquire();
73 : 0 : }
74 : :
75 : 0 : void ActionTriggerContainer::release() throw()
76 : : {
77 : 0 : PropertySetContainer::release();
78 : 0 : }
79 : :
80 : :
81 : : // XMultiServiceFactory
82 : 0 : Reference< XInterface > SAL_CALL ActionTriggerContainer::createInstance( const ::rtl::OUString& aServiceSpecifier )
83 : : throw ( ::com::sun::star::uno::Exception, RuntimeException)
84 : : {
85 [ # # ]: 0 : if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGER ))
86 [ # # ][ # # ]: 0 : return (OWeakObject *)( new ActionTriggerPropertySet( m_xServiceManager ));
87 [ # # ]: 0 : else if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGERCONTAINER ))
88 [ # # ][ # # ]: 0 : return (OWeakObject *)( new ActionTriggerContainer( m_xServiceManager ));
89 [ # # ]: 0 : else if ( aServiceSpecifier.equalsAscii( SERVICENAME_ACTIONTRIGGERSEPARATOR ))
90 [ # # ][ # # ]: 0 : return (OWeakObject *)( new ActionTriggerSeparatorPropertySet( m_xServiceManager ));
91 : : else
92 [ # # ][ # # ]: 0 : throw com::sun::star::uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unknown service specifier!" )), (OWeakObject *)this );
[ # # ]
93 : : }
94 : :
95 : :
96 : 0 : Reference< XInterface > SAL_CALL ActionTriggerContainer::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const Sequence< Any >& /*Arguments*/ )
97 : : throw ( Exception, RuntimeException)
98 : : {
99 : 0 : return createInstance( ServiceSpecifier );
100 : : }
101 : :
102 : :
103 : 0 : Sequence< ::rtl::OUString > SAL_CALL ActionTriggerContainer::getAvailableServiceNames()
104 : : throw ( RuntimeException )
105 : : {
106 : 0 : Sequence< ::rtl::OUString > aSeq( 3 );
107 : :
108 [ # # ][ # # ]: 0 : aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGER ));
109 [ # # ][ # # ]: 0 : aSeq[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERCONTAINER ));
110 [ # # ][ # # ]: 0 : aSeq[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERSEPARATOR ));
111 : :
112 : 0 : return aSeq;
113 : : }
114 : :
115 : : // XServiceInfo
116 : 0 : ::rtl::OUString SAL_CALL ActionTriggerContainer::getImplementationName()
117 : : throw ( RuntimeException )
118 : : {
119 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATIONNAME_ACTIONTRIGGERCONTAINER ));
120 : : }
121 : :
122 : 0 : sal_Bool SAL_CALL ActionTriggerContainer::supportsService( const ::rtl::OUString& ServiceName )
123 : : throw ( RuntimeException )
124 : : {
125 [ # # ]: 0 : if ( ServiceName.equalsAscii( SERVICENAME_ACTIONTRIGGERCONTAINER ))
126 : 0 : return sal_True;
127 : :
128 : 0 : return sal_False;
129 : : }
130 : :
131 : 0 : Sequence< ::rtl::OUString > SAL_CALL ActionTriggerContainer::getSupportedServiceNames()
132 : : throw ( RuntimeException )
133 : : {
134 : 0 : Sequence< ::rtl::OUString > seqServiceNames( 1 );
135 : :
136 [ # # ][ # # ]: 0 : seqServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICENAME_ACTIONTRIGGERCONTAINER ));
137 : 0 : return seqServiceNames;
138 : : }
139 : :
140 : : // XTypeProvider
141 : 0 : Sequence< Type > SAL_CALL ActionTriggerContainer::getTypes() throw ( RuntimeException )
142 : : {
143 : : // Optimize this method !
144 : : // We initialize a static variable only one time. And we don't must use a mutex at every call!
145 : : // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
146 : : static ::cppu::OTypeCollection* pTypeCollection = NULL ;
147 : :
148 [ # # ]: 0 : if ( pTypeCollection == NULL )
149 : : {
150 : : // Ready for multithreading; get global mutex for first call of this method only! see before
151 [ # # ][ # # ]: 0 : osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
152 : :
153 : : // Control these pointer again ... it can be, that another instance will be faster then these!
154 [ # # ]: 0 : if ( pTypeCollection == NULL )
155 : : {
156 : : // Create a static typecollection ...
157 : : static ::cppu::OTypeCollection aTypeCollection(
158 [ # # ]: 0 : ::getCppuType(( const Reference< XMultiServiceFactory >*)NULL ) ,
159 [ # # ]: 0 : ::getCppuType(( const Reference< XIndexContainer >*)NULL ) ,
160 [ # # ]: 0 : ::getCppuType(( const Reference< XIndexAccess >*)NULL ) ,
161 [ # # ]: 0 : ::getCppuType(( const Reference< XIndexReplace >*)NULL ) ,
162 [ # # ]: 0 : ::getCppuType(( const Reference< XServiceInfo >*)NULL ) ,
163 [ # # ][ # # ]: 0 : ::getCppuType(( const Reference< XTypeProvider >*)NULL ) ) ;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
164 : :
165 : : // ... and set his address to static pointer!
166 : 0 : pTypeCollection = &aTypeCollection ;
167 [ # # ]: 0 : }
168 : : }
169 : :
170 : 0 : return pTypeCollection->getTypes() ;
171 : : }
172 : :
173 : 0 : Sequence< sal_Int8 > SAL_CALL ActionTriggerContainer::getImplementationId() throw ( RuntimeException )
174 : : {
175 : : // Create one Id for all instances of this class.
176 : : // Use ethernet address to do this! (sal_True)
177 : :
178 : : // Optimize this method
179 : : // We initialize a static variable only one time. And we don't must use a mutex at every call!
180 : : // For the first call; pID is NULL - for the second call pID is different from NULL!
181 : : static ::cppu::OImplementationId* pID = NULL ;
182 : :
183 [ # # ]: 0 : if ( pID == NULL )
184 : : {
185 : : // Ready for multithreading; get global mutex for first call of this method only! see before
186 [ # # ][ # # ]: 0 : osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
187 : :
188 : : // Control these pointer again ... it can be, that another instance will be faster then these!
189 [ # # ]: 0 : if ( pID == NULL )
190 : : {
191 : : // Create a new static ID ...
192 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId aID( sal_False ) ;
193 : : // ... and set his address to static pointer!
194 : 0 : pID = &aID ;
195 [ # # ]: 0 : }
196 : : }
197 : :
198 : 0 : return pID->getImplementationId() ;
199 : : }
200 : :
201 : : }
202 : :
203 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|