1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_xmlsecurity.hxx" 26 27 #include "xmlelementwrapper_xmlsecimpl.hxx" 28 #include <cppuhelper/typeprovider.hxx> 29 30 namespace cssu = com::sun::star::uno; 31 namespace cssl = com::sun::star::lang; 32 33 #define SERVICE_NAME "com.sun.star.xml.wrapper.XMLElementWrapper" 34 #define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl" 35 XMLElementWrapper_XmlSecImpl(const xmlNodePtr pNode)36XMLElementWrapper_XmlSecImpl::XMLElementWrapper_XmlSecImpl(const xmlNodePtr pNode) 37 : m_pElement( pNode ) 38 { 39 } 40 41 /* XXMLElementWrapper */ 42 43 44 /* XUnoTunnel */ getUnoTunnelImplementationId(void)45cssu::Sequence< sal_Int8 > XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId( void ) 46 { 47 static ::cppu::OImplementationId* pId = 0; 48 if (! pId) 49 { 50 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 51 if (! pId) 52 { 53 static ::cppu::OImplementationId aId; 54 pId = &aId; 55 } 56 } 57 return pId->getImplementationId(); 58 } 59 getSomething(const cssu::Sequence<sal_Int8> & aIdentifier)60sal_Int64 SAL_CALL XMLElementWrapper_XmlSecImpl::getSomething( const cssu::Sequence< sal_Int8 >& aIdentifier ) 61 { 62 if (aIdentifier.getLength() == 16 && 63 0 == rtl_compareMemory( 64 getUnoTunnelImplementationId().getConstArray(), 65 aIdentifier.getConstArray(), 66 16 )) 67 { 68 return reinterpret_cast < sal_Int64 > ( this ); 69 } 70 else 71 { 72 return 0; 73 } 74 } 75 76 XMLElementWrapper_XmlSecImpl_getImplementationName()77rtl::OUString XMLElementWrapper_XmlSecImpl_getImplementationName () 78 { 79 return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) ); 80 } 81 XMLElementWrapper_XmlSecImpl_supportsService(const rtl::OUString & ServiceName)82sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl_supportsService( const rtl::OUString& ServiceName ) 83 { 84 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME )); 85 } 86 XMLElementWrapper_XmlSecImpl_getSupportedServiceNames()87cssu::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl_getSupportedServiceNames( ) 88 { 89 cssu::Sequence < rtl::OUString > aRet(1); 90 rtl::OUString* pArray = aRet.getArray(); 91 pArray[0] = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); 92 return aRet; 93 } 94 #undef SERVICE_NAME 95 96 cssu::Reference< cssu::XInterface > SAL_CALL XMLElementWrapper_XmlSecImpl_createInstance(const cssu::Reference<cssl::XMultiServiceFactory> &)97 XMLElementWrapper_XmlSecImpl_createInstance( 98 const cssu::Reference< cssl::XMultiServiceFactory > &) 99 { 100 return (cppu::OWeakObject*) new XMLElementWrapper_XmlSecImpl(NULL); 101 } 102 103 /* XServiceInfo */ getImplementationName()104rtl::OUString SAL_CALL XMLElementWrapper_XmlSecImpl::getImplementationName( ) 105 { 106 return XMLElementWrapper_XmlSecImpl_getImplementationName(); 107 } supportsService(const rtl::OUString & rServiceName)108sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl::supportsService( const rtl::OUString& rServiceName ) 109 { 110 return XMLElementWrapper_XmlSecImpl_supportsService( rServiceName ); 111 } getSupportedServiceNames()112cssu::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl::getSupportedServiceNames( ) 113 { 114 return XMLElementWrapper_XmlSecImpl_getSupportedServiceNames(); 115 } 116 getNativeElement() const117xmlNodePtr XMLElementWrapper_XmlSecImpl::getNativeElement( ) const 118 /****** XMLElementWrapper_XmlSecImpl/getNativeElement ************************* 119 * 120 * NAME 121 * getNativeElement -- Retrieves the libxml2 node wrapped by this object 122 * 123 * SYNOPSIS 124 * pNode = getNativeElement(); 125 * 126 * FUNCTION 127 * see NAME 128 * 129 * INPUTS 130 * empty 131 * 132 * RESULT 133 * pNode - the libxml2 node wrapped by this object 134 * 135 * HISTORY 136 * 05.01.2004 - implemented 137 * 138 * AUTHOR 139 * Michael Mi 140 * Email: michael.mi@sun.com 141 ******************************************************************************/ 142 { 143 return m_pElement; 144 } 145 setNativeElement(const xmlNodePtr pNode)146void 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 * HISTORY 165 * 05.01.2004 - implemented 166 * 167 * AUTHOR 168 * Michael Mi 169 * Email: michael.mi@sun.com 170 ******************************************************************************/ 171 { 172 m_pElement = pNode; 173 } 174