xref: /trunk/main/xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
30 
31 #include "xmlelementwrapper_xmlsecimpl.hxx"
32 #include <cppuhelper/typeprovider.hxx>
33 
34 namespace cssu = com::sun::star::uno;
35 namespace cssl = com::sun::star::lang;
36 
37 #define SERVICE_NAME "com.sun.star.xml.wrapper.XMLElementWrapper"
38 #define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl"
39 
40 XMLElementWrapper_XmlSecImpl::XMLElementWrapper_XmlSecImpl(const xmlNodePtr pNode)
41     : m_pElement( pNode )
42 {
43 }
44 
45 /* XXMLElementWrapper */
46 
47 
48 /* XUnoTunnel */
49 cssu::Sequence< sal_Int8 > XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId( void )
50     throw (cssu::RuntimeException)
51 {
52     static ::cppu::OImplementationId* pId = 0;
53     if (! pId)
54     {
55         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
56         if (! pId)
57         {
58             static ::cppu::OImplementationId aId;
59             pId = &aId;
60         }
61     }
62     return pId->getImplementationId();
63 }
64 
65 sal_Int64 SAL_CALL XMLElementWrapper_XmlSecImpl::getSomething( const cssu::Sequence< sal_Int8 >& aIdentifier )
66     throw (cssu::RuntimeException)
67 {
68     if (aIdentifier.getLength() == 16 &&
69         0 == rtl_compareMemory(
70             getUnoTunnelImplementationId().getConstArray(),
71             aIdentifier.getConstArray(),
72             16 ))
73     {
74         return reinterpret_cast < sal_Int64 > ( this );
75     }
76     else
77     {
78         return 0;
79     }
80 }
81 
82 
83 rtl::OUString XMLElementWrapper_XmlSecImpl_getImplementationName ()
84     throw (cssu::RuntimeException)
85 {
86     return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) );
87 }
88 
89 sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl_supportsService( const rtl::OUString& ServiceName )
90     throw (cssu::RuntimeException)
91 {
92     return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ));
93 }
94 
95 cssu::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl_getSupportedServiceNames(  )
96     throw (cssu::RuntimeException)
97 {
98     cssu::Sequence < rtl::OUString > aRet(1);
99     rtl::OUString* pArray = aRet.getArray();
100     pArray[0] =  rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
101     return aRet;
102 }
103 #undef SERVICE_NAME
104 
105 cssu::Reference< cssu::XInterface > SAL_CALL
106     XMLElementWrapper_XmlSecImpl_createInstance(
107         const cssu::Reference< cssl::XMultiServiceFactory > &)
108     throw( cssu::Exception )
109 {
110     return (cppu::OWeakObject*) new XMLElementWrapper_XmlSecImpl(NULL);
111 }
112 
113 /* XServiceInfo */
114 rtl::OUString SAL_CALL XMLElementWrapper_XmlSecImpl::getImplementationName(  )
115     throw (cssu::RuntimeException)
116 {
117     return XMLElementWrapper_XmlSecImpl_getImplementationName();
118 }
119 sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl::supportsService( const rtl::OUString& rServiceName )
120     throw (cssu::RuntimeException)
121 {
122     return XMLElementWrapper_XmlSecImpl_supportsService( rServiceName );
123 }
124 cssu::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl::getSupportedServiceNames(  )
125     throw (cssu::RuntimeException)
126 {
127     return XMLElementWrapper_XmlSecImpl_getSupportedServiceNames();
128 }
129 
130 xmlNodePtr XMLElementWrapper_XmlSecImpl::getNativeElement(  ) const
131 /****** XMLElementWrapper_XmlSecImpl/getNativeElement *************************
132  *
133  *   NAME
134  *  getNativeElement -- Retrieves the libxml2 node wrapped by this object
135  *
136  *   SYNOPSIS
137  *  pNode = getNativeElement();
138  *
139  *   FUNCTION
140  *  see NAME
141  *
142  *   INPUTS
143  *  empty
144  *
145  *   RESULT
146  *  pNode - the libxml2 node wrapped by this object
147  *
148  *   HISTORY
149  *  05.01.2004 -    implemented
150  *
151  *   AUTHOR
152  *  Michael Mi
153  *  Email: michael.mi@sun.com
154  ******************************************************************************/
155 {
156     return m_pElement;
157 }
158 
159 void XMLElementWrapper_XmlSecImpl::setNativeElement(const xmlNodePtr pNode)
160 /****** XMLElementWrapper_XmlSecImpl/setNativeElement *************************
161  *
162  *   NAME
163  *  setNativeElement -- Configures the libxml2 node wrapped by this object
164  *
165  *   SYNOPSIS
166  *  setNativeElement( pNode );
167  *
168  *   FUNCTION
169  *  see NAME
170  *
171  *   INPUTS
172  *  pNode - the new libxml2 node to be wrapped by this object
173  *
174  *   RESULT
175  *  empty
176  *
177  *   HISTORY
178  *  05.01.2004 -    implemented
179  *
180  *   AUTHOR
181  *  Michael Mi
182  *  Email: michael.mi@sun.com
183  ******************************************************************************/
184 {
185     m_pElement = pNode;
186 }
187 
188