Bump version to 5.0-14
[LibreOffice.git] / xmlsecurity / source / framework / xmlencryptiontemplateimpl.cxx
blob9dace2f479a803b28672906d4d29cdbdc6a1336f
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 .
20 #include <sal/config.h>
21 #include <rtl/uuid.h>
22 #include "xmlencryptiontemplateimpl.hxx"
24 using namespace ::com::sun::star::uno ;
25 using ::com::sun::star::lang::XMultiServiceFactory ;
26 using ::com::sun::star::lang::XSingleServiceFactory ;
28 using ::com::sun::star::xml::wrapper::XXMLElementWrapper ;
29 using ::com::sun::star::xml::crypto::XXMLEncryptionTemplate ;
31 XMLEncryptionTemplateImpl :: XMLEncryptionTemplateImpl( const Reference< XMultiServiceFactory >& aFactory )
32 : m_xTemplate( NULL ),
33 m_xTarget( NULL ),
34 m_xServiceManager( aFactory ),
35 m_nStatus ( ::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN ) {
38 XMLEncryptionTemplateImpl :: ~XMLEncryptionTemplateImpl() {
41 /* XXMLEncryptionTemplate */
42 void SAL_CALL XMLEncryptionTemplateImpl :: setTemplate( const Reference< XXMLElementWrapper >& aTemplate )
43 throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException, std::exception)
45 m_xTemplate = aTemplate ;
48 /* XXMLEncryptionTemplate */
49 Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTemplate()
50 throw (com::sun::star::uno::RuntimeException, std::exception)
52 return m_xTemplate ;
55 /* XXMLEncryptionTemplate */
56 void SAL_CALL XMLEncryptionTemplateImpl :: setTarget( const Reference< XXMLElementWrapper >& aTarget )
57 throw( com::sun::star::lang::IllegalArgumentException, std::exception ) {
58 m_xTarget = aTarget ;
61 /* XXMLEncryptionTemplate */
62 Reference< XXMLElementWrapper > SAL_CALL XMLEncryptionTemplateImpl :: getTarget()
63 throw (com::sun::star::uno::RuntimeException, std::exception)
65 return m_xTarget ;
68 void SAL_CALL XMLEncryptionTemplateImpl::setStatus(
69 ::com::sun::star::xml::crypto::SecurityOperationStatus status )
70 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
72 m_nStatus = status;
75 ::com::sun::star::xml::crypto::SecurityOperationStatus SAL_CALL XMLEncryptionTemplateImpl::getStatus( )
76 throw (::com::sun::star::uno::RuntimeException, std::exception)
78 return m_nStatus;
81 /* XServiceInfo */
82 OUString SAL_CALL XMLEncryptionTemplateImpl :: getImplementationName() throw( RuntimeException, std::exception ) {
83 return impl_getImplementationName() ;
86 /* XServiceInfo */
87 sal_Bool SAL_CALL XMLEncryptionTemplateImpl :: supportsService( const OUString& serviceName) throw( RuntimeException, std::exception ) {
88 Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
89 const OUString* pArray = seqServiceNames.getConstArray() ;
90 for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
91 if( *( pArray + i ) == serviceName )
92 return sal_True ;
94 return sal_False ;
97 /* XServiceInfo */
98 Sequence< OUString > SAL_CALL XMLEncryptionTemplateImpl :: getSupportedServiceNames() throw( RuntimeException, std::exception ) {
99 return impl_getSupportedServiceNames() ;
102 //Helper for XServiceInfo
103 Sequence< OUString > XMLEncryptionTemplateImpl :: impl_getSupportedServiceNames() {
104 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ;
105 Sequence< OUString > seqServiceNames( 1 ) ;
106 seqServiceNames[0] = "com.sun.star.xml.crypto.XMLEncryptionTemplate";
107 return seqServiceNames;
110 OUString XMLEncryptionTemplateImpl :: impl_getImplementationName() throw( RuntimeException ) {
111 return OUString("com.sun.star.xml.security.framework.XMLEncryptionTemplateImpl") ;
114 //Helper for registry
115 Reference< XInterface > SAL_CALL XMLEncryptionTemplateImpl :: impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) throw( RuntimeException ) {
116 return Reference< XInterface >( *new XMLEncryptionTemplateImpl( aServiceManager ) ) ;
119 Reference< XSingleServiceFactory > XMLEncryptionTemplateImpl :: impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
120 return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */