Line data Source code
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 <string.h>
21 :
22 : #include "xmlelementwrapper_xmlsecimpl.hxx"
23 : #include <cppuhelper/typeprovider.hxx>
24 :
25 : namespace cssu = com::sun::star::uno;
26 :
27 : #define SERVICE_NAME "com.sun.star.xml.wrapper.XMLElementWrapper"
28 : #define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl"
29 :
30 0 : XMLElementWrapper_XmlSecImpl::XMLElementWrapper_XmlSecImpl(const xmlNodePtr pNode)
31 0 : : m_pElement( pNode )
32 : {
33 0 : }
34 :
35 : /* XXMLElementWrapper */
36 :
37 :
38 : /* XUnoTunnel */
39 0 : cssu::Sequence< sal_Int8 > XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId( void )
40 : throw (cssu::RuntimeException)
41 : {
42 : static ::cppu::OImplementationId* pId = 0;
43 0 : if (! pId)
44 : {
45 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
46 0 : if (! pId)
47 : {
48 0 : static ::cppu::OImplementationId aId;
49 0 : pId = &aId;
50 0 : }
51 : }
52 0 : return pId->getImplementationId();
53 : }
54 :
55 0 : sal_Int64 SAL_CALL XMLElementWrapper_XmlSecImpl::getSomething( const cssu::Sequence< sal_Int8 >& aIdentifier )
56 : throw (cssu::RuntimeException)
57 : {
58 0 : if (aIdentifier.getLength() == 16 &&
59 : 0 == memcmp(
60 0 : getUnoTunnelImplementationId().getConstArray(),
61 0 : aIdentifier.getConstArray(),
62 0 : 16 ))
63 : {
64 0 : return reinterpret_cast < sal_Int64 > ( this );
65 : }
66 : else
67 : {
68 0 : return 0;
69 : }
70 : }
71 :
72 :
73 2 : rtl::OUString XMLElementWrapper_XmlSecImpl_getImplementationName ()
74 : throw (cssu::RuntimeException)
75 : {
76 2 : return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) );
77 : }
78 :
79 0 : sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl_supportsService( const rtl::OUString& ServiceName )
80 : throw (cssu::RuntimeException)
81 : {
82 0 : return ServiceName == SERVICE_NAME;
83 : }
84 :
85 0 : cssu::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl_getSupportedServiceNames( )
86 : throw (cssu::RuntimeException)
87 : {
88 0 : cssu::Sequence < rtl::OUString > aRet(1);
89 0 : rtl::OUString* pArray = aRet.getArray();
90 0 : pArray[0] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
91 0 : return aRet;
92 : }
93 : #undef SERVICE_NAME
94 :
95 : cssu::Reference< cssu::XInterface > SAL_CALL
96 0 : XMLElementWrapper_XmlSecImpl_createInstance(
97 : const cssu::Reference< cssu::XComponentContext > &)
98 : throw( cssu::Exception )
99 : {
100 0 : return (cppu::OWeakObject*) new XMLElementWrapper_XmlSecImpl(NULL);
101 : }
102 :
103 : /* XServiceInfo */
104 0 : rtl::OUString SAL_CALL XMLElementWrapper_XmlSecImpl::getImplementationName( )
105 : throw (cssu::RuntimeException)
106 : {
107 0 : return XMLElementWrapper_XmlSecImpl_getImplementationName();
108 : }
109 0 : sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl::supportsService( const rtl::OUString& rServiceName )
110 : throw (cssu::RuntimeException)
111 : {
112 0 : return XMLElementWrapper_XmlSecImpl_supportsService( rServiceName );
113 : }
114 0 : cssu::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl::getSupportedServiceNames( )
115 : throw (cssu::RuntimeException)
116 : {
117 0 : return XMLElementWrapper_XmlSecImpl_getSupportedServiceNames();
118 : }
119 :
120 0 : xmlNodePtr XMLElementWrapper_XmlSecImpl::getNativeElement( ) const
121 : /****** XMLElementWrapper_XmlSecImpl/getNativeElement *************************
122 : *
123 : * NAME
124 : * getNativeElement -- Retrieves the libxml2 node wrapped by this object
125 : *
126 : * SYNOPSIS
127 : * pNode = getNativeElement();
128 : *
129 : * FUNCTION
130 : * see NAME
131 : *
132 : * INPUTS
133 : * empty
134 : *
135 : * RESULT
136 : * pNode - the libxml2 node wrapped by this object
137 : *
138 : * AUTHOR
139 : * Michael Mi
140 : * Email: michael.mi@sun.com
141 : ******************************************************************************/
142 : {
143 0 : return m_pElement;
144 : }
145 :
146 0 : void XMLElementWrapper_XmlSecImpl::setNativeElement(const xmlNodePtr pNode)
147 : /****** XMLElementWrapper_XmlSecImpl/setNativeElement *************************
148 : *
149 : * NAME
150 : * setNativeElement -- Configures the libxml2 node wrapped by this object
151 : *
152 : * SYNOPSIS
153 : * setNativeElement( pNode );
154 : *
155 : * FUNCTION
156 : * see NAME
157 : *
158 : * INPUTS
159 : * pNode - the new libxml2 node to be wrapped by this object
160 : *
161 : * RESULT
162 : * empty
163 : *
164 : * AUTHOR
165 : * Michael Mi
166 : * Email: michael.mi@sun.com
167 : ******************************************************************************/
168 : {
169 0 : m_pElement = pNode;
170 0 : }
171 :
172 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|