summaryrefslogtreecommitdiff
path: root/stoc/test
diff options
context:
space:
mode:
Diffstat (limited to 'stoc/test')
-rw-r--r--stoc/test/excomp/example/ExampleComponent1.idl43
-rw-r--r--stoc/test/excomp/example/ExampleComponent2.idl43
-rw-r--r--stoc/test/excomp/example/XTest.idl49
-rw-r--r--stoc/test/excomp/excomp.cxx136
-rw-r--r--stoc/test/excomp/excomp1.cxx215
-rw-r--r--stoc/test/excomp/excomp1.xml33
-rw-r--r--stoc/test/excomp/excomp2.cxx286
-rw-r--r--stoc/test/excomp/excomp2.xml33
-rw-r--r--stoc/test/excomp/exports.dxp3
-rw-r--r--stoc/test/excomp/makefile.mk130
-rw-r--r--stoc/test/javavm/jvm_interaction/interactionhandler.cxx205
-rw-r--r--stoc/test/javavm/jvm_interaction/makefile.mk81
-rw-r--r--stoc/test/javavm/makefile.mk73
-rw-r--r--stoc/test/javavm/testapplet/TestApplet.html19
-rw-r--r--stoc/test/javavm/testapplet/TestApplet.java58
-rw-r--r--stoc/test/javavm/testapplet/makefile.mk55
-rw-r--r--stoc/test/javavm/testcomponent/TestComponent.java128
-rw-r--r--stoc/test/javavm/testcomponent/makefile.mk58
-rw-r--r--stoc/test/javavm/testcomponent/manifest1
-rw-r--r--stoc/test/javavm/testjavavm.cxx202
-rw-r--r--stoc/test/javavm/testjavavm.java39
-rw-r--r--stoc/test/language_binding.idl177
-rw-r--r--stoc/test/makefile.mk223
-rw-r--r--stoc/test/mergekeys_.cxx31
-rw-r--r--stoc/test/registry_tdprovider/makefile.mk63
-rw-r--r--stoc/test/registry_tdprovider/readme.txt4
-rw-r--r--stoc/test/registry_tdprovider/testregistrytdprovider.cxx943
-rw-r--r--stoc/test/registry_tdprovider/types.idl112
-rw-r--r--stoc/test/security/makefile.mk59
-rw-r--r--stoc/test/security/test_security.cxx523
-rw-r--r--stoc/test/security/test_security.ini6
-rw-r--r--stoc/test/security/test_security.policy37
-rw-r--r--stoc/test/security/test_security_singleuser.ini6
-rw-r--r--stoc/test/tdmanager/makefile.mk75
-rw-r--r--stoc/test/tdmanager/readme.txt4
-rw-r--r--stoc/test/tdmanager/testtdmanager.cxx374
-rw-r--r--stoc/test/tdmanager/types.idl45
-rw-r--r--stoc/test/tdmanager/types2_incomp.idl38
-rw-r--r--stoc/test/tdmanager/types3_incomp.idl33
-rw-r--r--stoc/test/tdmanager/types4_incomp.idl42
-rw-r--r--stoc/test/tdmanager/types5.idl45
-rw-r--r--stoc/test/tdmanager/types5_incomp.idl43
-rw-r--r--stoc/test/tdmanager/types6_incomp.idl43
-rw-r--r--stoc/test/testconv.cxx705
-rw-r--r--stoc/test/testcorefl.cxx412
-rw-r--r--stoc/test/testcorefl.idl102
-rw-r--r--stoc/test/testiadapter.cxx1069
-rw-r--r--stoc/test/testintrosp.cxx1617
-rw-r--r--stoc/test/testintrosp.idl220
-rw-r--r--stoc/test/testloader.cxx137
-rw-r--r--stoc/test/testproxyfac.cxx379
-rw-r--r--stoc/test/testregistry.cxx696
-rw-r--r--stoc/test/testsmgr.cxx105
-rw-r--r--stoc/test/testsmgr2.cxx118
-rw-r--r--stoc/test/testsmgr_cpnt.cxx472
-rw-r--r--stoc/test/testsmgr_cpnt.map9
-rw-r--r--stoc/test/uriproc/makefile.mk83
-rw-r--r--stoc/test/uriproc/test_uriproc.cxx1004
-rw-r--r--stoc/test/uriproc/version.map34
59 files changed, 11978 insertions, 0 deletions
diff --git a/stoc/test/excomp/example/ExampleComponent1.idl b/stoc/test/excomp/example/ExampleComponent1.idl
new file mode 100644
index 000000000000..6ebf2a7e4eb7
--- /dev/null
+++ b/stoc/test/excomp/example/ExampleComponent1.idl
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _EXCOMP_EXAMPLECOMPONENT1_IDL_
+#define _EXCOMP_EXAMPLECOMPONENT1_IDL_
+
+#include <example/XTest.idl>
+
+module example
+{
+
+service ExampleComponent1
+{
+ interface XTest;
+};
+
+}; // test
+
+
+#endif
diff --git a/stoc/test/excomp/example/ExampleComponent2.idl b/stoc/test/excomp/example/ExampleComponent2.idl
new file mode 100644
index 000000000000..ff2b3b28c5d0
--- /dev/null
+++ b/stoc/test/excomp/example/ExampleComponent2.idl
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _EXCOMP_EXAMPLECOMPONENT2_IDL_
+#define _EXCOMP_EXAMPLECOMPONENT2_IDL_
+
+#include <example/XTest.idl>
+
+module example
+{
+
+service ExampleComponent2
+{
+ interface XTest;
+};
+
+}; // test
+
+
+#endif
diff --git a/stoc/test/excomp/example/XTest.idl b/stoc/test/excomp/example/XTest.idl
new file mode 100644
index 000000000000..8bf578b10d29
--- /dev/null
+++ b/stoc/test/excomp/example/XTest.idl
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _EXCOMP_XTEST_IDL_
+#define _EXCOMP_XTEST_IDL_
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module example
+{
+/**
+ * Simple test interface.
+ *
+ * @author Juergen Schmidt
+ */
+interface XTest : com::sun::star::uno::XInterface
+{
+ /**
+ * in parameter test, tests by calls reference also (complex types)
+ */
+ string getMessage( );
+};
+
+}; // test
+
+#endif
diff --git a/stoc/test/excomp/excomp.cxx b/stoc/test/excomp/excomp.cxx
new file mode 100644
index 000000000000..bdfa520a6e39
--- /dev/null
+++ b/stoc/test/excomp/excomp.cxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sal/main.h>
+#include <osl/diagnose.h>
+#include <osl/process.h>
+
+#include <example/XTest.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::lang;
+using namespace example;
+using namespace cppu;
+using namespace rtl;
+
+#if OSL_DEBUG_LEVEL > 0
+#define TEST_ENSHURE(c, m) OSL_ENSURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) OSL_VERIFY(c)
+#endif
+
+OUString getExePath()
+{
+ OUString exe;
+
+ OSL_VERIFY(osl_getExecutableFile( &exe.pData) == osl_Process_E_None);
+
+#if defined(WIN32) || defined(__OS2__) || defined(WNT)
+ exe = exe.copy(0, exe.getLength() - 10);
+#else
+ exe = exe.copy(0, exe.getLength() - 6);
+#endif
+ return exe;
+}
+
+SAL_IMPLEMENT_MAIN()
+{
+#ifdef UNX
+ OUString compName1(RTL_CONSTASCII_USTRINGPARAM("libexcomp1.so"));
+ OUString compName2(RTL_CONSTASCII_USTRINGPARAM("libexcomp2.so"));
+#else
+ OUString compName1(RTL_CONSTASCII_USTRINGPARAM("excomp1"));
+ OUString compName2(RTL_CONSTASCII_USTRINGPARAM("excomp2"));
+#endif
+
+ OUString exePath( getExePath() );
+ OUString excompRdb(exePath);
+
+ excompRdb += OUString::createFromAscii("excomp.rdb");
+
+ Reference< XMultiServiceFactory > xSMgr = ::cppu::createRegistryServiceFactory( excompRdb );
+ TEST_ENSHURE( xSMgr.is(), "excomp error 0" );
+
+ typelib_TypeDescription* pTypeDesc = NULL;
+ OUString sType = OUString::createFromAscii("com.sun.star.text.XTextDocument");
+ typelib_typedescription_getByName( &pTypeDesc, sType.pData);
+// typelib_InterfaceTypeDescription* pInterDesc = (typelib_InterfaceTypeDescription*)pTypeDesc;
+
+ Reference< XInterface > xIFace = xSMgr->createInstance(OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration"));
+ Reference< XImplementationRegistration > xImpReg( xIFace, UNO_QUERY);
+ TEST_ENSHURE( xImpReg.is(), "excomp error 1" );
+ try
+ {
+ xImpReg->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ compName1,
+ Reference< XSimpleRegistry >() );
+ xImpReg->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ compName2,
+ Reference< XSimpleRegistry >() );
+ }
+ catch( CannotRegisterImplementationException& e)
+ {
+ TEST_ENSHURE( e.Message.getLength(), OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr() );
+ }
+
+ Reference< XTest > xTest1( xSMgr->createInstance(OUString::createFromAscii("example.ExampleComponent1")),
+ UNO_QUERY);
+ TEST_ENSHURE( xTest1.is(), "excomp error 2" );
+ Reference< XTest > xTest2( xSMgr->createInstance(OUString::createFromAscii("example.ExampleComponent2")),
+ UNO_QUERY);
+ TEST_ENSHURE( xTest2.is(), "excomp error 3" );
+
+ OUString m1 = xTest1->getMessage();
+ OUString m2 = xTest2->getMessage();
+
+ fprintf(stdout, "ExampleComponent1, Message = \"%s\"\n", OUStringToOString(m1, RTL_TEXTENCODING_ASCII_US).getStr());
+ fprintf(stdout, "ExampleComponent2, Message = \"%s\"\n", OUStringToOString(m2, RTL_TEXTENCODING_ASCII_US).getStr());
+
+ xImpReg->revokeImplementation(compName1, Reference< XSimpleRegistry >() );
+ xImpReg->revokeImplementation(compName2, Reference< XSimpleRegistry >() );
+
+ Reference< XComponent >( xSMgr, UNO_QUERY )->dispose();
+
+ return(0);
+}
+
+
diff --git a/stoc/test/excomp/excomp1.cxx b/stoc/test/excomp/excomp1.cxx
new file mode 100644
index 000000000000..210bee770cc9
--- /dev/null
+++ b/stoc/test/excomp/excomp1.cxx
@@ -0,0 +1,215 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+#include <rtl/alloc.h>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+#include <example/XTest.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+using namespace example;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+
+#define SERVICENAME1 "example.ExampleComponent1"
+#define IMPLNAME1 "example.ExampleComponent1.Impl"
+
+namespace excomp_impl {
+
+//*************************************************************************
+// ExampleComponent1Impl
+//*************************************************************************
+class ExampleComponent1Impl : public WeakImplHelper2< XTest, XServiceInfo >
+{
+public:
+ ExampleComponent1Impl( const Reference<XMultiServiceFactory> & rXSMgr );
+
+ ~ExampleComponent1Impl();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( );
+
+ // XSimpleRegistry
+ virtual OUString SAL_CALL getMessage() throw(RuntimeException);
+
+protected:
+ Mutex m_mutex;
+
+ Reference<XMultiServiceFactory> m_xSMgr;
+};
+
+//*************************************************************************
+ExampleComponent1Impl::ExampleComponent1Impl( const Reference<XMultiServiceFactory> & rXSMgr )
+ : m_xSMgr(rXSMgr)
+{
+}
+
+//*************************************************************************
+ExampleComponent1Impl::~ExampleComponent1Impl()
+{
+}
+
+//*************************************************************************
+OUString SAL_CALL ExampleComponent1Impl::getImplementationName( )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME1) );
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL ExampleComponent1Impl::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ExampleComponent1Impl::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return getSupportedServiceNames_Static();
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ExampleComponent1Impl::getSupportedServiceNames_Static( )
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME1) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//*************************************************************************
+OUString SAL_CALL ExampleComponent1Impl::getMessage() throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return OUString::createFromAscii("Lalelu nur der Mann im Mond schaut zu ...");
+}
+
+
+//*************************************************************************
+Reference<XInterface> SAL_CALL ExampleComponent1_CreateInstance( const Reference<XMultiServiceFactory>& rSMgr )
+{
+ Reference<XInterface> xRet;
+
+ XTest *pXTest = (XTest*) new ExampleComponent1Impl(rSMgr);
+
+ if (pXTest)
+ {
+ xRet = Reference< XInterface >::query(pXTest);
+ }
+
+ return xRet;
+}
+
+} // excomp_impl
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * /* pServiceManager */ , void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ // ExampleComponent1
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME1 "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL =
+ ::excomp_impl::ExampleComponent1Impl::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
+{
+ void * pRet = 0;
+
+ if (rtl_str_compare( pImplName, IMPLNAME1 ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME1) ),
+ ::excomp_impl::ExampleComponent1_CreateInstance,
+ ::excomp_impl::ExampleComponent1Impl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
+
diff --git a/stoc/test/excomp/excomp1.xml b/stoc/test/excomp/excomp1.xml
new file mode 100644
index 000000000000..80b6cb0450f9
--- /dev/null
+++ b/stoc/test/excomp/excomp1.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> excomp1 </module-name>
+ <component-description>
+ <author> Juergen Schmidt </author>
+ <name> example.ExampleComponent1.Impl </name>
+ <description>
+ This component provides a simple demo component.
+</description>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> c++ </language>
+ <status value="final"/>
+ <supported-service> example.ExampleComponent1 </supported-service>
+ <type> com.sun.star.lang.XTypeProvider </type>
+ <type> com.sun.star.lang.XServiceInfo </type>
+ <type> com.sun.star.lang.XSingleServiceFactory </type>
+ <type> com.sun.star.lang.XMultiServiceFactory </type>
+ <type> com.sun.star.registry.XRegistryKey </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ <type> example.XTest </type>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> vos </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <runtime-module-dependency> cppuhelper </runtime-module-dependency>
+ <runtime-module-dependency> cppu </runtime-module-dependency>
+ <runtime-module-dependency> vos </runtime-module-dependency>
+ <runtime-module-dependency> sal </runtime-module-dependency>
+</module-description>
diff --git a/stoc/test/excomp/excomp2.cxx b/stoc/test/excomp/excomp2.cxx
new file mode 100644
index 000000000000..3595b6ecda06
--- /dev/null
+++ b/stoc/test/excomp/excomp2.cxx
@@ -0,0 +1,286 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+#include <rtl/alloc.h>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/typeprovider.hxx>
+
+#include <example/XTest.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+using namespace example;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace cppu;
+using namespace osl;
+using namespace rtl;
+
+#define SERVICENAME2 "example.ExampleComponent2"
+#define IMPLNAME2 "example.ExampleComponent2.Impl"
+
+namespace excomp2_impl {
+
+//*************************************************************************
+// ExampleComponent2Impl
+//*************************************************************************
+class ExampleComponent2Impl : public OWeakObject
+ , public XTypeProvider
+ , public XServiceInfo
+ , public XTest
+{
+public:
+ ExampleComponent2Impl( const Reference<XMultiServiceFactory> & rXSMgr );
+
+ ~ExampleComponent2Impl();
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw()
+ { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw()
+ { OWeakObject::release(); }
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( );
+
+ // XTest
+ virtual OUString SAL_CALL getMessage() throw(RuntimeException);
+
+protected:
+ Mutex m_mutex;
+
+ Reference<XMultiServiceFactory> m_xSMgr;
+};
+
+//*************************************************************************
+ExampleComponent2Impl::ExampleComponent2Impl( const Reference<XMultiServiceFactory> & rXSMgr )
+ : m_xSMgr(rXSMgr)
+{
+}
+
+//*************************************************************************
+ExampleComponent2Impl::~ExampleComponent2Impl()
+{
+}
+
+//*************************************************************************
+Any SAL_CALL ExampleComponent2Impl::queryInterface( const ::com::sun::star::uno::Type & rType )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Any aRet = ::cppu::queryInterface(rType,
+ static_cast< XTypeProvider * >( this ),
+ static_cast< XServiceInfo * >( this ),
+ static_cast< XTest * >( this ) );
+ if ( aRet.hasValue() )
+ return aRet;
+
+ return OWeakObject::queryInterface( rType );
+}
+
+//*************************************************************************
+Sequence< Type > SAL_CALL ExampleComponent2Impl::getTypes()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OTypeCollection * pTypes = 0;
+ if (! pTypes)
+ {
+ MutexGuard aGuard( m_mutex );
+ if (! pTypes)
+ {
+ static OTypeCollection aTypes(
+ ::getCppuType( (const Reference< XInterface > *)0 ),
+ ::getCppuType( (const Reference< XWeak > *)0 ),
+ ::getCppuType( (const Reference< XTypeProvider > *)0 ),
+ ::getCppuType( (const Reference< XServiceInfo > *)0 ),
+ ::getCppuType( (const Reference< XTest > *)0 ) );
+ pTypes = &aTypes;
+ }
+ }
+ return pTypes->getTypes();
+}
+
+//*************************************************************************
+Sequence< sal_Int8 > SAL_CALL ExampleComponent2Impl::getImplementationId()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( m_mutex );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+//*************************************************************************
+OUString SAL_CALL ExampleComponent2Impl::getImplementationName( )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME2) );
+}
+
+//*************************************************************************
+sal_Bool SAL_CALL ExampleComponent2Impl::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ExampleComponent2Impl::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return getSupportedServiceNames_Static();
+}
+
+//*************************************************************************
+Sequence<OUString> SAL_CALL ExampleComponent2Impl::getSupportedServiceNames_Static( )
+{
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME2) );
+ return Sequence< OUString >( &aName, 1 );
+}
+
+//*************************************************************************
+OUString SAL_CALL ExampleComponent2Impl::getMessage() throw(RuntimeException)
+{
+ Guard< Mutex > aGuard( m_mutex );
+ return OUString::createFromAscii("Alle meine Entchen schwimmen auf dem See, schwimmen auf dem See ...");
+}
+
+
+//*************************************************************************
+Reference<XInterface> SAL_CALL ExampleComponent2_CreateInstance( const Reference<XMultiServiceFactory>& rSMgr )
+{
+ Reference<XInterface> xRet;
+
+ XTest *pXTest = (XTest*) new ExampleComponent2Impl(rSMgr);
+
+ if (pXTest)
+ {
+ xRet = Reference< XInterface >::query(pXTest);
+ }
+
+ return xRet;
+}
+
+
+} // excomp_impl
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * /* pServiceManager */, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ // ExampleComponent2
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME2 "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL =
+ ::excomp2_impl::ExampleComponent2Impl::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
+{
+ void * pRet = 0;
+
+ if (rtl_str_compare( pImplName, IMPLNAME2 ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME2) ),
+ ::excomp2_impl::ExampleComponent2_CreateInstance,
+ ::excomp2_impl::ExampleComponent2Impl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
+
diff --git a/stoc/test/excomp/excomp2.xml b/stoc/test/excomp/excomp2.xml
new file mode 100644
index 000000000000..67df74bd188d
--- /dev/null
+++ b/stoc/test/excomp/excomp2.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> excomp2 </module-name>
+ <component-description>
+ <author> Juergen Schmidt </author>
+ <name> example.ExampleComponent2.Impl </name>
+ <description>
+ This component provides a simple demo component.
+</description>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> c++ </language>
+ <status value="final"/>
+ <supported-service> example.ExampleComponent2 </supported-service>
+ <type> com.sun.star.lang.XTypeProvider </type>
+ <type> com.sun.star.lang.XServiceInfo </type>
+ <type> com.sun.star.lang.XSingleServiceFactory </type>
+ <type> com.sun.star.lang.XMultiServiceFactory </type>
+ <type> com.sun.star.registry.XRegistryKey </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ <type> example.XTest </type>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> vos </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <runtime-module-dependency> cppuhelper </runtime-module-dependency>
+ <runtime-module-dependency> cppu </runtime-module-dependency>
+ <runtime-module-dependency> vos </runtime-module-dependency>
+ <runtime-module-dependency> sal </runtime-module-dependency>
+</module-description>
diff --git a/stoc/test/excomp/exports.dxp b/stoc/test/excomp/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/stoc/test/excomp/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/stoc/test/excomp/makefile.mk b/stoc/test/excomp/makefile.mk
new file mode 100644
index 000000000000..b41acb372620
--- /dev/null
+++ b/stoc/test/excomp/makefile.mk
@@ -0,0 +1,130 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= stoc
+TARGET= excomp
+TARGET1= excomp1
+TARGET2= excomp2
+TARGETTYPE=CUI
+#LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE= TRUE
+NO_BSYMBOLIC= TRUE
+COMP1TYPELIST=$(TARGET1)
+COMP2TYPELIST=$(TARGET2)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# ------------------------------------------------------------------
+
+UNOUCRDEP= $(BIN)$/excomp.rdb
+UNOUCRRDB= $(BIN)$/excomp.rdb
+UNOUCROUT= $(OUT)$/inc
+INCPRE+= $(OUT)$/inc
+
+UNOTYPES=$($(TARGET1)_XML2CMPTYPES)
+UNOTYPES+=$($(TARGET2)_XML2CMPTYPES)
+UNOTYPES+= com.sun.star.registry.XImplementationRegistration \
+ com.sun.star.lang.XComponent
+
+# --- Application excomp ------------------------------------------------
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/excomp.obj
+
+APP1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+
+# ---- objects ----
+SLOFILES= \
+ $(SLO)$/excomp1.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj \
+ $(SLO)$/excomp2.obj \
+ $(SLO)$/$(COMP2TYPELIST)_description.obj
+
+# ---- excomp1 ------
+SHL1TARGET= $(TARGET1)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1LIBS=
+SHL1OBJS= $(SLO)$/excomp1.obj \
+ $(SLO)$/$(COMP1TYPELIST)_description.obj
+SHL1IMPLIB= i$(TARGET1)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# ---- excomp2 ------
+SHL2TARGET= $(TARGET2)
+
+SHL2STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+
+SHL2DEPN=
+SHL2LIBS=
+SHL2OBJS= $(SLO)$/excomp2.obj \
+ $(SLO)$/$(COMP2TYPELIST)_description.obj
+SHL2IMPLIB= i$(TARGET2)
+SHL2DEF= $(MISC)$/$(SHL2TARGET).def
+
+DEF2NAME= $(SHL2TARGET)
+DEF2EXPORTFILE= exports.dxp
+
+ALLIDLFILES:= example$/XTest.idl example$/ExampleComponent1.idl example$/ExampleComponent2.idl
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : $(BIN)$/excomp.rdb \
+ ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+$(BIN)$/excomp.rdb: $(ALLIDLFILES)
+ idlc -I$(PRJ) -I$(SOLARIDLDIR) -O$(MISC)$/excomp $?
+ regmerge $@ /UCR $(MISC)$/excomp$/{$(?:f:s/.idl/.urd/)}
+ regmerge $@ / $(SOLARBINDIR)$/udkapi.rdb
+ touch $@
+
diff --git a/stoc/test/javavm/jvm_interaction/interactionhandler.cxx b/stoc/test/javavm/jvm_interaction/interactionhandler.cxx
new file mode 100644
index 000000000000..076a2e9c1e62
--- /dev/null
+++ b/stoc/test/javavm/jvm_interaction/interactionhandler.cxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+
+#include <jni.h>
+
+//#include <iostream>
+#include <stdio.h>
+#include <sal/main.h>
+#include <rtl/process.h>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <osl/thread.h>
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/java/XJavaVM.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/java/XJavaThreadRegister_11.hpp>
+
+#include <com/sun/star/uno/XCurrentContext.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/task/XInteractionRequest.hpp>
+#include <com/sun/star/task/XInteractionContinuation.hpp>
+#include <com/sun/star/task/XInteractionAbort.hpp>
+#include <com/sun/star/task/XInteractionRetry.hpp>
+#include <com/sun/star/java/JavaNotConfiguredException.hpp>
+#include <com/sun/star/java/MissingJavaRuntimeException.hpp>
+#include <com/sun/star/java/JavaDisabledException.hpp>
+#include <com/sun/star/java/JavaVMCreationFailureException.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <uno/current_context.hxx>
+using namespace std;
+using namespace rtl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+//using namespace com::sun::star::reflection;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::java;
+using namespace com::sun::star::task;
+
+#define OUSTR( x ) OUString(RTL_CONSTASCII_USTRINGPARAM( x ))
+#define INTERACTION_HANDLER_NAME "java-vm.interaction-handler"
+
+class Context: public WeakImplHelper1<XCurrentContext>
+{
+ virtual Any SAL_CALL getValueByName( const OUString& Name ) throw (RuntimeException);
+};
+
+class InteractionHandler: public WeakImplHelper1<XInteractionHandler>
+{
+ virtual void SAL_CALL handle( const Reference< XInteractionRequest >& Request )
+ throw (RuntimeException);
+};
+
+Any SAL_CALL Context::getValueByName( const OUString& Name) throw (RuntimeException)
+{
+ Any retVal;
+ if( Name.equals( OUSTR(INTERACTION_HANDLER_NAME)))
+ {
+ Reference<XInteractionHandler> handler( static_cast<XWeak*>(new InteractionHandler()),
+ UNO_QUERY);
+ retVal <<= handler;
+ }
+ return retVal;
+}
+
+void SAL_CALL InteractionHandler::handle( const Reference< XInteractionRequest >& Request )
+ throw (RuntimeException)
+{
+ Any anyExc= Request->getRequest();
+ Sequence<Reference< XInteractionContinuation> >seqCont= Request->getContinuations();
+
+ Reference<XInteractionAbort> abort;
+ Reference<XInteractionRetry> retry;
+
+ for (sal_Int32 i= 0; i < seqCont.getLength(); i++)
+ {
+ abort= Reference<XInteractionAbort>::query( seqCont[i]);
+ if(abort.is())
+ break;
+ }
+ for (sal_Int32 i= 0; i < seqCont.getLength(); i++)
+ {
+ retry= Reference<XInteractionRetry>::query( seqCont[i]);
+ if(retry.is())
+ break;
+ }
+
+// if( abort.is())
+// abort->select();
+
+ static int cRetry= 0;
+
+ if( cRetry++ == 5)
+ {
+ if( abort.is())
+ abort->select();
+ return;
+ }
+ if( retry.is())
+ retry->select();
+}
+
+sal_Bool test1(const Reference< XMultiServiceFactory > & xMgr )
+{
+ sal_Bool retVal= sal_True;
+ setCurrentContext( Reference<XCurrentContext>( static_cast<XWeak*>(new Context()), UNO_QUERY));
+
+ OUString sVMService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.java.JavaVirtualMachine"));
+ Reference<XInterface> xXInt= xMgr->createInstance(sVMService);
+ if( ! xXInt.is())
+ return sal_False;
+ Reference<XJavaVM> xVM( xXInt, UNO_QUERY);
+ if( ! xVM.is())
+ return sal_False;
+
+
+ sal_Int8 arId[16];
+ rtl_getGlobalProcessId((sal_uInt8*) arId);
+
+ Any anyVM;
+ try
+ {
+ anyVM = xVM->getJavaVM( Sequence<sal_Int8>(arId, 16));
+ }
+ catch (JavaNotConfiguredException& e)
+ {
+ OString msg= OUStringToOString(e.Message, osl_getThreadTextEncoding());
+ printf("JavaNotConfiguredException: %s\n", msg.getStr());
+ }
+ catch (JavaVMCreationFailureException& e)
+ {
+ OString msg= OUStringToOString(e.Message, osl_getThreadTextEncoding());
+ printf("JavaVMCreationFailureException: %s\n", msg.getStr());
+ }
+ catch (MissingJavaRuntimeException& e)
+ {
+ OString msg= OUStringToOString(e.Message, osl_getThreadTextEncoding());
+ printf("MissingJavaRuntimeException: %s\n", msg.getStr());
+ }
+ catch (JavaDisabledException& e)
+ {
+ OString msg= OUStringToOString(e.Message, osl_getThreadTextEncoding());
+ printf("JavaDisabledException: %s\n", msg.getStr());
+ }
+ catch (RuntimeException & e)
+ {
+ OString msg= OUStringToOString(e.Message, osl_getThreadTextEncoding());
+ printf("###RuntimeException: %s\n", msg.getStr());
+ retVal= sal_False;
+ }
+ return retVal;
+}
+
+SAL_IMPLEMENT_MAIN()
+{
+ Reference<XSimpleRegistry> xreg= createSimpleRegistry();
+ xreg->open( OUString( RTL_CONSTASCII_USTRINGPARAM("applicat.rdb")),
+ sal_False, sal_False );
+
+ Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg);
+ Reference<XMultiComponentFactory> fac= context->getServiceManager();
+ Reference<XMultiServiceFactory> xMgr( fac, UNO_QUERY);
+
+ sal_Bool bSucc = sal_False;
+ bSucc= test1(xMgr);
+ Reference< XComponent > xCompContext( context, UNO_QUERY );
+ xCompContext->dispose();
+ return (bSucc ? 0 : -1);
+}
+
+
diff --git a/stoc/test/javavm/jvm_interaction/makefile.mk b/stoc/test/javavm/jvm_interaction/makefile.mk
new file mode 100644
index 000000000000..e2e78f2c13f5
--- /dev/null
+++ b/stoc/test/javavm/jvm_interaction/makefile.mk
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+TARGET= jvminteraction
+PRJNAME= stoc
+TARGET6= $(TARGET)
+TARGETTYPE= CUI
+LIBTARGET= NO
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC= TRUE
+
+UNOUCRDEP= $(SOLARBINDIR)$/udkapi.rdb
+UNOUCRRDB= $(SOLARBINDIR)$/udkapi.rdb
+UNOUCROUT= $(OUT)$/inc$
+INCPRE+= $(OUT)$/inc$
+
+
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : settings.mk
+
+# --- Application 6 - testjavavm ------------------------------------
+
+UNOTYPES= com.sun.star.lang.XMultiComponentFactory \
+ com.sun.star.uno.XWeak \
+ com.sun.star.java.XJavaVM \
+ com.sun.star.java.XJavaThreadRegister_11 \
+ com.sun.star.java.JavaNotConfiguredException \
+ com.sun.star.java.MissingJavaRuntimeException \
+ com.sun.star.java.JavaDisabledException \
+ com.sun.star.java.JavaVMCreationFailureException \
+ com.sun.star.registry.XSimpleRegistry \
+ com.sun.star.lang.XComponent \
+ com.sun.star.registry.XImplementationRegistration \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.uno.TypeClass \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.uno.XCurrentContext \
+ com.sun.star.task.XInteractionHandler \
+ com.sun.star.task.XInteractionRequest \
+ com.sun.star.task.XInteractionContinuation \
+ com.sun.star.task.XInteractionAbort \
+ com.sun.star.task.XInteractionRetry \
+
+
+APP6TARGET= $(TARGET6)
+APP6OBJS = $(OBJ)$/interactionhandler.obj
+APP6STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+
+# --- Target ------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/test/javavm/makefile.mk b/stoc/test/javavm/makefile.mk
new file mode 100644
index 000000000000..7f6190fecc4f
--- /dev/null
+++ b/stoc/test/javavm/makefile.mk
@@ -0,0 +1,73 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+TARGET= testjavavm
+PRJNAME= stoc
+TARGET6= testjavavm
+TARGETTYPE= CUI
+LIBTARGET= NO
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC= TRUE
+
+UNOUCRDEP= $(SOLARBINDIR)$/udkapi.rdb
+UNOUCRRDB= $(SOLARBINDIR)$/udkapi.rdb
+#UNOUCROUT= $(OUT)$/inc$/test
+UNOUCROUT= $(OUT)$/inc$
+#INCPRE+= $(OUT)$/inc$/test
+INCPRE+= $(OUT)$/inc$
+
+
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : settings.mk
+
+# --- Application 6 - testjavavm ------------------------------------
+
+UNOTYPES= com.sun.star.lang.XMultiComponentFactory \
+ com.sun.star.uno.XWeak \
+ com.sun.star.java.XJavaVM \
+ com.sun.star.java.XJavaThreadRegister_11 \
+ com.sun.star.registry.XSimpleRegistry \
+ com.sun.star.lang.XComponent \
+ com.sun.star.registry.XImplementationRegistration \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.uno.TypeClass \
+ com.sun.star.lang.XMultiServiceFactory
+
+APP6TARGET= $(TARGET6)
+APP6OBJS = $(OBJ)$/testjavavm.obj
+APP6STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+# $(UNOLIB)
+
+# --- Target ------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/test/javavm/testapplet/TestApplet.html b/stoc/test/javavm/testapplet/TestApplet.html
new file mode 100644
index 000000000000..e83d2ffe7d42
--- /dev/null
+++ b/stoc/test/javavm/testapplet/TestApplet.html
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+ <TITLE>A Clock (1.1)</TITLE>
+ <META NAME="GENERATOR" CONTENT="StarOffice 6.0 (Win32)">
+ <META NAME="CREATED" CONTENT="20011119;12262427">
+ <META NAME="CHANGED" CONTENT="16010101;0">
+</HEAD>
+<BODY LANG="de-DE">
+<H1>TestApplet</H1>
+<HR>
+<P>
+<APPLET CODE="TestApplet.class" ALIGN=BOTTOM WIDTH=170 HEIGHT=150>
+</APPLET>
+</P>
+
+</BODY>
+</HTML> \ No newline at end of file
diff --git a/stoc/test/javavm/testapplet/TestApplet.java b/stoc/test/javavm/testapplet/TestApplet.java
new file mode 100644
index 000000000000..55916cff784b
--- /dev/null
+++ b/stoc/test/javavm/testapplet/TestApplet.java
@@ -0,0 +1,58 @@
+import java.awt.Graphics;
+import java.awt.Color;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+/*
+ * TestApplet.java
+ *
+ * Created on 21. November 2001, 09:37
+ */
+
+/**
+ *
+ * @author jl97489
+ * @version
+ */
+public class TestApplet extends java.applet.Applet {
+
+ /** Initialization method that will be called after the applet is loaded
+ * into the browser.
+ */
+ public void init () {
+ setBackground( Color.green);
+ resize( 300, 300);
+
+ // Security tests.
+ File f= new File("d:\\temp\\javasecurity.txt");
+ SecurityManager mgr= System.getSecurityManager();
+ try {
+ f.createNewFile();
+
+ // local connection
+ URL url= new URL("http://localhost:8080/index.html");
+ InputStream is= url.openStream();
+ // remote connection
+ url= new URL("http://www.w3.org/index.html");
+ is= url.openStream();
+ }catch( MalformedURLException mue) {
+ }catch( IOException e) {
+ String s= e.getMessage();
+ System.out.println(s);
+ }catch( SandboxSecurityException sse) {
+ String s= sse.getMessage();
+ System.out.println("s");
+ }
+ // catch( Exception ex) {
+// String s= ex.getMessage();
+// ex.printStackTrace();
+// }
+
+ }
+
+ public void paint( Graphics g) {
+ super.paint( g);
+ }
+}
diff --git a/stoc/test/javavm/testapplet/makefile.mk b/stoc/test/javavm/testapplet/makefile.mk
new file mode 100644
index 000000000000..4ddadebd9aa2
--- /dev/null
+++ b/stoc/test/javavm/testapplet/makefile.mk
@@ -0,0 +1,55 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME = testapplet
+PACKAGE =
+TARGET = TestApplet
+
+
+# --- Settings -----------------------------------------------------
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+.INCLUDE : settings.mk
+# Files --------------------------------------------------------
+JARFILES = ridl.jar jurt.jar unoil.jar
+
+JAVAFILES= $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES)))
+
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/TestApplet.class
+
+JARCLASSDIRS= .
+#JARTARGET = $(TARGET).jar
+#JARCOMPRESS= TRUE
+#CUSTOMMANIFESTFILE= .$/manifest
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/test/javavm/testcomponent/TestComponent.java b/stoc/test/javavm/testcomponent/TestComponent.java
new file mode 100644
index 000000000000..5622ba087d7a
--- /dev/null
+++ b/stoc/test/javavm/testcomponent/TestComponent.java
@@ -0,0 +1,128 @@
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.lang.*;
+import com.sun.star.uno.*;
+import com.sun.star.registry.XRegistryKey;
+import java.io.*;
+import java.net.*;
+//import com.sun.star.lib.sandbox.*;
+
+
+/** This component implements XTypeProvider for use with StarBasic.
+ * The XServiceInfo is implemented to have an interface in which we can put some
+ * code just for the sake of debugging.
+ *
+ * To debug with JPDA (jdk 1.3), put these lines in the java.ini within the [Java] section:
+ * -Xdebug
+ * -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
+ *
+ * When the Virtual Machine service is instantiated it will block until the debugger
+ * attaches to it on port 8000. You can chose a different port. You attach to the VM using
+ * jdb by
+ *
+ * jdb -connect com.sun.jdi.SocketAttach:hostname=myhost,port=8000
+ *
+ * myhost is the hostname where the VM is running.
+*/
+public class TestComponent implements XServiceInfo, XTypeProvider
+{
+ public static final String __serviceName="JavaTestComponent";
+
+ // XTypeProvider
+ public com.sun.star.uno.Type[] getTypes( )
+ {
+ Type[] retValue= new Type[2];
+ retValue[0]= new Type( XServiceInfo.class);
+ retValue[1]= new Type( XTypeProvider.class);
+ return retValue;
+ }
+ // XTypeProvider
+ public byte[] getImplementationId( )
+ {
+ return TestComponent.class.getName().getBytes();
+ }
+
+
+ // XServiceName
+ public String getImplementationName( )
+ {
+ String a= "the functions are for debugging";
+ int abc= 34;
+ String prop= System.getProperty("ftp.proxyHost");
+ prop= System.getProperty("ftp.proxyPort");
+ prop= System.getProperty("http.proxyHost");
+ prop= System.getProperty("http.proxyPort");
+ prop= System.getProperty("ftp.nonProxyHosts");
+ prop= System.getProperty("http.nonProxyHosts");
+ prop= System.getProperty("socksProxyHost");
+ prop= System.getProperty("socksProxyPort");
+
+ prop= System.getProperty("stardiv.security.disableSecurity");
+ prop= System.getProperty("appletviewer.security.mode");
+
+ // Test security settings
+ File f= new File("c:/temp/javasecurity.txt");
+ try {
+ f.createNewFile();
+
+ // local connection
+ URL url= new URL("http://localhost:8080/index.html");
+ InputStream is= url.openStream();
+ // remote connection
+ url= new URL("http://www.w3.org/index.html");
+ is= url.openStream();
+ }catch( MalformedURLException mue) {
+ }catch( IOException e) {
+ String s= e.getMessage();
+ System.out.println(s);
+ }/*catch( SandboxSecurityException sse) {
+ String s= sse.getMessage();
+ System.out.println("s");
+ }
+*/
+
+ return __serviceName;
+ }
+ // XServiceName
+ public boolean supportsService( /*IN*/String ServiceName )
+ {
+
+ return false;
+ }
+
+ //XServiceName
+ public String[] getSupportedServiceNames( )
+ {
+ String[] retValue= new String[0];
+ return retValue;
+ }
+
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals( TestComponent.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory( TestComponent.class,
+ TestComponent.__serviceName,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
+ {
+ return FactoryHelper.writeRegistryServiceInfo( TestComponent.class.getName(),
+ TestComponent.__serviceName, regKey);
+ }
+
+}
diff --git a/stoc/test/javavm/testcomponent/makefile.mk b/stoc/test/javavm/testcomponent/makefile.mk
new file mode 100644
index 000000000000..a2f8eb16fe4d
--- /dev/null
+++ b/stoc/test/javavm/testcomponent/makefile.mk
@@ -0,0 +1,58 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME = testcomponent
+PACKAGE =
+TARGET = JavaTestComponent
+
+
+# --- Settings -----------------------------------------------------
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+.INCLUDE : settings.mk
+# Files --------------------------------------------------------
+JARFILES = ridl.jar jurt.jar unoil.jar
+
+CUSTOMMANIFESTFILE= manifest
+
+JARTARGET = $(TARGET).jar
+
+JAVAFILES= \
+ TestComponent.java
+
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+
+
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/test/javavm/testcomponent/manifest b/stoc/test/javavm/testcomponent/manifest
new file mode 100644
index 000000000000..1763d7bb95f7
--- /dev/null
+++ b/stoc/test/javavm/testcomponent/manifest
@@ -0,0 +1 @@
+RegistrationClassName: TestComponent
diff --git a/stoc/test/javavm/testjavavm.cxx b/stoc/test/javavm/testjavavm.cxx
new file mode 100644
index 000000000000..e9111bd3cd1d
--- /dev/null
+++ b/stoc/test/javavm/testjavavm.cxx
@@ -0,0 +1,202 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+
+#include <jni.h>
+
+//#include <iostream>
+#include <stdio.h>
+#include <sal/main.h>
+#include <rtl/process.h>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/bootstrap.hxx>
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/java/XJavaVM.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/java/XJavaThreadRegister_11.hpp>
+
+//#include <cppuhelper/implbase1.hxx>
+
+using namespace std;
+using namespace rtl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+//using namespace com::sun::star::reflection;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::java;
+
+
+sal_Bool testJavaVM(const Reference< XMultiServiceFactory > & xMgr )
+{
+
+ OUString sVMService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.java.JavaVirtualMachine"));
+ Reference<XInterface> xXInt= xMgr->createInstance(sVMService);
+ if( ! xXInt.is())
+ return sal_False;
+ Reference<XJavaVM> xVM( xXInt, UNO_QUERY);
+ if( ! xVM.is())
+ return sal_False;
+ Reference<XJavaThreadRegister_11> xreg11(xVM, UNO_QUERY);
+ if( ! xreg11.is())
+ return sal_False;
+
+
+ sal_Int8 arId[16];
+ rtl_getGlobalProcessId((sal_uInt8*) arId);
+ Any anyVM = xVM->getJavaVM( Sequence<sal_Int8>(arId, 16));
+ if ( ! anyVM.hasValue())
+ {
+ OSL_ENSURE(0,"could not get Java VM");
+ return sal_False;
+ }
+
+ sal_Bool b= xreg11->isThreadAttached();
+ xreg11->registerThread();
+ b= xreg11->isThreadAttached();
+ xreg11->revokeThread();
+ b= xreg11->isThreadAttached();
+
+
+ b= xVM->isVMEnabled();
+ b= xVM->isVMStarted();
+
+
+ b= xVM->isVMEnabled();
+ b= xVM->isVMStarted();
+
+
+ JavaVM* _jvm= *(JavaVM**) anyVM.getValue();
+ JNIEnv *p_env;
+ if( _jvm->AttachCurrentThread((void**) &p_env, 0))
+ return sal_False;
+
+// jclass aJProg = p_env->FindClass("TestJavaVM");
+// if( p_env->ExceptionOccurred()){
+// p_env->ExceptionDescribe();
+// p_env->ExceptionClear();
+// }
+//
+// jmethodID mid= p_env->GetStaticMethodID( aJProg,"main", "([Ljava/lang/String;)V");
+
+ jclass cls = p_env->FindClass( "TestJavaVM");
+ if (cls == 0) {
+ OSL_TRACE( "Can't find Prog class\n");
+ exit(1);
+ }
+
+// jmethodID methid = p_env->GetStaticMethodID( cls, "main", "([Ljava/lang/String;)V");
+// if (methid == 0) {
+// OSL_TRACE("Can't find Prog.main\n");
+// exit(1);
+// }
+
+// jstring jstr = p_env->NewStringUTF(" from C!");
+// if (jstr == 0) {
+// OSL_TRACE("Out of memory\n");
+// exit(1);
+// }
+// jobjectArray args = p_env->NewObjectArray( 1,
+// p_env->FindClass("java/lang/String"), jstr);
+// if (args == 0) {
+// OSL_TRACE( "Out of memory\n");
+// exit(1);
+// }
+// p_env->CallStaticVoidMethod( cls, methid, args);
+
+
+ jmethodID id = p_env->GetStaticMethodID( cls, "getInt", "()I");
+ if( id)
+ {
+// jint _i= p_env->CallStaticIntMethod(cls, id);
+ p_env->CallStaticIntMethod(cls, id);
+ }
+
+ if( p_env->ExceptionOccurred()){
+ p_env->ExceptionDescribe();
+ p_env->ExceptionClear();
+ }
+
+
+ _jvm->DetachCurrentThread();
+ return sal_True;
+}
+
+SAL_IMPLEMENT_MAIN()
+{
+ Reference<XSimpleRegistry> xreg= createSimpleRegistry();
+ xreg->open( OUString( RTL_CONSTASCII_USTRINGPARAM("applicat.rdb")),
+ sal_False, sal_False );
+
+ Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg);
+ Reference<XMultiComponentFactory> fac= context->getServiceManager();
+ Reference<XMultiServiceFactory> xMgr( fac, UNO_QUERY);
+
+ sal_Bool bSucc = sal_False;
+ try
+ {
+ OUString sImplReg(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.registry.ImplementationRegistration"));
+ Reference<com::sun::star::registry::XImplementationRegistration> xImplReg(
+ xMgr->createInstance( sImplReg ), UNO_QUERY );
+ OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
+
+
+ OUString sLibLoader( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary"));
+ OUString sJenLib(
+ RTL_CONSTASCII_USTRINGPARAM( "javavm.uno" SAL_DLLEXTENSION ) );
+ xImplReg->registerImplementation(
+ sLibLoader, sJenLib, Reference< XSimpleRegistry >() );
+
+ bSucc = testJavaVM( xMgr );
+ }
+ catch (Exception & rExc)
+ {
+ OSL_ENSURE( sal_False, "### exception occured!" );
+ OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### exception occured: " );
+ OSL_TRACE( aMsg.getStr() );
+ OSL_TRACE( "\n" );
+ }
+
+ Reference< XComponent > xCompContext( context, UNO_QUERY );
+ xCompContext->dispose();
+ printf("javavm %s", bSucc ? "succeeded" : "failed");
+// cout << "javavm " << (bSucc ? "succeeded" : "failed") << " !" << endl;
+ return (bSucc ? 0 : -1);
+}
+
+
diff --git a/stoc/test/javavm/testjavavm.java b/stoc/test/javavm/testjavavm.java
new file mode 100644
index 000000000000..3de93cfc690f
--- /dev/null
+++ b/stoc/test/javavm/testjavavm.java
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+class TestJavaVM
+{
+ public static int getInt()
+ {
+ return 100;
+ }
+
+ public static void main( String args[])
+ {
+ System.out.println("Hello World");
+ }
+}
diff --git a/stoc/test/language_binding.idl b/stoc/test/language_binding.idl
new file mode 100644
index 000000000000..705ef1c2825a
--- /dev/null
+++ b/stoc/test/language_binding.idl
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _TEST_LANGUAGE_BINDING_IDL_
+#define _TEST_LANGUAGE_BINDING_IDL_
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/lang/IllegalArgumentException.idl>
+
+module test
+{
+
+enum TestEnum
+{
+ TEST,
+ ONE,
+ TWO,
+ CHECK,
+ LOLA,
+ PALOO,
+ ZA
+};
+
+/**
+ * simple c++ types
+ */
+struct TestSimple
+{
+ boolean Bool;
+ char Char;
+ byte Byte;
+ short Short;
+ unsigned short UShort;
+ long Long;
+ unsigned long ULong;
+ hyper Hyper;
+ unsigned hyper UHyper;
+ float Float;
+ double Double;
+ test::TestEnum Enum;
+};
+/**
+ * complex c++ types
+ */
+struct TestElement : test::TestSimple
+{
+ string String;
+ com::sun::star::uno::XInterface Interface;
+ any Any;
+};
+struct TestDataElements : test::TestElement
+{
+ sequence<test::TestElement > Sequence;
+};
+
+typedef TestDataElements TestData;
+
+/**
+ * Monster test interface to test language binding calls.
+ *
+ * @author Daniel Boelzle
+ */
+interface XLBTestBase : com::sun::star::uno::XInterface
+{
+ /**
+ * in parameter test, tests by calls reference also (complex types)
+ */
+ [oneway] void setValues( [in] boolean bBool, [in] char cChar, [in] byte nByte,
+ [in] short nShort, [in] unsigned short nUShort,
+ [in] long nLong, [in] unsigned long nULong,
+ [in] hyper nHyper, [in] unsigned hyper nUHyper,
+ [in] float fFloat, [in] double fDouble,
+ [in] test::TestEnum eEnum, [in] string aString,
+ [in] com::sun::star::uno::XInterface xInterface, [in] any aAny,
+ [in] sequence<test::TestElement > aSequence,
+ [in] test::TestData aStruct );
+ /**
+ * inout parameter test
+ */
+ test::TestData setValues2( [inout] boolean bBool, [inout] char cChar, [inout] byte nByte,
+ [inout] short nShort, [inout] unsigned short nUShort,
+ [inout] long nLong, [inout] unsigned long nULong,
+ [inout] hyper nHyper, [inout] unsigned hyper nUHyper,
+ [inout] float fFloat, [inout] double fDouble,
+ [inout] test::TestEnum eEnum, [inout] string aString,
+ [inout] com::sun::star::uno::XInterface xInterface, [inout] any aAny,
+ [inout] sequence<test::TestElement > aSequence,
+ [inout] test::TestData aStruct );
+
+ /**
+ * out parameter test
+ */
+ test::TestData getValues( [out] boolean bBool, [out] char cChar, [out] byte nByte,
+ [out] short nShort, [out] unsigned short nUShort,
+ [out] long nLong, [out] unsigned long nULong,
+ [out] hyper nHyper, [out] unsigned hyper nUHyper,
+ [out] float fFloat, [out] double fDouble,
+ [out] test::TestEnum eEnum, [out] string aString,
+ [out] com::sun::star::uno::XInterface xInterface, [out] any aAny,
+ [out] sequence<test::TestElement > aSequence,
+ [out] test::TestData aStruct );
+
+ [attribute] boolean Bool;
+ [attribute] byte Byte;
+ [attribute] char Char;
+ [attribute] short Short;
+ [attribute] unsigned short UShort;
+ [attribute] long Long;
+ [attribute] unsigned long ULong;
+ [attribute] hyper Hyper;
+ [attribute] unsigned hyper UHyper;
+ [attribute] float Float;
+ [attribute] double Double;
+ [attribute] test::TestEnum Enum;
+ [attribute] string String;
+ [attribute] com::sun::star::uno::XInterface Interface;
+ [attribute] any Any;
+ [attribute] sequence<test::TestElement > Sequence;
+ [attribute] test::TestData Struct;
+};
+
+
+/**
+ * Inherting from monster; adds raiseException().
+ *
+ * @author Daniel Boelzle
+ */
+interface XLanguageBindingTest : test::XLBTestBase
+{
+ /**
+ * params are there only for dummy, to test if all temp out params will be released.
+ */
+ test::TestData raiseException( [out] boolean bBool, [out] char cChar, [out] byte nByte,
+ [out] short nShort, [out] unsigned short nUShort,
+ [out] long nLong, [out] unsigned long nULong,
+ [out] hyper nHyper, [out] unsigned hyper nUHyper,
+ [out] float fFloat, [out] double fDouble,
+ [out] test::TestEnum eEnum, [out] string aString,
+ [out] com::sun::star::uno::XInterface xInterface, [out] any aAny,
+ [out] sequence<test::TestElement > aSequence,
+ [out] test::TestData aStruct )
+ raises( com::sun::star::lang::IllegalArgumentException );
+
+ /**
+ * raises runtime exception
+ */
+ [attribute] long RuntimeException;
+};
+
+}; // test
+
+
+#endif
diff --git a/stoc/test/makefile.mk b/stoc/test/makefile.mk
new file mode 100644
index 000000000000..a7b18d062f8b
--- /dev/null
+++ b/stoc/test/makefile.mk
@@ -0,0 +1,223 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=stoc
+TARGET=stoc
+TARGET1=testloader
+TARGET2=testregistry
+TARGET3=testsmgr
+TARGET4=testcorefl
+TARGET5=testinvocation
+TARGET6=testintrosp
+TARGET7=testconv
+TARGET8=testproxyfac
+TARGET9=testsmgr2
+TARGETTYPE=CUI
+#LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- smgr component -----------------------------------------------
+SHL1OBJS= \
+ $(OBJ)$/testsmgr_cpnt.obj
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+
+SHL1TARGET=testsmgr_component
+SHL1DEPN=
+SHL1IMPLIB=i$(SHL1TARGET)
+#SHL1LIBS=$(SLB)$/$(SHL1TARGET).lib
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+SHL1VERSIONMAP=testsmgr_cpnt.map
+
+# --- Application 1 ------------------------------------------------
+APP1TARGET= $(TARGET1)
+APP1OBJS= $(OBJ)$/testloader.obj
+
+APP1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+
+# --- Application 2 ------------------------------------------------
+APP2TARGET= $(TARGET2)
+APP2OBJS= $(OBJ)$/testregistry.obj $(OBJ)$/mergekeys_.obj
+
+APP2STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(REGLIB) \
+ $(SALLIB)
+
+# --- Application 3 - testsmgr main ------------------------------------
+APP3TARGET= $(TARGET3)
+APP3OBJS = $(OBJ)$/testsmgr.obj
+APP3STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(REGLIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="UNX"
+APP3STDLIBS+= -l$(SHL1TARGET)
+.ENDIF
+.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
+APP3STDLIBS+= i$(SHL1TARGET).lib
+.ENDIF
+
+# --- Application 4 - testcorefl main ------------------------------------
+APP4TARGET= $(TARGET4)
+APP4OBJS = $(OBJ)$/testcorefl.obj
+APP4STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+# --- Application 5 - testinvocation main ------------------------------------
+APP5TARGET= $(TARGET5)
+APP5OBJS = $(OBJ)$/testiadapter.obj
+APP5STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+# --- Application 6 - testitrosp main ------------------------------------
+APP6TARGET= $(TARGET6)
+APP6OBJS = $(OBJ)$/testintrosp.obj
+APP6STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+
+# --- Application 7 - testconv main ------------------------------------
+APP7TARGET= $(TARGET7)
+APP7OBJS = $(OBJ)$/testconv.obj
+APP7STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+# --- Application 8 - testproxyfac main ------------------------------------
+APP8TARGET= $(TARGET8)
+APP8OBJS = $(OBJ)$/testproxyfac.obj
+APP8STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+# --- Application 9 - testproxyfac main ------------------------------------
+APP9TARGET= $(TARGET9)
+APP9OBJS = $(OBJ)$/testsmgr2.obj
+APP9STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+
+ALLIDLFILES:= testcorefl.idl language_binding.idl testintrosp.idl
+
+
+# --- Target ------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : $(MISC)$/test_types_generated.flag \
+ $(BIN)$/test1.rdb \
+ $(BIN)$/test2.rdb \
+ ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+CPPUMAKERFLAGS =
+.IF "$(COM)" == "MSC"
+CPPUMAKERFLAGS = -L
+.ENDIF
+
+FACTORYTYPES:= -T com.sun.star.lang.XSingleComponentFactory \
+ -T com.sun.star.uno.XComponentContext \
+ -T com.sun.star.uno.XWeak \
+ -T com.sun.star.container.XEnumeration \
+ -T com.sun.star.lang.XComponent \
+ -T com.sun.star.registry.XSimpleRegistry \
+ -T com.sun.star.lang.XInitialization \
+ -T com.sun.star.lang.XMultiServiceFactory\
+ -T com.sun.star.loader.XImplementationLoader \
+ -T com.sun.star.registry.XImplementationRegistration \
+ -T com.sun.star.container.XSet \
+ -T com.sun.star.lang.XSingleServiceFactory\
+ -T com.sun.star.lang.XServiceInfo \
+ -T com.sun.star.container.XContentEnumerationAccess \
+ -T com.sun.star.container.XEnumeration
+
+TESTCOREFL:=ModuleC;ModuleC.XInterfaceA;ModuleC.XInterfaceB;ModuleA.XInterface1;com.sun.star.reflection.XIdlReflection;com.sun.star.reflection.XIdlField;com.sun.star.reflection.XIdlArray;com.sun.star.reflection.XIdlMethod;com.sun.star.reflection.XIdlClass;com.sun.star.beans.XPropertySet;com.sun.star.lang.XComponent;com.sun.star.container.XHierarchicalNameAccess;com.sun.star.reflection.XIdlField2;com.sun.star.lang.DisposedException
+TESTIADAPTER:=com.sun.star.beans.XIntrospection;com.sun.star.beans.MethodConcept;com.sun.star.beans.XExactName;com.sun.star.lang.XTypeProvider;com.sun.star.uno.XAggregation;com.sun.star.script.XInvocationAdapterFactory;com.sun.star.script.XInvocationAdapterFactory2;com.sun.star.script.XInvocation;com.sun.star.lang.XMultiServiceFactory;com.sun.star.registry.XSimpleRegistry;com.sun.star.lang.XInitialization;test.XLanguageBindingTest
+TESTINTROSP:=ModuleA;ModuleA.XIntroTest;com.sun.star.beans.XPropertySet;com.sun.star.container.XIndexAccess;com.sun.star.container.XNameAccess;com.sun.star.beans.PropertyAttribute;com.sun.star.beans.PropertyConcept
+TESTCONV:=com.sun.star.script.XTypeConverter
+TESTPROXYFAC:=com.sun.star.reflection.XProxyFactory
+TESTSECURITY:=com.sun.star.security.AllPermission;com.sun.star.security.XPolicy;com.sun.star.security.XAccessController;com.sun.star.io.FilePermission;com.sun.star.connection.SocketPermission;com.sun.star.uno.XCurrentContext
+
+$(BIN)$/test1.rdb: $(SHL1TARGETN)
+.IF "$(GUI)"=="UNX"
+ cp $(SHL1TARGETN) $(BIN)
+.ENDIF
+ cd $(BIN) && regcomp -register -r test1.rdb -c $(SHL1TARGET)
+
+$(BIN)$/test2.rdb:
+ cd $(BIN) && regcomp -register -r test2.rdb -c remotebridge.uno$(DLLPOST)
+
+$(BIN)$/stoctest.rdb: $(ALLIDLFILES)
+ idlc -I$(PRJ) -I$(SOLARIDLDIR) -O$(BIN) $?
+ regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)}
+ regmerge $@ / $(SOLARBINDIR)$/udkapi.rdb
+ regcomp -register -r $@ -c reflection.uno$(DLLPOST)
+ touch $@
+
+$(MISC)$/test_types_generated.flag : $(BIN)$/stoctest.rdb makefile.mk
+ -rm -f $(MISC)$/test_types_generated.flag
+ cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) $(FACTORYTYPES) -T"$(TESTIADAPTER)" $(BIN)$/stoctest.rdb
+ cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TESTCOREFL)" $(BIN)$/stoctest.rdb
+ cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TESTINTROSP)" $(BIN)$/stoctest.rdb
+ cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TESTCONV)" $(BIN)$/stoctest.rdb
+ cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TESTPROXYFAC)" $(BIN)$/stoctest.rdb
+ cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TESTSECURITY)" $(BIN)$/stoctest.rdb
+ touch $(MISC)$/test_types_generated.flag
diff --git a/stoc/test/mergekeys_.cxx b/stoc/test/mergekeys_.cxx
new file mode 100644
index 000000000000..b75a1ef7df35
--- /dev/null
+++ b/stoc/test/mergekeys_.cxx
@@ -0,0 +1,31 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+#include "../source/implementationregistration/mergekeys.cxx"
diff --git a/stoc/test/registry_tdprovider/makefile.mk b/stoc/test/registry_tdprovider/makefile.mk
new file mode 100644
index 000000000000..f258963f9299
--- /dev/null
+++ b/stoc/test/registry_tdprovider/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ := ..$/..
+PRJNAME := stoc
+
+TARGET := test_registry_tdprovider
+
+ENABLE_EXCEPTIONS := TRUE
+
+.INCLUDE: settings.mk
+
+DLLPRE = # no leading "lib" on .so files
+
+SLOFILES = $(SLO)$/testregistrytdprovider.obj
+
+SHL1TARGET = testregistrytdprovider.uno
+SHL1OBJS = $(SLOFILES)
+SHL1VERSIONMAP = $(SOLARENV)/src/component.map
+SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB)
+SHL1IMPLIB = itestregistrytdprovider
+DEF1NAME = $(SHL1TARGET)
+
+.INCLUDE: target.mk
+
+ALLTAR: test
+
+$(MISC)$/$(TARGET)$/all.rdb: types.idl
+ - rm $@
+ - $(MKDIR) $(MISC)$/$(TARGET)
+ idlc -O$(MISC)$/$(TARGET) -I$(SOLARIDLDIR) -C -cid -we $<
+ regmerge $@ /UCR $(MISC)$/$(TARGET)$/types.urd
+ regmerge $@ / $(SOLARBINDIR)$/types.rdb
+
+$(SLOFILES): $(MISC)$/$(TARGET)$/all.rdb
+
+test .PHONY: $(SHL1TARGETN) $(MISC)$/$(TARGET)$/all.rdb
+ uno -c test.registrytdprovider.impl -l $(subst,$/,/ $(SHL1TARGETN)) \
+ -ro $(subst,$/,/ $(MISC)$/$(TARGET)$/all.rdb)
diff --git a/stoc/test/registry_tdprovider/readme.txt b/stoc/test/registry_tdprovider/readme.txt
new file mode 100644
index 000000000000..9267df8582f6
--- /dev/null
+++ b/stoc/test/registry_tdprovider/readme.txt
@@ -0,0 +1,4 @@
+This test uses the delivered regtypeprov.uno dynamic library, not the local one.
+(It might work to fix this, changing the test from a UNO component started from
+the uno executable to a stand-alone application that bootstraps UNO in a special
+way.)
diff --git a/stoc/test/registry_tdprovider/testregistrytdprovider.cxx b/stoc/test/registry_tdprovider/testregistrytdprovider.cxx
new file mode 100644
index 000000000000..ca245d7d7f43
--- /dev/null
+++ b/stoc/test/registry_tdprovider/testregistrytdprovider.cxx
@@ -0,0 +1,943 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
+#include "com/sun/star/lang/XMain.hpp"
+#include "com/sun/star/lang/XSingleComponentFactory.hpp"
+#include "com/sun/star/reflection/XCompoundTypeDescription.hpp"
+#include "com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp"
+#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp"
+#include "com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp"
+#include "com/sun/star/reflection/XInterfaceTypeDescription2.hpp"
+#include "com/sun/star/reflection/XPublished.hpp"
+#include "com/sun/star/reflection/XServiceTypeDescription2.hpp"
+#include "com/sun/star/reflection/XSingletonTypeDescription2.hpp"
+#include "com/sun/star/reflection/XStructTypeDescription.hpp"
+#include "com/sun/star/reflection/XTypeDescription.hpp"
+#include "com/sun/star/registry/InvalidRegistryException.hpp"
+#include "com/sun/star/registry/XRegistryKey.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/TypeClass.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "cppuhelper/weak.hxx"
+#include "rtl/textenc.h"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "uno/environment.h"
+#include "uno/lbnames.h"
+
+#include /*MSVC trouble: <cstdlib>*/ <stdlib.h>
+#include <iostream>
+#include <ostream>
+
+namespace css = com::sun::star;
+
+namespace {
+
+class Service: public cppu::WeakImplHelper1< css::lang::XMain > {
+public:
+ virtual sal_Int32 SAL_CALL
+ run(css::uno::Sequence< rtl::OUString > const & arguments)
+ throw (css::uno::RuntimeException);
+
+ static rtl::OUString getImplementationName();
+
+ static css::uno::Sequence< rtl::OUString > getSupportedServiceNames();
+
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
+ css::uno::Reference< css::uno::XComponentContext > const & context)
+ throw (css::uno::Exception);
+
+private:
+ explicit Service(
+ css::uno::Reference< css::uno::XComponentContext > const & context):
+ m_context(context)
+ {}
+
+ css::uno::Reference< css::uno::XComponentContext > m_context;
+};
+
+}
+
+namespace {
+
+std::ostream & operator <<(std::ostream & out, rtl::OUString const & value) {
+ return out << rtl::OUStringToOString(value, RTL_TEXTENCODING_UTF8).getStr();
+}
+
+void assertTrue(bool argument) {
+ if (!argument) {
+ std::cerr
+ << "assertTrue(" << argument << ") failed" << std::endl;
+ /*MSVC trouble: std::*/abort();
+ }
+}
+
+void assertFalse(bool argument) {
+ if (argument) {
+ std::cerr
+ << "assertFalse(" << argument << ") failed" << std::endl;
+ /*MSVC trouble: std::*/abort();
+ }
+}
+
+template< typename T > void assertEqual(T const & value, T const & argument) {
+ if (argument != value) {
+ std::cerr
+ << "assertEqual(" << value << ", " << argument << ") failed"
+ << std::endl;
+ /*MSVC trouble: std::*/abort();
+ }
+}
+
+}
+
+sal_Int32 Service::run(css::uno::Sequence< rtl::OUString > const &)
+ throw (css::uno::RuntimeException)
+{
+ css::uno::Reference< css::lang::XMultiComponentFactory > factory(
+ m_context->getServiceManager());
+ assertTrue(factory.is());
+ css::uno::Sequence< css::uno::Any > args(1);
+ args[0] = css::uno::Reference< css::beans::XPropertySet >(
+ factory, css::uno::UNO_QUERY_THROW)->getPropertyValue(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Registry")));
+ css::uno::Reference< css::container::XHierarchicalNameAccess > provider(
+ factory->createInstanceWithArgumentsAndContext(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.stoc.RegistryTypeDescriptionProvider")),
+ args, m_context),
+ css::uno::UNO_QUERY_THROW);
+
+ // The following assumes that interface members are sorted by increasing
+ // values of XInterfaceMemberTypeDescription.getPosition, the exceptions
+ // of interface attributes and interface methods, the constructors of
+ // services, and the exceptions of service constructors are sorted as given
+ // in the UNOIDL source code:
+
+ assertEqual< bool >(
+ false,
+ provider->hasByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("[][]boolean"))));
+ assertEqual< bool >(
+ false,
+ provider->hasByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Struct3<boolean,boolean>"))));
+ assertEqual< bool >(
+ false,
+ provider->hasByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.uno.XComponentContext::getValueByName"))));
+
+ css::uno::Reference< css::reflection::XCompoundTypeDescription > exception;
+ exception
+ = css::uno::Reference< css::reflection::XCompoundTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_EXCEPTION, exception->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception")),
+ exception->getName());
+ assertFalse(exception->getBaseType().is());
+ exception
+ = css::uno::Reference< css::reflection::XCompoundTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.uno.RuntimeException"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_EXCEPTION, exception->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.RuntimeException")),
+ exception->getName());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception")),
+ exception->getBaseType()->getName());
+
+ css::uno::Reference< css::reflection::XStructTypeDescription > structure;
+
+ structure = css::uno::Reference< css::reflection::XStructTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Struct2"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_STRUCT, structure->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Struct2")),
+ structure->getName());
+ assertFalse(structure->getBaseType().is());
+ assertEqual< sal_Int32 >(1, structure->getMemberTypes().getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Struct1")),
+ structure->getMemberTypes()[0]->getName());
+ assertEqual< sal_Int32 >(1, structure->getMemberNames().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("s1")),
+ structure->getMemberNames()[0]);
+ assertEqual< sal_Int32 >(0, structure->getTypeParameters().getLength());
+ assertEqual< sal_Int32 >(0, structure->getTypeArguments().getLength());
+
+ structure = css::uno::Reference< css::reflection::XStructTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Struct3"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_STRUCT, structure->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Struct3")),
+ structure->getName());
+ assertFalse(structure->getBaseType().is());
+ assertEqual< sal_Int32 >(1, structure->getMemberTypes().getLength());
+ assertEqual(
+ css::uno::TypeClass_UNKNOWN,
+ structure->getMemberTypes()[0]->getTypeClass());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("U")),
+ structure->getMemberTypes()[0]->getName());
+ assertEqual< sal_Int32 >(1, structure->getMemberNames().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("s2")),
+ structure->getMemberNames()[0]);
+ assertEqual< sal_Int32 >(2, structure->getTypeParameters().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("T")),
+ structure->getTypeParameters()[0]);
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("U")),
+ structure->getTypeParameters()[1]);
+ assertEqual< sal_Int32 >(0, structure->getTypeArguments().getLength());
+
+ structure = css::uno::Reference< css::reflection::XStructTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Struct4"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_STRUCT, structure->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Struct4")),
+ structure->getName());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Struct2")),
+ structure->getBaseType()->getName());
+ assertEqual< sal_Int32 >(1, structure->getMemberTypes().getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Struct3<"
+ "test.registrytdprovider.Struct2,"
+ "test.registrytdprovider.Struct3<boolean,any>>")),
+ structure->getMemberTypes()[0]->getName());
+ assertEqual< sal_Int32 >(1, structure->getMemberNames().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("s2")),
+ structure->getMemberNames()[0]);
+ assertEqual< sal_Int32 >(0, structure->getTypeParameters().getLength());
+ assertEqual< sal_Int32 >(0, structure->getTypeArguments().getLength());
+
+ css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >
+ interface;
+
+ interface
+ = css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.XTest1"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_INTERFACE, interface->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XTest1")),
+ interface->getName());
+ css::uno::Sequence<
+ css::uno::Reference< css::reflection::XTypeDescription > > bases(
+ interface->getBaseTypes());
+ assertEqual< sal_Int32 >(1, bases.getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface")),
+ bases[0]->getName());
+ css::uno::Sequence<
+ css::uno::Reference< css::reflection::XTypeDescription > >
+ optionalBases(interface->getOptionalBaseTypes());
+ assertEqual< sal_Int32 >(1, optionalBases.getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XBase")),
+ optionalBases[0]->getName());
+ css::uno::Sequence<
+ css::uno::Reference<
+ css::reflection::XInterfaceMemberTypeDescription > > members(
+ interface->getMembers());
+ assertEqual< sal_Int32 >(5, members.getLength());
+
+ css::uno::Reference< css::reflection::XInterfaceAttributeTypeDescription2 >
+ attribute;
+ css::uno::Sequence<
+ css::uno::Reference< css::reflection::XCompoundTypeDescription > >
+ getExceptions;
+ css::uno::Sequence<
+ css::uno::Reference< css::reflection::XCompoundTypeDescription > >
+ setExceptions;
+ css::uno::Reference< css::reflection::XInterfaceMethodTypeDescription >
+ method;
+
+ attribute = css::uno::Reference<
+ css::reflection::XInterfaceAttributeTypeDescription2 >(
+ members[0], css::uno::UNO_QUERY_THROW);
+ assertEqual(
+ css::uno::TypeClass_INTERFACE_ATTRIBUTE, attribute->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XTest1::a1")),
+ attribute->getName());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a1")),
+ attribute->getMemberName());
+ assertEqual< sal_Int32 >(3, attribute->getPosition());
+ assertEqual< bool >(false, attribute->isReadOnly());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("short")),
+ attribute->getType()->getName());
+ assertEqual< bool >(true, attribute->isBound());
+ getExceptions = attribute->getGetExceptions();
+ assertEqual< sal_Int32 >(0, getExceptions.getLength());
+ setExceptions = attribute->getSetExceptions();
+ assertEqual< sal_Int32 >(0, setExceptions.getLength());
+
+ attribute = css::uno::Reference<
+ css::reflection::XInterfaceAttributeTypeDescription2 >(
+ members[1], css::uno::UNO_QUERY_THROW);
+ assertEqual(
+ css::uno::TypeClass_INTERFACE_ATTRIBUTE, attribute->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XTest1::a2")),
+ attribute->getName());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a2")),
+ attribute->getMemberName());
+ assertEqual< sal_Int32 >(4, attribute->getPosition());
+ assertEqual< bool >(false, attribute->isReadOnly());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("long")),
+ attribute->getType()->getName());
+ assertEqual< bool >(false, attribute->isBound());
+ getExceptions = attribute->getGetExceptions();
+ assertEqual< sal_Int32 >(2, getExceptions.getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.lang.WrappedTargetException")),
+ getExceptions[0]->getName());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.RuntimeException")),
+ getExceptions[1]->getName());
+ setExceptions = attribute->getSetExceptions();
+ assertEqual< sal_Int32 >(2, setExceptions.getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception")),
+ setExceptions[0]->getName());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.lang.WrappedTargetException")),
+ setExceptions[1]->getName());
+
+ attribute = css::uno::Reference<
+ css::reflection::XInterfaceAttributeTypeDescription2 >(
+ members[2], css::uno::UNO_QUERY_THROW);
+ assertEqual(
+ css::uno::TypeClass_INTERFACE_ATTRIBUTE, attribute->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XTest1::a3")),
+ attribute->getName());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a3")),
+ attribute->getMemberName());
+ assertEqual< sal_Int32 >(5, attribute->getPosition());
+ assertEqual< bool >(true, attribute->isReadOnly());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("hyper")),
+ attribute->getType()->getName());
+ assertEqual< bool >(true, attribute->isBound());
+ getExceptions = attribute->getGetExceptions();
+ assertEqual< sal_Int32 >(1, getExceptions.getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.lang.WrappedTargetException")),
+ getExceptions[0]->getName());
+ setExceptions = attribute->getSetExceptions();
+ assertEqual< sal_Int32 >(0, setExceptions.getLength());
+
+ method = css::uno::Reference<
+ css::reflection::XInterfaceMethodTypeDescription >(
+ members[3], css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_INTERFACE_METHOD, method->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XTest1::f1")),
+ method->getName());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("f1")),
+ method->getMemberName());
+ assertEqual< sal_Int32 >(6, method->getPosition());
+ assertEqual< bool >(false, method->isOneway());
+ assertEqual< sal_Int32 >(1, method->getParameters().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("p")),
+ method->getParameters()[0]->getName());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")),
+ method->getParameters()[0]->getType()->getName());
+ assertEqual< bool >(false, method->getParameters()[0]->isIn());
+ assertEqual< bool >(true, method->getParameters()[0]->isOut());
+ assertEqual< sal_Int32 >(0, method->getParameters()[0]->getPosition());
+ assertEqual< sal_Int32 >(1, method->getExceptions().getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.RuntimeException")),
+ method->getExceptions()[0]->getName());
+
+ method = css::uno::Reference<
+ css::reflection::XInterfaceMethodTypeDescription >(
+ members[4], css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_INTERFACE_METHOD, method->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XTest1::f2")),
+ method->getName());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("f2")),
+ method->getMemberName());
+ assertEqual< sal_Int32 >(7, method->getPosition());
+ assertEqual< bool >(true, method->isOneway());
+ assertEqual< sal_Int32 >(0, method->getParameters().getLength());
+ assertEqual< sal_Int32 >(0, method->getExceptions().getLength());
+
+ interface
+ = css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.XTest2"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_INTERFACE, interface->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XTest2")),
+ interface->getName());
+ assertEqual< sal_Int32 >(1, interface->getBaseTypes().getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Typedef2")),
+ interface->getBaseTypes()[0]->getName());
+ assertEqual< sal_Int32 >(0, interface->getOptionalBaseTypes().getLength());
+ assertEqual< sal_Int32 >(0, interface->getMembers().getLength());
+
+ css::uno::Reference< css::reflection::XServiceTypeDescription2 > service;
+
+ service = css::uno::Reference< css::reflection::XServiceTypeDescription2 >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Service1"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_SERVICE, service->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Service1")),
+ service->getName());
+ assertEqual< sal_Int32 >(0, service->getMandatoryServices().getLength());
+ assertEqual< sal_Int32 >(0, service->getOptionalServices().getLength());
+ assertEqual< sal_Int32 >(0, service->getMandatoryInterfaces().getLength());
+ assertEqual< sal_Int32 >(0, service->getOptionalInterfaces().getLength());
+ assertEqual< bool >(true, service->isSingleInterfaceBased());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XTest1")),
+ service->getInterface()->getName());
+ assertEqual< sal_Int32 >(2, service->getConstructors().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("c1")),
+ service->getConstructors()[0]->getName());
+ assertEqual< sal_Int32 >(
+ 0, service->getConstructors()[0]->getParameters().getLength());
+ assertEqual< sal_Int32 >(
+ 0, service->getConstructors()[0]->getExceptions().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("c2")),
+ service->getConstructors()[1]->getName());
+ assertEqual< sal_Int32 >(
+ 1, service->getConstructors()[1]->getParameters().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("p")),
+ service->getConstructors()[1]->getParameters()[0]->getName());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")),
+ (service->getConstructors()[1]->getParameters()[0]->getType()->
+ getName()));
+ assertEqual< bool >(
+ true, service->getConstructors()[1]->getParameters()[0]->isIn());
+ assertEqual< bool >(
+ false, service->getConstructors()[1]->getParameters()[0]->isOut());
+ assertEqual< sal_Int32 >(
+ 0, service->getConstructors()[1]->getParameters()[0]->getPosition());
+ assertEqual< bool >(
+ true,
+ service->getConstructors()[1]->getParameters()[0]->isRestParameter());
+ assertEqual< sal_Int32 >(
+ 1, service->getConstructors()[1]->getExceptions().getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.RuntimeException")),
+ service->getConstructors()[1]->getExceptions()[0]->getName());
+
+ service = css::uno::Reference< css::reflection::XServiceTypeDescription2 >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Service2"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_SERVICE, service->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Service2")),
+ service->getName());
+ assertEqual< sal_Int32 >(0, service->getMandatoryServices().getLength());
+ assertEqual< sal_Int32 >(0, service->getOptionalServices().getLength());
+ assertEqual< sal_Int32 >(1, service->getMandatoryInterfaces().getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XTest1")),
+ service->getMandatoryInterfaces()[0]->getName());
+ assertEqual< sal_Int32 >(1, service->getOptionalInterfaces().getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XBase")),
+ service->getOptionalInterfaces()[0]->getName());
+ assertEqual< bool >(false, service->isSingleInterfaceBased());
+ assertFalse(service->getInterface().is());
+ assertEqual< sal_Int32 >(0, service->getConstructors().getLength());
+
+ service = css::uno::Reference< css::reflection::XServiceTypeDescription2 >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Service3"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_SERVICE, service->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Service3")),
+ service->getName());
+ assertEqual< sal_Int32 >(0, service->getMandatoryServices().getLength());
+ assertEqual< sal_Int32 >(0, service->getOptionalServices().getLength());
+ assertEqual< sal_Int32 >(0, service->getMandatoryInterfaces().getLength());
+ assertEqual< sal_Int32 >(0, service->getOptionalInterfaces().getLength());
+ assertEqual< bool >(true, service->isSingleInterfaceBased());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Typedef2")),
+ service->getInterface()->getName());
+ assertEqual< sal_Int32 >(0, service->getConstructors().getLength());
+
+ css::uno::Reference< css::reflection::XSingletonTypeDescription2 >
+ singleton;
+
+ singleton = css::uno::Reference<
+ css::reflection::XSingletonTypeDescription2 >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Singleton1"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_SINGLETON, singleton->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Singleton1")),
+ singleton->getName());
+ assertFalse(singleton->getService().is());
+ assertEqual< bool >(true, singleton->isInterfaceBased());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.XTest1")),
+ singleton->getInterface()->getName());
+
+ singleton = css::uno::Reference<
+ css::reflection::XSingletonTypeDescription2 >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Singleton2"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_SINGLETON, singleton->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Singleton2")),
+ singleton->getName());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Service1")),
+ singleton->getService()->getName());
+ assertEqual< bool >(false, singleton->isInterfaceBased());
+ assertFalse(singleton->getInterface().is());
+
+ singleton = css::uno::Reference<
+ css::reflection::XSingletonTypeDescription2 >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Singleton3"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_SINGLETON, singleton->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Singleton3")),
+ singleton->getName());
+ assertFalse(singleton->getService().is());
+ assertEqual< bool >(true, singleton->isInterfaceBased());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider.Typedef2")),
+ singleton->getInterface()->getName());
+
+ css::uno::Reference< css::reflection::XPublished > published;
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Enum1"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertTrue(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Enum2"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertFalse(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Struct1"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertTrue(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Struct2"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertFalse(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Struct3"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertTrue(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XStructTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Struct3"))),
+ css::uno::UNO_QUERY_THROW)->getMemberTypes()[0],
+ css::uno::UNO_QUERY);
+ assertFalse(published.is());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Struct3a"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertFalse(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Exception1"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertTrue(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Exception2"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertFalse(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.XTest1"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertTrue(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.XTest2"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertFalse(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Typedef1"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertTrue(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Typedef2"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertFalse(published->isPublished());
+ //TODO: check constants test.registrytdprovider.Const1 (published),
+ // test.registrytdprovider.Const2 (unpublished), and
+ // test.registrytdprovider.Consts1.C (no XPublished), which are not
+ // accessible via provider->getByHierarchicalName (see #i31428)
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Consts1"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertTrue(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Consts2"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertFalse(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("test.registrytdprovider"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertFalse(published.is());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Service1"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertTrue(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Service2"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertFalse(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Singleton2"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertTrue(published->isPublished());
+ published = css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ provider->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.registrytdprovider.Singleton1"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY);
+ assertTrue(published.is());
+ assertFalse(published->isPublished());
+
+ return 0;
+}
+
+rtl::OUString Service::getImplementationName() {
+ return rtl::OUString::createFromAscii("test.registrytdprovider.impl");
+}
+
+css::uno::Sequence< rtl::OUString > Service::getSupportedServiceNames() {
+ return css::uno::Sequence< rtl::OUString >();
+}
+
+css::uno::Reference< css::uno::XInterface > Service::createInstance(
+ css::uno::Reference< css::uno::XComponentContext > const & context)
+ throw (css::uno::Exception)
+{
+ return static_cast< cppu::OWeakObject * >(new Service(context));
+}
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ char const ** envTypeName, uno_Environment **)
+{
+ if (envTypeName != 0) {
+ *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+}
+
+extern "C" void * SAL_CALL component_getFactory(char const * implName,
+ void * serviceManager, void *) {
+ void * p = 0;
+ if (serviceManager != 0) {
+ css::uno::Reference< css::lang::XSingleComponentFactory > f;
+ if (Service::getImplementationName().equalsAscii(implName)) {
+ f = cppu::createSingleComponentFactory(
+ &Service::createInstance, Service::getImplementationName(),
+ Service::getSupportedServiceNames());
+ }
+ if (f.is()) {
+ f->acquire();
+ p = f.get();
+ }
+ }
+ return p;
+}
+
+namespace {
+
+bool writeInfo(void * registryKey, rtl::OUString const & implementationName,
+ css::uno::Sequence< rtl::OUString > const & serviceNames) {
+ rtl::OUString keyName(rtl::OUString::createFromAscii("/"));
+ keyName += implementationName;
+ keyName += rtl::OUString::createFromAscii("/UNO/SERVICES");
+ css::uno::Reference< css::registry::XRegistryKey > key;
+ try {
+ key = static_cast< css::registry::XRegistryKey * >(registryKey)->
+ createKey(keyName);
+ } catch (css::registry::InvalidRegistryException &) {}
+ if (!key.is()) {
+ return false;
+ }
+ bool success = true;
+ for (sal_Int32 i = 0; i < serviceNames.getLength(); ++i) {
+ try {
+ key->createKey(serviceNames[i]);
+ } catch (css::registry::InvalidRegistryException &) {
+ success = false;
+ break;
+ }
+ }
+ return success;
+}
+
+}
+
+extern "C" sal_Bool SAL_CALL component_writeInfo(void *, void * registryKey) {
+ return registryKey
+ && writeInfo(registryKey, Service::getImplementationName(),
+ Service::getSupportedServiceNames());
+}
diff --git a/stoc/test/registry_tdprovider/types.idl b/stoc/test/registry_tdprovider/types.idl
new file mode 100644
index 000000000000..636b272226be
--- /dev/null
+++ b/stoc/test/registry_tdprovider/types.idl
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "com/sun/star/lang/WrappedTargetException.idl"
+#include "com/sun/star/uno/Exception.idl"
+#include "com/sun/star/uno/RuntimeException.idl"
+#include "com/sun/star/uno/XInterface.idl"
+
+module test { module registrytdprovider {
+
+published enum Enum1 { E1 };
+
+enum Enum2 { E1 };
+
+published struct Struct1 { long s1; };
+
+struct Struct2 { Struct1 s1; };
+
+published struct Struct3<T, U> { U s2; };
+
+struct Struct3a<T, U> { U s2; };
+
+struct Struct4: Struct2 { Struct3< Struct2, Struct3< boolean, any > > s2; };
+
+published exception Exception1: com::sun::star::uno::Exception {};
+
+exception Exception2: com::sun::star::uno::Exception {};
+
+published interface XBase {};
+
+published typedef XBase Typedef1;
+
+typedef Typedef1 Typedef2;
+
+published interface XTest1 {
+ [optional] interface XBase;
+
+ void f1([out] any p) raises (com::sun::star::uno::RuntimeException);
+
+ [oneway] void f2();
+
+ [attribute, bound] short a1;
+
+ [attribute] long a2 {
+ get raises
+ (com::sun::star::lang::WrappedTargetException,
+ com::sun::star::uno::RuntimeException);
+ set raises
+ (com::sun::star::uno::Exception,
+ com::sun::star::lang::WrappedTargetException);
+ };
+
+ [attribute, readonly, bound] hyper a3 {
+ get raises (com::sun::star::lang::WrappedTargetException);
+ };
+};
+
+interface XTest2: Typedef2 {};
+
+published service Service1: XTest1 {
+ c1();
+
+ c2([in] any... p) raises (com::sun::star::uno::RuntimeException);
+};
+
+service Service2 {
+ [optional] interface XBase;
+
+ interface XTest1;
+};
+
+service Service3: Typedef2 {};
+
+singleton Singleton1: XTest1;
+
+published singleton Singleton2 { service Service1; };
+
+singleton Singleton3: Typedef2;
+
+published const long Const1 = 0;
+
+const long Const2 = 0;
+
+published constants Consts1 { const long C = 0; };
+
+constants Consts2 { const long C = 0; };
+
+}; };
diff --git a/stoc/test/security/makefile.mk b/stoc/test/security/makefile.mk
new file mode 100644
index 000000000000..8acd2c2903d0
--- /dev/null
+++ b/stoc/test/security/makefile.mk
@@ -0,0 +1,59 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=stoc
+TARGET=test_security
+TARGETTYPE=CUI
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Application 1 ------------------------------------------------
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/test_security.obj
+
+APP1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS+=
+# $(LIBCIMT) $(LIBCMT)
+.ENDIF
+
+
+# --- Target ------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/stoc/test/security/test_security.cxx b/stoc/test/security/test_security.cxx
new file mode 100644
index 000000000000..3678ed2b7c65
--- /dev/null
+++ b/stoc/test/security/test_security.cxx
@@ -0,0 +1,523 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include <stdio.h>
+
+#include <sal/main.h>
+#include <osl/diagnose.h>
+#include <osl/socket.hxx>
+#include <rtl/string.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <uno/current_context.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <cppuhelper/access_control.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/uno/XCurrentContext.hpp>
+
+#include <com/sun/star/io/FilePermission.hpp>
+
+#define USER_CREDS "access-control.user-credentials"
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+
+
+using namespace ::osl;
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+//--------------------------------------------------------------------------------------------------
+static OUString localhost( OUString const & addition ) SAL_THROW( () )
+{
+ static OUString ip;
+ if (! ip.getLength())
+ {
+ // dns lookup
+ SocketAddr addr;
+ SocketAddr::resolveHostname( OUSTR("localhost"), addr );
+ ::oslSocketResult rc = ::osl_getDottedInetAddrOfSocketAddr( addr.getHandle(), &ip.pData );
+ if (::osl_Socket_Ok != rc)
+ fprintf(stdout, "### cannot resolve localhost!" );
+ }
+ OUStringBuffer buf( 48 );
+ buf.append( ip );
+ buf.append( addition );
+ return buf.makeStringAndClear();
+}
+
+//--------------------------------------------------------------------------------------------------
+static inline void dispose( Reference< XInterface > const & x )
+ SAL_THROW( (RuntimeException) )
+{
+ Reference< lang::XComponent > xComp( x, UNO_QUERY );
+ if (xComp.is())
+ {
+ xComp->dispose();
+ }
+}
+//==================================================================================================
+class user_CurrentContext
+ : public ImplHelper1< XCurrentContext >
+{
+ oslInterlockedCount m_refcount;
+
+ Reference< XCurrentContext > m_xDelegate;
+ Any m_userId;
+
+public:
+ inline user_CurrentContext(
+ Reference< XCurrentContext > const & xDelegate,
+ OUString const & userId )
+ SAL_THROW( () )
+ : m_refcount( 0 )
+ , m_xDelegate( xDelegate )
+ , m_userId( makeAny( userId ) )
+ {}
+
+ // XInterface impl
+ virtual void SAL_CALL acquire()
+ throw ();
+ virtual void SAL_CALL release()
+ throw ();
+
+ // XCurrentContext impl
+ virtual Any SAL_CALL getValueByName( OUString const & name )
+ throw (RuntimeException);
+};
+//__________________________________________________________________________________________________
+void user_CurrentContext::acquire()
+ throw ()
+{
+ ::osl_incrementInterlockedCount( &m_refcount );
+}
+//__________________________________________________________________________________________________
+void user_CurrentContext::release()
+ throw ()
+{
+ if (! ::osl_decrementInterlockedCount( &m_refcount ))
+ {
+ delete this;
+ }
+}
+//__________________________________________________________________________________________________
+Any user_CurrentContext::getValueByName( OUString const & name )
+ throw (RuntimeException)
+{
+ if (name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(USER_CREDS ".id") ))
+ {
+ return m_userId;
+ }
+ else if (m_xDelegate.is())
+ {
+ return m_xDelegate->getValueByName( name );
+ }
+ else
+ {
+ return Any();
+ }
+}
+
+// prepends line number
+#define CHECK( check, negative_test ) \
+{ \
+ try \
+ { \
+ if (negative_test) \
+ { \
+ bool thrown = true; \
+ try \
+ { \
+ check; \
+ thrown = false; \
+ } \
+ catch (RuntimeException &) \
+ { \
+ } \
+ if (! thrown) \
+ { \
+ throw RuntimeException( \
+ OUSTR("expected RuntimeException upon check!"), Reference< XInterface >() ); \
+ } \
+ } \
+ else \
+ { \
+ check; \
+ } \
+ } \
+ catch (RuntimeException & exc) \
+ { \
+ OUStringBuffer buf( 64 ); \
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[line ") ); \
+ buf.append( (sal_Int32)__LINE__ ); \
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] ") ); \
+ buf.append( exc.Message ); \
+ throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface >() ); \
+ } \
+}
+
+/*
+grant
+{
+permission com.sun.star.io.FilePermission "file:///usr/bin/ *", "read";
+permission com.sun.star.io.FilePermission "file:///tmp/-", "read,write";
+permission com.sun.star.io.FilePermission "file:///etc/profile", "read";
+
+permission com.sun.star.security.RuntimePermission "DEF";
+
+permission com.sun.star.connection.SocketPermission "127.0.0.1:-1023", "resolve, connect, listen";
+permission com.sun.star.connection.SocketPermission "localhost:1024-", "accept, connect, listen, resolve,";
+permission com.sun.star.connection.SocketPermission "*.sun.com:1024-", "resolve";
+};
+*/
+static void check_defaults_pos( AccessControl & ac, bool invert = false )
+{
+ // positive tests
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/bin/bla"), OUSTR("read") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///tmp/bla"), OUSTR("read,write") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///tmp/path/path/bla"), OUSTR("write") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///etc/profile"), OUSTR("read") ), invert );
+ CHECK( ac.checkRuntimePermission( OUSTR("DEF") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("localhost:1024"), OUSTR("connect") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("localhost:65535"), OUSTR("resolve") ), invert );
+ CHECK( ac.checkSocketPermission( localhost(OUSTR(":2048")), OUSTR("accept,listen") ), invert );
+ CHECK( ac.checkSocketPermission( localhost(OUSTR(":1024-")), OUSTR("accept,connect,listen,resolve") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("localhost:-1023"), OUSTR("resolve,listen,connect") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("jl-1036.germany.sun.com:1024-"), OUSTR("resolve") ), invert );
+}
+static void check_defaults_neg( AccessControl & ac, bool invert = false )
+{
+ // negative tests
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/tmp"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/bin"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/bin/bla"), OUSTR("write") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/bin/bla"), OUSTR("execute") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/bin/path/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///tmp"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///tmp/"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///tm"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///etc/profile"), OUSTR("write") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///etc/profile/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///etc/blabla"), OUSTR("read,write,execute") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/root"), OUSTR("read,write,execute") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///root"), OUSTR("read,write,execute") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///root"), OUSTR("delete") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///root"), OUString() ), !invert );
+ CHECK( ac.checkRuntimePermission( OUSTR("ROOT") ), !invert );
+ CHECK( ac.checkSocketPermission( OUSTR("localhost:1023"), OUSTR("accept") ), !invert );
+ CHECK( ac.checkSocketPermission( OUSTR("localhost:123-"), OUSTR("accept") ), !invert );
+ CHECK( ac.checkSocketPermission( localhost(OUSTR(":-1023")), OUSTR("accept") ), !invert );
+ CHECK( ac.checkSocketPermission( OUSTR("localhost:-1023"), OUSTR("accept,resolve") ), !invert );
+ CHECK( ac.checkSocketPermission( OUSTR("sun.com:1024-"), OUSTR("resolve") ), !invert );
+}
+
+/*
+grant user "dbo"
+{
+permission com.sun.star.io.FilePermission "file:///home/dbo/-", "read,write";
+permission com.sun.star.io.FilePermission "-", "read,write";
+permission com.sun.star.io.FilePermission "file:///usr/local/dbo/ *", "read";
+
+permission com.sun.star.security.RuntimePermission "DBO";
+
+permission com.sun.star.connection.SocketPermission "dbo-1:1024-", "listen";
+permission com.sun.star.connection.SocketPermission "dbo-11081:-1023", "resolve";
+permission com.sun.star.connection.SocketPermission "dbo-11081:18", "listen";
+permission com.sun.star.connection.SocketPermission "dbo-11081:20-24", "listen";
+permission com.sun.star.connection.SocketPermission "dbo-11081", "connect";
+};
+*/
+static void check_dbo_pos( AccessControl & ac, bool invert = false )
+{
+ check_defaults_pos( ac, invert );
+ // positive tests
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("write") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read,write") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/path/bla"), OUSTR("read,write") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/path/path/bla"), OUSTR("read,write") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/*"), OUSTR("read") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/bla"), OUSTR("read") ), invert );
+ CHECK( ac.checkRuntimePermission( OUSTR("DBO") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-1:1024-"), OUSTR("listen") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-1:2048-3122"), OUSTR("listen") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-1:2048-"), OUSTR("listen") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:-1023"), OUSTR("resolve") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:20-1023"), OUSTR("resolve") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:18"), OUSTR("listen") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:20-24"), OUSTR("listen") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:22"), OUSTR("listen") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081"), OUSTR("connect") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:22"), OUSTR("connect") ), invert );
+}
+static void check_dbo_neg( AccessControl & ac, bool invert = false )
+{
+ check_defaults_neg( ac, invert );
+ // negative tests
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/-"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("write") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("read,write") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/path/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/path/path/bla"), OUSTR("read,execute") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/-"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/path/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/path/path/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkRuntimePermission( OUSTR("JBU") ), !invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081"), OUSTR("listen") ), !invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:22"), OUSTR("accept") ), !invert );
+ CHECK( ac.checkSocketPermission( OUSTR("jbu-11096:22"), OUSTR("resolve") ), !invert );
+}
+
+/*
+grant user "jbu"
+{
+permission com.sun.star.io.FilePermission "file:///home/jbu/-", "read,write";
+permission com.sun.star.io.FilePermission "*", "read,write";
+
+permission com.sun.star.security.RuntimePermission "JBU";
+
+permission com.sun.star.connection.SocketPermission "jbu-11096","resolve";
+};
+*/
+static void check_jbu_pos( AccessControl & ac, bool invert = false )
+{
+ check_defaults_pos( ac, invert );
+ // positive tests
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("read") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("write") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("read,write") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/path/bla"), OUSTR("read,write") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/path/path/bla"), OUSTR("read,write") ), invert );
+ CHECK( ac.checkRuntimePermission( OUSTR("JBU") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("jbu-11096"), OUSTR("resolve") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("jbu-11096:20-24"), OUSTR("resolve") ), invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081.germany.sun.com:2048"), OUSTR("resolve") ), invert );
+}
+static void check_jbu_neg( AccessControl & ac, bool invert = false )
+{
+ check_defaults_neg( ac, invert );
+ // negative tests
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/-"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/path/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/path/path/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("write") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read,write") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/-"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/path/path/bla"), OUSTR("read") ), !invert );
+ CHECK( ac.checkRuntimePermission( OUSTR("DBO") ), !invert );
+ CHECK( ac.checkSocketPermission( OUSTR("jbu-11096:20-24"), OUSTR("accept") ), !invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081"), OUSTR("connect") ), !invert );
+ CHECK( ac.checkSocketPermission( OUSTR("dbo-11081.germany.sun.com"), OUSTR("connect") ), !invert );
+}
+
+/*
+grant principal "root"
+{
+permission com.sun.star.security.AllPermission;
+};
+*/
+//==================================================================================================
+static void check_root_pos( AccessControl & ac, bool invert = false )
+{
+ check_defaults_pos( ac, invert );
+ check_defaults_neg( ac, !invert );
+ check_dbo_pos( ac, invert );
+ check_dbo_neg( ac, !invert );
+ check_jbu_pos( ac, invert );
+ check_jbu_neg( ac, !invert );
+ // some more root positive
+ CHECK( ac.checkFilePermission( OUSTR("file:///etc/blabla"), OUSTR("read,write,execute") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///home/root"), OUSTR("read,write,execute") ), invert );
+ CHECK( ac.checkFilePermission( OUSTR("file:///root"), OUSTR("read,write,execute") ), invert );
+ CHECK( ac.checkRuntimePermission( OUSTR("ROOT") ), invert );
+}
+
+//==================================================================================================
+class acc_Restr
+ : public WeakImplHelper1< security::XAccessControlContext >
+{
+ Any m_perm;
+
+public:
+ inline acc_Restr( Any const & perm = Any() ) SAL_THROW( () )
+ : m_perm( perm )
+ {}
+
+ // XAccessControlContext impl
+ virtual void SAL_CALL checkPermission( Any const & perm )
+ throw (RuntimeException);
+};
+//__________________________________________________________________________________________________
+void acc_Restr::checkPermission( Any const & perm )
+ throw (RuntimeException)
+{
+ if (perm != m_perm)
+ {
+ throw security::AccessControlException(
+ OUSTR("dyn violation!"), Reference< XInterface >(), perm );
+ }
+}
+
+typedef void (* t_action)( AccessControl &, Any const & arg );
+
+//==================================================================================================
+class Action
+ : public WeakImplHelper1< security::XAction >
+{
+ t_action m_action;
+ AccessControl & m_ac;
+ Any m_arg;
+
+public:
+ inline Action( t_action action, AccessControl & ac, Any const & arg = Any() ) SAL_THROW( () )
+ : m_action( action )
+ , m_ac( ac )
+ , m_arg( arg )
+ {}
+
+ // XAction impl
+ virtual Any SAL_CALL run()
+ throw (Exception);
+};
+//__________________________________________________________________________________________________
+Any Action::run()
+ throw (Exception)
+{
+ (*m_action)( m_ac, m_arg );
+ return Any();
+}
+
+//==================================================================================================
+// static void restr_file_permissions( AccessControl & ac )
+// {
+// // running in dbo's domain
+// /* permission com.sun.star.io.FilePermission "file:///home/dbo/-", ",,read , write "; */
+// CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read,write,execute") ), true );
+// CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read,write") ), false );
+// }
+//==================================================================================================
+static void all_dbo_permissions( AccessControl & ac, Any const & )
+{
+ check_dbo_pos( ac );
+ check_dbo_neg( ac );
+}
+//==================================================================================================
+static void no_permissions( AccessControl & ac, Any const & arg )
+{
+ check_dbo_pos( ac, true );
+ check_dbo_neg( ac );
+ // set privs to old dbo restr
+ Reference< security::XAccessControlContext > xContext;
+ OSL_VERIFY( arg >>= xContext );
+ ac->doPrivileged(
+ new Action( all_dbo_permissions, ac ),
+ xContext );
+}
+//==================================================================================================
+static void check_dbo_dynamic( AccessControl & ac )
+{
+ Any arg( makeAny( ac->getContext() ) );
+ ac->doRestricted(
+ new Action( no_permissions, ac, arg ),
+ new acc_Restr() );
+}
+
+SAL_IMPLEMENT_MAIN()
+{
+ try
+ {
+ // single-user test
+ Reference< XComponentContext > xContext( defaultBootstrap_InitialComponentContext(
+ OUSTR("../../test/security/test_security_singleuser.ini") ) );
+ {
+ ::fprintf( stderr, "[security test] single-user checking dbo..." );
+ AccessControl ac( xContext );
+ check_dbo_pos( ac );
+ check_dbo_neg( ac );
+ check_dbo_dynamic( ac );
+ ::fprintf( stderr, "dbo checked.\n" );
+ }
+
+ // multi-user test
+ dispose( xContext );
+ xContext = defaultBootstrap_InitialComponentContext(
+ OUSTR("../../test/security/test_security.ini") ); // UNO_AC=on
+ AccessControl ac( xContext );
+
+ {
+ // set up dbo current context
+ ContextLayer layer( new user_CurrentContext( getCurrentContext(), OUSTR("dbo") ) );
+ ::fprintf( stderr, "[security test] multi-user checking dbo..." );
+ check_dbo_pos( ac );
+ check_dbo_neg( ac );
+ check_dbo_dynamic( ac );
+ ::fprintf( stderr, "dbo checked.\n" );
+ }
+ {
+ // set up jbu current context
+ ContextLayer layer( new user_CurrentContext( getCurrentContext(), OUSTR("jbu") ) );
+ ::fprintf( stderr, "[security test] multi-user checking jbu..." );
+ check_jbu_pos( ac );
+ check_jbu_neg( ac );
+ ::fprintf( stderr, "jbu checked.\n" );
+ }
+ {
+ // set up root current context
+ ContextLayer layer( new user_CurrentContext( getCurrentContext(), OUSTR("root") ) );
+ ::fprintf( stderr, "[security test] multi-user checking root..." );
+ check_root_pos( ac );
+ ::fprintf( stderr, "root checked.\n" );
+ }
+ {
+ // set up unknown guest user current context => default permissions
+ ContextLayer layer( new user_CurrentContext( getCurrentContext(), OUSTR("guest") ) );
+ ::fprintf( stderr, "[security test] multi-user checking guest..." );
+ check_defaults_pos( ac );
+ check_defaults_neg( ac );
+ ::fprintf( stderr, "guest checked.\n" );
+ }
+
+ dispose( xContext );
+ ::fprintf( stderr, "security test succeeded.\n" );
+ return 0;
+ }
+ catch (Exception & exc)
+ {
+ OString str( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ ::fprintf( stderr, "[security test] error: %s!\n", str.getStr() );
+ return 1;
+ }
+}
diff --git a/stoc/test/security/test_security.ini b/stoc/test/security/test_security.ini
new file mode 100644
index 000000000000..d751bb615164
--- /dev/null
+++ b/stoc/test/security/test_security.ini
@@ -0,0 +1,6 @@
+UNO_TYPES=stoctest.rdb
+UNO_SERVICES=stoctest.rdb
+UNO_WRITERDB=stoctest.rdb
+UNO_AC=on
+UNO_AC_POLICYFILE=../../test/security/test_security.policy
+UNO_AC_USERCACHE_SIZE=2
diff --git a/stoc/test/security/test_security.policy b/stoc/test/security/test_security.policy
new file mode 100644
index 000000000000..93c2571f7122
--- /dev/null
+++ b/stoc/test/security/test_security.policy
@@ -0,0 +1,37 @@
+/** dbo
+ permissions
+*/
+grant user "dbo"{
+ permission com.sun.star.io.FilePermission "file:///home/dbo/-", ",,read , write ";
+ permission com.sun.star.io.FilePermission "-", "read ,write";
+ permission com.sun.star.connection.SocketPermission "dbo-1:1024-", "listen";
+ permission com.sun.star.security.RuntimePermission "DBO";
+ permission com.sun.star.connection.SocketPermission "dbo-11081:-1023", "resolve";
+ permission com.sun.star.connection.SocketPermission "dbo-11081:18", "listen";
+ permission com.sun.star.connection.SocketPermission "dbo-11081:20-24", "listen";
+ permission com.sun.star.connection.SocketPermission "dbo-11081", "connect";
+ permission com.sun.star.io.FilePermission "file:///usr/local/dbo/*" , "read ";};
+grant user "jbu" {
+permission com.sun.star.security.RuntimePermission "JBU";
+permission com.sun.star.io.FilePermission "file:///home/jbu/-" ,"read,write,";
+/*jbu resolve*/permission com.sun.star.connection.SocketPermission "jbu-11096","resolve";
+ permission com.sun.star.io.FilePermission "*",",read,write";}; grant user "root"{permission com.sun.star.security.AllPermission;};
+
+// granted to anyone
+ grant
+{
+ // read out this file
+ permission com.sun.star.io.FilePermission "../../test/security/test_security.policy",
+ "read";
+
+ permission com.sun.star.security.RuntimePermission "DEF";
+ permission com.sun.star.io.FilePermission "file:///usr/bin/*", "read";
+ permission com.sun.star.io.FilePermission "file:///usr/bin/*", "read";
+ permission com.sun.star.io.FilePermission "file:///tmp/-", "read, write";
+ permission com.sun.star.io.FilePermission "file:///etc/profile", "read,,";
+ permission com.sun.star.connection.SocketPermission "127.0.0.1:-1023", "resolve, connect, listen";
+ permission com.sun.star.connection.SocketPermission "localhost:1024-", "accept, connect, listen, resolve,";
+ permission com.sun.star.connection.SocketPermission "*.sun.com:1024-", "resolve";
+ } ;
+
+# eof \ No newline at end of file
diff --git a/stoc/test/security/test_security_singleuser.ini b/stoc/test/security/test_security_singleuser.ini
new file mode 100644
index 000000000000..243c45d997f5
--- /dev/null
+++ b/stoc/test/security/test_security_singleuser.ini
@@ -0,0 +1,6 @@
+UNO_TYPES=stoctest.rdb
+UNO_SERVICES=stoctest.rdb
+UNO_WRITERDB=stoctest.rdb
+UNO_AC=single-user
+UNO_AC_SINGLEUSER=dbo
+UNO_AC_POLICYFILE=../../test/security/test_security.policy
diff --git a/stoc/test/tdmanager/makefile.mk b/stoc/test/tdmanager/makefile.mk
new file mode 100644
index 000000000000..8f39ac552038
--- /dev/null
+++ b/stoc/test/tdmanager/makefile.mk
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ := ..$/..
+PRJNAME := stoc
+
+TARGET := test_tdmanager
+
+ENABLE_EXCEPTIONS := TRUE
+
+.INCLUDE: settings.mk
+
+DLLPRE = # no leading "lib" on .so files
+
+SLOFILES = $(SLO)$/testtdmanager.obj
+
+SHL1TARGET = testtdmanager.uno
+SHL1OBJS = $(SLOFILES)
+SHL1VERSIONMAP = $(SOLARENV)/src/component.map
+SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB)
+SHL1IMPLIB = itesttdmanager
+DEF1NAME = $(SHL1TARGET)
+
+.INCLUDE: target.mk
+
+ALLTAR: test
+
+$(MISC)$/$(TARGET)$/%.rdb : %.idl
+ - rm $@
+ - $(MKDIR) $(MISC)$/$(TARGET)
+ idlc -O$(MISC)$/$(TARGET) -I$(SOLARIDLDIR) -C -cid -we $<
+ regmerge $@ /UCR $(subst,.rdb,.urd $@)
+
+IDL_FILES = \
+ types.idl \
+ types2_incomp.idl \
+ types3_incomp.idl \
+ types4_incomp.idl \
+ types5_incomp.idl \
+ types5.idl \
+ types6_incomp.idl
+
+RDB_FILES = $(foreach,i,$(subst,.idl,.rdb $(IDL_FILES)) $(MISC)$/$(TARGET)$/$i)
+
+$(SLOFILES): $(RDB_FILES)
+
+test .PHONY: $(SHL1TARGETN) $(RDB_FILES)
+ uno -c test.tdmanager.impl -l $(subst,$/,/ $(SHL1TARGETN)) \
+ -ro $(subst,$/,/ $(SOLARBINDIR)$/udkapi_doc.rdb) \
+ -- $(subst,$/,/ $(SOLARBINDIR)$/types_doc.rdb) \
+ $(subst,$/,/ $(RDB_FILES))
diff --git a/stoc/test/tdmanager/readme.txt b/stoc/test/tdmanager/readme.txt
new file mode 100644
index 000000000000..f4977204960f
--- /dev/null
+++ b/stoc/test/tdmanager/readme.txt
@@ -0,0 +1,4 @@
+This test uses the delivered typemgr.uno dynamic library, not the local one.
+(It might work to fix this, changing the test from a UNO component started from
+the uno executable to a stand-alone application that bootstraps UNO in a special
+way.)
diff --git a/stoc/test/tdmanager/testtdmanager.cxx b/stoc/test/tdmanager/testtdmanager.cxx
new file mode 100644
index 000000000000..53b793c8fbe4
--- /dev/null
+++ b/stoc/test/tdmanager/testtdmanager.cxx
@@ -0,0 +1,374 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
+#include "com/sun/star/container/XSet.hpp"
+#include "com/sun/star/lang/XMain.hpp"
+#include "com/sun/star/lang/XSingleComponentFactory.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/reflection/XIndirectTypeDescription.hpp"
+#include "com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp"
+#include "com/sun/star/reflection/XPublished.hpp"
+#include "com/sun/star/reflection/XStructTypeDescription.hpp"
+#include "com/sun/star/reflection/XTypeDescription.hpp"
+#include "com/sun/star/registry/InvalidRegistryException.hpp"
+#include "com/sun/star/registry/XRegistryKey.hpp"
+#include "com/sun/star/registry/XSimpleRegistry.hpp"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/TypeClass.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "cppuhelper/weak.hxx"
+#include "osl/file.h"
+#include "osl/thread.h"
+#include "rtl/textenc.h"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "uno/environment.h"
+#include "uno/lbnames.h"
+
+#include /*MSVC trouble: <cstdlib>*/ <stdlib.h>
+#include <iostream>
+#include <ostream>
+
+namespace css = com::sun::star;
+
+namespace {
+
+class Service: public cppu::WeakImplHelper1< css::lang::XMain > {
+public:
+ virtual sal_Int32 SAL_CALL
+ run(css::uno::Sequence< rtl::OUString > const & arguments)
+ throw (css::uno::RuntimeException);
+
+ static rtl::OUString getImplementationName();
+
+ static css::uno::Sequence< rtl::OUString > getSupportedServiceNames();
+
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
+ css::uno::Reference< css::uno::XComponentContext > const & context)
+ throw (css::uno::Exception);
+
+private:
+ explicit Service(
+ css::uno::Reference< css::uno::XComponentContext > const & context):
+ m_context(context)
+ {}
+
+ css::uno::Reference< css::uno::XComponentContext > m_context;
+};
+
+}
+
+namespace {
+
+std::ostream & operator <<(std::ostream & out, rtl::OUString const & value) {
+ return out << rtl::OUStringToOString(value, RTL_TEXTENCODING_UTF8).getStr();
+}
+
+void assertTrue(bool argument) {
+ if (!argument) {
+ std::cerr
+ << "assertTrue(" << argument << ") failed" << std::endl;
+ /*MSVC trouble: std::*/abort();
+ }
+}
+
+void assertFalse(bool argument) {
+ if (argument) {
+ std::cerr
+ << "assertFalse(" << argument << ") failed" << std::endl;
+ /*MSVC trouble: std::*/abort();
+ }
+}
+
+template< typename T > void assertEqual(T const & value, T const & argument) {
+ if (argument != value) {
+ std::cerr
+ << "assertEqual(" << value << ", " << argument << ") failed"
+ << std::endl;
+ /*MSVC trouble: std::*/abort();
+ }
+}
+
+}
+
+sal_Int32 Service::run(css::uno::Sequence< rtl::OUString > const & arguments)
+ throw (css::uno::RuntimeException)
+{
+ css::uno::Reference< css::lang::XMultiComponentFactory > factory(
+ m_context->getServiceManager());
+ assertTrue(factory.is());
+ css::uno::Reference< css::container::XHierarchicalNameAccess > manager(
+ m_context->getValueByName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "/singletons/"
+ "com.sun.star.reflection.theTypeDescriptionManager"))),
+ css::uno::UNO_QUERY_THROW);
+
+ ////////////////////////////////////////
+ // test: add cmd line rdbs to manager
+ ////////////////////////////////////////
+
+ OSL_ASSERT( arguments.getLength() > 0 );
+ css::uno::Reference<css::container::XSet> xSet(
+ manager, css::uno::UNO_QUERY_THROW );
+ for ( sal_Int32 argPos = 0; argPos < arguments.getLength(); ++argPos ) {
+ rtl::OUString url;
+ OSL_VERIFY( osl_File_E_None == osl_getFileURLFromSystemPath(
+ arguments[argPos].pData, &url.pData ) );
+ bool supposedToBeCompatible = ! url.endsWithIgnoreAsciiCaseAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("_incomp.rdb") );
+
+ css::uno::Reference<css::registry::XSimpleRegistry> xReg(
+ m_context->getServiceManager()->createInstanceWithContext(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.registry.SimpleRegistry") ),
+ m_context ), css::uno::UNO_QUERY_THROW );
+ xReg->open( url, true /* read-only */, false /* ! create */ );
+ css::uno::Any arg( css::uno::makeAny(xReg) );
+ css::uno::Reference<css::container::XHierarchicalNameAccess> xTDprov(
+ m_context->getServiceManager()->
+ createInstanceWithArgumentsAndContext(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.comp.stoc."
+ "RegistryTypeDescriptionProvider") ),
+ css::uno::Sequence<css::uno::Any>( &arg, 1 ), m_context ),
+ css::uno::UNO_QUERY_THROW );
+ try {
+ xSet->insert( css::uno::makeAny(xTDprov) );
+ if (! supposedToBeCompatible)
+ std::cerr << "current rdb file: " <<
+ rtl::OUStringToOString(
+ url, osl_getThreadTextEncoding()).getStr() << std::endl;
+ assertTrue(supposedToBeCompatible);
+ } catch (css::lang::IllegalArgumentException &) {
+ if (supposedToBeCompatible)
+ throw;
+ assertFalse(supposedToBeCompatible);
+ }
+ }
+
+ ///////
+
+ css::uno::Reference< css::reflection::XIndirectTypeDescription > sequence(
+ manager->getByHierarchicalName(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[][]boolean"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_SEQUENCE, sequence->getTypeClass());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[][]boolean")),
+ sequence->getName());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[]boolean")),
+ sequence->getReferencedType()->getName());
+
+ css::uno::Reference< css::reflection::XStructTypeDescription > structure(
+ manager->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.tdmanager.Struct<boolean,test.tdmanager.Struct<"
+ "any,com.sun.star.uno.XInterface>>"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_STRUCT, structure->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.tdmanager.Struct<boolean,test.tdmanager.Struct<"
+ "any,com.sun.star.uno.XInterface>>")),
+ structure->getName());
+ assertEqual< bool >(false, structure->getBaseType().is());
+ assertEqual< sal_Int32 >(1, structure->getMemberTypes().getLength());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.tdmanager.Struct<any,com.sun.star.uno.XInterface>")),
+ structure->getMemberTypes()[0]->getName());
+ assertEqual< sal_Int32 >(1, structure->getMemberNames().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("s")),
+ structure->getMemberNames()[0]);
+ assertEqual< sal_Int32 >(0, structure->getTypeParameters().getLength());
+ assertEqual< sal_Int32 >(2, structure->getTypeArguments().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("boolean")),
+ structure->getTypeArguments()[0]->getName());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "test.tdmanager.Struct<any,com.sun.star.uno.XInterface>")),
+ structure->getTypeArguments()[1]->getName());
+
+ css::uno::Reference< css::reflection::XInterfaceMethodTypeDescription >
+ method(
+ manager->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.uno.XComponentContext::getValueByName"))),
+ css::uno::UNO_QUERY_THROW);
+ assertEqual(css::uno::TypeClass_INTERFACE_METHOD, method->getTypeClass());
+ assertEqual(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.uno.XComponentContext::getValueByName")),
+ method->getName());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("getValueByName")),
+ method->getMemberName());
+ assertEqual< sal_Int32 >(3, method->getPosition());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")),
+ method->getReturnType()->getName());
+ assertEqual< bool >(false, method->isOneway());
+ assertEqual< sal_Int32 >(1, method->getParameters().getLength());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")),
+ method->getParameters()[0]->getName());
+ assertEqual(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("string")),
+ method->getParameters()[0]->getType()->getName());
+ assertEqual< bool >(true, method->getParameters()[0]->isIn());
+ assertEqual< bool >(false, method->getParameters()[0]->isOut());
+ assertEqual< sal_Int32 >(0, method->getParameters()[0]->getPosition());
+ assertEqual< sal_Int32 >(0, method->getExceptions().getLength());
+
+ assertFalse(
+ css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ manager->getByHierarchicalName(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[]boolean"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY).is());
+ assertFalse(
+ css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ manager->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.beans.XIntroTest::ObjectName"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY).is());
+ assertFalse(
+ css::uno::Reference< css::reflection::XPublished >(
+ css::uno::Reference< css::reflection::XTypeDescription >(
+ manager->getByHierarchicalName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.beans.XIntroTest::writeln"))),
+ css::uno::UNO_QUERY_THROW),
+ css::uno::UNO_QUERY).is());
+ //TODO: check that the reflection of a property of an accumulation-based
+ // service does not support XPublished
+
+ return 0;
+}
+
+rtl::OUString Service::getImplementationName() {
+ return rtl::OUString::createFromAscii("test.tdmanager.impl");
+}
+
+css::uno::Sequence< rtl::OUString > Service::getSupportedServiceNames() {
+ return css::uno::Sequence< rtl::OUString >();
+}
+
+css::uno::Reference< css::uno::XInterface > Service::createInstance(
+ css::uno::Reference< css::uno::XComponentContext > const & context)
+ throw (css::uno::Exception)
+{
+ return static_cast< cppu::OWeakObject * >(new Service(context));
+}
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ char const ** envTypeName, uno_Environment **)
+{
+ if (envTypeName != 0) {
+ *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+}
+
+extern "C" void * SAL_CALL component_getFactory(char const * implName,
+ void * serviceManager, void *) {
+ void * p = 0;
+ if (serviceManager != 0) {
+ css::uno::Reference< css::lang::XSingleComponentFactory > f;
+ if (Service::getImplementationName().equalsAscii(implName)) {
+ f = cppu::createSingleComponentFactory(
+ &Service::createInstance, Service::getImplementationName(),
+ Service::getSupportedServiceNames());
+ }
+ if (f.is()) {
+ f->acquire();
+ p = f.get();
+ }
+ }
+ return p;
+}
+
+namespace {
+
+bool writeInfo(void * registryKey, rtl::OUString const & implementationName,
+ css::uno::Sequence< rtl::OUString > const & serviceNames) {
+ rtl::OUString keyName(rtl::OUString::createFromAscii("/"));
+ keyName += implementationName;
+ keyName += rtl::OUString::createFromAscii("/UNO/SERVICES");
+ css::uno::Reference< css::registry::XRegistryKey > key;
+ try {
+ key = static_cast< css::registry::XRegistryKey * >(registryKey)->
+ createKey(keyName);
+ } catch (css::registry::InvalidRegistryException &) {}
+ if (!key.is()) {
+ return false;
+ }
+ bool success = true;
+ for (sal_Int32 i = 0; i < serviceNames.getLength(); ++i) {
+ try {
+ key->createKey(serviceNames[i]);
+ } catch (css::registry::InvalidRegistryException &) {
+ success = false;
+ break;
+ }
+ }
+ return success;
+}
+
+}
+
+extern "C" sal_Bool SAL_CALL component_writeInfo(void *, void * registryKey) {
+ return registryKey
+ && writeInfo(registryKey, Service::getImplementationName(),
+ Service::getSupportedServiceNames());
+}
diff --git a/stoc/test/tdmanager/types.idl b/stoc/test/tdmanager/types.idl
new file mode 100644
index 000000000000..68644509639c
--- /dev/null
+++ b/stoc/test/tdmanager/types.idl
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module test { module tdmanager {
+
+struct Struct<T, U> { U s; };
+
+published interface XAnother {
+ void f();
+};
+
+service MyService {
+ [optional] interface XAnother;
+ [property, optional] boolean b;
+};
+
+const long CCC = 5;
+
+}; };
diff --git a/stoc/test/tdmanager/types2_incomp.idl b/stoc/test/tdmanager/types2_incomp.idl
new file mode 100644
index 000000000000..8caec558c4bf
--- /dev/null
+++ b/stoc/test/tdmanager/types2_incomp.idl
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+module com { module sun { module star { module text {
+
+typedef long XTextField;
+
+}; }; }; };
+
+module test { module tdmanager {
+
+const long CCC = 6;
+
+}; };
diff --git a/stoc/test/tdmanager/types3_incomp.idl b/stoc/test/tdmanager/types3_incomp.idl
new file mode 100644
index 000000000000..3cb7436f471a
--- /dev/null
+++ b/stoc/test/tdmanager/types3_incomp.idl
@@ -0,0 +1,33 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+module test { module tdmanager {
+
+// added member:
+struct Struct<T, U> { U s; long n; };
+
+}; };
diff --git a/stoc/test/tdmanager/types4_incomp.idl b/stoc/test/tdmanager/types4_incomp.idl
new file mode 100644
index 000000000000..127a90647824
--- /dev/null
+++ b/stoc/test/tdmanager/types4_incomp.idl
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module test { module tdmanager {
+
+published interface XAnother {
+ // wrong name:
+ void f2();
+};
+
+service MyService {
+ [optional] interface XAnother;
+ [property, optional] boolean b;
+};
+
+}; };
diff --git a/stoc/test/tdmanager/types5.idl b/stoc/test/tdmanager/types5.idl
new file mode 100644
index 000000000000..9c09f24015de
--- /dev/null
+++ b/stoc/test/tdmanager/types5.idl
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module test { module tdmanager {
+
+published interface XAnother {
+ void f();
+};
+
+service MyService {
+ [optional] interface XAnother;
+ // correct order:
+ [property, optional] boolean b;
+ [property, optional] boolean b2;
+};
+
+const long CCC = 5;
+
+}; };
diff --git a/stoc/test/tdmanager/types5_incomp.idl b/stoc/test/tdmanager/types5_incomp.idl
new file mode 100644
index 000000000000..86d94f3b86f8
--- /dev/null
+++ b/stoc/test/tdmanager/types5_incomp.idl
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module test { module tdmanager {
+
+published interface XAnother {
+ void f();
+};
+
+service MyService {
+ [optional] interface XAnother;
+ // wrong order:
+ [property, optional] boolean b2;
+ [property, optional] boolean b;
+};
+
+}; };
diff --git a/stoc/test/tdmanager/types6_incomp.idl b/stoc/test/tdmanager/types6_incomp.idl
new file mode 100644
index 000000000000..98ab905e2f76
--- /dev/null
+++ b/stoc/test/tdmanager/types6_incomp.idl
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module test { module tdmanager {
+
+published interface XAnother {
+ void f();
+};
+
+service MyService {
+ // made non-optional:
+ interface XAnother;
+ [property, optional] boolean b;
+ [property, optional] boolean b2;
+};
+
+}; };
diff --git a/stoc/test/testconv.cxx b/stoc/test/testconv.cxx
new file mode 100644
index 000000000000..0687046512af
--- /dev/null
+++ b/stoc/test/testconv.cxx
@@ -0,0 +1,705 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include <sal/main.h>
+#include <osl/diagnose.h>
+#include <rtl/ustrbuf.hxx>
+#include <cppuhelper/servicefactory.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/reflection/FieldAccessMode.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+
+#include <float.h>
+#include <stdio.h>
+
+
+using namespace rtl;
+using namespace cppu;
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::script;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::registry;
+
+const double MIN_DOUBLE = -DBL_MAX;
+const double MAX_DOUBLE = DBL_MAX;
+const double MIN_FLOAT = -FLT_MAX;
+const double MAX_FLOAT = FLT_MAX;
+
+//==================================================================================================
+static void printValue( const Any & rVal )
+{
+ // print value
+ OString aStr( OUStringToOString( rVal.getValueType().getTypeName(), RTL_TEXTENCODING_ISO_8859_1 ) );
+ printf( "(%s)", aStr.getStr() );
+
+ switch (rVal.getValueTypeClass())
+ {
+ case TypeClass_VOID:
+ printf( "void" );
+ break;
+ case TypeClass_ANY:
+ if (rVal.hasValue())
+ printValue( *(Any *)rVal.getValue() );
+ break;
+ case TypeClass_BOOLEAN:
+ printf( "%s", (*(sal_Bool *)rVal.getValue() ? "true" : "false") );
+ break;
+ case TypeClass_CHAR:
+ {
+ char ar[2];
+ ar[0] = (char)*(sal_Unicode *)rVal.getValue();
+ ar[1] = 0;
+ printf( ar );
+ break;
+ }
+ case TypeClass_BYTE:
+ printf( "%x", (int)*(sal_Int8 *)rVal.getValue() );
+ break;
+ case TypeClass_SHORT:
+ printf( "%x", *(sal_Int16 *)rVal.getValue() );
+ break;
+ case TypeClass_UNSIGNED_SHORT:
+ printf( "%x", *(sal_uInt16 *)rVal.getValue() );
+ break;
+ case TypeClass_LONG:
+ printf( "%lx", static_cast<long>(*(sal_Int32 *)rVal.getValue()) );
+ break;
+ case TypeClass_UNSIGNED_LONG:
+ printf( "%lx", static_cast<unsigned long>(*(sal_uInt32 *)rVal.getValue()) );
+ break;
+ case TypeClass_HYPER:
+ printf( "%lx", (long)*(sal_Int64 *)rVal.getValue() );
+ break;
+ case TypeClass_UNSIGNED_HYPER:
+ printf( "%lx", (unsigned long)*(sal_uInt64 *)rVal.getValue() );
+ break;
+ case TypeClass_FLOAT:
+ printf( "%f", *(float *)rVal.getValue() );
+ break;
+ case TypeClass_DOUBLE:
+ printf( "%g", *(double *)rVal.getValue() );
+ break;
+ case TypeClass_STRING:
+ {
+ OString aStr2( OUStringToOString( *(OUString *)rVal.getValue(), RTL_TEXTENCODING_ISO_8859_1 ) );
+ printf( aStr2.getStr() );
+ break;
+ }
+ case TypeClass_ENUM:
+ {
+ typelib_EnumTypeDescription * pEnumTD = 0;
+ TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pEnumTD, rVal.getValueTypeRef() );
+
+ for ( sal_Int32 nPos = pEnumTD->nEnumValues; nPos--; )
+ {
+ if (pEnumTD->pEnumValues[nPos] == *(int *)rVal.getValue())
+ {
+ printf( OUStringToOString(pEnumTD->ppEnumNames[nPos]->buffer, RTL_TEXTENCODING_ASCII_US).getStr() );
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pEnumTD );
+ return;
+ }
+ }
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pEnumTD );
+ printf( ">ENUM not found!<" );
+ break;
+ }
+ case TypeClass_SEQUENCE:
+ {
+ uno_Sequence * pSeq = *(uno_Sequence **)rVal.getValue();
+ typelib_TypeDescription * pSeqTD = 0;
+ TYPELIB_DANGER_GET( &pSeqTD, rVal.getValueTypeRef() );
+ typelib_TypeDescription * pElemTD = 0;
+ TYPELIB_DANGER_GET( &pElemTD, ((typelib_IndirectTypeDescription *)pSeqTD)->pType );
+
+ sal_Int32 nLen = pSeq->nElements;
+ if (nLen)
+ {
+ printf( "{ " );
+ for ( sal_Int32 nPos = 0; nPos < nLen; ++nPos )
+ {
+ printValue( Any( ((char *)pSeq->elements) + (nPos * pElemTD->nSize), pElemTD ) );
+ if (nPos < (nLen-1))
+ printf( ", " );
+ }
+ printf( " }" );
+ }
+
+ TYPELIB_DANGER_RELEASE( pElemTD );
+ TYPELIB_DANGER_RELEASE( pSeqTD );
+ break;
+ }
+
+ default:
+ printf( ">not printable<" );
+ break;
+ }
+}
+
+static Reference< XTypeConverter > s_xConverter;
+
+//==================================================================================================
+static sal_Bool convertTo( const Type & rDestType, const Any & rVal, sal_Bool bExpectSuccess )
+{
+ sal_Bool bCanConvert = sal_False;
+ Any aRet;
+
+ OString aExcMsg;
+
+ try
+ {
+ aRet = s_xConverter->convertTo( rVal, rDestType );
+ bCanConvert = sal_True;
+ }
+ catch (Exception & rExc)
+ {
+ aExcMsg = OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US );
+ }
+
+ if (bExpectSuccess && !bCanConvert)
+ {
+ printf( "# conversion of " );
+ printValue( rVal );
+ printf( " to " );
+ printf( OUStringToOString(rDestType.getTypeName(), RTL_TEXTENCODING_ASCII_US).getStr() );
+ printf( " failed, but success was expected! [" );
+ printf( aExcMsg.getStr() );
+ printf( "]\n" );
+ aRet = s_xConverter->convertTo( rVal, rDestType );
+#if OSL_DEBUG_LEVEL > 1
+ // for debugging, to trace again
+ try
+ {
+ aRet = s_xConverter->convertTo( rVal, rDestType );
+ }
+ catch (Exception &)
+ {
+ }
+#endif
+ return sal_False;
+ }
+ if (!bExpectSuccess && bCanConvert)
+ {
+ printf( "# conversion of " );
+ printValue( rVal );
+ printf( " to " );
+ printValue( aRet );
+ printf( " was successful, but was not expected to be!\n" );
+#if OSL_DEBUG_LEVEL > 1
+ // for debugging, to trace again
+ aRet = s_xConverter->convertTo( rVal, rDestType );
+#endif
+ return sal_False;
+ }
+
+#ifdef __RECONVERSION_OUTPUT__
+//= re-conversion output =
+ if (bCanConvert)
+ {
+ // re convert to original type
+ sal_Bool bReConvert = sal_False;
+ Any aRet2;
+
+ try
+ {
+ aRet2 = s_xConverter->convertTo( aRet, rVal.getValueType() );
+ bReConvert = sal_True;
+ }
+ catch (Exception & rExc)
+ {
+ aExcMsg = OUStringToOString( rExc.Message, RTL_TEXTENCODING_ISO_8859_1 );
+ }
+
+ if (bReConvert)
+ {
+ if (rVal != aRet2)
+ {
+ printf( "# re-conversion of " );
+ printValue( rVal );
+ printf( " to " );
+ printValue( aRet );
+ printf( " to " );
+ printValue( aRet2 );
+ printf( ": first and last do not match!\n" );
+ }
+ }
+ else
+ {
+ printf( "# re-conversion of " );
+ printValue( aRet );
+ printf( " to " );
+ printf( rVal.getValueType().getTypeName().getStr() );
+ printf( " failed! [" );
+ printf( aExcMsg.getStr() );
+ printf( "]\n" );
+ }
+ }
+#endif
+
+ return sal_True;
+}
+
+
+//==================================================================================================
+typedef struct _ConvBlock
+{
+ Any _value;
+ sal_Bool _toString, _toDouble, _toFloat;
+ sal_Bool _toUINT32, _toINT32, _toUINT16, _toINT16, _toBYTE, _toBOOL, _toChar;
+ sal_Bool _toTypeClass, _toSeqINT16, _toSeqAny;
+
+ _ConvBlock()
+ {
+ }
+ _ConvBlock( const Any & rValue_,
+ sal_Bool toString_, sal_Bool toDouble_, sal_Bool toFloat_,
+ sal_Bool toUINT32_, sal_Bool toINT32_, sal_Bool toUINT16_, sal_Bool toINT16_,
+ sal_Bool toBYTE_, sal_Bool toBOOL_, sal_Bool toChar_,
+ sal_Bool toTypeClass_, sal_Bool toSeqINT16_, sal_Bool toSeqAny_ )
+ : _value( rValue_ )
+ , _toString( toString_ ), _toDouble( toDouble_ ), _toFloat( toFloat_ )
+ , _toUINT32( toUINT32_ ), _toINT32( toINT32_ ), _toUINT16( toUINT16_ ), _toINT16( toINT16_ )
+ , _toBYTE( toBYTE_ ), _toBOOL( toBOOL_ ), _toChar( toChar_ )
+ , _toTypeClass( toTypeClass_ ), _toSeqINT16( toSeqINT16_ ), _toSeqAny( toSeqAny_ )
+ {
+ }
+} ConvBlock;
+
+
+//==================================================================================================
+static sal_Int32 initBlocks( ConvBlock * pTestBlocks )
+{
+ Any aVal;
+
+ sal_uInt32 nElems = 0;
+
+ // ==BYTE==
+ aVal <<= OUString::createFromAscii( "0xff" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "255" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_Int8)0xffu;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "0x80" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "128" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_Int8)( 0x80u );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "0x7f" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "127" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_Int8)( 0x7f );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "5" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "+5" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_Int8)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "-5" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int8)( -5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "256" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==UINT16==
+ aVal <<= OUString::createFromAscii( "65535" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0xffff" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt16)( 0xffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "32768" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt16)( 0x8000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "32767" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0x7fff" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt16)( 0x7fff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "256" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0x100" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt16)( 0x100 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_uInt16)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_uInt16)( -5 ); // is 0xfffb
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==INT16==
+ aVal <<= (sal_Int16)( -1 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int16)( -0x8000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int16)( 0x7fff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int16)( 0x100 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int16)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int16)( -5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==UINT32==
+ aVal <<= OUString::createFromAscii( "+4294967295" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "4294967295" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0xffffffff" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt32)( 0xffffffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "-2147483648" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "-0x80000000" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_uInt32)( 0x80000000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "2147483647" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0x7fffffff" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt32)( 0x7fffffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "65536" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= OUString::createFromAscii( "0x10000" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt32)( 0x10000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_uInt32)( 0x8000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_uInt32)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "0xfffffffb" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (sal_uInt32)( -5 ); // is 0xfffffffb
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==INT32==
+ aVal <<= (sal_Int32)( 0xffffffff ); // is -1
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( 0x80000000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( 0x7fffffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( 0x10000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( -0x8001 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (sal_Int32)( -5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==FLOAT==
+ aVal <<= OUString::createFromAscii( "-3.4e+38" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (float)( MIN_FLOAT );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "+3.4e+38" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (float)( MAX_FLOAT );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "9e-20" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= (float)( 9e-20 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "+.7071067811865" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= (float)( .7071067811865 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "3.14159265359" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ aVal <<= (float)( 3.14159265359 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (float)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==DOUBLE==
+ aVal <<= OUString::createFromAscii( "-1.7976931348623155e+308" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (double)( MIN_DOUBLE );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "1.7976931348623155e+308" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+ aVal <<= (double)( MAX_DOUBLE );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( MIN_FLOAT );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( MAX_FLOAT );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( -((double)0x80000000) );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( -((double)0x80000001) );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( 0x7fffffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( 0x80000000 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( 0xffffffff );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "0x100000000" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+#ifndef OS2
+ aVal <<= (double)( SAL_CONST_INT64(0x100000000) );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+#endif
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= (double)( 5 );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==CHAR==
+ sal_Unicode c = 'A';
+ aVal.setValue( &c, ::getCharCppuType() );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "A" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==BOOL==
+ aVal <<= OUString::createFromAscii( "0" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "1" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "False" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "true" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+
+ sal_Bool bTmp = sal_True;
+ aVal.setValue( &bTmp, getBooleanCppuType() );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==ZERO STRINGS==
+ aVal <<= OUString();
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "-" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "-0" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==TYPECLASS ENUM==
+ aVal <<= OUString::createFromAscii( "eNuM" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal <<= OUString::createFromAscii( "DOUBLE" );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ int e = 1;
+ aVal.setValue( &e, ::getCppuType( (const TypeClass *)0 ) );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ aVal.setValue( &e, ::getCppuType( (const FieldAccessMode *)0 ) );
+ pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==SEQ of INT==
+ Sequence< sal_Int32 > aINT32Seq( 3 ), aINT32Seq2( 3 );
+ sal_Int32 * pINT32Seq = aINT32Seq.getArray();
+ pINT32Seq[0] = -32768;
+ pINT32Seq[1] = 0;
+ pINT32Seq[2] = 32767;
+ aVal <<= aINT32Seq;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ pINT32Seq = aINT32Seq2.getArray();
+ pINT32Seq[0] = -32768;
+ pINT32Seq[1] = -32769;
+ pINT32Seq[2] = 32767;
+ aVal <<= aINT32Seq2;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ // ==SEQ of ANY==
+ Sequence< Any > aAnySeq( 2 ), aAnySeq2( 2 ), aAnySeq3( 2 );
+ Any * pAnySeq = aAnySeq.getArray();
+ pAnySeq[0] = makeAny( aINT32Seq );
+ pAnySeq[1] = makeAny( OUString::createFromAscii("lala") );
+ aVal <<= aAnySeq;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ pAnySeq = aAnySeq2.getArray();
+ pAnySeq[0] <<= (sal_Int32)4711;
+ pAnySeq[1] <<= OUString::createFromAscii("0815");
+ aVal <<= aAnySeq2;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ pAnySeq = aAnySeq3.getArray();
+ pAnySeq[0] <<= OUString::createFromAscii("TypeClass_UNION");
+ pAnySeq[1] <<= OUString::createFromAscii("TypeClass_ENUM");
+ aVal <<= aAnySeq3;
+ pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 );
+ // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
+ return nElems;
+}
+
+//==================================================================================================
+static void test_Conversion( const Reference< XMultiServiceFactory > & xMgr )
+{
+ printf( "test_Conversion(): start...\n" );
+
+ Reference< XTypeConverter > xConverter( xMgr->createInstance(
+ OUString::createFromAscii( "com.sun.star.script.Converter" ) ), UNO_QUERY );
+
+ ConvBlock * pTestBlocks = new ConvBlock[256];
+ sal_Int32 nPos = initBlocks( pTestBlocks );
+
+ s_xConverter = xConverter;
+ while (nPos--)
+ {
+ const ConvBlock& rBlock = pTestBlocks[nPos];
+ const Any & rVal = rBlock._value;
+
+ convertTo( ::getCppuType( (const OUString *)0 ), rVal, rBlock._toString );
+ convertTo( ::getCppuType( (const float *)0 ), rVal, rBlock._toFloat );
+ convertTo( ::getCppuType( (const double *)0 ), rVal, rBlock._toDouble );
+ convertTo( ::getCppuType( (const sal_uInt32 *)0 ), rVal, rBlock._toUINT32 );
+ convertTo( ::getCppuType( (const sal_Int32 *)0 ), rVal, rBlock._toINT32 );
+ convertTo( ::getCppuType( (const sal_uInt16 *)0 ), rVal, rBlock._toUINT16 );
+ convertTo( ::getCppuType( (const sal_Int16 *)0 ), rVal, rBlock._toINT16 );
+ convertTo( ::getCppuType( (const sal_Int8 *)0 ), rVal, rBlock._toBYTE );
+ convertTo( ::getBooleanCppuType(), rVal, rBlock._toBOOL );
+ convertTo( ::getCharCppuType(), rVal, rBlock._toChar );
+ convertTo( ::getCppuType( (const TypeClass *)0 ), rVal, rBlock._toTypeClass );
+ convertTo( ::getCppuType( (const Sequence< sal_Int16 > *)0 ), rVal, rBlock._toSeqINT16 );
+ convertTo( ::getCppuType( (const Sequence< Any > *)0 ), rVal, rBlock._toSeqAny );
+
+ convertTo( ::getVoidCppuType(), rVal, sal_True ); // anything converts to void
+ }
+ s_xConverter.clear();
+
+ delete [] pTestBlocks;
+
+ Any aRet;
+ aRet = xConverter->convertTo( Any( &xMgr, ::getCppuType( (const Reference< XMultiServiceFactory > *)0 ) ),
+ ::getCppuType( (const Reference< XServiceInfo > *)0 ) );
+ aRet = xConverter->convertTo( aRet, ::getCppuType( (const Reference< XMultiServiceFactory > *)0 ) );
+ aRet = xConverter->convertTo( aRet, ::getCppuType( (const Reference< XServiceInfo > *)0 ) );
+ aRet <<= SAL_CONST_INT64(0x7fffffffffffffff);
+ aRet = xConverter->convertTo( aRet, ::getCppuType( (const sal_uInt64 *)0 ) );
+ OSL_ASSERT( *(const sal_uInt64 *)aRet.getValue() == SAL_CONST_UINT64(0x7fffffffffffffff) );
+ aRet <<= SAL_CONST_UINT64(0xffffffffffffffff);
+ aRet = xConverter->convertTo( aRet, ::getCppuType( (const sal_uInt64 *)0 ) );
+ OSL_ASSERT( *(const sal_uInt64 *)aRet.getValue() == SAL_CONST_UINT64(0xffffffffffffffff) );
+ aRet <<= SAL_CONST_INT64(-1);
+ aRet = xConverter->convertTo( aRet, ::getCppuType( (const sal_Int8 *)0 ) );
+ OSL_ASSERT( *(const sal_Int8 *)aRet.getValue() == (-1) );
+ printf( "test_Conversion(): end.\n" );
+}
+
+SAL_IMPLEMENT_MAIN()
+{
+ Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory( OUString::createFromAscii("stoctest.rdb") ) );
+
+ try
+ {
+ Reference< XImplementationRegistration > xImplReg(
+ xMgr->createInstance( OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration") ), UNO_QUERY );
+ OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
+
+ OUString aLibName(
+ RTL_CONSTASCII_USTRINGPARAM("stocservices.uno" SAL_DLLEXTENSION) );
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ aLibName, Reference< XSimpleRegistry >() );
+
+ test_Conversion( xMgr );
+ }
+ catch (Exception & rExc)
+ {
+ OSL_ENSURE( sal_False, "### exception occured!" );
+ OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### exception occured: " );
+ OSL_TRACE( aMsg.getStr() );
+ OSL_TRACE( "\n" );
+ }
+
+ Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
+ return 0;
+}
diff --git a/stoc/test/testcorefl.cxx b/stoc/test/testcorefl.cxx
new file mode 100644
index 000000000000..31cc9fc18b8a
--- /dev/null
+++ b/stoc/test/testcorefl.cxx
@@ -0,0 +1,412 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include <sal/main.h>
+#include <osl/diagnose.h>
+
+#if OSL_DEBUG_LEVEL > 0
+#define TEST_ENSHURE(c, m) OSL_ENSURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) OSL_VERIFY(c)
+#endif
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+#include <ModuleA/XInterface1.hpp>
+#include <ModuleC/XInterfaceA.hpp>
+#include <ModuleC/XInterfaceB.hpp>
+#include <ModuleC/ModuleC.hpp>
+
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/reflection/XIdlReflection.hpp>
+#include <com/sun/star/reflection/XIdlField2.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <stdio.h>
+
+
+using namespace rtl;
+using namespace cppu;
+using namespace osl;
+using namespace ModuleA;
+using namespace ModuleB;
+using namespace ModuleC;
+using namespace ModuleA::ModuleB;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::container;
+
+
+//==================================================================================================
+class OInterfaceA : public WeakImplHelper1< XInterfaceA >
+{
+public:
+
+ virtual void SAL_CALL methodA(void) throw (RuntimeException)
+ {}
+
+ virtual void SAL_CALL methodB(sal_Int16 /*aShort*/) throw (RuntimeException)
+ {}
+ virtual Sequence< StructB > SAL_CALL methodC(const StructC& /*aStructC*/, StructA& /*aStructA*/) throw (RuntimeException)
+ { return Sequence< StructB >(); }
+};
+
+//==================================================================================================
+static inline bool uik_equals( const Uik & rUik1, const Uik & rUik2 )
+{
+ return (rUik1.m_Data1 == rUik2.m_Data1 &&
+ rUik1.m_Data2 == rUik2.m_Data2 &&
+ rUik1.m_Data3 == rUik2.m_Data3 &&
+ rUik1.m_Data4 == rUik2.m_Data4 &&
+ rUik1.m_Data5 == rUik2.m_Data5);
+}
+//==================================================================================================
+static sal_Bool test_corefl( const Reference< XIdlReflection > & xRefl )
+{
+ Reference< XIdlClass > xClass;
+ Reference< XHierarchicalNameAccess > xHNameAccess( xRefl, UNO_QUERY );
+ TEST_ENSHURE(xHNameAccess.is(), "### cannot get XHierarchicalNameAccess!" );
+
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.StructA"))->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 2b");
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.ExceptionB"))->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 2c");
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.ModuleB.EnumA")).is(), "test_RegCoreReflection(): error 2e");
+ // const
+
+ TEST_ENSHURE(*(const sal_Bool *)xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstBoolean")).getValue() == aConstBoolean, "test_RegCoreReflection(): error 4c");
+ TEST_ENSHURE(*(const sal_Int8 *)xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstByte")).getValue() == aConstByte, "test_RegCoreReflection(): error 4e");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstShort")) == aConstShort, "test_RegCoreReflection(): error 4g");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstUShort")) == aConstUShort, "test_RegCoreReflection(): error 4i");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstLong")) == aConstLong, "test_RegCoreReflection(): error 4k");
+ TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstULong")) == aConstULong, "test_RegCoreReflection(): error 4m");
+// TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstFloat")) == aConstFloat, "test_RegCoreReflection(): error 4o");
+// TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstDouble")) == aConstDouble, "test_RegCoreReflection(): error 4q");
+
+ // Enums
+
+ xClass = xRefl->forName(OUString::createFromAscii("ModuleA.ModuleB.EnumA"));
+
+ TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 5");
+
+ Sequence<Reference< XIdlField > > fields = xClass->getFields();
+
+ TEST_ENSHURE(
+ (fields.getLength() == 3) &&
+ (fields.getArray()[0]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_1") )) &&
+ (*(EnumA*)fields.getArray()[0]->get(Any()).getValue() == EnumA_VAL_1) &&
+ (fields.getArray()[1]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_2") )) &&
+ (*(EnumA*)fields.getArray()[1]->get(Any()).getValue() == EnumA_VAL_2) &&
+ (fields.getArray()[2]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_3") )) &&
+ (*(EnumA*)fields.getArray()[2]->get(Any()).getValue() == EnumA_VAL_3),
+ "test_RegCoreReflection(): error 6");
+
+
+ // Interface
+
+ Reference< XIdlClass > xA = xRefl->forName( OUString::createFromAscii("ModuleC.XInterfaceB") );
+
+ xClass = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceB"));
+
+ TEST_ENSHURE(xClass == xA, "test_RegCoreReflection(): error 7");
+ TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 7a");
+
+ typelib_TypeDescription * pTD = 0;
+ OUString aModuleName( RTL_CONSTASCII_USTRINGPARAM("ModuleC.XInterfaceB") );
+ typelib_typedescription_getByName( &pTD, aModuleName.pData );
+ TEST_ENSHURE( pTD, "### cannot get typedescription for ModuleC.XInterfaceB!" );
+
+ TEST_ENSHURE( uik_equals( *(Uik *)&((typelib_InterfaceTypeDescription *)pTD)->aUik,
+ xClass->getUik() ),
+ "test_RegCoreReflection(): error 8" );
+ typelib_typedescription_release( pTD );
+
+ TEST_ENSHURE(xClass->getSuperclasses().getLength() == 1, "test_RegCoreReflection(): error 9");
+ TEST_ENSHURE(xClass->getSuperclasses().getArray()[0]->getName() == OUString::createFromAscii("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 10");
+ TEST_ENSHURE(xClass->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11");
+ TEST_ENSHURE(xA->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11a");
+ TEST_ENSHURE(xClass->getMethods().getArray()[3]->getName() == OUString::createFromAscii("methodA"), "test_RegCoreReflection(): 12");
+ TEST_ENSHURE(xClass->getMethods().getArray()[3]->getReturnType()->getTypeClass() == TypeClass_VOID, "test_RegCoreReflection(): error 13");
+ TEST_ENSHURE(xClass->getMethods().getArray()[3]->getParameterTypes().getLength() == 0, "test_RegCoreReflection(): error 14");
+ TEST_ENSHURE(xClass->getMethods().getArray()[3]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 15");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("methodB") ), "test_RegCoreReflection(): error 16");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getMode() == MethodMode_ONEWAY, "test_RegCoreReflection(): error 16a");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getReturnType()->getTypeClass() == TypeClass_VOID, "test_RegCoreReflection(): error 16");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 17");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_SHORT, "test_RegCoreReflection(): error 18");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aName == OUString( RTL_CONSTASCII_USTRINGPARAM("aShort") ), "test_RegCoreReflection(): error 18a");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aType == xRefl->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("short") ) ), "test_RegCoreReflection(): error 18b");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aMode == ParamMode_IN, "test_RegCoreReflection(): error 18c");
+ TEST_ENSHURE(xClass->getMethods().getArray()[4]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 19");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getName() == OUString::createFromAscii("methodC"), "test_RegCoreReflection(): error 20");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getMode() == MethodMode_TWOWAY, "test_RegCoreReflection(): error 20a");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 21");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getComponentType()->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 22");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getComponentType()->getName() == OUString::createFromAscii("ModuleA.StructB"), "test_RegCoreReflection(): error 23");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getLength() == 2, "test_RegCoreReflection(): error 24");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 25");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.StructC"), "test_RegCoreReflection(): error 26");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 27");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 28");
+ TEST_ENSHURE(xClass->getMethods().getArray()[5]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 29");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getName() == OUString::createFromAscii("methodD"), "test_RegCoreReflection(): error 30");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getReturnType()->getTypeClass() == TypeClass_INTERFACE, "test_RegCoreReflection(): error 31");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getReturnType()->getName() == OUString::createFromAscii("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 32");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 33");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_ENUM, "test_RegCoreReflection(): error 34");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.ModuleB.EnumA"), "test_RegCoreReflection(): error 35");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getLength() == 3, "test_RegCoreReflection(): error 36");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 37");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.ExceptionA"), "test_RegCoreReflection(): error 38");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 38");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getName() == OUString::createFromAscii("ModuleA.ExceptionB"), "test_RegCoreReflection(): error 39");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 40");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getName() == OUString::createFromAscii("ModuleA.ExceptionC"), "test_RegCoreReflection(): error 41");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getLength() == 3, "test_RegCoreReflection(): error 42");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getTypeClass() == TypeClass_BOOLEAN, "test_RegCoreReflection(): error 43");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getName() == OUString::createFromAscii("boolean"), "test_RegCoreReflection(): error 43a");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 44");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getName() == OUString::createFromAscii("ModuleA.StructC"), "test_RegCoreReflection(): error 45");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getTypeClass() == TypeClass_INTERFACE, "test_RegCoreReflection(): error 46");
+ TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getName() == OUString::createFromAscii("ModuleA.XInterface1"), "test_RegCoreReflection(): error 47");
+
+ // SequenceReflections
+
+ TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 48");
+ TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->getComponentType().is(), "test_RegCoreReflection(): error 49");
+ TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[][]ModuleA.StructA") )->getComponentType()->getComponentType()->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 50");
+ TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]com.sun.star.uno.XInterface") ) == xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructC") ))->getField(OUString::createFromAscii("aInterfaceSeq"))->getType(), "test_RegCoreReflection(): error 51");
+
+ StructC aStructC;
+ aStructC.aLong = aConstLong;
+ aStructC.aShort = aConstShort;
+ aStructC.aFloat = aConstFloat;
+ aStructC.aDouble = aConstDouble;
+ aStructC.aInterfaceSeq = Sequence<Reference<XInterface > >();
+
+ Any aAny;
+
+ xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aInterfaceSeq"))->getType()->createObject(aAny);
+
+ TEST_ENSHURE(aAny.getValueType() == ::getCppuType( (const Sequence<Reference< XInterface > > *)0 ), "test_RegCoreReflection(): error 51a");
+
+ Any aStructAny(&aStructC, ::getCppuType( (const StructC *) 0 ));
+
+ sal_Int32 nLong = aConstLong * 2;
+ aAny.setValue( &nLong, ::getCppuType( (const sal_Int32 *)0 ) );
+
+ TEST_ENSHURE(*(sal_Int32*)xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructA") ))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->get(
+ Any(&aStructC, ::getCppuType( (const StructC *)0 ))).getValue() == aConstLong, "test_RegCoreReflection(): error 52");
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.StructA"))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->getAccessMode() == FieldAccessMode_READWRITE, "test_RegCoreReflection(): error 52a");
+ Reference< XIdlField2 > rField ( xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructC") ))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") )) , UNO_QUERY );
+ rField->set(aStructAny, aAny);
+ TEST_ENSHURE(*(sal_Int32*)xRefl->forName(OUString::createFromAscii("ModuleA.StructB"))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->get(aStructAny).getValue() == *(sal_Int32*)aAny.getValue(), "test_RegCoreReflection(): error 53");
+
+ xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->createObject(aAny);
+
+ TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("[]ModuleA.StructA")), "test_RegCoreReflection(): error 54");
+ xRefl->forName(OUString::createFromAscii("[][]ModuleA.StructA"))->createObject(aAny);
+
+ TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("[][]ModuleA.StructA") ), "test_RegCoreReflection(): error 56");
+
+// xClass = xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.XIntroTest") ));
+
+// TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 58");
+// TEST_ENSHURE(xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 59");
+// TEST_ENSHURE(xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->getComponentType()->getName() == OUString::createFromAscii("string"), "test_RegCoreReflection(): error 60");
+
+// xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->createObject(aAny);
+// TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("[]string") ), "test_RegCoreReflection(): error 61");
+
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("[][][]unsigned long"))->getComponentType()->getComponentType()->getComponentType()->getTypeClass() == TypeClass_UNSIGNED_LONG, "test_RegCoreReflection(): error 62");
+
+ try
+ {
+ fprintf( stderr, "%1\n" );
+ Any bla = xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->get(Any());
+ TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 63");
+ return sal_False;
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+
+ try
+ {
+ fprintf( stderr, "%2\n" );
+ Any blup;
+ blup <<= aStructC;
+ Any gulp;
+ rField = Reference< XIdlField2 > ( xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString")) , UNO_QUERY);
+ rField->set( blup, gulp);
+// xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp);
+ TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 64");
+ return sal_False;
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+
+ try
+ {
+ fprintf( stderr, "%3\n" );
+ Any gulp;
+ gulp <<= 3.14f;
+ Any blup;
+ blup <<= aStructC;
+ rField = Reference< XIdlField2 > (
+ xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString")) , UNO_QUERY);
+ xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp);
+ TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 65");
+ return sal_False;
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+
+ Any gulp;
+ gulp <<= OUString(OUString::createFromAscii("Test"));
+ Any blup;
+ blup <<= aStructC;
+ xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp);
+
+ Reference< XInterfaceA > xAI = new OInterfaceA();
+
+ try
+ {
+ Sequence< Any > params;
+ fprintf( stderr, "%4\n" );
+
+ Any a;
+ a <<= xAI;
+ Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params);
+ TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 66");
+ return sal_False;
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+
+ StructA aStructA;
+
+ {
+ Sequence< Any > params(2);
+
+ params.getArray()[0].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
+ params.getArray()[1].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
+
+ Any a;
+ a <<= xAI;
+ Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params);
+ }
+ try
+ {
+ Sequence< Any > params(2);
+
+ params.getArray()[0].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
+ params.getArray()[1].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
+
+ Any a;
+ a <<= xAI;
+ Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params);
+ TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 67");
+ return sal_False;
+ }
+ catch (IllegalArgumentException &)
+ {
+ }
+
+ Sequence< Any > params(2);
+
+ params.getArray()[0].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
+ params.getArray()[1].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
+
+ Any a;
+ a <<= xAI;
+ TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params).getValueType()
+ == ::getCppuType( (const Sequence<StructB> *)0 ), "test_RegCoreReflection(): error 68");
+
+ return sal_True;
+}
+
+SAL_IMPLEMENT_MAIN()
+{
+ sal_Bool bSucc = sal_False;
+ try
+ {
+ OUString aLibName( RTL_CONSTASCII_USTRINGPARAM(
+ "reflection.uno" SAL_DLLEXTENSION) );
+
+ Reference< XMultiServiceFactory > xMgr(
+ createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
+ Reference< XComponentContext > xContext;
+ Reference< beans::XPropertySet > xProps( xMgr, UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ xProps->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>=
+ xContext;
+ OSL_ASSERT( xContext.is() );
+
+ Reference< XIdlReflection > xRefl;
+ xContext->getValueByName(
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "/singletons/com.sun.star.reflection.theCoreReflection")) )
+ >>= xRefl;
+ OSL_ENSURE(
+ xRefl.is(), "### CoreReflection singleton not accessable!?" );
+
+ bSucc = test_corefl( xRefl );
+
+ Reference< XComponent >( xContext, UNO_QUERY )->dispose();
+ }
+ catch (Exception & rExc)
+ {
+ OSL_ENSURE( sal_False, "### exception occured!" );
+ OString aMsg(
+ OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### exception occured: " );
+ OSL_TRACE( aMsg.getStr() );
+ OSL_TRACE( "\n" );
+ }
+
+ printf( "testcorefl %s !\n", (bSucc ? "succeeded" : "failed") );
+ return (bSucc ? 0 : -1);
+}
diff --git a/stoc/test/testcorefl.idl b/stoc/test/testcorefl.idl
new file mode 100644
index 000000000000..1ae37a6f45e9
--- /dev/null
+++ b/stoc/test/testcorefl.idl
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <com/sun/star/uno/XInterface.idl>
+
+module ModuleA
+{
+ exception ExceptionA
+ {
+ boolean aBoolean;
+ };
+
+ struct StructA
+ {
+ long aLong;
+ short aShort;
+ };
+
+ struct StructB : StructA
+ {
+ double aDouble;
+ float aFloat;
+ };
+
+ struct StructC : StructB
+ {
+ string aString;
+ sequence<com::sun::star::uno::XInterface> aInterfaceSeq;
+ };
+
+ exception ExceptionB : ExceptionA
+ {
+ StructC aStructC;
+ };
+
+ interface XInterface1 : com::sun::star::uno::XInterface
+ {
+ };
+
+ exception ExceptionC : ExceptionB
+ {
+ XInterface1 aInterface1;
+ };
+
+ module ModuleB
+ {
+ enum EnumA { VAL_1, VAL_2, VAL_3 = 17};
+ };
+
+};
+
+module ModuleC
+{
+ const boolean aConstBoolean = True;
+ const byte aConstByte = 0;
+ const short aConstShort = -1;
+ const unsigned short aConstUShort = 1;
+ const long aConstLong = -2;
+ const unsigned long aConstULong = 2;
+// const hyper aConstHyper = -3;
+// const unsigned hyper aConstUHyper = 3;
+ const float aConstFloat = 3.14;
+ const double aConstDouble = 3.14e-10;
+
+
+ interface XInterfaceA : com::sun::star::uno::XInterface
+ {
+ void methodA();
+ [oneway] void methodB([in] short aShort);
+ sequence<ModuleA::StructB> methodC([in] ModuleA::StructC aStructC, [inout] ModuleA::StructA aStructA);
+ };
+
+ interface XInterfaceB : XInterfaceA
+ {
+ [attribute] string aString;
+
+ XInterfaceA methodD([in] ModuleA::ModuleB::EnumA aEnumA) raises (ModuleA::ExceptionA, ModuleA::ExceptionB, ModuleA::ExceptionC);
+ };
+};
diff --git a/stoc/test/testiadapter.cxx b/stoc/test/testiadapter.cxx
new file mode 100644
index 000000000000..62c9736aa204
--- /dev/null
+++ b/stoc/test/testiadapter.cxx
@@ -0,0 +1,1069 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include <stdio.h>
+
+#include <sal/main.h>
+#include <osl/diagnose.h>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/weak.hxx>
+
+#include <test/XLanguageBindingTest.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/script/XInvocationAdapterFactory.hpp>
+#include <com/sun/star/script/XInvocationAdapterFactory2.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+
+
+using namespace test;
+using namespace rtl;
+using namespace cppu;
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::script;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+
+//==================================================================================================
+sal_Bool equals( const test::TestElement & rData1, const test::TestElement & rData2 )
+{
+ OSL_ENSURE( rData1.Bool == rData2.Bool, "### bool does not match!" );
+ OSL_ENSURE( rData1.Char == rData2.Char, "### char does not match!" );
+ OSL_ENSURE( rData1.Byte == rData2.Byte, "### byte does not match!" );
+ OSL_ENSURE( rData1.Short == rData2.Short, "### short does not match!" );
+ OSL_ENSURE( rData1.UShort == rData2.UShort, "### unsigned short does not match!" );
+ OSL_ENSURE( rData1.Long == rData2.Long, "### long does not match!" );
+ OSL_ENSURE( rData1.ULong == rData2.ULong, "### unsigned long does not match!" );
+ OSL_ENSURE( rData1.Hyper == rData2.Hyper, "### hyper does not match!" );
+ OSL_ENSURE( rData1.UHyper == rData2.UHyper, "### unsigned hyper does not match!" );
+ OSL_ENSURE( rData1.Float == rData2.Float, "### float does not match!" );
+ OSL_ENSURE( rData1.Double == rData2.Double, "### double does not match!" );
+ OSL_ENSURE( rData1.Enum == rData2.Enum, "### enum does not match!" );
+ OSL_ENSURE( rData1.String == rData2.String, "### string does not match!" );
+ OSL_ENSURE( rData1.Interface == rData2.Interface, "### interface does not match!" );
+ OSL_ENSURE( rData1.Any == rData2.Any, "### any does not match!" );
+
+ return (rData1.Bool == rData2.Bool &&
+ rData1.Char == rData2.Char &&
+ rData1.Byte == rData2.Byte &&
+ rData1.Short == rData2.Short &&
+ rData1.UShort == rData2.UShort &&
+ rData1.Long == rData2.Long &&
+ rData1.ULong == rData2.ULong &&
+ rData1.Hyper == rData2.Hyper &&
+ rData1.UHyper == rData2.UHyper &&
+ rData1.Float == rData2.Float &&
+ rData1.Double == rData2.Double &&
+ rData1.Enum == rData2.Enum &&
+ rData1.String == rData2.String &&
+ rData1.Interface == rData2.Interface &&
+ rData1.Any == rData2.Any);
+}
+//==================================================================================================
+sal_Bool equals( const test::TestData & rData1, const test::TestData & rData2 )
+{
+ sal_Int32 nLen;
+
+ if ((rData1.Sequence == rData2.Sequence) &&
+ equals( (const test::TestElement &)rData1, (const test::TestElement &)rData2 ) &&
+ (nLen = rData1.Sequence.getLength()) == rData2.Sequence.getLength())
+ {
+ // once again by hand sequence ==
+ const test::TestElement * pElements1 = rData1.Sequence.getConstArray();
+ const test::TestElement * pElements2 = rData2.Sequence.getConstArray();
+ for ( ; nLen--; )
+ {
+ if (! equals( pElements1[nLen], pElements2[nLen] ))
+ {
+ OSL_ENSURE( sal_False, "### sequence element did not match!" );
+ return sal_False;
+ }
+ }
+ return sal_True;
+ }
+ return sal_False;
+}
+//==================================================================================================
+void assign( test::TestElement & rData,
+ sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny )
+{
+ rData.Bool = bBool;
+ rData.Char = cChar;
+ rData.Byte = nByte;
+ rData.Short = nShort;
+ rData.UShort = nUShort;
+ rData.Long = nLong;
+ rData.ULong = nULong;
+ rData.Hyper = nHyper;
+ rData.UHyper = nUHyper;
+ rData.Float = fFloat;
+ rData.Double = fDouble;
+ rData.Enum = eEnum;
+ rData.String = rStr;
+ rData.Interface = xTest;
+ rData.Any = rAny;
+}
+//==================================================================================================
+void assign( test::TestData & rData,
+ sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny,
+ const com::sun::star::uno::Sequence< test::TestElement >& rSequence )
+{
+ assign( (test::TestElement &)rData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, xTest, rAny );
+ rData.Sequence = rSequence;
+}
+
+//==================================================================================================
+class Test_Impl : public WeakImplHelper1< XLanguageBindingTest >
+{
+ test::TestData _aData, _aStructData;
+
+public:
+ virtual ~Test_Impl()
+ { OSL_TRACE( "> scalar Test_Impl dtor <\n" ); }
+
+ // XLBTestBase
+ virtual void SAL_CALL setValues( sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny,
+ const ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ const test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException);
+
+ virtual test::TestData SAL_CALL setValues2( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException);
+
+ virtual test::TestData SAL_CALL getValues( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence< test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL getBool() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Bool; }
+ virtual sal_Int8 SAL_CALL getByte() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Byte; }
+ virtual sal_Unicode SAL_CALL getChar() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Char; }
+ virtual sal_Int16 SAL_CALL getShort() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Short; }
+ virtual sal_uInt16 SAL_CALL getUShort() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.UShort; }
+ virtual sal_Int32 SAL_CALL getLong() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Long; }
+ virtual sal_uInt32 SAL_CALL getULong() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.ULong; }
+ virtual sal_Int64 SAL_CALL getHyper() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Hyper; }
+ virtual sal_uInt64 SAL_CALL getUHyper() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.UHyper; }
+ virtual float SAL_CALL getFloat() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Float; }
+ virtual double SAL_CALL getDouble() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Double; }
+ virtual test::TestEnum SAL_CALL getEnum() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Enum; }
+ virtual rtl::OUString SAL_CALL getString() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.String; }
+ virtual com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getInterface( ) throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Interface; }
+ virtual com::sun::star::uno::Any SAL_CALL getAny() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Any; }
+ virtual com::sun::star::uno::Sequence< test::TestElement > SAL_CALL getSequence() throw(com::sun::star::uno::RuntimeException)
+ { return _aData.Sequence; }
+ virtual test::TestData SAL_CALL getStruct() throw(com::sun::star::uno::RuntimeException)
+ { return _aStructData; }
+
+ virtual void SAL_CALL setBool( sal_Bool _bool ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Bool = _bool; }
+ virtual void SAL_CALL setByte( sal_Int8 _byte ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Byte = _byte; }
+ virtual void SAL_CALL setChar( sal_Unicode _char ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Char = _char; }
+ virtual void SAL_CALL setShort( sal_Int16 _short ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Short = _short; }
+ virtual void SAL_CALL setUShort( sal_uInt16 _ushort ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.UShort = _ushort; }
+ virtual void SAL_CALL setLong( sal_Int32 _long ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Long = _long; }
+ virtual void SAL_CALL setULong( sal_uInt32 _ulong ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.ULong = _ulong; }
+ virtual void SAL_CALL setHyper( sal_Int64 _hyper ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Hyper = _hyper; }
+ virtual void SAL_CALL setUHyper( sal_uInt64 _uhyper ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.UHyper = _uhyper; }
+ virtual void SAL_CALL setFloat( float _float ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Float = _float; }
+ virtual void SAL_CALL setDouble( double _double ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Double = _double; }
+ virtual void SAL_CALL setEnum( test::TestEnum _enum ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Enum = _enum; }
+ virtual void SAL_CALL setString( const ::rtl::OUString& _string ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.String = _string; }
+ virtual void SAL_CALL setInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _interface ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Interface = _interface; }
+ virtual void SAL_CALL setAny( const ::com::sun::star::uno::Any& _any ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Any = _any; }
+ virtual void SAL_CALL setSequence( const ::com::sun::star::uno::Sequence<test::TestElement >& _sequence ) throw(::com::sun::star::uno::RuntimeException)
+ { _aData.Sequence = _sequence; }
+ virtual void SAL_CALL setStruct( const test::TestData& _struct ) throw(::com::sun::star::uno::RuntimeException)
+ { _aStructData = _struct; }
+
+ // XLanguageBindingTest
+ virtual test::TestData SAL_CALL raiseException( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, sal_Int16& nShort, sal_uInt16& nUShort, sal_Int32& nLong, sal_uInt32& nULong, sal_Int64& nHyper, sal_uInt64& nUHyper, float& fFloat, double& fDouble, test::TestEnum& eEnum, ::rtl::OUString& aString, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInterface, ::com::sun::star::uno::Any& aAny, ::com::sun::star::uno::Sequence<test::TestElement >& aSequence,test::TestData& aStruct )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getRuntimeException() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRuntimeException( sal_Int32 _runtimeexception ) throw(::com::sun::star::uno::RuntimeException);
+};
+//==================================================================================================
+class XLB_Invocation : public WeakImplHelper1< XInvocation >
+{
+ Reference< XLanguageBindingTest > _xLBT;
+
+public:
+ XLB_Invocation( const Reference< XMultiServiceFactory > & /*xMgr*/,
+ const Reference< XLanguageBindingTest > & xLBT )
+ : _xLBT( xLBT )
+ {}
+
+ // XInvocation
+ virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() throw(::com::sun::star::uno::RuntimeException)
+ { return Reference< XIntrospectionAccess >(); }
+ virtual Any SAL_CALL invoke( const OUString & rFunctionName,
+ const Sequence< Any > & rParams,
+ Sequence< sal_Int16 > & rOutParamIndex,
+ Sequence< Any > & rOutParam ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const OUString & rPropertyName, const Any & rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual Any SAL_CALL getValue( const OUString & rPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasMethod( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasProperty( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
+};
+//__________________________________________________________________________________________________
+Any XLB_Invocation::invoke( const OUString & rFunctionName,
+ const Sequence< Any > & rParams,
+ Sequence< sal_Int16 > & rOutParamIndex,
+ Sequence< Any > & rOutParam )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ bool bImplementedMethod = true;
+
+ Any aRet;
+
+ OSL_ASSERT( rOutParam.getLength() == 0 );
+ OSL_ASSERT( rOutParamIndex.getLength() == 0 );
+
+ try
+ {
+ sal_Bool aBool;
+ sal_Unicode aChar;
+ sal_Int8 nByte;
+ sal_Int16 nShort;
+ sal_uInt16 nUShort;
+ sal_Int32 nLong;
+ sal_uInt32 nULong;
+ sal_Int64 nHyper;
+ sal_uInt64 nUHyper;
+ float fFloat;
+ double fDouble;
+ TestEnum eEnum;
+ OUString aString;
+ Reference< XInterface > xInterface;
+ Any aAny;
+ Sequence< TestElement > aSeq;
+ TestData aData;
+
+ if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues") ))
+ {
+ OSL_ASSERT( rParams.getLength() == 17 );
+ aBool = *(sal_Bool *)rParams[0].getValue();
+ aChar = *(sal_Unicode *)rParams[1].getValue();
+ rParams[2] >>= nByte;
+ rParams[3] >>= nShort;
+ rParams[4] >>= nUShort;
+ rParams[5] >>= nLong;
+ rParams[6] >>= nULong;
+ rParams[7] >>= nHyper;
+ rParams[8] >>= nUHyper;
+ rParams[9] >>= fFloat;
+ rParams[10] >>= fDouble;
+ rParams[11] >>= eEnum;
+ rParams[12] >>= aString;
+ rParams[13] >>= xInterface;
+ rParams[14] >>= aAny;
+ rParams[15] >>= aSeq;
+ rParams[16] >>= aData;
+
+ _xLBT->setValues( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
+ nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
+ aAny, aSeq, aData );
+
+ rOutParamIndex.realloc( 0 );
+ rOutParam.realloc( 0 );
+ }
+ else if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues2") ))
+ {
+ aBool = *(sal_Bool *)rParams[0].getValue();
+ aChar = *(sal_Unicode *)rParams[1].getValue();
+ rParams[2] >>= nByte;
+ rParams[3] >>= nShort;
+ rParams[4] >>= nUShort;
+ rParams[5] >>= nLong;
+ rParams[6] >>= nULong;
+ rParams[7] >>= nHyper;
+ rParams[8] >>= nUHyper;
+ rParams[9] >>= fFloat;
+ rParams[10] >>= fDouble;
+ rParams[11] >>= eEnum;
+ rParams[12] >>= aString;
+ rParams[13] >>= xInterface;
+ rParams[14] >>= aAny;
+ rParams[15] >>= aSeq;
+ rParams[16] >>= aData;
+
+ aRet <<= _xLBT->setValues2( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
+ nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
+ aAny, aSeq, aData );
+
+ rOutParamIndex.realloc( 17 );
+ rOutParamIndex[0] = 0;
+ rOutParamIndex[1] = 1;
+ rOutParamIndex[2] = 2;
+ rOutParamIndex[3] = 3;
+ rOutParamIndex[4] = 4;
+ rOutParamIndex[5] = 5;
+ rOutParamIndex[6] = 6;
+ rOutParamIndex[7] = 7;
+ rOutParamIndex[8] = 8;
+ rOutParamIndex[9] = 9;
+ rOutParamIndex[10] = 10;
+ rOutParamIndex[11] = 11;
+ rOutParamIndex[12] = 12;
+ rOutParamIndex[13] = 13;
+ rOutParamIndex[14] = 14;
+ rOutParamIndex[15] = 15;
+ rOutParamIndex[16] = 16;
+
+ rOutParam.realloc( 17 );
+ rOutParam[0].setValue( &aBool, ::getCppuBooleanType() );
+ rOutParam[1].setValue( &aChar, ::getCppuCharType() );
+ rOutParam[2] <<= nByte;
+ rOutParam[3] <<= nShort;
+ rOutParam[4] <<= nUShort;
+ rOutParam[5] <<= nLong;
+ rOutParam[6] <<= nULong;
+ rOutParam[7] <<= nHyper;
+ rOutParam[8] <<= nUHyper;
+ rOutParam[9] <<= fFloat;
+ rOutParam[10] <<= fDouble;
+ rOutParam[11] <<= eEnum;
+ rOutParam[12] <<= aString;
+ rOutParam[13] <<= xInterface;
+ rOutParam[14] <<= aAny;
+ rOutParam[15] <<= aSeq;
+ rOutParam[16] <<= aData;
+ }
+ else if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("getValues") ))
+ {
+ aRet <<= _xLBT->getValues( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
+ nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
+ aAny, aSeq, aData );
+
+ rOutParamIndex.realloc( 17 );
+ rOutParamIndex[0] = 0;
+ rOutParamIndex[1] = 1;
+ rOutParamIndex[2] = 2;
+ rOutParamIndex[3] = 3;
+ rOutParamIndex[4] = 4;
+ rOutParamIndex[5] = 5;
+ rOutParamIndex[6] = 6;
+ rOutParamIndex[7] = 7;
+ rOutParamIndex[8] = 8;
+ rOutParamIndex[9] = 9;
+ rOutParamIndex[10] = 10;
+ rOutParamIndex[11] = 11;
+ rOutParamIndex[12] = 12;
+ rOutParamIndex[13] = 13;
+ rOutParamIndex[14] = 14;
+ rOutParamIndex[15] = 15;
+ rOutParamIndex[16] = 16;
+
+ rOutParam.realloc( 17 );
+ rOutParam[0].setValue( &aBool, ::getCppuBooleanType() );
+ rOutParam[1].setValue( &aChar, ::getCppuCharType() );
+ rOutParam[2] <<= nByte;
+ rOutParam[3] <<= nShort;
+ rOutParam[4] <<= nUShort;
+ rOutParam[5] <<= nLong;
+ rOutParam[6] <<= nULong;
+ rOutParam[7] <<= nHyper;
+ rOutParam[8] <<= nUHyper;
+ rOutParam[9] <<= fFloat;
+ rOutParam[10] <<= fDouble;
+ rOutParam[11] <<= eEnum;
+ rOutParam[12] <<= aString;
+ rOutParam[13] <<= xInterface;
+ rOutParam[14] <<= aAny;
+ rOutParam[15] <<= aSeq;
+ rOutParam[16] <<= aData;
+ }
+ else if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raiseException") ))
+ {
+ aRet <<= _xLBT->raiseException( aBool, aChar, nByte, nShort, nUShort, nLong, nULong,
+ nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface,
+ aAny, aSeq, aData );
+
+ rOutParamIndex.realloc( 17 );
+ rOutParamIndex[0] = 0;
+ rOutParamIndex[1] = 1;
+ rOutParamIndex[2] = 2;
+ rOutParamIndex[3] = 3;
+ rOutParamIndex[4] = 4;
+ rOutParamIndex[5] = 5;
+ rOutParamIndex[6] = 6;
+ rOutParamIndex[7] = 7;
+ rOutParamIndex[8] = 8;
+ rOutParamIndex[9] = 9;
+ rOutParamIndex[10] = 10;
+ rOutParamIndex[11] = 11;
+ rOutParamIndex[12] = 12;
+ rOutParamIndex[13] = 13;
+ rOutParamIndex[14] = 14;
+ rOutParamIndex[15] = 15;
+ rOutParamIndex[16] = 16;
+
+ rOutParam.realloc( 17 );
+ rOutParam[0].setValue( &aBool, ::getCppuBooleanType() );
+ rOutParam[1].setValue( &aChar, ::getCppuCharType() );
+ rOutParam[2] <<= nByte;
+ rOutParam[3] <<= nShort;
+ rOutParam[4] <<= nUShort;
+ rOutParam[5] <<= nLong;
+ rOutParam[6] <<= nULong;
+ rOutParam[7] <<= nHyper;
+ rOutParam[8] <<= nUHyper;
+ rOutParam[9] <<= fFloat;
+ rOutParam[10] <<= fDouble;
+ rOutParam[11] <<= eEnum;
+ rOutParam[12] <<= aString;
+ rOutParam[13] <<= xInterface;
+ rOutParam[14] <<= aAny;
+ rOutParam[15] <<= aSeq;
+ rOutParam[16] <<= aData;
+ }
+ else
+ {
+ bImplementedMethod = false;
+ }
+ }
+ catch (IllegalArgumentException & rExc)
+ {
+ // thrown by raiseException() call
+ InvocationTargetException aExc;
+ aExc.TargetException <<= rExc;
+ throw aExc;
+ }
+ catch (Exception &)
+ {
+ OSL_ENSURE( sal_False, "### unexpected exception caught!" );
+ throw;
+ }
+
+ if (! bImplementedMethod)
+ {
+ throw IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("not an implemented method!") ),
+ (OWeakObject *)this, 0 );
+ }
+
+ return aRet;
+}
+//__________________________________________________________________________________________________
+void XLB_Invocation::setValue( const OUString & rName, const Any & rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ))
+ _xLBT->setBool( *(const sal_Bool *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ))
+ _xLBT->setByte( *(const sal_Int8 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ))
+ _xLBT->setChar( *(const sal_Unicode *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ))
+ _xLBT->setShort( *(const sal_Int16 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ))
+ _xLBT->setUShort( *(const sal_uInt16 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ))
+ _xLBT->setLong( *(const sal_Int32 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ))
+ _xLBT->setULong( *(const sal_uInt32 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ))
+ _xLBT->setHyper( *(const sal_Int64 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ))
+ _xLBT->setUHyper( *(const sal_uInt64 *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ))
+ _xLBT->setFloat( *(const float *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ))
+ _xLBT->setDouble( *(const double *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ))
+ _xLBT->setEnum( *(const TestEnum *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ))
+ _xLBT->setString( *(const OUString *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ))
+ _xLBT->setInterface( *(const Reference< XInterface > *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ))
+ _xLBT->setAny( rValue );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ))
+ _xLBT->setSequence( *(const Sequence< TestElement > *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ))
+ _xLBT->setStruct( *(const TestData *)rValue.getValue() );
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ))
+ _xLBT->setRuntimeException( *(const sal_Int32 *)rValue.getValue() );
+}
+//__________________________________________________________________________________________________
+Any XLB_Invocation::getValue( const OUString & rName )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
+{
+ Any aRet;
+ if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ))
+ {
+ sal_Bool aBool = _xLBT->getBool();
+ aRet.setValue( &aBool, ::getCppuBooleanType() );
+ }
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ))
+ aRet <<= _xLBT->getByte();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ))
+ {
+ sal_Unicode aChar = _xLBT->getChar();
+ aRet.setValue( &aChar, ::getCppuCharType() );
+ }
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ))
+ aRet <<= _xLBT->getShort();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ))
+ aRet <<= _xLBT->getUShort();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ))
+ aRet <<= _xLBT->getLong();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ))
+ aRet <<= _xLBT->getULong();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ))
+ aRet <<= _xLBT->getHyper();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ))
+ aRet <<= _xLBT->getUHyper();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ))
+ aRet <<= _xLBT->getFloat();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ))
+ aRet <<= _xLBT->getDouble();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ))
+ aRet <<= _xLBT->getEnum();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ))
+ aRet <<= _xLBT->getString();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ))
+ aRet <<= _xLBT->getInterface();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ))
+ aRet <<= _xLBT->getAny();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ))
+ aRet <<= _xLBT->getSequence();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ))
+ aRet <<= _xLBT->getStruct();
+ else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ))
+ aRet <<= _xLBT->getRuntimeException();
+ return aRet;
+}
+//__________________________________________________________________________________________________
+sal_Bool XLB_Invocation::hasMethod( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raiseException") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("getValues") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues2") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("acquire") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("release") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("queryInterface") ));
+}
+//__________________________________________________________________________________________________
+sal_Bool XLB_Invocation::hasProperty( const OUString & rName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ) ||
+ rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ) );
+}
+
+//##################################################################################################
+
+//__________________________________________________________________________________________________
+void Test_Impl::setValues( sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte,
+ sal_Int16 nShort, sal_uInt16 nUShort,
+ sal_Int32 nLong, sal_uInt32 nULong,
+ sal_Int64 nHyper, sal_uInt64 nUHyper,
+ float fFloat, double fDouble,
+ test::TestEnum eEnum, const ::rtl::OUString& rStr,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ const ::com::sun::star::uno::Any& rAny,
+ const ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ const test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ assign( _aData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, xTest, rAny, rSequence );
+ _aStructData = rStruct;
+}
+//__________________________________________________________________________________________________
+test::TestData Test_Impl::setValues2( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ assign( _aData,
+ bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
+ eEnum, rStr, xTest, rAny, rSequence );
+ _aStructData = rStruct;
+ return _aStructData;
+}
+//__________________________________________________________________________________________________
+test::TestData Test_Impl::getValues( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte,
+ sal_Int16& nShort, sal_uInt16& nUShort,
+ sal_Int32& nLong, sal_uInt32& nULong,
+ sal_Int64& nHyper, sal_uInt64& nUHyper,
+ float& fFloat, double& fDouble,
+ test::TestEnum& eEnum, rtl::OUString& rStr,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest,
+ ::com::sun::star::uno::Any& rAny,
+ ::com::sun::star::uno::Sequence<test::TestElement >& rSequence,
+ test::TestData& rStruct )
+ throw(com::sun::star::uno::RuntimeException)
+{
+ bBool = _aData.Bool;
+ cChar = _aData.Char;
+ nByte = _aData.Byte;
+ nShort = _aData.Short;
+ nUShort = _aData.UShort;
+ nLong = _aData.Long;
+ nULong = _aData.ULong;
+ nHyper = _aData.Hyper;
+ nUHyper = _aData.UHyper;
+ fFloat = _aData.Float;
+ fDouble = _aData.Double;
+ eEnum = _aData.Enum;
+ rStr = _aData.String;
+ xTest = _aData.Interface;
+ rAny = _aData.Any;
+ rSequence = _aData.Sequence;
+ rStruct = _aStructData;
+ return _aStructData;
+}
+
+//==================================================================================================
+sal_Bool performTest( const Reference<XLanguageBindingTest > & xLBT )
+{
+ OSL_ENSURE( xLBT.is(), "### no test interface!" );
+ if (xLBT.is())
+ {
+ // this data is never ever granted access to by calls other than equals(), assign()!
+ test::TestData aData; // test against this data
+
+ Reference<XInterface > xI( *new OWeakObject() );
+
+ assign( (test::TestElement &)aData,
+ sal_True, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
+ SAL_CONST_INT64(0x123456789abcdef0),
+ SAL_CONST_UINT64(0xfedcba9876543210),
+ (float)17.0815, 3.1415926359, TestEnum_LOLA, OUString::createFromAscii("dumdidum"), xI,
+ Any( &xI, ::getCppuType( (const Reference<XInterface > *)0 ) ) );
+
+ OSL_ENSURE( aData.Any == xI, "### unexpected any!" );
+ OSL_ENSURE( !(aData.Any != xI), "### unexpected any!" );
+
+ aData.Sequence = Sequence<test::TestElement >( (const test::TestElement *)&aData, 1 );
+ // aData complete
+ //================================================================================
+
+ // this is a manually copy of aData for first setting...
+ test::TestData aSetData;
+
+ assign( (test::TestElement &)aSetData,
+ aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort,
+ aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, aData.Double,
+ aData.Enum, aData.String, xI,
+ Any( &xI, ::getCppuType( (const Reference<XInterface > *)0 ) ) );
+
+ aSetData.Sequence = Sequence<test::TestElement >( (const test::TestElement *)&aSetData, 1 );
+
+ xLBT->setValues(
+ aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, aSetData.UShort,
+ aSetData.Long, aSetData.ULong, aSetData.Hyper, aSetData.UHyper, aSetData.Float, aSetData.Double,
+ aSetData.Enum, aSetData.String, aSetData.Interface, aSetData.Any, aSetData.Sequence, aSetData );
+
+ {
+ test::TestData aRet, aRet2;
+ xLBT->getValues(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+
+ OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) );
+
+ // set last retrieved values
+ test::TestData aSV2ret = xLBT->setValues2(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+
+ OSL_ASSERT( equals( aData, aSV2ret ) && equals( aData, aRet2 ) );
+ }
+ {
+ test::TestData aRet, aRet2;
+ test::TestData aGVret = xLBT->getValues(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+
+ OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) && equals( aData, aGVret ) );
+
+ // set last retrieved values
+ xLBT->setBool( aRet.Bool );
+ xLBT->setChar( aRet.Char );
+ xLBT->setByte( aRet.Byte );
+ xLBT->setShort( aRet.Short );
+ xLBT->setUShort( aRet.UShort );
+ xLBT->setLong( aRet.Long );
+ xLBT->setULong( aRet.ULong );
+ xLBT->setHyper( aRet.Hyper );
+ xLBT->setUHyper( aRet.UHyper );
+ xLBT->setFloat( aRet.Float );
+ xLBT->setDouble( aRet.Double );
+ xLBT->setEnum( aRet.Enum );
+ xLBT->setString( aRet.String );
+ xLBT->setInterface( aRet.Interface );
+ xLBT->setAny( aRet.Any );
+ xLBT->setSequence( aRet.Sequence );
+ xLBT->setStruct( aRet2 );
+ }
+ {
+ test::TestData aRet, aRet2;
+ aRet.Hyper = xLBT->getHyper();
+ aRet.UHyper = xLBT->getUHyper();
+ aRet.Float = xLBT->getFloat();
+ aRet.Double = xLBT->getDouble();
+ aRet.Byte = xLBT->getByte();
+ aRet.Char = xLBT->getChar();
+ aRet.Bool = xLBT->getBool();
+ aRet.Short = xLBT->getShort();
+ aRet.UShort = xLBT->getUShort();
+ aRet.Long = xLBT->getLong();
+ aRet.ULong = xLBT->getULong();
+ aRet.Enum = xLBT->getEnum();
+ aRet.String = xLBT->getString();
+ aRet.Interface = xLBT->getInterface();
+ aRet.Any = xLBT->getAny();
+ aRet.Sequence = xLBT->getSequence();
+ aRet2 = xLBT->getStruct();
+
+ return (equals( aData, aRet ) && equals( aData, aRet2 ));
+ }
+ }
+ return sal_False;
+}
+
+//__________________________________________________________________________________________________
+test::TestData Test_Impl::raiseException( sal_Bool& /*bBool*/, sal_Unicode& /*cChar*/, sal_Int8& /*nByte*/, sal_Int16& /*nShort*/, sal_uInt16& /*nUShort*/, sal_Int32& /*nLong*/, sal_uInt32& /*nULong*/, sal_Int64& /*nHyper*/, sal_uInt64& /*nUHyper*/, float& /*fFloat*/, double& /*fDouble*/, test::TestEnum& /*eEnum*/, ::rtl::OUString& /*aString*/, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& /*xInterface*/, ::com::sun::star::uno::Any& /*aAny*/, ::com::sun::star::uno::Sequence< test::TestElement >& /*aSequence*/, test::TestData& /*aStruct*/ )
+ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+ IllegalArgumentException aExc;
+ aExc.ArgumentPosition = 5;
+ aExc.Message = OUString::createFromAscii("dum dum dum ich tanz im kreis herum...");
+ aExc.Context = *this;
+ throw aExc;
+}
+//__________________________________________________________________________________________________
+sal_Int32 Test_Impl::getRuntimeException() throw(::com::sun::star::uno::RuntimeException)
+{
+ RuntimeException aExc;
+ aExc.Message = OUString::createFromAscii("dum dum dum ich tanz im kreis herum...");
+ aExc.Context = *this;
+ throw aExc;
+}
+//__________________________________________________________________________________________________
+void Test_Impl::setRuntimeException( sal_Int32 /*_runtimeexception*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+ RuntimeException aExc;
+ aExc.Message = OUString::createFromAscii("dum dum dum ich tanz im kreis herum...");
+ aExc.Context = *this;
+ throw aExc;
+}
+
+//==================================================================================================
+sal_Bool raiseException( const Reference<XLanguageBindingTest > & xLBT )
+{
+ try
+ {
+ try
+ {
+ try
+ {
+ test::TestData aRet, aRet2;
+ xLBT->raiseException(
+ aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort,
+ aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double,
+ aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 );
+ return sal_False;
+ }
+ catch (IllegalArgumentException aExc)
+ {
+ OSL_ENSURE( aExc.ArgumentPosition == 5 &&
+// aExc.Context == xLBT &&
+ aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
+ "### unexpected exception content!" );
+
+ Reference<XLanguageBindingTest > xLBT2(
+ Reference<XLanguageBindingTest >::query( aExc.Context ) );
+
+ OSL_ENSURE( xLBT2.is(), "### unexpected source of exception!" );
+ if (xLBT2.is())
+ xLBT2->getRuntimeException();
+ else
+ return sal_False;
+ }
+ }
+ catch (const RuntimeException & rExc)
+ {
+ OSL_ENSURE(//rExc.Context == xLBT &&
+ rExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
+ "### unexpected exception content!" );
+
+ Reference<XLanguageBindingTest > xLBT2(
+ Reference<XLanguageBindingTest >::query( rExc.Context ) );
+
+ OSL_ENSURE( xLBT2.is(), "### unexpected source of exception!" );
+ if (xLBT2.is())
+ xLBT2->setRuntimeException( 0xcafebabe );
+ else
+ return sal_False;
+ }
+ }
+ catch (Exception & aExc)
+ {
+ OSL_ENSURE( //aExc.Context == xLBT &&
+ aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")),
+ "### unexpected exception content!" );
+ return (//aExc.Context == xLBT &&
+ aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")));
+ }
+ return sal_False;
+}
+
+//==================================================================================================
+static sal_Bool test_adapter( const Reference< XMultiServiceFactory > & xMgr )
+{
+ Reference< XInvocationAdapterFactory > xAdapFac(
+ xMgr->createInstance( OUString::createFromAscii("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY );
+ Reference< XInvocationAdapterFactory2 > xAdapFac2( xAdapFac, UNO_QUERY_THROW );
+
+ Reference< XLanguageBindingTest > xOriginal( (XLanguageBindingTest *)new Test_Impl() );
+ Reference< XInvocation > xInvok( new XLB_Invocation( xMgr, xOriginal ) );
+ Reference< XLanguageBindingTest > xLBT( xAdapFac->createAdapter(
+ xInvok, ::getCppuType( (const Reference< XLanguageBindingTest > *)0 ) ), UNO_QUERY );
+ Reference< XLanguageBindingTest > xLBT2(
+ xAdapFac->createAdapter(
+ xInvok, ::getCppuType( (const Reference< XLanguageBindingTest > *)0 ) ), UNO_QUERY );
+ if (xLBT != xLBT2)
+ return sal_False;
+ Reference< XInterface > xLBT3(
+ xAdapFac->createAdapter(
+ xInvok, ::getCppuType( (const Reference< XInterface > *)0 ) ), UNO_QUERY );
+ if (xLBT != xLBT3)
+ return sal_False;
+ Type ar[ 2 ] = {
+ ::getCppuType( (const Reference< XLBTestBase > *)0 ),
+ ::getCppuType( (const Reference< XInterface > *)0 ) };
+ Reference< XInterface > xLBT4(
+ xAdapFac2->createAdapter( xInvok, Sequence< Type >( ar, 2 ) ), UNO_QUERY );
+ if (xLBT != xLBT4)
+ return sal_False;
+ Reference< XSimpleRegistry > xInvalidAdapter(
+ xAdapFac->createAdapter(
+ xInvok, ::getCppuType( (const Reference< XSimpleRegistry > *)0 ) ), UNO_QUERY );
+ if (xLBT == xInvalidAdapter)
+ return sal_False;
+
+ try
+ {
+ xInvalidAdapter->isValid();
+ return sal_False;
+ }
+ catch (RuntimeException &)
+ {
+ }
+
+ return (performTest( xLBT ) && raiseException( xLBT ));
+}
+//==================================================================================================
+static sal_Bool test_invocation( const Reference< XMultiServiceFactory > & xMgr )
+{
+ Reference< XInvocationAdapterFactory > xAdapFac(
+ xMgr->createInstance( OUString::createFromAscii("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY );
+ Reference< XSingleServiceFactory > xInvocFac(
+ xMgr->createInstance( OUString::createFromAscii("com.sun.star.script.Invocation") ), UNO_QUERY );
+
+ Reference< XLanguageBindingTest > xOriginal( (XLanguageBindingTest *)new Test_Impl() );
+ Any aOriginal( &xOriginal, ::getCppuType( &xOriginal ) );
+ Reference< XInvocation > xInvok(
+ xInvocFac->createInstanceWithArguments( Sequence< Any >( &aOriginal, 1 ) ), UNO_REF_QUERY );
+
+ Reference< XLanguageBindingTest > xLBT( xAdapFac->createAdapter(
+ xInvok, ::getCppuType( (const Reference< XLanguageBindingTest > *)0 ) ), UNO_QUERY );
+
+ return (performTest( xLBT ) && raiseException( xLBT ));
+}
+
+SAL_IMPLEMENT_MAIN()
+{
+ Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
+
+ try
+ {
+ Reference< XImplementationRegistration > xImplReg(
+ xMgr->createInstance(
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.registry.ImplementationRegistration") ) ),
+ UNO_QUERY );
+ OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
+
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ OUString::createFromAscii("invocadapt.uno" SAL_DLLEXTENSION),
+ Reference< XSimpleRegistry >() );
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ OUString::createFromAscii("stocservices.uno" SAL_DLLEXTENSION),
+ Reference< XSimpleRegistry >() );
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ OUString::createFromAscii("invocation.uno" SAL_DLLEXTENSION),
+ Reference< XSimpleRegistry >() );
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ OUString::createFromAscii("reflection.uno" SAL_DLLEXTENSION),
+ Reference< XSimpleRegistry >() );
+ xImplReg->registerImplementation(
+ OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ OUString::createFromAscii("introspection.uno" SAL_DLLEXTENSION),
+ Reference< XSimpleRegistry >() );
+
+ if (test_adapter( xMgr ))
+ {
+ fprintf( stderr, "> test_iadapter() succeeded.\n" );
+ if (test_invocation( xMgr ))
+ {
+ fprintf( stderr, "> test_invocation() succeeded.\n" );
+ }
+ }
+ }
+ catch (Exception & rExc)
+ {
+ fprintf( stderr, "> exception occured: " );
+ OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ fprintf( stderr, "%s\n", aMsg.getStr() );
+ }
+
+ Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
+
+ return 0;
+}
diff --git a/stoc/test/testintrosp.cxx b/stoc/test/testintrosp.cxx
new file mode 100644
index 000000000000..a706f8666fee
--- /dev/null
+++ b/stoc/test/testintrosp.cxx
@@ -0,0 +1,1617 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include <sal/main.h>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <osl/diagnose.h>
+
+//#include <vos/dynload.hxx>
+
+#include <ModuleA/XIntroTest.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/PropertyConcept.hpp>
+#include <com/sun/star/beans/MethodConcept.hpp>
+#include <com/sun/star/beans/XExactName.hpp>
+#include <com/sun/star/container/XElementAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/reflection/XIdlReflection.hpp>
+//#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <stdio.h>
+#include <string.h>
+
+
+using namespace rtl;
+using namespace cppu;
+//using namespace vos;
+using namespace ModuleA;
+//using namespace ModuleB;
+//using namespace ModuleC;
+//using namespace ModuleA::ModuleB;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::container;
+using namespace com::sun::star::beans::PropertyAttribute;
+
+
+typedef WeakImplHelper4< XIntroTest, XPropertySet, XNameAccess, XIndexAccess > ImplIntroTestHelper;
+typedef WeakImplHelper1< XPropertySetInfo > ImplPropertySetInfoHelper;
+
+
+#define DEFAULT_INDEX_ACCESS_COUNT 10
+#define DEFAULT_NAME_ACCESS_COUNT 5
+
+#if OSL_DEBUG_LEVEL > 0
+#define TEST_ENSHURE(c, m) OSL_ENSURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) OSL_VERIFY(c)
+#endif
+
+//class IntroTestWritelnOutput;
+
+
+
+//**************************************************************
+//*** Hilfs-Funktion, um vom Type eine XIdlClass zu bekommen ***
+//**************************************************************
+Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XMultiServiceFactory > & xMgr )
+{
+ static Reference< XIdlReflection > xRefl;
+
+ // void als Default-Klasse eintragen
+ Reference<XIdlClass> xRetClass;
+ typelib_TypeDescription * pTD = 0;
+ rType.getDescription( &pTD );
+ if( pTD )
+ {
+ OUString sOWName( pTD->pTypeName );
+ if( !xRefl.is() )
+ {
+ xRefl = Reference< XIdlReflection >( xMgr->createInstance(
+ OUString::createFromAscii("com.sun.star.reflection.CoreReflection") ), UNO_QUERY );
+ OSL_ENSURE( xRefl.is(), "### no corereflection!" );
+ }
+ xRetClass = xRefl->forName( sOWName );
+ }
+ return xRetClass;
+}
+
+
+//****************************************************
+//*** Hilfs-Funktion, um Any als UString auszugeben ***
+//****************************************************
+// ACHTUNG: Kann mal an eine zentrale Stelle uebernommen werden
+// Wird zunaechst nur fuer einfache Datentypen ausgefuehrt
+
+OUString AnyToString( const Any& aValue, sal_Bool bIncludeType, const Reference< XMultiServiceFactory > & xMgr )
+{
+ Type aValType = aValue.getValueType();
+ TypeClass eType = aValType.getTypeClass();
+ char pBuffer[50];
+
+ OUString aRetStr;
+ switch( eType )
+ {
+ case TypeClass_TYPE: aRetStr = OUString::createFromAscii("TYPE TYPE"); break;
+ case TypeClass_INTERFACE: aRetStr = OUString::createFromAscii("TYPE INTERFACE"); break;
+ case TypeClass_SERVICE: aRetStr = OUString::createFromAscii("TYPE SERVICE"); break;
+ case TypeClass_STRUCT: aRetStr = OUString::createFromAscii("TYPE STRUCT"); break;
+ case TypeClass_TYPEDEF: aRetStr = OUString::createFromAscii("TYPE TYPEDEF"); break;
+ case TypeClass_UNION: aRetStr = OUString::createFromAscii("TYPE UNION"); break;
+ case TypeClass_ENUM: aRetStr = OUString::createFromAscii("TYPE ENUM"); break;
+ case TypeClass_EXCEPTION: aRetStr = OUString::createFromAscii("TYPE EXCEPTION"); break;
+ case TypeClass_ARRAY: aRetStr = OUString::createFromAscii("TYPE ARRAY"); break;
+ case TypeClass_SEQUENCE: aRetStr = OUString::createFromAscii("TYPE SEQUENCE"); break;
+ case TypeClass_VOID: aRetStr = OUString::createFromAscii("TYPE void"); break;
+ case TypeClass_ANY: aRetStr = OUString::createFromAscii("TYPE any"); break;
+ case TypeClass_UNKNOWN: aRetStr = OUString::createFromAscii("TYPE unknown"); break;
+ case TypeClass_BOOLEAN:
+ {
+ sal_Bool b = *(sal_Bool*)aValue.getValue();
+ //aRet.setValue( &b, getCppuBooleanType() );
+ //aValue >>= b;
+ aRetStr = OUString::valueOf( b );
+ break;
+ }
+ case TypeClass_CHAR:
+ {
+ sal_Unicode c = *(sal_Unicode*)aValue.getValue();
+ //aValue >>= c;
+ //getCppuCharType()
+ aRetStr = OUString::valueOf( c );
+ break;
+ }
+ case TypeClass_STRING:
+ {
+ aValue >>= aRetStr;
+ break;
+ }
+ case TypeClass_FLOAT:
+ {
+ float f(0.0);
+ aValue >>= f;
+ snprintf( pBuffer, sizeof( pBuffer ), "%f", f );
+ aRetStr = OUString( pBuffer, strlen( pBuffer ), RTL_TEXTENCODING_ASCII_US );
+ break;
+ }
+ case TypeClass_DOUBLE:
+ {
+ double d(0.0);
+ aValue >>= d;
+ snprintf( pBuffer, sizeof( pBuffer ), "%f", d );
+ aRetStr = OUString( pBuffer, strlen( pBuffer ), RTL_TEXTENCODING_ASCII_US );
+ break;
+ }
+ case TypeClass_BYTE:
+ {
+ sal_Int8 n(0);
+ aValue >>= n;
+ aRetStr = OUString::valueOf( (sal_Int32) n );
+ break;
+ }
+ case TypeClass_SHORT:
+ {
+ sal_Int16 n(0);
+ aValue >>= n;
+ aRetStr = OUString::valueOf( (sal_Int32) n );
+ break;
+ }
+ case TypeClass_LONG:
+ {
+ sal_Int32 n(0);
+ aValue >>= n;
+ aRetStr = OUString::valueOf( n );
+ break;
+ }
+ /*
+ case TypeClass_HYPER:
+ {
+ aRetStr = L"TYPE HYPER";
+ break;
+ }
+ case TypeClass_UNSIGNED_SHORT:
+ {
+ aRetStr = StringToUString(WSString(aValue.getUINT16()), CHARSET_SYSTEM);
+ break;
+ }
+ case TypeClass_UNSIGNED_LONG:
+ {
+ aRetStr = StringToUString(WSString(aValue.getUINT32()), CHARSET_SYSTEM);
+ break;
+ }
+ case TypeClass_UNSIGNED_HYPER:
+ {
+ aRetStr = L"TYPE UNSIGNED_HYPER";
+ break;
+ }
+ */
+ default: ;
+ }
+
+ if( bIncludeType )
+ {
+ Reference< XIdlClass > xIdlClass = TypeToIdlClass( aValType, xMgr );
+ aRetStr = aRetStr + OUString( OUString::createFromAscii(" (Typ: ") ) + xIdlClass->getName() + OUString::createFromAscii(")");
+ }
+ return aRetStr;
+}
+
+/*
+// Hilfs-Funktion, um ein UString in einen Any zu konvertieren
+UsrAny StringToAny( UString aStr, TypeClass eTargetType )
+{
+ UsrAny aRetAny;
+ switch( eTargetType )
+ {
+ case TypeClass_INTERFACE: break;
+ case TypeClass_SERVICE: break;
+ case TypeClass_STRUCT: break;
+ case TypeClass_TYPEDEF: break;
+ case TypeClass_UNION: break;
+ case TypeClass_ENUM: break;
+ case TypeClass_EXCEPTION: break;
+ case TypeClass_ARRAY: break;
+ case TypeClass_SEQUENCE: break;
+ case TypeClass_VOID: break;
+ case TypeClass_ANY: break;
+ case TypeClass_UNKNOWN: break;
+ case TypeClass_BOOLEAN: aRetAny.setBOOL( short(aStr)!=0 ); break;
+ case TypeClass_CHAR: aRetAny.setChar( char(aStr) ); break;
+ case TypeClass_STRING: aRetAny.setString( aStr ); break;
+ case TypeClass_FLOAT: aRetAny.setFloat( (float)strtod( aStr.GetStr(), NULL ) ); break;
+ case TypeClass_DOUBLE: aRetAny.setDouble( strtod( aStr.GetStr(), NULL ) ); break;
+ case TypeClass_BYTE: aRetAny.setBYTE( BYTE(short(aStr)) ); break;
+ case TypeClass_SHORT: aRetAny.setINT16( short(aStr) ); break;
+ case TypeClass_LONG: aRetAny.setINT32( long(aStr) ); break;
+ case TypeClass_HYPER: break;
+ case TypeClass_UNSIGNED_SHORT: aRetAny.setUINT16( USHORT(aStr) ); break;
+ case TypeClass_UNSIGNED_LONG: aRetAny.setUINT32( ULONG(aStr) ); break;
+ case TypeClass_UNSIGNED_HYPER: break;
+ }
+ return aRetAny;
+}
+*/
+
+
+//*****************************************
+//*** XPropertySetInfo fuer Test-Klasse ***
+//*****************************************
+
+class ImplPropertySetInfo : public ImplPropertySetInfoHelper
+{
+ friend class ImplIntroTest;
+
+ Reference< XMultiServiceFactory > mxMgr;
+
+public:
+ ImplPropertySetInfo( const Reference< XMultiServiceFactory > & xMgr )
+ : mxMgr( xMgr ) {}
+ //: mxMgr( xMgr ), ImplPropertySetInfoHelper( xMgr ) {}
+
+/*
+ // Methoden von XInterface
+ virtual sal_Bool SAL_CALL queryInterface( const Uik & rUik, Any & ifc ) throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
+ virtual void SAL_CALL release() throw() { OWeakObject::release(); }
+ //ALT: sal_Bool queryInterface( Uik aUik, Reference<XInterface> & rOut );
+*/
+
+ // Methods of XPropertySetInfo
+ virtual Sequence< Property > SAL_CALL getProperties( )
+ throw(RuntimeException);
+ virtual Property SAL_CALL getPropertyByName( const OUString& aName )
+ throw(UnknownPropertyException, RuntimeException);
+ virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name )
+ throw(RuntimeException);
+ //virtual Sequence< Property > SAL_CALL getProperties(void) throw( RuntimeException );
+ //virtual Property SAL_CALL getPropertyByName(const OUString& Name) throw( RuntimeException );
+ //virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& Name) throw( RuntimeException );
+};
+
+
+/*
+// Methoden von XInterface
+sal_Bool SAL_CALL ImplPropertySetInfo::queryInterface( const Uik & rUik, Any & ifc )
+ throw( RuntimeException )
+{
+ // PropertySet-Implementation
+ if( com::sun::star::uno::queryInterface( rUik, ifc,
+ SAL_STATIC_CAST(XPropertySetInfo*, this) ) )
+ return sal_True;
+
+ return OWeakObject::queryInterface( rUik, ifc );
+}
+
+sal_Bool ImplPropertySetInfo::queryInterface( Uik aUik, Reference<XInterface> & rOut )
+{
+ if( aUik == XPropertySetInfo::getSmartUik() )
+ rOut = (XPropertySetInfo *)this;
+ else
+ UsrObject::queryInterface( aUik, rOut );
+ return rOut.is();
+}
+*/
+
+Sequence< Property > ImplPropertySetInfo::getProperties(void)
+ throw( RuntimeException )
+{
+ static Sequence<Property> * pSeq = NULL;
+
+ if( !pSeq )
+ {
+ // die Informationen für die Properties "Width", "Height" und "Name" anlegen
+ pSeq = new Sequence<Property>( 3 );
+ Property * pAry = pSeq->getArray();
+
+ pAry[0].Name = OUString::createFromAscii("Factor");
+ pAry[0].Handle = -1;
+ pAry[0].Type = getCppuType( (double*) NULL );
+ //pAry[0].Type = TypeToIdlClass( getCppuType( (double*) NULL ), mxMgr );
+ //pAry[0].Type = Double_getReflection()->getIdlClass();
+ pAry[0].Attributes = BOUND | TRANSIENT;
+
+ pAry[1].Name = OUString::createFromAscii("MyCount");
+ pAry[1].Handle = -1;
+ pAry[1].Type = getCppuType( (sal_Int32*) NULL );
+ //pAry[1].Type = TypeToIdlClass( getCppuType( (sal_Int32*) NULL ), mxMgr );
+ //pAry[1].Type = INT32_getReflection()->getIdlClass();
+ pAry[1].Attributes = BOUND | TRANSIENT;
+
+ pAry[2].Name = OUString::createFromAscii("Info");
+ pAry[2].Handle = -1;
+ pAry[2].Type = getCppuType( (OUString*) NULL );
+ //pAry[2].Type = TypeToIdlClass( getCppuType( (OUString*) NULL ), mxMgr );
+ //pAry[2].Type = OUString_getReflection()->getIdlClass();
+ pAry[2].Attributes = TRANSIENT;
+ }
+ // Die Information über alle drei Properties liefern.
+ return *pSeq;
+}
+
+Property ImplPropertySetInfo::getPropertyByName(const OUString& Name)
+ throw( UnknownPropertyException, RuntimeException )
+{
+ Sequence<Property> aSeq = getProperties();
+ const Property * pAry = aSeq.getConstArray();
+
+ for( sal_Int32 i = aSeq.getLength(); i--; )
+ {
+ if( pAry[i].Name == Name )
+ return pAry[i];
+ }
+ // Property unbekannt, also leere liefern
+ return Property();
+}
+
+sal_Bool ImplPropertySetInfo::hasPropertyByName(const OUString& Name)
+ throw( RuntimeException )
+{
+ Sequence<Property> aSeq = getProperties();
+ const Property * pAry = aSeq.getConstArray();
+
+ for( sal_Int32 i = aSeq.getLength(); i--; )
+ {
+ if( pAry[i].Name == Name )
+ return sal_True;
+ }
+ // Property unbekannt, also leere liefern
+ return sal_False;
+}
+
+
+
+
+//*****************************************************************
+
+
+
+class ImplIntroTest : public ImplIntroTestHelper
+{
+ Reference< XMultiServiceFactory > mxMgr;
+
+ friend class ImplPropertySetInfo;
+
+ // Properties fuer das PropertySet
+ Any aAnyArray[10];
+
+ // Optionale Schnittstelle fuer die writeln-Ausgabe
+ //IntroTestWritelnOutput* m_pOutput;
+
+ Reference< XPropertySetInfo > m_xMyInfo;
+
+ OUString m_ObjectName;
+
+ sal_Int16 m_nMarkusAge;
+ sal_Int16 m_nMarkusChildrenCount;
+
+ long m_lDroenk;
+ sal_Int16 m_nBla;
+ sal_Int16 m_nBlub;
+ sal_Int16 m_nGulp;
+ sal_Int16 m_nLaber;
+ TypeClass eTypeClass;
+ Sequence< OUString > aStringSeq;
+ Sequence< Sequence< Sequence< sal_Int16 > > > aMultSeq;
+ Reference< XIntroTest > m_xIntroTest;
+
+ // Daten fuer NameAccess
+ Reference< XIntroTest >* pNameAccessTab;
+
+ // Daten fuer IndexAccess
+ Reference< XIntroTest >* pIndexAccessTab;
+ sal_Int16 iIndexAccessCount;
+
+ // struct-Properties
+ Property m_aFirstStruct;
+ PropertyValue m_aSecondStruct;
+
+ // Listener merken (zunaechst einfach, nur einen pro Property)
+ Reference< XPropertyChangeListener > aPropChangeListener;
+ OUString aPropChangeListenerStr;
+ Reference< XVetoableChangeListener > aVetoPropChangeListener;
+ OUString aVetoPropChangeListenerStr;
+
+ void Init( void );
+
+public:
+ ImplIntroTest( const Reference< XMultiServiceFactory > & xMgr )
+ : mxMgr( xMgr )
+ //: mxMgr( xMgr ), ImplIntroTestHelper( xMgr )
+ {
+ Init();
+ }
+
+ /*
+ ImplIntroTest( IntroTestWritelnOutput* pOutput_ )
+ {
+ Init();
+ m_pOutput = pOutput_;
+ }
+ */
+
+ //SMART_UNO_DECLARATION(ImplIntroTest,UsrObject);
+
+ //BOOL queryInterface( Uik aUik, Reference< XInterface > & rOut );
+ //Reference< XIdlClass > getIdlClass();
+
+ // Trotz virtual inline, um Schreibarbeit zu sparen (nur fuer Testzwecke)
+ // XPropertySet
+ virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo( )
+ throw(RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException);
+ virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*xListener*/ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+ {}
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*aListener*/ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+ {}
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+ {}
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+ {}
+
+ /*
+ virtual void setIndexedPropertyValue(const OUString& aPropertyName, INT32 nIndex, const Any& aValue) {}
+ virtual Any getIndexedPropertyValue(const UString& aPropertyName, INT32 nIndex) const { return Any(); }
+ virtual void addPropertyChangeListener(const UString& aPropertyName, const XPropertyChangeListenerRef& aListener)
+ THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
+ virtual void removePropertyChangeListener(const UString& aPropertyName, const XPropertyChangeListenerRef& aListener)
+ THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
+ virtual void addVetoableChangeListener(const UString& aPropertyName, const XVetoableChangeListenerRef& aListener)
+ THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
+ virtual void removeVetoableChangeListener(const UString& aPropertyName, const XVetoableChangeListenerRef& aListener)
+ THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
+ */
+
+ // XIntroTest-Methoden
+ // Attributes
+ virtual OUString SAL_CALL getObjectName() throw(RuntimeException)
+ { return m_ObjectName; }
+ virtual void SAL_CALL setObjectName( const OUString& _objectname ) throw(RuntimeException)
+ { m_ObjectName = _objectname; }
+ virtual OUString SAL_CALL getFirstName()
+ throw(RuntimeException);
+ virtual OUString SAL_CALL getLastName() throw(RuntimeException)
+ { return OUString( OUString::createFromAscii("Meyer") ); }
+ virtual sal_Int16 SAL_CALL getAge() throw(RuntimeException)
+ { return m_nMarkusAge; }
+ virtual sal_Int16 SAL_CALL getChildrenCount() throw(RuntimeException)
+ { return m_nMarkusChildrenCount; }
+ virtual void SAL_CALL setChildrenCount( sal_Int16 _childrencount ) throw(RuntimeException)
+ { m_nMarkusChildrenCount = _childrencount; }
+ virtual Property SAL_CALL getFirstStruct() throw(RuntimeException)
+ { return m_aFirstStruct; }
+ virtual void SAL_CALL setFirstStruct( const Property& _firststruct ) throw(RuntimeException)
+ { m_aFirstStruct = _firststruct; }
+ virtual PropertyValue SAL_CALL getSecondStruct() throw(RuntimeException)
+ { return m_aSecondStruct; }
+ virtual void SAL_CALL setSecondStruct( const PropertyValue& _secondstruct ) throw(RuntimeException)
+ { m_aSecondStruct = _secondstruct; }
+
+ // Methods
+ virtual void SAL_CALL writeln( const OUString& Text )
+ throw(RuntimeException);
+ virtual sal_Int32 SAL_CALL getDroenk( ) throw(RuntimeException)
+ { return m_lDroenk; }
+ virtual Reference< ::ModuleA::XIntroTest > SAL_CALL getIntroTest( ) throw(RuntimeException);
+ virtual sal_Int32 SAL_CALL getUps( sal_Int32 l ) throw(RuntimeException)
+ { return 2*l; }
+ virtual void SAL_CALL setDroenk( sal_Int32 l ) throw(RuntimeException)
+ { m_lDroenk = l; }
+ virtual sal_Int16 SAL_CALL getBla( ) throw(RuntimeException)
+ { return m_nBla; }
+ virtual void SAL_CALL setBla( sal_Int32 n ) throw(RuntimeException)
+ { m_nBla = (sal_Int16)n; }
+ virtual sal_Int16 SAL_CALL getBlub( ) throw(RuntimeException)
+ { return m_nBlub; }
+ virtual void SAL_CALL setBlub( sal_Int16 n ) throw(RuntimeException)
+ { m_nBlub = n; }
+ virtual sal_Int16 SAL_CALL getGulp( ) throw(RuntimeException)
+ { return m_nGulp; }
+ virtual sal_Int16 SAL_CALL setGulp( sal_Int16 n ) throw(RuntimeException)
+ { m_nGulp = n; return 1; }
+ virtual TypeClass SAL_CALL getTypeClass( sal_Int16 /*n*/ ) throw(RuntimeException)
+ { return eTypeClass; }
+ virtual void SAL_CALL setTypeClass( TypeClass t, double /*d1*/, double /*d2*/ ) throw(RuntimeException)
+ { eTypeClass = t; }
+ virtual Sequence< OUString > SAL_CALL getStrings( ) throw(RuntimeException)
+ { return aStringSeq; }
+ virtual void SAL_CALL setStrings( const Sequence< OUString >& Strings ) throw(RuntimeException)
+ { aStringSeq = Strings; }
+ virtual void SAL_CALL setStringsPerMethod( const Sequence< OUString >& Strings, sal_Int16 /*n*/ ) throw(RuntimeException)
+ { aStringSeq = Strings; }
+ virtual Sequence< Sequence< Sequence< sal_Int16 > > > SAL_CALL getMultiSequence( ) throw(RuntimeException)
+ { return aMultSeq; }
+ virtual void SAL_CALL setMultiSequence( const Sequence< Sequence< Sequence< sal_Int16 > > >& Seq ) throw(RuntimeException)
+ { aMultSeq = Seq; }
+ virtual void SAL_CALL addPropertiesChangeListener( const Sequence< OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener )
+ throw(RuntimeException);
+ virtual void SAL_CALL removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& Listener )
+ throw(RuntimeException);
+
+
+ // Methods of XElementAccess
+ virtual Type SAL_CALL getElementType( )
+ throw(RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( )
+ throw(RuntimeException);
+ //virtual XIdlClassRef getElementType(void) constTHROWS( (UsrSystemException) );
+ //virtual BOOL hasElements(void) const THROWS( (UsrSystemException) );
+
+ // XNameAccess-Methoden
+ // Methods
+ virtual Any SAL_CALL getByName( const OUString& aName )
+ throw(NoSuchElementException, WrappedTargetException, RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getElementNames( )
+ throw(RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
+ throw(RuntimeException);
+ //virtual Any getByName(const UString& Name) const
+ //THROWS( (NoSuchElementException, WrappedTargetException, UsrSystemException) );
+ //virtual Sequence<UString> getElementNames(void) const THROWS( (UsrSystemException) );
+ //virtual BOOL hasByName(const UString& Name) const THROWS( (UsrSystemException) );
+
+ // XIndexAccess-Methoden
+ // Methods
+ virtual sal_Int32 SAL_CALL getCount( )
+ throw(RuntimeException);
+ virtual Any SAL_CALL getByIndex( sal_Int32 Index )
+ throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
+ //virtual INT32 getCount(void) const THROWS( (UsrSystemException) );
+ //virtual Any getByIndex(INT32 Index) const
+ //THROWS( (IndexOutOfBoundsException, WrappedTargetException, UsrSystemException) );
+};
+
+//SMART_UNO_IMPLEMENTATION(ImplIntroTest,UsrObject)
+
+void ImplIntroTest::Init( void )
+{
+ // Eindeutigen Namen verpassen
+ static sal_Int32 nObjCount = 0;
+ OUString aName( OUString::createFromAscii("IntroTest-Obj Nr. ") );
+ aName += OUString::valueOf( nObjCount );
+ setObjectName( aName );
+
+ // Properties initialisieren
+ aAnyArray[0] <<= 3.14;
+ aAnyArray[1] <<= (sal_Int32)42;
+ aAnyArray[2] <<= OUString( OUString::createFromAscii("Hallo") );
+
+ // Output-Interface
+ //m_pOutput = NULL;
+
+ // Einmal fuer den internen Gebrauch die PropertySetInfo abholen
+ m_xMyInfo = getPropertySetInfo();
+ m_xMyInfo->acquire(); // sonst raucht es am Programm-Ende ab
+
+ m_nMarkusAge = 33;
+ m_nMarkusChildrenCount = 2;
+
+ m_lDroenk = 314;
+ m_nBla = 42;
+ m_nBlub = 111;
+ m_nGulp = 99;
+ m_nLaber = 1;
+ eTypeClass = TypeClass_INTERFACE;
+
+ // String-Sequence intitialisieren
+ aStringSeq.realloc( 3 );
+ OUString* pStr = aStringSeq.getArray();
+ pStr[ 0 ] = OUString( OUString::createFromAscii("String 0") );
+ pStr[ 1 ] = OUString( OUString::createFromAscii("String 1") );
+ pStr[ 2 ] = OUString( OUString::createFromAscii("String 2") );
+
+ // structs initialisieren
+ m_aFirstStruct.Name = OUString::createFromAscii("FirstStruct-Name");
+ m_aFirstStruct.Handle = 77777;
+ //XIdlClassRef Type;
+ m_aFirstStruct.Attributes = -222;
+
+ //XInterfaceRef Source;
+ Any Value;
+ Value <<= 2.718281828459;
+ m_aSecondStruct.Value = Value;
+ //XIdlClassRef ListenerType;
+ m_aSecondStruct.State = PropertyState_DIRECT_VALUE;
+
+ // IndexAccess
+ iIndexAccessCount = DEFAULT_INDEX_ACCESS_COUNT;
+ pIndexAccessTab = NULL;
+ pNameAccessTab = NULL;
+}
+
+/*
+BOOL ImplIntroTest::queryInterface( Uik aUik, XInterfaceRef & rOut )
+{
+ if( aUik == XIntroTest::getSmartUik() )
+ rOut = (XIntroTest*)this;
+ else if( aUik == XPropertySet::getSmartUik() )
+ rOut = (XPropertySet*)this;
+ else if( aUik == XNameAccess::getSmartUik() )
+ rOut = (XNameAccess*)this;
+ else if( aUik == XIndexAccess::getSmartUik() )
+ rOut = (XIndexAccess*)this;
+ else if( aUik == ((XElementAccess*)NULL)->getSmartUik() )
+ rOut = (XElementAccess*)(XIndexAccess *)this;
+ else
+ UsrObject::queryInterface( aUik, rOut );
+ return rOut.is();
+}
+
+XIdlClassRef ImplIntroTest::getIdlClass()
+{
+ static XIdlClassRef xClass = createStandardClass( L"ImplIntroTest",
+ UsrObject::getUsrObjectIdlClass(), 4,
+ XIntroTest_getReflection(),
+ XPropertySet_getReflection(),
+ XNameAccess_getReflection(),
+ XIndexAccess_getReflection() );
+ return xClass;
+}
+*/
+
+Reference< XPropertySetInfo > ImplIntroTest::getPropertySetInfo()
+ throw(RuntimeException)
+{
+ static ImplPropertySetInfo aInfo( mxMgr );
+ // Alle Objekt haben die gleichen Properties, deshalb kann
+ // die Info für alle gleich sein
+ return &aInfo;
+
+ //if( m_xMyInfo == NULL )
+ // ((ImplIntroTest*)this)->m_xMyInfo = new ImplPropertySetInfo( this );
+ //return m_xMyInfo;
+}
+
+void ImplIntroTest::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+//void ImplIntroTest::setPropertyValue( const UString& aPropertyName, const Any& aValue )
+// THROWS( (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, UsrSystemException) )
+{
+ if( aPropChangeListener.is() && aPropertyName == aPropChangeListenerStr )
+ {
+ PropertyChangeEvent aEvt;
+ aEvt.Source = (OWeakObject*)this;
+ aEvt.PropertyName = aPropertyName;
+ aEvt.PropertyHandle = 0L;
+ //aEvt.OldValue;
+ //aEvt.NewValue;
+ //aEvt.PropagationId;
+ aPropChangeListener->propertyChange( aEvt );
+ }
+ if( aVetoPropChangeListener.is() && aPropertyName == aVetoPropChangeListenerStr )
+ {
+ PropertyChangeEvent aEvt;
+ aEvt.Source = (OWeakObject*)this;
+ aEvt.PropertyName = aVetoPropChangeListenerStr;
+ aEvt.PropertyHandle = 0L;
+ //aEvt.OldValue;
+ //aEvt.NewValue;
+ //aEvt.PropagationId;
+ aVetoPropChangeListener->vetoableChange( aEvt );
+ }
+
+ Sequence<Property> aPropSeq = m_xMyInfo->getProperties();
+ sal_Int32 nLen = aPropSeq.getLength();
+ for( sal_Int32 i = 0 ; i < nLen ; i++ )
+ {
+ Property aProp = aPropSeq.getArray()[ i ];
+ if( aProp.Name == aPropertyName )
+ aAnyArray[i] = aValue;
+ }
+}
+
+Any ImplIntroTest::getPropertyValue( const OUString& PropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+//Any ImplIntroTest::getPropertyValue(const UString& aPropertyName) const
+ //THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) )
+{
+ Sequence<Property> aPropSeq = m_xMyInfo->getProperties();
+ sal_Int32 nLen = aPropSeq.getLength();
+ for( sal_Int32 i = 0 ; i < nLen ; i++ )
+ {
+ Property aProp = aPropSeq.getArray()[ i ];
+ if( aProp.Name == PropertyName )
+ return aAnyArray[i];
+ }
+ return Any();
+}
+
+OUString ImplIntroTest::getFirstName(void)
+ throw(RuntimeException)
+{
+ return OUString( OUString::createFromAscii("Markus") );
+}
+
+void ImplIntroTest::writeln( const OUString& Text )
+ throw(RuntimeException)
+{
+ OString aStr( Text.getStr(), Text.getLength(), RTL_TEXTENCODING_ASCII_US );
+
+ // Haben wir ein Output?
+ //if( m_pOutput )
+ //{
+ //m_pOutput->doWriteln( TextStr );
+ //}
+ // Sonst einfach rausbraten
+ //else
+ {
+ printf( "%s", aStr.getStr() );
+ }
+}
+
+Reference< XIntroTest > ImplIntroTest::getIntroTest()
+ throw(RuntimeException)
+//XIntroTestRef ImplIntroTest::getIntroTest(void) THROWS( (UsrSystemException) )
+{
+ if( !m_xIntroTest.is() )
+ m_xIntroTest = new ImplIntroTest( mxMgr );
+ return m_xIntroTest;
+}
+
+// Methoden von XElementAccess
+Type ImplIntroTest::getElementType( )
+ throw(RuntimeException)
+//XIdlClassRef ImplIntroTest::getElementType(void) const THROWS( (UsrSystemException) )
+{
+ // TODO
+ Type aRetType;
+ return aRetType;
+ //return Reference< XIdlClass >();
+ //return Void_getReflection()->getIdlClass();
+}
+
+sal_Bool ImplIntroTest::hasElements( )
+ throw(RuntimeException)
+//BOOL ImplIntroTest::hasElements(void) const THROWS( (UsrSystemException) )
+{
+ return sal_True;
+}
+
+// XNameAccess-Methoden
+sal_Int32 getIndexForName( const OUString& ItemName )
+{
+ OUString aLeftStr = ItemName.copy( 0, 4 );
+ if( aLeftStr == OUString::createFromAscii("Item") )
+ {
+ // TODO
+ OUString aNumStr = ItemName.copy( 4 );
+ //sal_Int32 iIndex = (INT32)UStringToString( aNumStr, CHARSET_SYSTEM );
+ //if( iIndex < DEFAULT_NAME_ACCESS_COUNT )
+ //return iIndex;
+ }
+ return -1;
+}
+
+
+Any ImplIntroTest::getByName( const OUString& aName )
+ throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+//Any ImplIntroTest::getByName(const UString& Name) const
+ //THROWS( (NoSuchElementException, WrappedTargetException, UsrSystemException) )
+{
+ Any aRetAny;
+
+ if( !pNameAccessTab )
+ ((ImplIntroTest*)this)->pNameAccessTab = new Reference< XIntroTest >[ DEFAULT_NAME_ACCESS_COUNT ];
+
+ sal_Int32 iIndex = getIndexForName( aName );
+ if( iIndex != -1 )
+ {
+ if( !pNameAccessTab[iIndex].is() )
+ {
+ ImplIntroTest* p = new ImplIntroTest( mxMgr );
+ OUString aName2( OUString::createFromAscii("IntroTest by Name-Access, Index = ") );
+ aName2 += OUString::valueOf( iIndex );
+ //aName2 = aName2 + StringToUString( String( iIndex ), CHARSET_SYSTEM );
+ p->setObjectName( aName2 );
+ pNameAccessTab[iIndex] = p;
+ }
+
+ Reference< XIntroTest > xRet = pNameAccessTab[iIndex];
+ aRetAny = makeAny( xRet );
+
+ //aRetAny.set( &xRet, XIntroTest_getReflection() );
+ //return (UsrObject*)(XIntroTest*)pNameAccessTab[iIndex];
+ }
+ return aRetAny;
+}
+
+Sequence< OUString > ImplIntroTest::getElementNames( )
+ throw(RuntimeException)
+//Sequence<UString> ImplIntroTest::getElementNames(void) const THROWS( (UsrSystemException) )
+{
+ Sequence<OUString> aStrSeq( DEFAULT_NAME_ACCESS_COUNT );
+ OUString* pStr = aStrSeq.getArray();
+ for( sal_Int32 i = 0 ; i < DEFAULT_NAME_ACCESS_COUNT ; i++ )
+ {
+ OUString aName( OUString::createFromAscii("Item") );
+ aName += OUString::valueOf( i );
+ //aName = aName + StringToUString( i, CHARSET_SYSTEM );
+ pStr[i] = aName;
+ }
+ return aStrSeq;
+}
+
+sal_Bool ImplIntroTest::hasByName( const OUString& aName )
+ throw(RuntimeException)
+//BOOL ImplIntroTest::hasByName(const UString& Name) const THROWS( (UsrSystemException) )
+{
+ return ( getIndexForName( aName ) != -1 );
+}
+
+// XIndexAccess-Methoden
+sal_Int32 ImplIntroTest::getCount( )
+ throw(RuntimeException)
+//sal_Int32 ImplIntroTest::getCount(void) const THROWS( (UsrSystemException) )
+{
+ return iIndexAccessCount;
+}
+
+Any ImplIntroTest::getByIndex( sal_Int32 Index )
+ throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+//Any ImplIntroTest::getByIndex( sal_Int32 Index ) const
+ //THROWS( (IndexOutOfBoundsException, WrappedTargetException, UsrSystemException) )
+{
+ Any aRetAny;
+
+ if( !pIndexAccessTab )
+ ((ImplIntroTest*)this)->pIndexAccessTab = new Reference< XIntroTest >[ iIndexAccessCount ];
+
+ if( Index < iIndexAccessCount )
+ {
+ if( !pNameAccessTab[Index].is() )
+ {
+ ImplIntroTest* p = new ImplIntroTest( mxMgr );
+ OUString aName( OUString::createFromAscii("IntroTest by Index-Access, Index = ") );
+ aName += OUString::valueOf( Index );
+ //aName = aName + StringToUString( String( iIndex ), CHARSET_SYSTEM );
+ p->setObjectName( aName );
+ pIndexAccessTab[Index] = p;
+ }
+ Reference< XIntroTest > xRet = pIndexAccessTab[Index];
+ aRetAny = makeAny( xRet );
+ }
+ return aRetAny;
+}
+
+void ImplIntroTest::addPropertiesChangeListener( const Sequence< OUString >& /*PropertyNames*/,
+ const Reference< XPropertiesChangeListener >& /*Listener*/ )
+ throw(RuntimeException)
+//void ImplIntroTest::addPropertiesChangeListener
+//(const Sequence< UString >& PropertyNames, const XPropertiesChangeListenerRef& Listener)
+ //THROWS( (UsrSystemException) )
+{
+}
+
+void ImplIntroTest::removePropertiesChangeListener
+( const Reference< XPropertiesChangeListener >& /*Listener*/ )
+ throw(RuntimeException)
+//void ImplIntroTest::removePropertiesChangeListener(const XPropertiesChangeListenerRef& Listener)
+ //THROWS( (UsrSystemException) )
+{
+}
+
+
+
+struct DefItem
+{
+ char const * pName;
+ sal_Int32 nConcept;
+};
+
+// Spezial-Wert fuer Method-Concept, um "normale" Funktionen kennzeichnen zu koennen
+#define MethodConcept_NORMAL_IMPL 0x80000000
+
+
+// Test-Objekt liefern
+Any getIntrospectionTestObject( const Reference< XMultiServiceFactory > & xMgr )
+{
+ Any aObjAny;
+ Reference< XIntroTest > xTestObj = new ImplIntroTest( xMgr );
+ aObjAny.setValue( &xTestObj, ::getCppuType( (const Reference< XIntroTest > *)0 ) );
+ return aObjAny;
+}
+
+static sal_Bool test_introsp( Reference< XMultiServiceFactory > xMgr,
+ Reference< XIdlReflection > /*xRefl*/, Reference< XIntrospection > xIntrospection )
+{
+ DefItem pPropertyDefs[] =
+ {
+ { "Factor", PropertyConcept::PROPERTYSET },
+ { "MyCount", PropertyConcept::PROPERTYSET },
+ { "Info", PropertyConcept::PROPERTYSET },
+ { "ObjectName", PropertyConcept::ATTRIBUTES },
+ { "FirstName", PropertyConcept::ATTRIBUTES },
+ { "LastName", PropertyConcept::ATTRIBUTES },
+ { "Age", PropertyConcept::ATTRIBUTES },
+ { "ChildrenCount", PropertyConcept::ATTRIBUTES },
+ { "FirstStruct", PropertyConcept::ATTRIBUTES },
+ { "SecondStruct", PropertyConcept::ATTRIBUTES },
+ { "Droenk", PropertyConcept::METHODS },
+ { "IntroTest", PropertyConcept::METHODS },
+ { "Bla", PropertyConcept::METHODS },
+ { "Blub", PropertyConcept::METHODS },
+ { "Gulp", PropertyConcept::METHODS },
+ { "Strings", PropertyConcept::METHODS },
+ { "MultiSequence", PropertyConcept::METHODS },
+ { "PropertySetInfo", PropertyConcept::METHODS },
+ { "ElementType", PropertyConcept::METHODS },
+ { "ElementNames", PropertyConcept::METHODS },
+ { "Count", PropertyConcept::METHODS },
+ { "Types", PropertyConcept::METHODS },
+ { "ImplementationId", PropertyConcept::METHODS },
+ { NULL, 0 }
+ };
+
+ // Tabelle der Property-Namen, die gefunden werden muessen
+// char* pDemandedPropNames[] =
+// {
+// "Factor",
+// "MyCount",
+// "Info",
+// "ObjectName",
+// "FirstName",
+// "LastName",
+// "Age",
+// "ChildrenCount",
+// "FirstStruct",
+// "SecondStruct",
+// "Droenk",
+// "IntroTest",
+// "Bla",
+// "Blub",
+// "Gulp",
+// "Strings",
+// "MultiSequence",
+// "PropertySetInfo",
+// "ElementType",
+// "ElementNames",
+// "Count",
+// "Types"
+// "ImplementationId"
+// };
+
+ char const * pDemandedPropVals[] =
+ {
+ "3.140000",
+ "42",
+ "Hallo",
+ "IntroTest-Obj Nr. 0",
+ "Markus",
+ "Meyer",
+ "33",
+ "2",
+ "TYPE STRUCT",
+ "TYPE STRUCT",
+ "314",
+ "TYPE INTERFACE",
+ "42",
+ "111",
+ "99",
+ "TYPE SEQUENCE",
+ "TYPE SEQUENCE",
+ "TYPE INTERFACE",
+ "TYPE TYPE",
+ "TYPE SEQUENCE",
+ "10",
+ "TYPE SEQUENCE",
+ "TYPE SEQUENCE",
+ };
+
+ char const * pDemandedModifiedPropVals[] =
+ {
+ "4.140000",
+ "43",
+ "Hallo (Modified!)",
+ "IntroTest-Obj Nr. 0 (Modified!)",
+ "Markus",
+ "Meyer",
+ "33",
+ "3",
+ "Wert wurde nicht modifiziert",
+ "Wert wurde nicht modifiziert",
+ "315",
+ "Wert wurde nicht modifiziert",
+ "42",
+ "112",
+ "99",
+ "Wert wurde nicht modifiziert",
+ "Wert wurde nicht modifiziert",
+ "Wert wurde nicht modifiziert",
+ "Wert wurde nicht modifiziert",
+ "Wert wurde nicht modifiziert",
+ "10",
+ "Wert wurde nicht modifiziert"
+ "Wert wurde nicht modifiziert"
+ };
+
+ char const * pDemandedPropTypes[] =
+ {
+ "double",
+ "long",
+ "string",
+ "string",
+ "string",
+ "string",
+ "short",
+ "short",
+ "com.sun.star.beans.Property",
+ "com.sun.star.beans.PropertyValue",
+ "long",
+ "ModuleA.XIntroTest",
+ "short",
+ "short",
+ "short",
+ "[]string",
+ "[][][]short",
+ "com.sun.star.beans.XPropertySetInfo",
+ "type",
+ "[]string",
+ "long",
+ "[]type",
+ "[]byte",
+ };
+ //is() nDemandedPropCount = 22;
+
+
+ DefItem pMethodDefs[] =
+ {
+ { "queryInterface", MethodConcept_NORMAL_IMPL },
+ { "acquire", MethodConcept::DANGEROUS },
+ { "release", MethodConcept::DANGEROUS },
+ { "writeln", MethodConcept_NORMAL_IMPL },
+ { "getDroenk", MethodConcept::PROPERTY },
+ { "getIntroTest", MethodConcept::PROPERTY },
+ { "getUps", MethodConcept_NORMAL_IMPL },
+ { "setDroenk", MethodConcept::PROPERTY },
+ { "getBla", MethodConcept::PROPERTY },
+ { "setBla", MethodConcept_NORMAL_IMPL },
+ { "getBlub", MethodConcept::PROPERTY },
+ { "setBlub", MethodConcept::PROPERTY },
+ { "getGulp", MethodConcept::PROPERTY },
+ { "setGulp", MethodConcept_NORMAL_IMPL },
+ { "getTypeClass", MethodConcept_NORMAL_IMPL },
+ { "setTypeClass", MethodConcept_NORMAL_IMPL },
+ { "getStrings", MethodConcept::PROPERTY },
+ { "setStrings", MethodConcept::PROPERTY },
+ { "setStringsPerMethod", MethodConcept_NORMAL_IMPL },
+ { "getMultiSequence", MethodConcept::PROPERTY },
+ { "setMultiSequence", MethodConcept::PROPERTY },
+ { "addPropertiesChangeListener", MethodConcept::LISTENER },
+ { "removePropertiesChangeListener", MethodConcept::LISTENER },
+ { "getPropertySetInfo", MethodConcept::PROPERTY },
+ { "setPropertyValue", MethodConcept_NORMAL_IMPL },
+ { "getPropertyValue", MethodConcept_NORMAL_IMPL },
+ { "addPropertyChangeListener", MethodConcept::LISTENER },
+ { "removePropertyChangeListener", MethodConcept::LISTENER },
+ { "addVetoableChangeListener", MethodConcept::LISTENER },
+ { "removeVetoableChangeListener", MethodConcept::LISTENER },
+ { "getElementType", MethodConcept::PROPERTY | MethodConcept::NAMECONTAINER| MethodConcept::INDEXCONTAINER | MethodConcept::ENUMERATION },
+ { "hasElements", MethodConcept::NAMECONTAINER | MethodConcept::INDEXCONTAINER | MethodConcept::ENUMERATION },
+ { "getByName", MethodConcept::NAMECONTAINER },
+ { "getElementNames", MethodConcept::PROPERTY | MethodConcept::NAMECONTAINER },
+ { "hasByName", MethodConcept::NAMECONTAINER },
+ { "getCount", MethodConcept::PROPERTY | MethodConcept::INDEXCONTAINER },
+ { "getByIndex", MethodConcept::INDEXCONTAINER },
+ { "getTypes", MethodConcept::PROPERTY },
+ { "getImplementationId", MethodConcept::PROPERTY },
+ { "queryAdapter", MethodConcept_NORMAL_IMPL },
+ { NULL, 0 }
+ };
+
+ OString aErrorStr;
+
+ //******************************************************
+
+ // Test-Objekt anlegen
+ Any aObjAny = getIntrospectionTestObject( xMgr );
+
+ // Introspection-Service holen
+ //Reference< XMultiServiceFactory > xServiceManager(getProcessServiceManager(), USR_QUERY);
+ //Reference< XIntrospection > xIntrospection( xMgr->createInstance(L"com.sun.star.beans.Introspection"), UNO_QUERY );
+ //TEST_ENSHURE( xIntrospection.is(), "Creation of introspection instance failed" );
+ //if( !xIntrospection.is() )
+ //return sal_False;
+
+ // und unspecten
+ Reference< XIntrospectionAccess > xAccess = xIntrospection->inspect( aObjAny );
+ xAccess = xIntrospection->inspect( aObjAny );
+ xAccess = xIntrospection->inspect( aObjAny );
+ TEST_ENSHURE( xAccess.is(), "introspection failed, no XIntrospectionAccess returned" );
+ if( !xAccess.is() )
+ return sal_False;
+
+ // Ergebnis der Introspection pruefen
+
+ // XPropertySet-UIK ermitteln
+ Type aType = getCppuType( (Reference< XPropertySet >*) NULL );
+ //typelib_InterfaceTypeDescription* pTypeDesc = NULL;
+ //aType.getDescription( (typelib_TypeDescription**)&pTypeDesc );
+ //Uik aPropertySetUik = *(Uik*)&pTypeDesc->aUik;
+ //typelib_typedescription_release( (typelib_TypeDescription*)pTypeDesc );
+
+ Reference< XInterface > xPropSetIface = xAccess->queryAdapter( aType );
+ //Reference< XInterface > xPropSetIface = xAccess->queryAdapter( aPropertySetUik );
+ Reference< XPropertySet > xPropSet( xPropSetIface, UNO_QUERY );
+ //XPropertySetRef xPropSet = (XPropertySet*)xPropSetIface->
+ // queryInterface( XPropertySet::getSmartUik() );
+ TEST_ENSHURE( xPropSet.is(), "Could not get XPropertySet by queryAdapter()" );
+
+ // XExactName
+ Reference< XExactName > xExactName( xAccess, UNO_QUERY );
+ TEST_ENSHURE( xExactName.is(), "Introspection unterstuetzt kein ExactName" );
+
+ // Schleife ueber alle Kombinationen von Concepts
+ for( sal_Int32 nConcepts = 0 ; nConcepts < 16 ; nConcepts++ )
+ {
+//printf( "*******************************************************\n" );
+//printf( "nConcepts = %ld\n", nConcepts );
+
+ // Wieviele Properties sollten es sein
+ sal_Int32 nDemandedPropCount = 0;
+ sal_Int32 iList = 0;
+ while( pPropertyDefs[ iList ].pName )
+ {
+ if( pPropertyDefs[ iList ].nConcept & nConcepts )
+ nDemandedPropCount++;
+ iList++;
+ }
+
+ if( xPropSet.is() )
+ {
+ Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ //Sequence<Property> aRetSeq = xPropSetInfo->getProperties();
+ Sequence<Property> aRetSeq = xAccess->getProperties( nConcepts );
+
+ sal_Int32 nLen = aRetSeq.getLength();
+
+ aErrorStr = "Expected to find ";
+ aErrorStr += OString::valueOf( nDemandedPropCount );
+ aErrorStr += " properties but found ";
+ aErrorStr += OString::valueOf( nLen );
+ TEST_ENSHURE( nLen == nDemandedPropCount, aErrorStr.getStr() );
+
+ // cout << "**********************************\n";
+ // cout << "*** Ergebnis der Introspection ***\n";
+ // cout << "**********************************\n";
+ // cout << "\nIntrospection hat " << nLen << " Properties gefunden:\n";
+
+ const Property* pProps = aRetSeq.getConstArray();
+ Any aPropVal;
+ sal_Int32 i;
+ iList = 0;
+ for( i = 0 ; i < nLen ; i++ )
+ {
+ const Property aProp = pProps[ i ];
+
+ // Naechste Passende Methode in der Liste suchen
+ while( pPropertyDefs[ iList ].pName )
+ {
+ if( pPropertyDefs[ iList ].nConcept & nConcepts )
+ break;
+ iList++;
+ }
+ sal_Int32 iDemanded = iList;
+ iList++;
+
+ OUString aPropName = aProp.Name;
+ OString aNameStr( aPropName.getStr(), aPropName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ //UStringToString(aPropName, CHARSET_SYSTEM);
+
+//printf( "Property = %s\n", aNameStr.getStr() );
+
+ OString aDemandedName = pPropertyDefs[ iDemanded ].pName;
+ //OString aDemandedName = pDemandedPropNames[ i ];
+ aErrorStr = "Expected property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", found \"";
+ aErrorStr += aNameStr;
+ aErrorStr += "\"";
+ TEST_ENSHURE( aNameStr == aDemandedName, aErrorStr.getStr() );
+ // cout << "Property " << (i+1) << ": \"" << (const char*)UStringToString(aPropName, CHARSET_SYSTEM) << "\"";
+
+
+ Type aPropType = aProp.Type;
+ OString aTypeNameStr( OUStringToOString(aPropType.getTypeName(), RTL_TEXTENCODING_ASCII_US) );
+ //Reference< XIdlClass > xPropType = aProp.Type;
+ //OString aTypeNameStr( xPropType->getName(), xPropType->getName().getLength(), RTL_TEXTENCODING_ASCII_US );
+ OString aDemandedTypeNameStr = pDemandedPropTypes[ iDemanded ];
+ //OString aDemandedTypeNameStr = pDemandedPropTypes[ i ];
+ aErrorStr = "Property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", expected type >";
+ aErrorStr += aDemandedTypeNameStr;
+ aErrorStr += "< found type >";
+ aErrorStr += aTypeNameStr;
+ aErrorStr += "<";
+ TEST_ENSHURE( aTypeNameStr == aDemandedTypeNameStr, aErrorStr.getStr() );
+ // cout << " (Prop-Typ: " << (const char*)UStringToString(xPropType->getName(), CHARSET_SYSTEM) << ")";
+
+ // Wert des Property lesen und ausgeben
+ aPropVal = xPropSet->getPropertyValue( aPropName );
+ // cout << "\n\tWert = " << (const char*)UStringToString(AnyToString( aPropVal, sal_True ), CHARSET_SYSTEM);
+
+ OString aValStr = OUStringToOString( AnyToString( aPropVal, sal_False, xMgr ), RTL_TEXTENCODING_ASCII_US );
+ OString aDemandedValStr = pDemandedPropVals[ iDemanded ];
+ //OString aDemandedValStr = pDemandedPropVals[ i ];
+ aErrorStr = "Property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", expected val >";
+ aErrorStr += aDemandedValStr;
+ aErrorStr += "< found val >";
+ aErrorStr += aValStr;
+ aErrorStr += "<";
+ TEST_ENSHURE( aValStr == aDemandedValStr, aErrorStr.getStr() );
+
+ // Wert pruefen und typgerecht modifizieren
+ TypeClass eType = aPropVal.getValueType().getTypeClass();
+ //Reference< XIdlClass > xIdlClass = aPropVal.getReflection()->getIdlClass();
+ //TypeClass eType = xIdlClass->getTypeClass();
+ Any aNewVal;
+ sal_Bool bModify = sal_True;
+ switch( eType )
+ {
+ case TypeClass_STRING:
+ {
+ OUString aStr;
+ aPropVal >>= aStr;
+ //OString aStr = aPropVal.getString();
+ aStr = aStr + OUString::createFromAscii(" (Modified!)");
+ aNewVal <<= aStr;
+ break;
+ }
+ case TypeClass_DOUBLE:
+ {
+ double d(0.0);
+ aPropVal >>= d;
+ aNewVal <<= d + 1.0;
+ break;
+ }
+ case TypeClass_SHORT:
+ {
+ sal_Int16 n(0);
+ aPropVal >>= n;
+ aNewVal <<= sal_Int16( n + 1 );
+ break;
+ }
+ case TypeClass_LONG:
+ {
+ sal_Int32 n(0);
+ aPropVal >>= n;
+ aNewVal <<= sal_Int32( n + 1 );
+ break;
+ }
+ default:
+ bModify = sal_False;
+ break;
+ }
+
+ // Modifizieren nur beim letzten Durchlauf
+ if( nConcepts == 15 )
+ {
+ // XExactName pruefen, dafuer alles gross machen
+ // (Introspection ist mit LowerCase implementiert, also anders machen)
+ OUString aUpperUStr = aPropName.toAsciiUpperCase();
+ OUString aExactName = xExactName->getExactName( aUpperUStr );
+ if( aExactName != aPropName )
+ {
+ aErrorStr = "Property \"";
+ aErrorStr += OUStringToOString( aPropName, RTL_TEXTENCODING_ASCII_US );
+ aErrorStr += "\", not found as \"";
+ aErrorStr += OUStringToOString(aUpperUStr, RTL_TEXTENCODING_ASCII_US );
+ aErrorStr += "\" using XExactName";
+ TEST_ENSHURE( sal_False, aErrorStr.getStr() );
+ }
+ }
+ else
+ {
+ bModify = sal_False;
+ }
+
+ // Neuen Wert setzen, wieder lesen und ausgeben
+ if( bModify )
+ {
+ // cout.flush();
+
+ // 1.7.1999, UnknownPropertyException bei ReadOnly-Properties abfangen
+ try
+ {
+ xPropSet->setPropertyValue( aPropName, aNewVal );
+ }
+ catch(UnknownPropertyException e1)
+ {
+ }
+
+ aPropVal = xPropSet->getPropertyValue( aPropName );
+ // cout << "\n\tModifizierter Wert = " << (const char*) UStringToString(AnyToString( aPropVal, sal_True ), CHARSET_SYSTEM) << "\n";
+
+ OUString aStr = AnyToString( aPropVal, sal_False, xMgr );
+ OString aModifiedValStr = OUStringToOString( aStr, RTL_TEXTENCODING_ASCII_US );
+ OString aDemandedModifiedValStr = pDemandedModifiedPropVals[ i ];
+ aErrorStr = "Property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", expected modified val >";
+ aErrorStr += aDemandedModifiedValStr;
+ aErrorStr += "< found val >";
+ aErrorStr += aModifiedValStr;
+ aErrorStr += "<";
+ TEST_ENSHURE( aModifiedValStr == aDemandedModifiedValStr, aErrorStr.getStr() );
+ }
+ else
+ {
+ // cout << "\n\tWert wurde nicht modifiziert\n";
+ }
+
+ // Checken, ob alle Properties auch einzeln gefunden werden
+ aErrorStr = "property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\" not found with hasProperty()";
+ OUString aWDemandedName = OStringToOUString(aDemandedName, RTL_TEXTENCODING_ASCII_US );
+ sal_Bool bProperty = xAccess->hasProperty( aWDemandedName, nConcepts );
+ //sal_Bool bProperty = xAccess->hasProperty( aWDemandedName, PropertyConcept::ALL - PropertyConcept::DANGEROUS );
+ TEST_ENSHURE( bProperty, aErrorStr.getStr() );
+
+ aErrorStr = "property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\" not equal to same Property in sequence returned by getProperties()";
+ try
+ {
+ Property aGetProp = xAccess->getProperty( aWDemandedName, nConcepts );
+ //Property aGetProp = xAccess->getProperty( aWDemandedName, PropertyConcept::ALL );
+ //TEST_ENSHURE( aGetProp == aProp , aErrorStr.getStr() );
+ }
+ catch (RuntimeException e1)
+ {
+ aErrorStr = "property \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", exception was thrown when trying getProperty()";
+ TEST_ENSHURE( sal_False, aErrorStr.getStr() );
+ }
+
+ }
+ }
+ }
+
+ // Schleife ueber alle Kombinationen von Concepts
+ for( sal_Int32 nConcepts = 0 ; nConcepts < 128 ; nConcepts++ )
+ {
+//printf( "*******************************************************\n" );
+//printf( "nConcepts = %ld\n", nConcepts );
+
+ // Das 2^6-Bit steht fuer "den Rest"
+ sal_Int32 nRealConcepts = nConcepts;
+ if( nConcepts & 0x40 )
+ nRealConcepts |= (0xFFFFFFFF - 0x3F);
+
+ // Wieviele Methoden sollten es sein
+ sal_Int32 nDemandedMethCount = 0;
+ sal_Int32 iList = 0;
+ while( pMethodDefs[ iList ].pName )
+ {
+ if( pMethodDefs[ iList ].nConcept & nRealConcepts )
+ nDemandedMethCount++;
+ iList++;
+ }
+
+ // Methoden-Array ausgeben
+ //aMethodSeq = xAccess->getMethods
+ Sequence< Reference< XIdlMethod > > aMethodSeq = xAccess->getMethods( nRealConcepts );
+ //Sequence<XIdlMethodRef> aMethodSeq = xAccess->getMethods
+ // ( MethodConcept::ALL - MethodConcept::DANGEROUS - MethodConcept::PROPERTY );
+ sal_Int32 nLen = aMethodSeq.getLength();
+ // cout << "\n\n*** Methoden ***\n";
+ // cout << "Introspection hat " << nLen << " Methoden gefunden:\n";
+
+ aErrorStr = "Expected to find ";
+ aErrorStr += OString::valueOf( nDemandedMethCount );
+ aErrorStr += " methods but found ";
+ aErrorStr += OString::valueOf( nLen );
+ TEST_ENSHURE( nLen == nDemandedMethCount, aErrorStr.getStr() );
+
+ const Reference< XIdlMethod >* pMethods = aMethodSeq.getConstArray();
+ sal_Int32 i;
+ iList = 0;
+
+ for( i = 0 ; i < nLen ; i++ )
+ {
+ // Methode ansprechen
+ const Reference< XIdlMethod >& rxMethod = pMethods[i];
+
+ // Methode ausgeben
+ OUString aMethName = rxMethod->getName();
+ OString aNameStr = OUStringToOString(aMethName, RTL_TEXTENCODING_ASCII_US );
+
+//printf( "Method = %s\n", aNameStr.getStr() );
+
+ // Naechste Passende Methode in der Liste suchen
+ while( pMethodDefs[ iList ].pName )
+ {
+ if( pMethodDefs[ iList ].nConcept & nRealConcepts )
+ break;
+ iList++;
+ }
+ OString aDemandedName = pMethodDefs[ iList ].pName;
+ iList++;
+
+ //OString aDemandedName = pDemandedMethNames[ i ];
+ aErrorStr = "Expected method \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", found \"";
+ aErrorStr += aNameStr;
+ aErrorStr += "\"";
+ TEST_ENSHURE( aNameStr == aDemandedName, aErrorStr.getStr() );
+ // cout << "Methode " << (i+1) << ": " << (const char*) UStringToString(rxMethod->getReturnType()->getName(), CHARSET_SYSTEM)
+ // << " " << (const char*) UStringToString(rxMethod->getName(), CHARSET_SYSTEM) << "( ";
+
+ // Checken, ob alle Methoden auch einzeln gefunden werden
+ aErrorStr = "method \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\" not found with hasMethod()";
+ OUString aWDemandedName = OStringToOUString(aDemandedName, RTL_TEXTENCODING_ASCII_US );
+ sal_Bool bMethod = xAccess->hasMethod( aWDemandedName, nRealConcepts );
+ //sal_Bool bMethod = xAccess->hasMethod( aWDemandedName, MethodConcept::ALL );
+ TEST_ENSHURE( bMethod, aErrorStr.getStr() );
+
+ aErrorStr = "method \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\" not equal to same method in sequence returned by getMethods()";
+ try
+ {
+ Reference< XIdlMethod > xGetMethod = xAccess->getMethod( aWDemandedName, nRealConcepts );
+ //XIdlMethodRef xGetMethod = xAccess->getMethod( aWDemandedName, MethodConcept::ALL );
+ TEST_ENSHURE( xGetMethod == rxMethod , aErrorStr.getStr() );
+ }
+ catch (RuntimeException e1)
+ {
+ aErrorStr = "method \"";
+ aErrorStr += aDemandedName;
+ aErrorStr += "\", exception was thrown when trying getMethod()";
+ TEST_ENSHURE( sal_False, aErrorStr.getStr() );
+ }
+ }
+ }
+
+ // Listener-Klassen ausgeben
+ Sequence< Type > aClassSeq = xAccess->getSupportedListeners();
+ sal_Int32 nLen = aClassSeq.getLength();
+ // cout << "\n\n*** Anmeldbare Listener ***\n";
+ // cout << "Introspection hat " << nLen << " Listener gefunden:\n";
+
+ const Type* pListeners = aClassSeq.getConstArray();
+ for( sal_Int32 i = 0 ; i < nLen ; i++ )
+ {
+ // Methode ansprechen
+ const Type& aListenerType = pListeners[i];
+
+ // Namen besorgen
+ OUString aListenerClassName = aListenerType.getTypeName();
+ // cout << "Listener " << (i+1) << ": " << (const char*)UStringToString(aListenerClassName, CHARSET_SYSTEM) << "\n";
+ }
+
+
+ // Performance bei hasMethod testen.
+ //CheckMethodPerformance( xAccess, "queryInterface", 100000 );
+ //CheckMethodPerformance( xAccess, "getIdlClasses", 100000 );
+
+ // cout.flush();
+
+
+
+
+ return sal_True;
+}
+
+
+SAL_IMPLEMENT_MAIN()
+{
+ Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory( OUString::createFromAscii("stoctest.rdb") ) );
+
+ sal_Bool bSucc = sal_False;
+ try
+ {
+ Reference< XImplementationRegistration > xImplReg(
+ xMgr->createInstance( OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration") ), UNO_QUERY );
+ OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
+
+ // Register services
+ OUString libName( RTL_CONSTASCII_USTRINGPARAM(
+ "reflection.uno" SAL_DLLEXTENSION) );
+// ORealDynamicLoader::computeLibraryName( OUString::createFromAscii("corefl"), libName);
+ fprintf(stderr, "1\n" );
+ xImplReg->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ libName, Reference< XSimpleRegistry >() );
+ fprintf(stderr, "2\n" );
+ Reference< XIdlReflection > xRefl( xMgr->createInstance( OUString::createFromAscii("com.sun.star.reflection.CoreReflection") ), UNO_QUERY );
+ OSL_ENSURE( xRefl.is(), "### no corereflection!" );
+
+ // Introspection
+ libName = OUString::createFromAscii(
+ "introspection.uno" SAL_DLLEXTENSION);
+// ORealDynamicLoader::computeLibraryName( OUString::createFromAscii("insp"), libName);
+ fprintf(stderr, "3\n" );
+ xImplReg->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
+ libName, Reference< XSimpleRegistry >() );
+ fprintf(stderr, "4\n" );
+ Reference< XIntrospection > xIntrosp( xMgr->createInstance( OUString::createFromAscii("com.sun.star.beans.Introspection") ), UNO_QUERY );
+ OSL_ENSURE( xRefl.is(), "### no corereflection!" );
+
+ fprintf(stderr, "before test_introsp\n" );
+ bSucc = test_introsp( xMgr, xRefl, xIntrosp );
+ fprintf(stderr, "after test_introsp\n" );
+ //bSucc = test_corefl( xRefl );
+ }
+ catch (Exception & rExc)
+ {
+ OSL_ENSURE( sal_False, "### exception occured!" );
+ OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ OSL_TRACE( "### exception occured: " );
+ OSL_TRACE( aMsg.getStr() );
+ OSL_TRACE( "\n" );
+ }
+
+ Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
+
+ printf( "testintrosp %s !\n", (bSucc ? "succeeded" : "failed") );
+ return (bSucc ? 0 : -1);
+}
+
+
+
+
+
+
+
+//*****************************
+//*** TEST-Implementationen ***
+//*****************************
+// Bleibt auf Dauer nicht drin, dient als exportierbare Test-Klasse
+// z.B. fuer Basic-Anbindung
+
+
+
+
+
+
diff --git a/stoc/test/testintrosp.idl b/stoc/test/testintrosp.idl
new file mode 100644
index 000000000000..d2d01cbb692d
--- /dev/null
+++ b/stoc/test/testintrosp.idl
@@ -0,0 +1,220 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __com_sun_star_beans_XIntroTest_idl__
+#define __com_sun_star_beans_XIntroTest_idl__
+
+#ifndef __com_sun_star_uno_XInterface_idl__
+#include <com/sun/star/uno/XInterface.idl>
+#endif
+
+#ifndef __com_sun_star_beans_Property_idl__
+#include <com/sun/star/beans/Property.idl>
+#endif
+
+#ifndef __com_sun_star_beans_PropertyValue_idl__
+#include <com/sun/star/beans/PropertyValue.idl>
+#endif
+
+#ifndef __com_sun_star_uno_TypeClass_idl__
+#include <com/sun/star/uno/TypeClass.idl>
+#endif
+
+#ifndef __com_sun_star_beans_XPropertiesChangeListener_idl__
+#include <com/sun/star/beans/XPropertiesChangeListener.idl>
+#endif
+
+
+//=============================================================================
+
+module ModuleA
+{
+//module com { module sun { module star { module beans {
+
+//interface XPropertyChangeListener;
+//interface XPropertiesChangeListener;
+
+//=============================================================================
+/** This is a test interface for introspection.
+
+ <p>IMPORTANT: FOR TEST ONLY!
+
+ <p>The following interface is just for testing purposes. It will not
+ stay in the product. It is only used as an exportable test class,
+ i.e. for BASIC integration.
+
+ @deprecated
+*/
+interface XIntroTest: com::sun::star::uno::XInterface
+{
+ //-------------------------------------------------------------------------
+ /** contains the ID-String of the implementation.
+ */
+ [attribute] string ObjectName;
+
+ //-------------------------------------------------------------------------
+ /** contains the first name of a person.
+ */
+ [readonly, attribute] string FirstName;
+
+ //-------------------------------------------------------------------------
+ /** contains the last name of a person.
+ */
+ [readonly, attribute] string LastName;
+
+ //-------------------------------------------------------------------------
+ /** contains the age of a person.
+ */
+ [readonly, attribute] short Age;
+
+ //-------------------------------------------------------------------------
+ /** contains the number of children person has.
+ */
+ [attribute] short ChildrenCount;
+
+ //-------------------------------------------------------------------------
+ /** contains a struct of type Property.
+ */
+ [attribute] com::sun::star::beans::Property FirstStruct;
+
+ //-------------------------------------------------------------------------
+ /** contains a struct of type PropertyValue.
+ */
+ [attribute] com::sun::star::beans::PropertyValue SecondStruct;
+
+ //-------------------------------------------------------------------------
+ /** Ausgabe-Methode
+ */
+ void writeln( [in] string Text );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ long getDroenk();
+
+ //-------------------------------------------------------------------------
+ /** Weitere Introspection-Test-Objekt holen
+ */
+ XIntroTest getIntroTest();
+ //com::sun::star::beans::XIntroTest getIntroTest();
+
+ //-------------------------------------------------------------------------
+ /** !!! No property, because parameter exists
+ */
+ long getUps( [in] long l );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setDroenk( [in] long l );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ short getBla();
+
+ //-------------------------------------------------------------------------
+ /** !!! Not the set method for property Bla, because param type != return type.
+ */
+ void setBla( [in] long n );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ short getBlub();
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setBlub( [in] short n );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ short getGulp();
+
+ //-------------------------------------------------------------------------
+ /** !!! Not the set method for property Gulp, because return type != void.
+ */
+ short setGulp( [in] short n );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ com::sun::star::uno::TypeClass getTypeClass( [in] short n );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setTypeClass( [in] com::sun::star::uno::TypeClass t,
+ [in] double d1,
+ [in] double d2 );
+
+ //-------------------------------------------------------------------------
+ /**
+ */
+ sequence<string> getStrings();
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setStrings( [in] sequence<string> Strings );
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setStringsPerMethod( [in] sequence<string> Strings,
+ [in] short n );
+
+ //-------------------------------------------------------------------------
+ /**
+ */
+ sequence< sequence< sequence< short > > > getMultiSequence();
+
+ //-------------------------------------------------------------------------
+ /** ...
+ */
+ void setMultiSequence( [in] sequence< sequence< sequence< short > > > Seq );
+
+ //-------------------------------------------------------------------------
+ /**Add a PropertiesChangeListener
+ */
+ [oneway] void addPropertiesChangeListener( [in] sequence< string > PropertyNames,
+ [in] com::sun::star::beans::XPropertiesChangeListener Listener );
+
+ //-------------------------------------------------------------------------
+ /**Remove a PropertiesChangeListener
+ */
+ [oneway] void removePropertiesChangeListener( [in] com::sun::star::beans::XPropertiesChangeListener Listener );
+
+};
+
+//=============================================================================
+
+};
+//}; }; }; };
+
+#endif
diff --git a/stoc/test/testloader.cxx b/stoc/test/testloader.cxx
new file mode 100644
index 000000000000..a0ef275565e0
--- /dev/null
+++ b/stoc/test/testloader.cxx
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include <stdio.h>
+
+#include <sal/main.h>
+#ifndef _OSL_MODULE_H_
+#include <osl/module.hxx>
+#endif
+#include <osl/diagnose.h>
+
+#include <com/sun/star/loader/XImplementationLoader.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/factory.hxx>
+
+#if defined ( UNX )
+#include <limits.h>
+#define _MAX_PATH PATH_MAX
+#endif
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::loader;
+using namespace com::sun::star::lang;
+using namespace osl;
+using namespace rtl;
+using namespace cppu;
+
+#if OSL_DEBUG_LEVEL > 0
+#define TEST_ENSHURE(c, m) OSL_ENSURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) OSL_VERIFY(c)
+#endif
+
+class EmptyComponentContext : public WeakImplHelper1< XComponentContext >
+{
+public:
+ virtual Any SAL_CALL getValueByName( const OUString& /*Name*/ )
+ throw (RuntimeException)
+ {
+ return Any();
+ }
+ virtual Reference< XMultiComponentFactory > SAL_CALL getServiceManager( )
+ throw (RuntimeException)
+ {
+ return Reference< XMultiComponentFactory > ();
+ }
+
+};
+
+
+SAL_IMPLEMENT_MAIN()
+{
+ Reference<XInterface> xIFace;
+
+ Module module;
+
+ OUString dllName(
+ RTL_CONSTASCII_USTRINGPARAM("bootstrap.uno" SAL_DLLEXTENSION) );
+
+ if (module.load(dllName))
+ {
+ // try to get provider from module
+ component_getFactoryFunc pCompFactoryFunc = (component_getFactoryFunc)
+ module.getFunctionSymbol( OUString::createFromAscii(COMPONENT_GETFACTORY) );
+
+ if (pCompFactoryFunc)
+ {
+ XSingleServiceFactory * pRet = (XSingleServiceFactory *)(*pCompFactoryFunc)(
+ "com.sun.star.comp.stoc.DLLComponentLoader", 0, 0 );
+ if (pRet)
+ {
+ xIFace = pRet;
+ pRet->release();
+ }
+ }
+ }
+
+ TEST_ENSHURE( xIFace.is(), "testloader error1");
+
+ Reference<XSingleComponentFactory> xFactory( Reference<XSingleComponentFactory>::query(xIFace) );
+
+ TEST_ENSHURE( xFactory.is(), "testloader error2");
+
+ Reference<XInterface> xLoader = xFactory->createInstanceWithContext( new EmptyComponentContext );
+
+ TEST_ENSHURE( xLoader.is(), "testloader error3");
+
+ Reference<XServiceInfo> xServInfo( Reference<XServiceInfo>::query(xLoader) );
+
+ TEST_ENSHURE( xServInfo.is(), "testloader error4");
+
+ TEST_ENSHURE( xServInfo->getImplementationName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.comp.stoc.DLLComponentLoader") ), "testloader error5");
+ TEST_ENSHURE( xServInfo->supportsService(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")) ), "testloader error6");
+ TEST_ENSHURE( xServInfo->getSupportedServiceNames().getLength() == 1, "testloader error7");
+
+ xIFace.clear();
+ xFactory.clear();
+ xLoader.clear();
+ xServInfo.clear();
+
+ printf("Test Dll ComponentLoader, OK!\n");
+
+ return(0);
+}
+
+
diff --git a/stoc/test/testproxyfac.cxx b/stoc/test/testproxyfac.cxx
new file mode 100644
index 000000000000..38ab9eef51d2
--- /dev/null
+++ b/stoc/test/testproxyfac.cxx
@@ -0,0 +1,379 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include "sal/main.h"
+#include "osl/diagnose.h"
+#include "rtl/alloc.h"
+#include "uno/environment.hxx"
+#include "cppuhelper/servicefactory.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "cppuhelper/implbase3.hxx"
+#include "com/sun/star/uno/XCurrentContext.hpp"
+#include "com/sun/star/lang/DisposedException.hpp"
+#include "com/sun/star/lang/XComponent.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/registry/XSimpleRegistry.hpp"
+#include "com/sun/star/registry/XImplementationRegistration.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/reflection/XProxyFactory.hpp"
+
+#include <stdio.h>
+
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+typedef WeakImplHelper3< lang::XServiceInfo,
+ XCurrentContext,
+ reflection::XProxyFactory > t_impl;
+
+//==============================================================================
+class TargetObject : public t_impl
+{
+public:
+ static int s_obj;
+
+ virtual ~TargetObject() {
+ --s_obj;
+ OSL_TRACE( "~TargetObject()" );
+ }
+ TargetObject()
+ { ++s_obj; }
+
+ Any SAL_CALL queryInterface( Type const & type )
+ throw (RuntimeException);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw (RuntimeException)
+ { return OUString::createFromAscii( "target" ); }
+ virtual sal_Bool SAL_CALL supportsService( const OUString & /*rServiceName*/ )
+ throw (RuntimeException)
+ { return sal_False; }
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw (RuntimeException)
+ { return Sequence< OUString >(); }
+ // XProxyFactory
+ virtual Reference< XAggregation > SAL_CALL createProxy(
+ const Reference< XInterface > & xTarget ) throw (RuntimeException)
+ { return Reference< XAggregation >( xTarget, UNO_QUERY ); }
+ // XCurrentContext
+ virtual Any SAL_CALL getValueByName( OUString const & name )
+ throw (RuntimeException)
+ { return makeAny( name ); }
+};
+
+//______________________________________________________________________________
+Any TargetObject::queryInterface( Type const & type )
+ throw (RuntimeException)
+{
+ Any ret( t_impl::queryInterface( type ) );
+ if (ret.hasValue())
+ return ret;
+ throw lang::DisposedException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("my test exception") ),
+ static_cast< OWeakObject * >(this) );
+}
+
+int TargetObject::s_obj = 0;
+
+
+//==============================================================================
+class TestMaster : public WeakImplHelper1< lang::XServiceInfo >
+{
+ Reference< XAggregation > m_xProxyTarget;
+ Reference<lang::XServiceInfo> m_xOtherProxyTargetBeforeSetDelegator;
+
+ inline TestMaster() { ++s_obj; }
+public:
+ static int s_obj;
+ static Reference< XInterface > create(
+ Reference< reflection::XProxyFactory > const & xProxyFac );
+ static Reference< XInterface > create(
+ Reference< XInterface > const & xTarget,
+ Reference< reflection::XProxyFactory > const & xProxyFac );
+
+ virtual ~TestMaster() {
+ --s_obj;
+ OSL_TRACE( "~TestMaster()" );
+ }
+
+ virtual Any SAL_CALL queryInterface( const Type & rType )
+ throw (RuntimeException)
+ {
+ Any aRet(
+ WeakImplHelper1< lang::XServiceInfo >::queryInterface( rType ) );
+ if (aRet.hasValue())
+ return aRet;
+ return m_xProxyTarget->queryAggregation( rType );
+ }
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw (RuntimeException)
+ { return OUString::createFromAscii( "master" ); }
+ virtual sal_Bool SAL_CALL supportsService( const OUString & /*rServiceName*/ )
+ throw (RuntimeException)
+ { return sal_False; }
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw (RuntimeException)
+ { return Sequence< OUString >(); }
+};
+
+int TestMaster::s_obj = 0;
+
+
+Reference< XInterface > TestMaster::create(
+ Reference< XInterface > const & xTarget,
+ Reference< reflection::XProxyFactory > const & xProxyFac )
+{
+ TestMaster * that = new TestMaster;
+ Reference< XInterface > xRet( static_cast< OWeakObject * >( that ) );
+ {
+ Reference< XAggregation > xAgg( xProxyFac->createProxy( xTarget ) );
+ // ownership take over
+ that->m_xProxyTarget.set( xAgg, UNO_QUERY_THROW );
+ that->m_xOtherProxyTargetBeforeSetDelegator.set(
+ that->m_xProxyTarget, UNO_QUERY );
+ }
+ that->m_xProxyTarget->setDelegator( xRet );
+ return xRet;
+}
+
+Reference< XInterface > TestMaster::create(
+ Reference< reflection::XProxyFactory > const & xProxyFac )
+{
+ return create(
+ static_cast< OWeakObject * >( new TargetObject ), xProxyFac );
+}
+
+
+static void test_proxyfac_(
+ Reference< XInterface > const & xMaster, OUString const & test,
+ Reference< reflection::XProxyFactory > const & /*xProxyFac*/ )
+{
+ (void)test;
+ Reference< lang::XServiceInfo > xMaster_XServiceInfo(
+ xMaster, UNO_QUERY_THROW );
+ OSL_ASSERT( xMaster_XServiceInfo->getImplementationName().equals( test ) );
+
+ Reference< reflection::XProxyFactory > xTarget( xMaster, UNO_QUERY_THROW );
+ Reference< XCurrentContext > xTarget_XCurrentContext(
+ xTarget, UNO_QUERY_THROW );
+ Reference< XCurrentContext > xMaster_XCurrentContext(
+ xMaster, UNO_QUERY_THROW );
+
+ OSL_ASSERT(
+ xTarget_XCurrentContext->getValueByName( test ) == makeAny( test ) );
+ OSL_ASSERT(
+ xMaster_XCurrentContext->getValueByName( test ) == makeAny( test ) );
+
+ Reference< XAggregation > xFakeAgg( xTarget->createProxy( xTarget ) );
+ if (xFakeAgg.is())
+ {
+ OSL_ASSERT( xTarget == xFakeAgg );
+ OSL_ASSERT( xMaster == xFakeAgg );
+ }
+
+ Reference< lang::XServiceInfo > xTarget_XServiceInfo(
+ xTarget, UNO_QUERY_THROW );
+ OSL_ASSERT( xTarget_XServiceInfo->getImplementationName().equals( test ) );
+ Reference< lang::XServiceInfo > xTarget_XServiceInfo2(
+ xTarget, UNO_QUERY_THROW );
+ OSL_ASSERT( xTarget_XServiceInfo2.get() == xTarget_XServiceInfo.get() );
+
+ OSL_ASSERT( xTarget == xTarget_XCurrentContext );
+ OSL_ASSERT( xTarget_XCurrentContext == xMaster );
+ OSL_ASSERT(
+ xTarget_XCurrentContext.get() == xMaster_XCurrentContext.get() );
+ OSL_ASSERT( xTarget_XCurrentContext == xMaster );
+ OSL_ASSERT( xTarget == xMaster );
+ OSL_ASSERT( xTarget_XServiceInfo.get() == xMaster_XServiceInfo.get() );
+ OSL_ASSERT( xTarget_XServiceInfo == xMaster );
+ OSL_ASSERT( xMaster_XServiceInfo == xMaster );
+
+ try
+ {
+ Reference< registry::XRegistryKey >(
+ xMaster, UNO_QUERY_THROW );
+ }
+ catch (lang::DisposedException & exc)
+ {
+ if (! exc.Message.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("my test exception") ))
+ throw;
+ }
+}
+
+static void test_proxyfac(
+ Reference< XInterface > const & xMaster, OUString const & test,
+ Reference< reflection::XProxyFactory > const & xProxyFac )
+{
+ test_proxyfac_( xMaster, test, xProxyFac );
+ // proxy the proxy...
+ Reference< XInterface > xNew( TestMaster::create( xMaster, xProxyFac ) );
+ test_proxyfac_(
+ xNew, OUString( RTL_CONSTASCII_USTRINGPARAM("master") ), xProxyFac );
+}
+
+SAL_IMPLEMENT_MAIN()
+{
+ bool success = true;
+
+ Environment cpp_env;
+ OUString cpp( RTL_CONSTASCII_USTRINGPARAM(
+ CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
+ uno_getEnvironment(
+ reinterpret_cast< uno_Environment ** >( &cpp_env ),
+ cpp.pData, 0 );
+ OSL_ENSURE( cpp_env.is(), "### cannot get C++ uno env!" );
+
+ {
+ Reference< lang::XMultiServiceFactory > xMgr(
+ createRegistryServiceFactory(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
+
+ try
+ {
+ Reference< registry::XImplementationRegistration > xImplReg(
+ xMgr->createInstance(
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.registry.ImplementationRegistration")
+ ) ),
+ UNO_QUERY );
+ OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
+
+ OUString aLibName(
+ RTL_CONSTASCII_USTRINGPARAM("proxyfac.uno" SAL_DLLEXTENSION) );
+ xImplReg->registerImplementation(
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.loader.SharedLibrary") ),
+ aLibName, Reference< registry::XSimpleRegistry >() );
+
+ Reference< reflection::XProxyFactory > xProxyFac(
+ xMgr->createInstance(
+ OUString::createFromAscii(
+ "com.sun.star.reflection.ProxyFactory") ),
+ UNO_QUERY_THROW );
+
+ Reference< XAggregation > x(
+ xProxyFac->createProxy(
+ static_cast< OWeakObject * >( new TargetObject ) ) );
+ // no call
+
+ {
+ Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
+ test_proxyfac(
+ xMaster,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("master") ),
+ xProxyFac );
+ }
+ {
+ Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
+ // no call
+ }
+
+ {
+ Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
+ Reference< reflection::XProxyFactory > xSlave_lives_alone(
+ xMaster, UNO_QUERY_THROW );
+ xMaster.clear();
+ test_proxyfac(
+ xSlave_lives_alone,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("master") ),
+ xProxyFac );
+ uno_dumpEnvironment( stdout, cpp_env.get(), 0 );
+ }
+ {
+ Reference< XInterface > xMaster( TestMaster::create( xProxyFac ) );
+ Reference< reflection::XProxyFactory > xSlave_lives_alone(
+ xMaster, UNO_QUERY_THROW );
+ // no call
+ }
+
+ test_proxyfac(
+ xProxyFac->createProxy(
+ static_cast< OWeakObject * >( new TargetObject ) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("target") ),
+ xProxyFac );
+ uno_dumpEnvironment( stdout, cpp_env.get(), 0 );
+ }
+ catch (Exception & rExc)
+ {
+ (void)rExc;
+ OSL_ENSURE(
+ ! __FILE__,
+ OUStringToOString(
+ rExc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ success = false;
+ }
+
+
+ Reference< lang::XComponent > xComp;
+ Reference< beans::XPropertySet >(
+ xMgr, UNO_QUERY_THROW )->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) )
+ >>= xComp;
+ xComp->dispose();
+ }
+
+ if (TestMaster::s_obj != 0)
+ fprintf( stderr, "TestMaster objects: %d\n", TestMaster::s_obj );
+ if (TargetObject::s_obj != 0)
+ fprintf( stderr, "TargetObject objects: %d\n", TargetObject::s_obj );
+
+ uno_dumpEnvironment( stdout, cpp_env.get(), 0 );
+ void ** ppInterfaces;
+ sal_Int32 len;
+ uno_ExtEnvironment * env = cpp_env.get()->pExtEnv;
+ (*env->getRegisteredInterfaces)(
+ env, &ppInterfaces, &len, rtl_allocateMemory );
+ if (len != 0)
+ fprintf( stderr, "%d registered C++ interfaces left!\n", len );
+
+ success &= (TestMaster::s_obj == 0 &&
+ TargetObject::s_obj == 0 &&
+ len == 0);
+ if (success)
+ {
+ printf( "testproxyfac succeeded.\n" );
+ return 0;
+ }
+ else
+ {
+ fprintf( stderr, "testproxyfac failed!\n" );
+ return 1;
+ }
+}
+
diff --git a/stoc/test/testregistry.cxx b/stoc/test/testregistry.cxx
new file mode 100644
index 000000000000..7be7136933e7
--- /dev/null
+++ b/stoc/test/testregistry.cxx
@@ -0,0 +1,696 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sal/main.h>
+#include <osl/module.hxx>
+#include <osl/diagnose.h>
+#include <osl/process.h>
+#include <registry/registry.hxx>
+
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <cppuhelper/servicefactory.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+#if defined ( UNX )
+#include <limits.h>
+#define _MAX_PATH PATH_MAX
+#endif
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace rtl;
+using namespace osl;
+
+#if OSL_DEBUG_LEVEL > 0
+#define TEST_ENSHURE(c, m) OSL_ENSURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) OSL_VERIFY(c)
+#endif
+
+namespace stoc_impreg
+{
+void SAL_CALL mergeKeys(
+ Reference< registry::XRegistryKey > const & xDest,
+ Reference< registry::XRegistryKey > const & xSource )
+ SAL_THROW( (registry::InvalidRegistryException, registry::MergeConflictException) );
+}
+static void mergeKeys(
+ Reference< registry::XSimpleRegistry > const & xDest,
+ OUString const & rBaseNode,
+ OUString const & rURL )
+ SAL_THROW( (registry::InvalidRegistryException, registry::MergeConflictException) )
+{
+ Reference< registry::XRegistryKey > xDestRoot( xDest->getRootKey() );
+ Reference< registry::XRegistryKey > xDestKey;
+ if (rBaseNode.getLength())
+ {
+ xDestKey = xDestRoot->createKey( rBaseNode );
+ xDestRoot->closeKey();
+ }
+ else
+ {
+ xDestKey = xDestRoot;
+ }
+ Reference< registry::XSimpleRegistry > xSimReg( ::cppu::createSimpleRegistry() );
+ xSimReg->open( rURL, sal_True, sal_False );
+ OSL_ASSERT( xSimReg->isValid() );
+ Reference< registry::XRegistryKey > xSourceKey( xSimReg->getRootKey() );
+ ::stoc_impreg::mergeKeys( xDestKey, xSourceKey );
+ xSourceKey->closeKey();
+ xSimReg->close();
+ xDestKey->closeKey();
+}
+
+
+OString userRegEnv("STAR_USER_REGISTRY=");
+
+OUString getExePath()
+{
+ OUString exe;
+ OSL_VERIFY( osl_getExecutableFile( &exe.pData ) == osl_Process_E_None);
+#if defined(WIN32) || defined(__OS2__) || defined(WNT)
+ exe = exe.copy(0, exe.getLength() - 16);
+#else
+ exe = exe.copy(0, exe.getLength() - 12);
+#endif
+ return exe;
+}
+
+void setStarUserRegistry()
+{
+ Registry *myRegistry = new Registry();
+
+ RegistryKey rootKey, rKey, rKey2;
+
+ OUString userReg = getExePath();
+ userReg += OUString::createFromAscii("user.rdb");
+ if(myRegistry->open(userReg, REG_READWRITE))
+ {
+ TEST_ENSHURE(!myRegistry->create(userReg), "setStarUserRegistry error 1");
+ }
+
+ TEST_ENSHURE(!myRegistry->close(), "setStarUserRegistry error 9");
+ delete myRegistry;
+
+ userRegEnv += OUStringToOString(userReg, RTL_TEXTENCODING_ASCII_US);
+ putenv((char *)userRegEnv.getStr());
+}
+
+void setLinkInDefaultRegistry(const OUString& linkName, const OUString& linkTarget)
+{
+ Registry *myRegistry = new Registry();
+
+ RegistryKey rootKey;
+
+ OUString appReg = getExePath();
+ appReg += OUString::createFromAscii("stoctest.rdb");
+
+ TEST_ENSHURE(!myRegistry->open(appReg, REG_READWRITE), "setLinkInDefaultRegistry error 1");
+ TEST_ENSHURE(!myRegistry->openRootKey(rootKey), "setLinkInDefaultRegistry error 2");
+
+ TEST_ENSHURE(!rootKey.createLink(linkName, linkTarget), "setLinkInDefaultRegistry error 3");
+
+ TEST_ENSHURE(!rootKey.closeKey(), "setLinkInDefaultRegistry error 4");
+ TEST_ENSHURE(!myRegistry->close(), "setLinkInDefaultRegistry error 5");
+
+ delete myRegistry;
+}
+
+
+void test_SimpleRegistry(
+ OUString const & testreg,
+ OUString const & testreg2,
+ bool bMergeDifferently = true )
+{
+ Reference<XInterface> xIFace;
+ Module module;
+
+ OUString dllName(
+ RTL_CONSTASCII_USTRINGPARAM("simplereg.uno" SAL_DLLEXTENSION) );
+
+ if (module.load(dllName))
+ {
+ // try to get provider from module
+ component_getFactoryFunc pCompFactoryFunc = (component_getFactoryFunc)
+ module.getFunctionSymbol( OUString::createFromAscii(COMPONENT_GETFACTORY) );
+
+ if (pCompFactoryFunc)
+ {
+ XSingleServiceFactory * pRet = (XSingleServiceFactory *)
+ (*pCompFactoryFunc)(
+ "com.sun.star.comp.stoc.SimpleRegistry", 0, 0 );
+ if (pRet)
+ {
+ xIFace = pRet;
+ pRet->release();
+ }
+ }
+ }
+
+ TEST_ENSHURE( xIFace.is(), "test_SimpleRegistry error1");
+
+ Reference<XSingleServiceFactory> xFactory( Reference<XSingleServiceFactory>::query(xIFace) );
+ xIFace.clear();
+
+ TEST_ENSHURE( xFactory.is(), "testloader error11");
+
+ Reference<XInterface> xIFace2 = xFactory->createInstance();
+ xFactory.clear();
+
+ TEST_ENSHURE( xIFace2.is(), "testloader error12");
+
+ Reference<XServiceInfo> xServInfo( Reference<XServiceInfo>::query(xIFace2) );
+
+ TEST_ENSHURE( xServInfo.is(), "test_SimpleRegistry error2");
+
+ TEST_ENSHURE( xServInfo->getImplementationName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.comp.stoc.SimpleRegistry") ), "test_SimpleRegistry error3");
+ TEST_ENSHURE( xServInfo->supportsService(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.SimpleRegistry"))), "test_SimpleRegistry error4");
+ TEST_ENSHURE( xServInfo->getSupportedServiceNames().getLength() == 1, "test_SimpleRegistry error5");
+ xServInfo.clear();
+
+ Reference<XSimpleRegistry> xReg( Reference<XSimpleRegistry>::query(xIFace2) );
+ xIFace2.clear();
+
+ TEST_ENSHURE( xReg.is(), "test_SimpleRegistry error6");
+
+ try
+ {
+ xReg->open(testreg, sal_False, sal_True);
+
+ TEST_ENSHURE( xReg->isValid() != sal_False, "test_SimpleRegistry error 7" );
+ TEST_ENSHURE( xReg->isReadOnly() == sal_False, "test_SimpleRegistry error 8" );
+
+ Reference<XRegistryKey> xRootKey(xReg->getRootKey());
+ TEST_ENSHURE( xRootKey->isValid(), "test_SimpleRegistry error 9" );
+
+ Reference<XRegistryKey> xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FirstKey") ));
+
+ Reference<XRegistryKey> xSubKey = xKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FirstSubKey") ));
+ xSubKey->setLongValue(123456789);
+
+ xSubKey = xKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SecondSubKey") ));
+ xSubKey->setAsciiValue(OUString( RTL_CONSTASCII_USTRINGPARAM("ich bin ein acsii value") ));
+
+ xSubKey = xKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("ThirdSubKey") ));
+ xSubKey->setStringValue(OUString( RTL_CONSTASCII_USTRINGPARAM("ich bin ein unicode value") ));
+
+ xSubKey = xKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FourthSubKey") ));
+ Sequence<sal_Int8> aSeq((sal_Int8*)"ich bin ein binary value", 25);
+ xSubKey->setBinaryValue(aSeq);
+
+ Sequence<OUString> seqNames = xKey->getKeyNames();
+ Sequence< Reference<XRegistryKey> > seqKeys = xKey->openKeys();
+
+ OUString name;
+ for (sal_Int32 i=0; i < seqNames.getLength(); i++)
+ {
+ name = seqNames.getArray()[i];
+ xSubKey = seqKeys.getArray()[i];
+
+ if (name == OUString( RTL_CONSTASCII_USTRINGPARAM("/FirstKey/FirstSubKey") ))
+ {
+ TEST_ENSHURE( xSubKey->getLongValue() == 123456789,
+ "test_SimpleRegistry error 10" );
+ } else
+ if (name == OUString( RTL_CONSTASCII_USTRINGPARAM("/FirstKey/SecondSubKey") ))
+ {
+ TEST_ENSHURE( xSubKey->getAsciiValue() == OUString( RTL_CONSTASCII_USTRINGPARAM("ich bin ein acsii value") ),
+ "test_SimpleRegistry error 11" );
+ } else
+ if (name == OUString( RTL_CONSTASCII_USTRINGPARAM("/FirstKey/ThirdSubKey") ))
+ {
+ TEST_ENSHURE( xSubKey->getStringValue() == OUString( RTL_CONSTASCII_USTRINGPARAM("ich bin ein unicode value") ),
+ "test_SimpleRegistry error 12" );
+ } else
+ if (name == OUString( RTL_CONSTASCII_USTRINGPARAM("/FirstKey/FourthSubKey") ))
+ {
+ Sequence<sal_Int8> seqByte = xSubKey->getBinaryValue();
+ TEST_ENSHURE(!strcmp(((const char*)seqByte.getArray()), "ich bin ein binary value"),
+ "test_SimpleRegistry error 13" );
+ }
+
+ seqKeys.getArray()[i]->closeKey();
+ }
+
+ xKey->closeKey();
+
+ xRootKey->deleteKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FirstKey") ));
+ xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SecondFirstKey" )));
+
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SecondKey") ));
+ sal_Int32 pLongs[3] = {123, 456, 789};
+ Sequence<sal_Int32> seqLongs(pLongs, 3);
+ xKey->setLongListValue(seqLongs);
+
+ Sequence<sal_Int32> seqLongs2;
+ seqLongs2 = xKey->getLongListValue();
+ TEST_ENSHURE( seqLongs.getLength() == 3, "test_SimpleRegistry error 14" );
+ TEST_ENSHURE( seqLongs.getArray()[0] == 123, "test_SimpleRegistry error 15" );
+ TEST_ENSHURE( seqLongs.getArray()[1] == 456, "test_SimpleRegistry error 16" );
+ TEST_ENSHURE( seqLongs.getArray()[2] == 789, "test_SimpleRegistry error 17" );
+
+
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("ThirdKey") ));
+ OUString pAscii[3];
+ pAscii[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("Hallo") );
+ pAscii[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("jetzt komm") );
+ pAscii[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("ich") );
+
+ Sequence<OUString> seqAscii(pAscii, 3);
+ xKey->setAsciiListValue(seqAscii);
+
+ Sequence<OUString> seqAscii2;
+ seqAscii2 = xKey->getAsciiListValue();
+ TEST_ENSHURE( seqAscii2.getLength() == 3, "test_SimpleRegistry error 18" );
+ TEST_ENSHURE( seqAscii2.getArray()[0] == OUString( RTL_CONSTASCII_USTRINGPARAM("Hallo") ), "test_SimpleRegistry error 19");
+ TEST_ENSHURE( seqAscii2.getArray()[1] == OUString( RTL_CONSTASCII_USTRINGPARAM("jetzt komm") ), "test_SimpleRegistry error 20");
+ TEST_ENSHURE( seqAscii2.getArray()[2] == OUString( RTL_CONSTASCII_USTRINGPARAM("ich") ), "test_SimpleRegistry error 21");
+
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FourthKey") ));
+ OUString pUnicode[3];
+ pUnicode[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("Hallo") );
+ pUnicode[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("jetzt komm") );
+ pUnicode[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("ich als unicode") );
+
+ Sequence<OUString> seqUnicode(pUnicode, 3);
+ xKey->setStringListValue(seqUnicode);
+
+ Sequence<OUString> seqUnicode2;
+ seqUnicode2 = xKey->getStringListValue();
+ TEST_ENSHURE( seqUnicode2.getLength() == 3, "test_SimpleRegistry error 22" );
+ TEST_ENSHURE( seqUnicode2.getArray()[0] == OUString( RTL_CONSTASCII_USTRINGPARAM("Hallo") ), "test_SimpleRegistry error 23");
+ TEST_ENSHURE( seqUnicode2.getArray()[1] == OUString( RTL_CONSTASCII_USTRINGPARAM("jetzt komm") ), "test_SimpleRegistry error 24");
+ TEST_ENSHURE( seqUnicode2.getArray()[2] == OUString( RTL_CONSTASCII_USTRINGPARAM("ich als unicode") ), "test_SimpleRegistry error 25");
+
+
+ xReg->open(testreg2, sal_False, sal_True);
+ TEST_ENSHURE( xReg->isValid() != sal_False, "test_SimpleRegistry error 25" );
+ xRootKey = xReg->getRootKey();
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("ThirdKey/FirstSubKey/WithSubSubKey") ));
+ xKey->closeKey();
+ TEST_ENSHURE(
+ xRootKey->createLink(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("LinkTest") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/ThirdKey/FirstSubKey/WithSubSubKey") )),
+ "test_SimpleRegistry error 1212" );
+ xRootKey->closeKey();
+ xReg->close();
+
+ xReg->open(testreg, sal_False, sal_False);
+ TEST_ENSHURE( xReg->isValid() != sal_False, "test_SimpleRegistry error 26" );
+
+ if (bMergeDifferently)
+ {
+ mergeKeys(
+ xReg,
+ OUString(),
+ testreg2 );
+ }
+ else
+ {
+ xReg->mergeKey(OUString(), testreg2);
+ }
+
+ xRootKey = xReg->getRootKey();
+ xKey = xRootKey->openKey( OUString( RTL_CONSTASCII_USTRINGPARAM("LinkTest") ) );
+ TEST_ENSHURE(
+ xKey.is() && xKey->isValid() &&
+ xKey->getKeyName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("/ThirdKey/FirstSubKey/WithSubSubKey") ),
+ "test_SimpleRegistry error 1213" );
+ xKey->closeKey();
+ TEST_ENSHURE(
+ xRootKey->getKeyType( OUString( RTL_CONSTASCII_USTRINGPARAM("LinkTest") ) ) ==
+ registry::RegistryKeyType_LINK,
+ "test_SimpleRegistry error 1214" );
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FirstKey/SecondSubKey") ));
+ TEST_ENSHURE( !xKey.is(), "test_SimpleRegistry error 27" );
+
+ // Test Links
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("FifthKey") ));
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("MyFirstLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/ThirdKey/FirstSubKey") ));
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/FifthKey/MyFirstLink") ));
+ TEST_ENSHURE( xKey->isValid(), "test_SimpleRegistry error 27" );
+ TEST_ENSHURE( xKey->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/ThirdKey/FirstSubKey") ), "test_SimpleRegistry error 28" );
+
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ));
+
+ TEST_ENSHURE( xKey->getLinkTarget(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ), "test_SimpleRegistry error 29" );
+
+ try
+ {
+ TEST_ENSHURE( xKey->getResolvedName(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink/BlaBlaBla") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink/BlaBlaBla") ), "test_SimpleRegistry error 30" );
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ xRootKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/SixthKey/MyThirdLink") ));
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SixthKey") ));
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("MyThirdLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ));
+
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/SixthKey/SixthSubKey") ));
+
+ try
+ {
+ xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ));
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ TEST_ENSHURE( xRootKey->getLinkTarget(OUString( RTL_CONSTASCII_USTRINGPARAM("/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ), "test_SimpleRegistry error 31" );
+
+ xRootKey->deleteLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ));
+
+ xRootKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/ThirdKey/FirstSubKey/WithSubSubKey") ));
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SixthKey") ));
+ seqNames = xKey->getKeyNames();
+ seqKeys = xKey->openKeys();
+
+ TEST_ENSHURE( seqNames.getArray()[0] == OUString( RTL_CONSTASCII_USTRINGPARAM("/SixthKey/SixthSubKey") ),
+ "test_SimpleRegistry error 32" );
+ TEST_ENSHURE( seqNames.getArray()[1] == OUString( RTL_CONSTASCII_USTRINGPARAM("/SixthKey/MyThirdLink") ),
+ "test_SimpleRegistry error 33" );
+
+ TEST_ENSHURE( seqKeys.getArray()[0]->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/SixthKey/SixthSubKey") ),
+ "test_SimpleRegistry error 34" );
+ TEST_ENSHURE( seqKeys.getArray()[1]->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/ThirdKey/FirstSubKey/WithSubSubKey") ),
+ "test_SimpleRegistry error 35" );
+
+ xRootKey->deleteLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/FourthKey/MySecondLink") ));
+ xRootKey->closeKey();
+ }
+ catch(InvalidRegistryException&)
+ {
+ TEST_ENSHURE(0, "exception InvalidRegistryExcption raised while doing test_SimpleRegistry");
+ }
+ catch(InvalidValueException&)
+ {
+ TEST_ENSHURE(0, "exception InvalidValueExcption raised while doing test_SimpleRegistry()");
+ }
+
+ xReg.clear();
+
+ printf("Test SimpleRegistry, OK!\n");
+}
+
+
+void test_DefaultRegistry(
+ OUString const & testreg,
+ OUString const & testreg2,
+ bool bMergeDifferently = false )
+{
+ // Test NestedRegistry
+ OUString exePath( getExePath() );
+ OUString userRdb(exePath);
+ OUString applicatRdb(exePath);
+
+ userRdb += OUString::createFromAscii("user.rdb");
+ applicatRdb += OUString::createFromAscii("stoctest.rdb");
+
+ Reference < XMultiServiceFactory > rSMgr = ::cppu::createRegistryServiceFactory( userRdb, applicatRdb, sal_False, OUString());
+ //OUString::createFromAscii("//./e:/src596/stoc/wntmsci3/bin") );
+
+ Reference< XPropertySet > xPropSet( rSMgr, UNO_QUERY);
+ TEST_ENSHURE( xPropSet.is(), "test_DefaultRegistry error0");
+
+ Any aPropertyAny( xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Registry")) ) );
+ TEST_ENSHURE( aPropertyAny.hasValue(), "test_DefaultRegistry error1");
+
+ Reference<XSimpleRegistry> xReg;
+ aPropertyAny >>= xReg;
+ TEST_ENSHURE( xReg.is(), "test_DefaultRegistry error1a");
+
+ Reference<XServiceInfo> xServInfo( Reference<XServiceInfo>::query(xReg) );
+
+ TEST_ENSHURE( xServInfo.is(), "test_DefaultRegistry error2");
+
+ TEST_ENSHURE( xServInfo->getImplementationName() == OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.NestedRegistry") ), "test_DefualtRegistry error3");
+ TEST_ENSHURE( xServInfo->supportsService(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.NestedRegistry") )), "test_DefaultRegistry error4");
+ TEST_ENSHURE( xServInfo->getSupportedServiceNames().getLength() == 1, "test_DefaultRegistry error5");
+ xServInfo.clear();
+
+ TEST_ENSHURE( xReg.is(), "test_DefaultRegistry error6");
+
+ try
+ {
+ Reference<XRegistryKey> xRootKey(xReg->getRootKey());
+
+ Reference<XRegistryKey> xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/UCR/com/sun/star/registry/XSimpleRegistry") ));
+
+ TEST_ENSHURE( xKey->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/UCR/com/sun/star/registry/XSimpleRegistry") ),
+ "test_DefaultRegistry error 7" );
+
+ if (bMergeDifferently)
+ {
+ mergeKeys(
+ xReg,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("Test") ),
+ testreg );
+ }
+ else
+ {
+ xReg->mergeKey(OUString( RTL_CONSTASCII_USTRINGPARAM("Test") ), testreg );
+ }
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("Test/ThirdKey/FirstSubKey/WithSubSubKey") ));
+ if (xKey.is())
+ xKey->setLongValue(123456789);
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("Test/ThirdKey/FirstSubKey") ));
+ if (xKey.is())
+ {
+ xKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("SecondSubSubKey") ));
+
+ Sequence<OUString> seqNames = xKey->getKeyNames();
+
+ TEST_ENSHURE( seqNames.getLength() == 2, "test_DefaultRegistry error 8" );
+ }
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/ThirdKey") ));
+ if (xKey.is())
+ {
+ RegistryValueType valueType = xKey->getValueType();
+ TEST_ENSHURE( valueType == RegistryValueType_ASCIILIST, "test_DefaultRegistry error 9" );
+
+ Sequence<OUString> seqValue = xKey->getAsciiListValue();
+
+ TEST_ENSHURE( seqValue.getLength() == 3, "test_DefaultRegistry error 10" );
+ TEST_ENSHURE( seqValue.getArray()[0] == OUString( RTL_CONSTASCII_USTRINGPARAM("Hallo") ),
+ "test_DefaultRegistry error 11" );
+ TEST_ENSHURE( seqValue.getArray()[1] == OUString( RTL_CONSTASCII_USTRINGPARAM("jetzt komm") ),
+ "test_DefaultRegistry error 12" );
+ TEST_ENSHURE( seqValue.getArray()[2] == OUString( RTL_CONSTASCII_USTRINGPARAM("ich") ),
+ "test_DefaultRegistry error 13" );
+
+ Sequence<sal_Int32> seqLong(3);
+ seqLong.getArray()[0] = 1234;
+ seqLong.getArray()[1] = 4567;
+ seqLong.getArray()[2] = 7890;
+
+ xKey->setLongListValue(seqLong);
+
+ Sequence<sal_Int32> seqLongValue = xKey->getLongListValue();
+
+ TEST_ENSHURE( seqLongValue.getLength() == 3, "test_DefaultRegistry error 14" );
+ TEST_ENSHURE( seqLongValue.getArray()[0] == 1234, "test_DefaultRegistry error 15" );
+ TEST_ENSHURE( seqLongValue.getArray()[1] == 4567, "test_DefaultRegistry error 16" );
+ TEST_ENSHURE( seqLongValue.getArray()[2] == 7890, "test_DefaultRegistry error 17" );
+ }
+
+ // Test Links
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FifthKey") ));
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("MyFirstLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/ThirdKey/FirstSubKey") ));
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FifthKey/MyFirstLink") ));
+ TEST_ENSHURE( xKey->isValid(), "test_DefaultRegistry error 18" );
+ TEST_ENSHURE( xKey->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/ThirdKey/FirstSubKey") ),
+ "test_DefaultRegistry error 19" );
+
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink") ));
+
+ TEST_ENSHURE( xKey->getLinkTarget(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink") ),
+ "test_DefaultRegistry error 20" );
+
+ try
+ {
+ TEST_ENSHURE( xKey->getResolvedName(OUString( RTL_CONSTASCII_USTRINGPARAM("/WithSubSubKey/MyFourthLink/BlaBlaBla") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink/BlaBlaBla") ),
+ "test_DefaultRegistry error 21" );
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+
+ xRootKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/SixthKey/MyThirdLink") ));
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/SixthKey") ));
+ xKey->createLink(OUString( RTL_CONSTASCII_USTRINGPARAM("MyThirdLink") ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink") ));
+
+ try
+ {
+ xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ));
+ }
+ catch(InvalidRegistryException&)
+ {
+ printf("test InvalidRegistryExcption OK!\n");
+ }
+
+ TEST_ENSHURE( xRootKey->getLinkTarget(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ))
+ == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FourthKey/MySecondLink") ),
+ "test_DefaultRegistry error 22" );
+
+ xRootKey->deleteLink(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/FifthKey/MyFirstLink/WithSubSubKey/MyFourthLink") ));
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/DefaultLink/SecondSubSubKey") ));
+ if (xKey.is())
+ {
+ TEST_ENSHURE( xKey->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/ThirdKey/FirstSubKey/SecondSubSubKey") ), "test_DefaultRegistry error 23" );
+ }
+ xKey = xRootKey->createKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/DefaultLink/ThirdSubSubKey") ));
+ if (xKey.is())
+ {
+ TEST_ENSHURE( xKey->getKeyName() == OUString( RTL_CONSTASCII_USTRINGPARAM("/Test/ThirdKey/FirstSubKey/ThirdSubSubKey") ),
+ "test_DefaultRegistry error 24" );
+ }
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("Test") ));
+ TEST_ENSHURE( xKey->isValid(), "test_DefaultRegistry error 25" );
+
+ xRootKey->deleteKey(OUString( RTL_CONSTASCII_USTRINGPARAM("Test") ));
+
+ if (bMergeDifferently)
+ {
+ mergeKeys(
+ xReg,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("AllFromTestreg2") ),
+ testreg2);
+ }
+ else
+ {
+ xReg->mergeKey(OUString( RTL_CONSTASCII_USTRINGPARAM("AllFromTestreg2") ),
+ testreg2);
+ }
+
+ xKey = xRootKey->openKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/AllFromTestreg2/ThirdKey/FirstSubKey") ));
+ if (xKey.is())
+ {
+ xRootKey->deleteKey(OUString( RTL_CONSTASCII_USTRINGPARAM("/AllFromTestreg2") ));
+ }
+
+ }
+ catch(InvalidRegistryException&)
+ {
+ TEST_ENSHURE(0, "exception InvalidRegistryExcption raised while doing test_DefaultRegistry");
+ }
+ catch(InvalidValueException&)
+ {
+ TEST_ENSHURE(0, "exception InvalidValueExcption raised while doing test_DefaultRegistry()");
+ }
+ try
+ {
+ xReg->close();
+ }
+ catch(InvalidRegistryException& e)
+ {
+ (void)e;
+ TEST_ENSHURE(0, OUStringToOString(e.Message,RTL_TEXTENCODING_ASCII_US).getStr());
+ }
+
+
+ xReg.clear();
+
+ // shutdown
+ Reference< ::com::sun::star::lang::XComponent > xComp( rSMgr, UNO_QUERY );
+ OSL_ENSURE( xComp.is(), "### serivce manager has to implement XComponent!" );
+ xComp->dispose();
+
+ printf("Test DefaultRegistry, OK!\n");
+}
+
+
+SAL_IMPLEMENT_MAIN()
+{
+// setStarUserRegistry();
+ setLinkInDefaultRegistry(OUString::createFromAscii("/Test/DefaultLink"),
+ OUString::createFromAscii("/Test/FifthKey/MyFirstLink"));
+
+ OUString reg1( RTL_CONSTASCII_USTRINGPARAM("testreg1.rdb") );
+ OUString reg2( RTL_CONSTASCII_USTRINGPARAM("testreg2.rdb") );
+ OUString areg1( RTL_CONSTASCII_USTRINGPARAM("atestreg1.rdb") );
+ OUString areg2( RTL_CONSTASCII_USTRINGPARAM("atestreg2.rdb") );
+
+ test_SimpleRegistry( reg1, reg2 );
+ test_DefaultRegistry( reg1, reg2 );
+ test_SimpleRegistry( areg1, areg2, true ); // use different merge
+ test_DefaultRegistry( areg1, areg2, true );
+
+ Reference< XSimpleRegistry > xSimReg( ::cppu::createSimpleRegistry() );
+ xSimReg->open( reg1, sal_False, sal_True );
+ xSimReg->destroy();
+ xSimReg->open( reg2, sal_False, sal_True );
+ xSimReg->destroy();
+ xSimReg->open( areg1, sal_False, sal_True );
+ xSimReg->destroy();
+ xSimReg->open( areg2, sal_False, sal_True );
+ xSimReg->destroy();
+ return(0);
+}
+
+
diff --git a/stoc/test/testsmgr.cxx b/stoc/test/testsmgr.cxx
new file mode 100644
index 000000000000..afa1291db8e3
--- /dev/null
+++ b/stoc/test/testsmgr.cxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+#include <stdio.h>
+
+#include <sal/main.h>
+#include <osl/process.h>
+#include <registry/registry.hxx>
+#include <uno/mapping.hxx>
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+extern "C" void SAL_CALL test_ServiceManager();
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#if OSL_DEBUG_LEVEL > 0
+#define TEST_ENSHURE(c, m) OSL_ENSURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) OSL_VERIFY(c)
+#endif
+
+
+using namespace ::rtl;
+OString userRegEnv("STAR_USER_REGISTRY=");
+
+OUString getExePath()
+{
+ OUString exe;
+
+ OSL_VERIFY( osl_getExecutableFile( &exe.pData) == osl_Process_E_None);
+
+#if defined(WIN32) || defined(__OS2__) || defined(WNT)
+ exe = exe.copy(0, exe.getLength() - 16);
+#else
+ exe = exe.copy(0, exe.getLength() - 12);
+#endif
+ return exe;
+}
+
+void setStarUserRegistry()
+{
+ Registry *myRegistry = new Registry();
+
+ RegistryKey rootKey, rKey, rKey2;
+
+ OUString userReg = getExePath();
+ userReg += OUString::createFromAscii("user.rdb");
+ if(myRegistry->open(userReg, REG_READWRITE))
+ {
+ TEST_ENSHURE(!myRegistry->create(userReg), "setStarUserRegistry error 1");
+ }
+
+ TEST_ENSHURE(!myRegistry->close(), "setStarUserRegistry error 9");
+ delete myRegistry;
+
+ userRegEnv += OUStringToOString(userReg, RTL_TEXTENCODING_ASCII_US);
+ putenv((char *)userRegEnv.getStr());
+}
+
+
+SAL_IMPLEMENT_MAIN()
+{
+ printf( "ServiceManagerTest : \r");
+ setStarUserRegistry();
+ fflush( stdout );
+ test_ServiceManager();
+
+ printf( "ServiceManagerTest : OK\n" );
+ return 0;
+}
diff --git a/stoc/test/testsmgr2.cxx b/stoc/test/testsmgr2.cxx
new file mode 100644
index 000000000000..b04f188c10f9
--- /dev/null
+++ b/stoc/test/testsmgr2.cxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+#include <stdio.h>
+
+#include <sal/main.h>
+#include <cppuhelper/bootstrap.hxx>
+
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::registry;
+
+SAL_IMPLEMENT_MAIN()
+{
+ try
+ {
+
+ Reference< XSimpleRegistry > r1 = createSimpleRegistry();
+ Reference< XSimpleRegistry > r2 = createSimpleRegistry();
+ r1->open( OUString( RTL_CONSTASCII_USTRINGPARAM( "test1.rdb" ) ), sal_True, sal_False );
+ r2->open( OUString( RTL_CONSTASCII_USTRINGPARAM( "test2.rdb" ) ), sal_True, sal_False );
+ Reference< XSimpleRegistry > r = createNestedRegistry( );
+ Reference< XInitialization > rInit( r, UNO_QUERY );
+ Sequence< Any > seq( 2 );
+ seq[0] <<= r1;
+ seq[1] <<= r2;
+ rInit->initialize( seq );
+
+ Reference< XComponentContext > rComp = bootstrap_InitialComponentContext( r );
+
+ Reference< XContentEnumerationAccess > xCtAccess( rComp->getServiceManager(), UNO_QUERY );
+
+ Reference< XEnumeration > rEnum =
+ xCtAccess->createContentEnumeration( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.bridge.Bridge" ) ) );
+
+ sal_Int32 n = 0;
+ while( rEnum->hasMoreElements() )
+ {
+ Reference< XServiceInfo > r3;
+ rEnum->nextElement() >>= r3;
+ OString o = OUStringToOString( r3->getImplementationName() , RTL_TEXTENCODING_ASCII_US );
+ printf( "%s\n" , o.getStr() );
+ Sequence< OUString > seq2 = r3->getSupportedServiceNames();
+ for( int i = 0 ;i < seq2.getLength() ; i ++ )
+ {
+ o = OUStringToOString( seq2[i] , RTL_TEXTENCODING_ASCII_US );
+ printf( " %s\n" , o.getStr() );
+ }
+ n ++;
+ }
+ // there are two services in two registries !
+ OSL_ASSERT( 2 == n );
+ if( 2 == n )
+ {
+ printf( "test passed\n" );
+ }
+
+ Reference< XComponent > xComp( rComp, UNO_QUERY );
+ xComp->dispose();
+ try
+ {
+ xCtAccess->createContentEnumeration(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "blabla" ) ) );
+ }
+ catch (DisposedException &)
+ {
+ printf( "already disposed results in DisposedException: ok.\n" );
+ return 0;
+ }
+ fprintf( stderr, "missing DisposedException!\n" );
+ return 1;
+ }
+ catch ( Exception & e )
+ {
+ OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US );
+ printf( "%s\n" , o.getStr() );
+ OSL_ASSERT( 0 );
+ return 1;
+ }
+}
diff --git a/stoc/test/testsmgr_cpnt.cxx b/stoc/test/testsmgr_cpnt.cxx
new file mode 100644
index 000000000000..aecdbc55514f
--- /dev/null
+++ b/stoc/test/testsmgr_cpnt.cxx
@@ -0,0 +1,472 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+#include <rtl/alloc.h>
+#include <osl/security.h>
+#include <osl/thread.h>
+#include <osl/mutex.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/weak.hxx>
+#include <uno/mapping.hxx>
+
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <registry/registry.hxx>
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+
+#if defined ( UNX )
+#include <limits.h>
+#define _MAX_PATH PATH_MAX
+#endif
+
+
+
+#if OSL_DEBUG_LEVEL > 0
+#define TEST_ENSHURE(c, m) OSL_ENSURE(c, m)
+#else
+#define TEST_ENSHURE(c, m) OSL_VERIFY(c)
+#endif
+
+
+#define IMPLEMENTATION_NAME "com.sun.star.DummyService.V10"
+#define SERVICE_NAME "com.sun.star.ts.TestManagerImpl"
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
+using namespace osl;
+using namespace rtl;
+using namespace cppu;
+
+
+Reference<XMultiServiceFactory> getProcessServiceManager()
+{
+ Reference<XMultiServiceFactory > s_x;
+ if (! s_x.is())
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! s_x.is())
+ s_x = createRegistryServiceFactory( OUString::createFromAscii( "stoctest.rdb" ), sal_False );
+ }
+ return s_x;
+}
+
+Reference< XMultiServiceFactory > createRegistryServiceManager( const OUString& registryName )
+{
+ return createRegistryServiceFactory( registryName );
+}
+
+
+/**********************************
+* The service, that is used to test the Service manager
+*
+*
+*
+*************************************/
+static sal_uInt32 nInstanceCount = 0;
+class Test_Manager_Impl : public WeakImplHelper1< XServiceInfo >
+{
+public:
+ Test_Manager_Impl(){ nInstanceCount++;}
+ ~Test_Manager_Impl();
+
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName() throw();
+ sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw();
+ Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw();
+ static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static(void) throw();
+
+private:
+// static XIdlClassRef getStaticIdlClass();
+};
+
+Test_Manager_Impl::~Test_Manager_Impl()
+{
+ nInstanceCount--;
+}
+
+
+// alt, wird von der neuen Mimic nicht mehr gebraucht
+Reference< XInterface > SAL_CALL Test_Manager_Impl_CreateInstance_Impl()
+{
+ return (OWeakObject *)new Test_Manager_Impl();
+}
+
+
+//*************************************************************************
+// Test_Manager_Impl_CreateInstance()
+//
+Reference < XInterface > SAL_CALL Test_Manager_Impl_CreateInstance(
+ const Reference< XMultiServiceFactory > & /*rSMgr*/ ) throw (Exception)
+{
+ Reference < XInterface > xService = (XWeak *)(OWeakObject *)new Test_Manager_Impl( );
+
+ return xService;
+}
+
+
+//*************************************************************************
+// Test_Manager_Impl::getImplementationName
+//
+OUString Test_Manager_Impl::getImplementationName() throw()
+{
+ return OUString::createFromAscii(IMPLEMENTATION_NAME);
+}
+
+//*************************************************************************
+// Test_Manager_Impl::supportsService
+//
+sal_Bool Test_Manager_Impl::supportsService( const OUString& ServiceName ) throw()
+{
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//*************************************************************************
+// Test_Manager_Impl::getSupportedServiceNames
+//
+Sequence< OUString > Test_Manager_Impl::getSupportedServiceNames(void) throw ()
+{
+ return getSupportedServiceNames_Static();
+}
+
+//*************************************************************************
+// Test_Manager_Impl::getSupportedServiceNames_Static
+//
+Sequence< OUString > Test_Manager_Impl::getSupportedServiceNames_Static(void) throw ()
+{
+ Sequence< OUString > aSNS( 2 );
+ aSNS.getArray()[0] = OUString::createFromAscii(SERVICE_NAME);
+ aSNS.getArray()[1] = OUString::createFromAscii("com.sun.star.bridge.Bridge");
+ return aSNS;
+}
+
+
+
+
+/****
+*
+*
+* This routine performs the test of the process service manager ( getProcessServiceManager is called )
+*
+*
+*
+****/
+
+#include <stdio.h>
+
+extern "C" void SAL_CALL test_ServiceManager()
+{
+#if ! defined SAL_DLLPREFIX
+#define SAL_DLLPREFIX ""
+#endif
+ OUString atUModule2 = OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ SAL_DLLPREFIX "testsmgr_component" SAL_DLLEXTENSION ) );
+
+ // expand shared library name
+ OString atModule2( OUStringToOString(atUModule2, RTL_TEXTENCODING_ASCII_US) );
+
+ // get the process servicemanager
+ Reference <XMultiServiceFactory> xSMgr = getProcessServiceManager();
+
+ TEST_ENSHURE( xSMgr.is() , "query on XServiceManager failed" );
+
+ Reference<XContentEnumerationAccess> xContEnum(xSMgr, UNO_QUERY);
+ TEST_ENSHURE( xContEnum.is() , "query on XContentEnumerationAccess failed" );
+ Reference<XEnumeration > xEnum(xContEnum->createContentEnumeration(OUString::createFromAscii("com.sun.star.registry.SimpleRegistry")));
+ TEST_ENSHURE( xEnum.is() , "createContentEnumeration failed" );
+ sal_Int32 nLen = 0;
+ while( xEnum->hasMoreElements() )
+ {
+ nLen++;
+ xEnum->nextElement();
+ }
+ TEST_ENSHURE( nLen == 1, "more than one implementation for SimpleRegistry" );
+
+ Reference<XEnumerationAccess> xImplEnum(xSMgr, UNO_QUERY);
+ TEST_ENSHURE( xImplEnum.is() , "query on XEnumeration failed" );
+ xEnum = Reference<XEnumeration >(xImplEnum->createEnumeration());
+ TEST_ENSHURE( xEnum.is() , "createEnumeration failed" );
+ nLen = 0;
+ while( xEnum->hasMoreElements() )
+ {
+ nLen++;
+ Reference< XServiceInfo > sf( xEnum->nextElement(), UNO_QUERY );
+ OString str( OUStringToOString( sf->getImplementationName(), RTL_TEXTENCODING_ASCII_US ) );
+ ::fprintf( stderr, "> implementation name: %s\n", str.getStr() );
+ }
+ TEST_ENSHURE( nLen == 8, "more than 6 factories" );
+
+ // try to get an instance for a unknown service
+ TEST_ENSHURE( !xSMgr->createInstance(OUString::createFromAscii("bla.blup.Q")).is(), "unknown service provider found" );
+
+ //
+ // First test : register service via the internal function of the component itself
+ //
+ {
+ Reference< XImplementationRegistration >
+ xInst( xSMgr->createInstance(OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration")), UNO_QUERY );
+ TEST_ENSHURE( xInst.is(), "no ImplementationRegistration" );
+
+ try {
+ // register the services via writeComponentRegInfo (see at end of this file)
+ xInst->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), atUModule2, Reference< XSimpleRegistry >() );
+ }
+ catch( CannotRegisterImplementationException e ) {
+ TEST_ENSHURE( 0, "register implementation failed" );
+ }
+
+ // getImplementations() check
+ Sequence<OUString> seqImpl = xInst->getImplementations(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), atUModule2);
+ TEST_ENSHURE( seqImpl.getLength() == 1, "count of implementantions is wrong" );
+ TEST_ENSHURE( seqImpl.getConstArray()[0] == OUString::createFromAscii("com.sun.star.DummyService.V10"), "implementation name is not equal" );
+
+
+ // tests, if a service provider can be instantiated.
+
+ Reference< XInterface > xIFace(xSMgr->createInstance(OUString::createFromAscii("com.sun.star.ts.TestManagerImpl")));
+ TEST_ENSHURE( xIFace.is(), "loadable service not found" );
+
+ // remove the service
+ TEST_ENSHURE( xInst->revokeImplementation(atUModule2, Reference< XSimpleRegistry > ()),
+ "revoke implementation failed" );
+ }
+
+
+// Reference < XSimpleRegistry > xSReg( xSMgr->createInstance(OUString::createFromAscii("com::sun::star.uno.repos.SimpleRegistry")), UNO_QUERY );
+// TEST_ENSHURE( xSReg.is() , "Simple registry couldn't be instantiated" );
+
+// xSReg->open(OUString::createFromAscii("dummy.reg"), sal_False, sal_True);
+// xSReg->close();
+
+ // laut dbo : C-API muss nicht mehr unterstuezt werden
+ //TEST_ENSHURE( registerExternService(atModule, "dummy.reg"), "install failed" );
+ //TEST_ENSHURE( deregisterExternService(atModule, "dummy.reg"), "deinstall failed" );
+
+
+// UNO_INTERFACE(XMultiServiceFactory) xUnoSMgr = {0,0};
+// smart2uno(xSMgr, xUnoSMgr);
+
+// TEST_ENSHURE(registerExternImplementation(xUnoSMgr, "com::sun::star.loader.SharedLibrary", atModule2, "dummy.reg"), "install failed" );
+// TEST_ENSHURE(revokeExternImplementation(xUnoSMgr, atModule2, "dummy.reg"), "deinstall failed" );
+
+// TEST_ENSHURE(registerExternImplementation(xUnoSMgr, "com::sun::star.loader.SharedLibrary", atModule2, "dummy2.reg"), "install failed" );
+
+//TODO : Java loader test
+// String testUrl(getTestJarUrl());
+// TEST_ENSHURE(registerExternImplementation(xUnoSMgr, "com::sun::star.loader.Java", testUrl, "dummy.reg"), "install failed" );
+// TEST_ENSHURE(revokeExternImplementation(xUnoSMgr, testUrl, "dummy.reg"), "deinstall failed" );
+
+// if (!UNO_isNull((UNO_Ifc*)&xUnoSMgr))
+// xUnoSMgr.m_pVmt->release(xUnoSMgr.m_pCtx);
+
+// xSReg->open(OUString::createFromAscii("dummy.reg"), sal_True, sal_False);
+// TEST_ENSHURE(!xSReg->getRootKey()->openKey(OUString::createFromAscii("/SERVICES/com::sun::star/ts/TestManagerImpl/URL")).is(),
+// "deinstall failed" );
+
+// xSReg->close();
+
+// xSReg->open(OUString::createFromAscii("dummy.reg"), sal_False, sal_False);
+// xSReg->destroy();
+// xSReg->open(OUString::createFromAscii("dummy2.reg"), sal_False, sal_False);
+// xSReg->destroy();
+
+
+ // Test initialisieren
+/*
+ XServiceProviderRef xSiSP1 = createSimpleServiceProvider( OUString::createFromAscii("com::sun::star.usr.Test_Manager_Impl1"), Test_Manager_Impl_getReflection );
+ XServiceProviderRef xSiSP11 = createSimpleServiceProvider( OUString::createFromAscii("com::sun::star.usr.Test_Manager_Impl1"), Test_Manager_Impl_getReflection );
+ XServiceProviderRef xSiSP2 = createSimpleServiceProvider( OUString::createFromAscii("com::sun::star.usr.Test_Manager_Impl2"), Test_Manager_Impl_getReflection );
+*/
+/*
+ // second test
+ // create XServiceProvider via createSingleFactory and write them directly into the registry
+ // For this is needed a sequence of supported servicenames and a createComponent function pointer
+ {
+ Reference< XServiceProvider > xSiSP1(createSingleFactory(
+ xSMgr,
+ OUString::createFromAscii("com::sun::star.usr.Test_Manager_Impl1),
+ Test_Manager_Impl_CreateInstance,
+ Test_Manager_Impl::getSupportedServiceNames_Static() ), UNO_QUERY);
+ Reference< XServiceProvider > xSiSP11(createSingleFactory(
+ xSMgr,
+ OUString::createFromAscii("com::sun::star.usr.Test_Manager_Impl1"),
+ Test_Manager_Impl_CreateInstance,
+ Test_Manager_Impl::getSupportedServiceNames_Static() ),UNO_QUERY);
+ Reference< XServiceProvider > xSiSP2(createSingleFactory(
+ xSMgr,
+ L"com::sun::star.usr.Test_Manager_Impl2",
+ Test_Manager_Impl_CreateInstance,
+ Test_Manager_Impl::getSupportedServiceNames_Static() ), UNO_QUERY);
+
+ // put the service providers into the registry
+ xReg->registerServiceProvider( L"com::sun::star.test.TestManager1", xSiSP1 );
+ xReg->registerServiceProvider( L"com::sun::star.test.TestManager1", xSiSP11 );
+ xReg->registerServiceProvider( L"com::sun::star.test.TestManager2", xSiSP2 );
+
+ // TestManager1
+ Reference< XServiceProvider > xProv = xSMgr->queryServiceProvider( L"com::sun::star.test.TestManager1");
+ Reference< XSingleServiceFactory > xFact( xProv, UNO_QUERY );
+ TEST_ENSHURE( xFact.is(), "Service com::sun::star.test.TestManager1 not found" );
+
+ Reference< XInterface > xTest1 = xFact->createInstance();
+ TEST_ENSHURE( nInstanceCount == 1, "wrong service instanciated" );
+
+ // TestManager2
+ xProv = xSMgr->queryServiceProvider( L"com::sun::star.test.TestManager2");
+ xFact = Reference < XSingleServiceFactory > ( xProv , UNO_QUERY );
+ TEST_ENSHURE( xFact.is(), "Service com::sun::star.test.TestManager2 not found" );
+
+ Reference < XInterface > xTest2 = xFact->createInstance();
+ TEST_ENSHURE( nInstanceCount == 2, "wrong service instanciated" );
+
+ xTest1 = Reference< XInterface >();
+ xTest2 = Reference< XInterface >();
+ TEST_ENSHURE( nInstanceCount == 0, "wrong service deleted" );
+
+ Reference< XEnumeration > xEnum = xSMgr->createProviderEnumeration( L"com::sun::star.test.TestManager1");
+ TEST_ENSHURE( xEnum.is() , "no provider enumeration" );
+
+ sal_Int32 nSPTestManagerImplLen2 = 0;
+
+ while (xEnum.is() && xEnum->hasMoreElements())
+ {
+ nSPTestManagerImplLen2++;
+ xEnum->nextElement();
+
+ }
+ TEST_ENSHURE( nSPTestManagerImplLen2 == 2, "queryServiceProviders() wrong length" );
+
+ sal_Int32 nCount = 0;
+ xEnum = xSMgr->createProviderEnumeration( L"com::sun::star.test.TestManager1");
+ while (xEnum->hasMoreElements())
+ {
+ Reference< XServiceProvider > xProv;
+ xEnum->nextElement() >>= xProv;
+ if (xProv == xSiSP1 || xProv == xSiSP11)
+ nCount++;
+ }
+
+ TEST_ENSHURE( nCount == 2 , "not all com::sun::star.testimpl.TestManagerImpl registered" );
+*/
+/*
+ {
+ Reference< XMultiServiceFactory > xTestManager(createRegistryServiceManager(L"testmanager.rdb"));
+ TEST_ENSHURE( xTestManager.is(), "create Test ServiceManager failed!" );
+ }
+*/
+ Reference<XComponent> xComp(xSMgr, UNO_QUERY);
+ xComp->dispose();
+
+ xComp.clear();
+ xSMgr.clear();
+}
+
+
+
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * /*pServiceManager*/, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLEMENTATION_NAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL =
+ Test_Manager_Impl::getSupportedServiceNames_Static();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
+{
+ void * pRet = 0;
+
+ if (rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLEMENTATION_NAME) ),
+ Test_Manager_Impl_CreateInstance,
+ Test_Manager_Impl::getSupportedServiceNames_Static() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+
+
diff --git a/stoc/test/testsmgr_cpnt.map b/stoc/test/testsmgr_cpnt.map
new file mode 100644
index 000000000000..ab5ed357b461
--- /dev/null
+++ b/stoc/test/testsmgr_cpnt.map
@@ -0,0 +1,9 @@
+UDK_3_0_0 {
+ global:
+ component_getImplementationEnvironment;
+ component_writeInfo;
+ component_getFactory;
+ test_ServiceManager;
+ local:
+ *;
+};
diff --git a/stoc/test/uriproc/makefile.mk b/stoc/test/uriproc/makefile.mk
new file mode 100644
index 000000000000..05ffd5fdd210
--- /dev/null
+++ b/stoc/test/uriproc/makefile.mk
@@ -0,0 +1,83 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ := ../..
+PRJNAME := stoc
+TARGET := test_uriproc
+
+ENABLE_EXCEPTIONS := TRUE
+
+my_components = stocservices
+
+.INCLUDE: settings.mk
+
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+DLLPRE = # no leading "lib" on .so files
+
+SHL1TARGET = $(TARGET)
+SHL1OBJS = $(SLO)/test_uriproc.obj
+SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB)
+SHL1VERSIONMAP = version.map
+SHL1RPATH = NONE
+SHL1IMPLIB = i$(SHL1TARGET)
+DEF1NAME = $(SHL1TARGET)
+
+SLOFILES = $(SHL1OBJS)
+
+.INCLUDE: target.mk
+
+.IF "$(OS)" == "WNT"
+my_file = file:///
+.ELSE
+my_file = file://
+.END
+
+ALLTAR: test
+
+test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/services.rdb
+ $(CPPUNITTESTER) $(SHL1TARGETN) \
+ -env:UNO_TYPES=$(my_file)$(SOLARBINDIR)/udkapi.rdb \
+ -env:UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \
+ -env:URE_INTERNAL_LIB_DIR=$(my_file)$(PWD)/$(DLLDEST)
+
+$(MISC)/$(TARGET)/services.rdb .ERRREMOVE: $(SOLARENV)/bin/packcomponents.xslt \
+ $(MISC)/$(TARGET)/services.input \
+ $(my_components:^"$(MISC)/":+".component")
+ $(XSLTPROC) --nonet --stringparam prefix $(PWD)/$(MISC)/ -o $@ \
+ $(SOLARENV)/bin/packcomponents.xslt $(MISC)/$(TARGET)/services.input
+
+$(MISC)/$(TARGET)/services.input:
+ $(MKDIRHIER) $(@:d)
+ echo \
+ '<list>$(my_components:^"<filename>":+".component</filename>")</list>' \
+ > $@
+
+.END
diff --git a/stoc/test/uriproc/test_uriproc.cxx b/stoc/test/uriproc/test_uriproc.cxx
new file mode 100644
index 000000000000..a7ad8d9abf94
--- /dev/null
+++ b/stoc/test/uriproc/test_uriproc.cxx
@@ -0,0 +1,1004 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_stoc.hxx"
+
+#include "com/sun/star/lang/XComponent.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uri/ExternalUriReferenceTranslator.hpp"
+#include "com/sun/star/uri/UriReferenceFactory.hpp"
+#include "com/sun/star/uri/VndSunStarPkgUrlReferenceFactory.hpp"
+#include "com/sun/star/uri/XExternalUriReferenceTranslator.hpp"
+#include "com/sun/star/uri/XUriReference.hpp"
+#include "com/sun/star/uri/XUriReferenceFactory.hpp"
+#include "com/sun/star/uri/XVndSunStarExpandUrlReference.hpp"
+#include "com/sun/star/uri/XVndSunStarPkgUrlReferenceFactory.hpp"
+#include "com/sun/star/uri/XVndSunStarScriptUrlReference.hpp"
+#include "com/sun/star/util/XMacroExpander.hpp"
+#include "cppuhelper/bootstrap.hxx"
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+#include "cppunit/plugin/TestPlugIn.h"
+#include "osl/diagnose.h"
+#include "rtl/string.h"
+#include "rtl/string.hxx"
+#include "rtl/textenc.h"
+#include "rtl/ustrbuf.hxx"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+
+#include <cstdlib>
+
+namespace css = com::sun::star;
+
+namespace {
+
+#define TEST_ASSERT_EQUAL(token1, token2, token3, expected, actual) \
+ CPPUNIT_ASSERT_MESSAGE( \
+ createTestAssertEqualMessage( \
+ token1, token2, token3, #expected, #actual, expected, actual). \
+ getStr(), \
+ (actual) == (expected))
+
+template< typename T > void append(
+ rtl::OUStringBuffer & buffer, T const & value)
+{
+ buffer.append(value);
+}
+
+template<> void append(rtl::OUStringBuffer & buffer, bool const & value) {
+ buffer.append(static_cast< sal_Bool >(value));
+}
+
+template<> void append(rtl::OUStringBuffer & buffer, std::size_t const & value)
+{
+ buffer.append(static_cast< sal_Int32 >(value));
+}
+
+template<> void append(rtl::OUStringBuffer & buffer, char const * const & value)
+{
+ buffer.appendAscii(value);
+}
+
+template< typename T1, typename T2, typename T3, typename T4 >
+rtl::OString createTestAssertEqualMessage(
+ char const * token1, T1 const & token2, T2 const & token3,
+ char const * expectedExpr, char const * actualExpr, T3 const & expected,
+ T4 const & actual)
+{
+ rtl::OUStringBuffer buf;
+ buf.appendAscii(token1);
+ buf.append(static_cast< sal_Unicode >('|'));
+ append(buf, token2);
+ buf.append(static_cast< sal_Unicode >('|'));
+ append(buf, token3);
+ buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(": TEST_ASSERT_EQUAL("));
+ buf.appendAscii(expectedExpr);
+ buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ buf.appendAscii(actualExpr);
+ buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("): <"));
+ append(buf, expected);
+ buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("> != <"));
+ append(buf, actual);
+ buf.append(static_cast< sal_Unicode >('>'));
+ return rtl::OUStringToOString(
+ buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US);
+}
+
+class Test: public CppUnit::TestFixture {
+public:
+ virtual void setUp();
+
+ virtual void tearDown();
+
+ void testParse();
+
+ void testMakeAbsolute();
+
+ void testMakeRelative();
+
+ void testVndSunStarExpand();
+
+ void testVndSunStarScript();
+
+ void testTranslator();
+
+ void testPkgUrlFactory();
+
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testMakeAbsolute);
+ CPPUNIT_TEST(testMakeRelative);
+ CPPUNIT_TEST(testVndSunStarExpand);
+ CPPUNIT_TEST(testVndSunStarScript);
+ CPPUNIT_TEST(testTranslator);
+ CPPUNIT_TEST(testPkgUrlFactory);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ css::uno::Reference< css::uno::XComponentContext > m_context;
+ css::uno::Reference< css::uri::XUriReferenceFactory > m_uriFactory;
+};
+
+void Test::setUp() {
+ m_context = cppu::defaultBootstrap_InitialComponentContext();
+ m_uriFactory = css::uri::UriReferenceFactory::create(m_context);
+}
+
+void Test::tearDown() {
+ m_uriFactory.clear();
+ css::uno::Reference< css::lang::XComponent >(
+ m_context, css::uno::UNO_QUERY_THROW)->dispose();
+}
+
+void Test::testParse() {
+ struct Data {
+ char const * uriReference;
+ char const * scheme;
+ char const * schemeSpecificPart;
+ bool isHierarchical;
+ char const * authority;
+ char const * path;
+ bool hasRelativePath;
+ sal_Int32 pathSegmentCount;
+ char const * pathSegment0;
+ char const * pathSegment1;
+ char const * pathSegment2;
+ char const * pathSegment3;
+ char const * pathSegment4;
+ char const * query;
+ char const * fragment;
+ };
+ Data data[] = {
+ { "", 0, "", true, 0,
+ "", true, 0, "", "", "", "", "", 0, 0 },
+ { "scheme:", 0, 0, false, 0,
+ 0, false, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { "scheme:/", "scheme", "/", true, 0,
+ "/", false, 1, "", "", "", "", "", 0, 0 },
+ { "scheme://", "scheme", "//", true, "",
+ "", false, 0, "", "", "", "", "", 0, 0 },
+ { "scheme:///", "scheme", "///", true, "",
+ "/", false, 1, "", "", "", "", "", 0, 0 },
+ { "scheme:////", "scheme", "////", true, "",
+ "//", false, 2, "", "", "", "", "", 0, 0 },
+ { "scheme:////", "scheme", "////", true, "",
+ "//", false, 2, "", "", "", "", "", 0, 0 },
+ { "scheme:#", 0, 0, false, 0,
+ 0, false, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { "scheme:?", "scheme", "?", false, 0,
+ "?", false, 0, "", "", "", "", "", 0, 0 },
+ { "/", 0, "/", true, 0,
+ "/", false, 1, "", "", "", "", "", 0, 0 },
+ { "//", 0, "//", true, "",
+ "", false, 0, "", "", "", "", "", 0, 0 },
+ { "///", 0, "///", true, "",
+ "/", false, 1, "", "", "", "", "", 0, 0 },
+ { "////", 0, "////", true, "",
+ "//", false, 2, "", "", "", "", "", 0, 0 } };
+ for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ css::uno::Reference< css::uri::XUriReference > uriRef(
+ m_uriFactory->parse(
+ rtl::OUString::createFromAscii(data[i].uriReference)));
+ CPPUNIT_ASSERT(uriRef.is() == (data[i].schemeSpecificPart != 0));
+ if (uriRef.is()) {
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].uriReference),
+ uriRef->getUriReference());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ data[i].scheme != 0, uriRef->isAbsolute());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(
+ data[i].scheme == 0 ? "" : data[i].scheme),
+ uriRef->getScheme());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].schemeSpecificPart),
+ uriRef->getSchemeSpecificPart());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ data[i].isHierarchical,
+ static_cast< bool >(uriRef->isHierarchical()));
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ data[i].authority != 0, uriRef->hasAuthority());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(
+ data[i].authority == 0 ? "" : data[i].authority),
+ uriRef->getAuthority());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].path),
+ uriRef->getPath());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ data[i].hasRelativePath,
+ static_cast< bool >(uriRef->hasRelativePath()));
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ data[i].pathSegmentCount, uriRef->getPathSegmentCount());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(""), uriRef->getPathSegment(-1));
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].pathSegment0),
+ uriRef->getPathSegment(0));
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].pathSegment1),
+ uriRef->getPathSegment(1));
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].pathSegment2),
+ uriRef->getPathSegment(2));
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].pathSegment3),
+ uriRef->getPathSegment(3));
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].pathSegment4),
+ uriRef->getPathSegment(4));
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(""), uriRef->getPathSegment(5));
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ data[i].query != 0, uriRef->hasQuery());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(
+ data[i].query == 0 ? "" : data[i].query),
+ uriRef->getQuery());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ data[i].fragment != 0, uriRef->hasFragment());
+ TEST_ASSERT_EQUAL(
+ "testParse", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(
+ data[i].fragment == 0 ? "" : data[i].fragment),
+ uriRef->getFragment());
+ }
+ }
+}
+
+void Test::testMakeAbsolute() {
+ struct Data {
+ char const * baseUriReference;
+ char const * uriReference;
+ bool processSpecialBaseSegments;
+ css::uri::RelativeUriExcessParentSegments excessParentSegments;
+ char const * absolute;
+ };
+ Data data[] = {
+ // The following tests are taken from RFC 2396, Appendix C:
+ { "http://a/b/c/d;p?q", "g:h", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "g:h" },
+ { "http://a/b/c/d;p?q", "g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g" },
+ { "http://a/b/c/d;p?q", "./g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g" },
+ { "http://a/b/c/d;p?q", "g/", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g/" },
+ { "http://a/b/c/d;p?q", "//g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://g" },
+ { "http://a/b/c/d;p?q", "?y", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/?y" },
+ { "http://a/b/c/d;p?q", "g?y", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g?y" },
+ { "http://a/b/c/d;p?q", "#s", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/d;p?q#s" },
+ { "http://a/b/c/d;p?q", "g#s", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g#s" },
+ { "http://a/b/c/d;p?q", "g?y#s", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g?y#s" },
+ { "http://a/b/c/d;p?q", ";x", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/;x" },
+ { "http://a/b/c/d;p?q", "g;x", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g;x" },
+ { "http://a/b/c/d;p?q", "g;x?y#s", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g;x?y#s" },
+ { "http://a/b/c/d;p?q", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/" },
+ { "http://a/b/c/d;p?q", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/" },
+ { "http://a/b/c/d;p?q", "..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/" },
+ { "http://a/b/c/d;p?q", "../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/" },
+ { "http://a/b/c/d;p?q", "../g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/g" },
+ { "http://a/b/c/d;p?q", "../..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/" },
+ { "http://a/b/c/d;p?q", "../../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/" },
+ { "http://a/b/c/d;p?q", "../../g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/g" },
+ { "http://a/b/c/d;p?q", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/d;p?q" },
+ { "http://a/b/c/d;p?q", "../../../g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, 0 },
+ { "http://a/b/c/d;p?q", "../../../g", true,
+ css::uri::RelativeUriExcessParentSegments_RETAIN, "http://a/../g" },
+ { "http://a/b/c/d;p?q", "../../../g", true,
+ css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
+ { "http://a/b/c/d;p?q", "../../../../g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, 0 },
+ { "http://a/b/c/d;p?q", "../../../../g", true,
+ css::uri::RelativeUriExcessParentSegments_RETAIN,
+ "http://a/../../g" },
+ { "http://a/b/c/d;p?q", "../../../../g", true,
+ css::uri::RelativeUriExcessParentSegments_REMOVE, "http://a/g" },
+ { "http://a/b/c/d;p?q", "/./g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/./g" },
+ { "http://a/b/c/d;p?q", "/../g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/../g" },
+ { "http://a/b/c/d;p?q", "g.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g." },
+ { "http://a/b/c/d;p?q", ".g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/.g" },
+ { "http://a/b/c/d;p?q", "g..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g.." },
+ { "http://a/b/c/d;p?q", "..g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/..g" },
+ { "http://a/b/c/d;p?q", "./../g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/g" },
+ { "http://a/b/c/d;p?q", "./g/.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/g/" },
+ { "http://a/b/c/d;p?q", "g/./h", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g/h" },
+ { "http://a/b/c/d;p?q", "g/../h", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/h" },
+ { "http://a/b/c/d;p?q", "g;x=1/./y", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g;x=1/y" },
+ { "http://a/b/c/d;p?q", "g;x=1/../y", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http://a/b/c/y" },
+ { "http://a/b/c/d;p?q", "g?y/./x", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g?y/./x" },
+ { "http://a/b/c/d;p?q", "g?y/../x", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g?y/../x" },
+ { "http://a/b/c/d;p?q", "g#s/./x", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g#s/./x" },
+ { "http://a/b/c/d;p?q", "g#s/../x", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR,
+ "http://a/b/c/g#s/../x" },
+ { "http.://a/b/c/d;p?q", "http.:g", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "http.:g" },
+
+ { "scheme://a", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+
+ { "scheme://a/", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+
+ { "scheme://a/b", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b" },
+ { "scheme://a/b", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+ { "scheme://a/b", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/" },
+
+ { "scheme://a/b/", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", ".", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "./", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "./.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "x/../", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "./x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "./././x/..", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "./x/../.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "./x/.././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "././x/.././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "././x/../././", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+ { "scheme://a/b/", "./././x/../././.", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a/b/" },
+
+ { "scheme://a#s", "", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a" },
+ { "scheme://a", "?q", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a?q" },
+ { "scheme://a#s", "?q", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a?q" },
+ { "scheme://a", "#s", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s" },
+ { "scheme://a#s1", "#s2", true,
+ css::uri::RelativeUriExcessParentSegments_ERROR, "scheme://a#s2" } };
+ for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ css::uno::Reference< css::uri::XUriReference > baseUriRef(
+ m_uriFactory->parse(
+ rtl::OUString::createFromAscii(data[i].baseUriReference)));
+ CPPUNIT_ASSERT(baseUriRef.is());
+ css::uno::Reference< css::uri::XUriReference > uriRef(
+ m_uriFactory->parse(
+ rtl::OUString::createFromAscii(data[i].uriReference)));
+ CPPUNIT_ASSERT(uriRef.is());
+ css::uno::Reference< css::uri::XUriReference > absolute(
+ m_uriFactory->makeAbsolute(
+ baseUriRef, uriRef, data[i].processSpecialBaseSegments,
+ data[i].excessParentSegments));
+ TEST_ASSERT_EQUAL(
+ "testMakeAbsolute", i, data[i].uriReference,
+ data[i].absolute != 0, absolute.is());
+ if (absolute.is()) {
+ TEST_ASSERT_EQUAL(
+ "testMakeAbsolute", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].absolute),
+ absolute->getUriReference());
+ }
+ }
+}
+
+void Test::testMakeRelative() {
+ struct Data {
+ char const * baseUriReference;
+ char const * uriReference;
+ bool preferAuthorityOverRelativePath;
+ bool preferAbsoluteOverRelativePath;
+ bool encodeRetainedSpecialSegments;
+ char const * relative;
+ char const * absolute;
+ };
+ Data data[] = {
+ { "scheme1://a/b/c", "scheme2://a/b/c?q#s", true, true, false,
+ "scheme2://a/b/c?q#s", 0 },
+ { "scheme://a/b/c", "scheme:a/b/c?q#s", true, true, false,
+ "scheme:a/b/c?q#s", 0 },
+ { "scheme://a/b/c", "", true, true, false, "", "scheme://a/b/c" },
+ { "scheme://a/b/c", "//d/e/f", true, true, false, "//d/e/f",
+ "scheme://d/e/f" },
+ { "scheme://a/b/c", "./e?q#s", true, true, false, "./e?q#s",
+ "scheme://a/b/e?q#s" },
+ { "scheme://a/b", "scheme://a?q", true, true, false, "/?q",
+ "scheme://a/?q" },
+ { "scheme://a/b", "scheme://a?q", true, false, false, "?q",
+ "scheme://a/?q" },
+ { "scheme://a", "scheme://a?q", true, true, false, "?q", 0 },
+ { "scheme://a/", "scheme://a?q", true, true, false, "?q",
+ "scheme://a/?q" },
+ { "scheme://a", "scheme://a/?q", true, true, false, "?q",
+ "scheme://a?q" },
+ { "scheme://a/", "scheme://a/?q", true, true, false, "?q",
+ "scheme://a/?q" },
+ { "scheme://a?q", "scheme://a?q", true, true, false, "", 0 },
+ { "scheme://a/?q", "scheme://a?q", true, true, false, "",
+ "scheme://a/?q" },
+ { "scheme://a?q", "scheme://a/?q", true, true, false, "",
+ "scheme://a?q" },
+ { "scheme://a/?q", "scheme://a/?q", true, true, false, "", 0 },
+ { "scheme://a/b/c/d", "scheme://a//", true, true, false, "//a//", 0 },
+ { "scheme://a/b/c/d", "scheme://a//", false, true, false, "../..//",
+ 0 },
+ { "scheme://a/b/c/d", "scheme://a//", true, false, false, "../..//",
+ 0 },
+ { "scheme://a/b/c/d", "scheme://a//", false, false, false, "../..//",
+ 0 },
+ { "scheme://a/b/c/d", "scheme://a/e", true, true, false, "/e", 0 },
+ { "scheme://a/b/c/d", "scheme://a/e", true, false, false, "../../e",
+ 0 },
+ { "scheme://a/b/c/d/e", "scheme://a/b/f", true, true, false, "../../f",
+ 0 },
+ { "scheme://a/b/c/d/e", "scheme://a/b", true, true, false, "/b", 0 },
+ { "scheme://a/b/c/d/e", "scheme://a/b", true, false, false,
+ "../../../b", 0 },
+ { "scheme://a/b/c/d/e", "scheme://a/b/", true, true, false, "../..",
+ 0 },
+ { "scheme://a/b/c/d/e", "scheme://a/b/c", true, true, false, "../../c",
+ 0 },
+ { "scheme://a/b/c/d/e", "scheme://a/b/c/", true, true, false, "..", 0 },
+ { "scheme://a/b/", "scheme://a/b/c/d", true, true, false, "c/d", 0 },
+ { "scheme://a/b/", "scheme://a/b/c/d/", true, true, false, "c/d/", 0 },
+ { "scheme://a/b/c", "scheme://a/b//", true, true, false, ".//", 0 },
+ { "scheme://a/b/c", "scheme://a/b//d", true, true, false, ".//d", 0 },
+ { "scheme://a/b/c", "scheme://a/b//d//", true, true, false, ".//d//",
+ 0 },
+ { "scheme://a/b/c", "scheme://a/b/d+:", true, true, false, "./d+:", 0 },
+ { "scheme://a/b/c", "scheme://a/b/+d:", true, true, false, "+d:", 0 },
+ { "scheme://a/b/c", "scheme://a/b/d#e:f", true, true, false, "d#e:f",
+ 0 },
+ { "scheme://a/b/c/", "scheme://a/b/../d/.e/.", true, true, false,
+ "../../d/.e/.",
+ "scheme://a/d/.e/" },
+ { "scheme://a/b/c/", "scheme://a/b/../d/.e/.", true, true, true,
+ "../%2E%2E/d/.e/%2E", "scheme://a/b/%2E%2E/d/.e/%2E" },
+ { "scheme://auth/a/b", "scheme://auth//c/d", true, true, false,
+ "//auth//c/d", 0 },
+ { "scheme://auth/a/b", "scheme://auth//c/d", false, true, false,
+ "..//c/d", 0 },
+ { "scheme://auth/a/b", "scheme://auth/c/d", true, true, false, "/c/d",
+ 0 },
+ { "scheme://auth/a/b", "scheme://auth/c/d", true, false, false,
+ "../c/d", 0 } };
+ for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ css::uno::Reference< css::uri::XUriReference > baseUriRef(
+ m_uriFactory->parse(
+ rtl::OUString::createFromAscii(data[i].baseUriReference)));
+ CPPUNIT_ASSERT(baseUriRef.is());
+ css::uno::Reference< css::uri::XUriReference > uriRef(
+ m_uriFactory->parse(
+ rtl::OUString::createFromAscii(data[i].uriReference)));
+ CPPUNIT_ASSERT(uriRef.is());
+ css::uno::Reference< css::uri::XUriReference > relative(
+ m_uriFactory->makeRelative(
+ baseUriRef, uriRef, data[i].preferAuthorityOverRelativePath,
+ data[i].preferAbsoluteOverRelativePath,
+ data[i].encodeRetainedSpecialSegments));
+ TEST_ASSERT_EQUAL(
+ "testMakeRelative", i, data[i].uriReference,
+ data[i].relative != 0, relative.is());
+ if (relative.is()) {
+ TEST_ASSERT_EQUAL(
+ "testMakeRelative", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].relative),
+ relative->getUriReference());
+ css::uno::Reference< css::uri::XUriReference > absolute(
+ m_uriFactory->makeAbsolute(
+ baseUriRef, relative, true,
+ css::uri::RelativeUriExcessParentSegments_ERROR));
+ CPPUNIT_ASSERT(absolute.is());
+ TEST_ASSERT_EQUAL(
+ "testMakeRelative", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(
+ data[i].absolute == 0
+ ? data[i].uriReference : data[i].absolute),
+ absolute->getUriReference());
+ }
+ }
+}
+
+void Test::testVndSunStarExpand() {
+ struct Data {
+ char const * uriReference;
+ char const * expanded;
+ };
+ Data data[] = {
+ { "vnd.sun.star.expand:", "" }, // liberally accepted
+ { "vnd.sun.star.expand:/", "/" }, // liberally accepted
+ { "vnd.sun.star.expand:%80", 0 },
+ { "vnd.sun.star.expand:%5C$%5C%24%5C%5C", "$$\\" } };
+ css::uno::Reference< css::util::XMacroExpander > expander(
+ m_context->getValueByName(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "/singletons/com.sun.star.util.theMacroExpander"))),
+ css::uno::UNO_QUERY_THROW);
+ for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ css::uno::Reference< css::uri::XUriReference > uriRef(
+ m_uriFactory->parse(
+ rtl::OUString::createFromAscii(data[i].uriReference)));
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarExpand", i, data[i].uriReference,
+ data[i].expanded != 0, uriRef.is());
+ if (uriRef.is()) {
+ css::uno::Reference< css::uri::XVndSunStarExpandUrlReference >
+ expandUrl(uriRef, css::uno::UNO_QUERY_THROW);
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarExpand", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].expanded),
+ expandUrl->expand(expander));
+ }
+ }
+}
+
+void Test::testVndSunStarScript() {
+ struct Parameter {
+ char const * key;
+ char const * value;
+ };
+ std::size_t const parameterCount = 3;
+ struct Data {
+ char const * uriReference;
+ char const * name;
+ const bool normalized;
+ Parameter parameters[parameterCount];
+ };
+ Data data[] = {
+ { "vnd.sun.star.script:", 0, false, {} },
+ { "vnd.sun.star.script:/", 0, false, {} },
+ { "vnd.sun.star.script:/abc/def?ghi=jkl&mno=pqr", 0, false, {} },
+ { "vnd.sun.star.script:abc%3fdef/ghi", "abc?def/ghi", false, {} },
+ { "vnd.sun.star.script:name?a", 0, false, {} },
+ { "vnd.sun.star.script:name?a=", "name", true, { { "a", "" }, { "A", 0 } } },
+ { "vnd.sun.star.script:name?a=&", 0, true, {} },
+ { "vnd.sun.star.script:name?key1=&%26=%3D&key1=hello", "name", true,
+ { { "key1", "" }, { "key2", 0 }, { "&", "=" } } } };
+ for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ css::uno::Reference< css::uri::XUriReference > uriRef(
+ m_uriFactory->parse(
+ rtl::OUString::createFromAscii(data[i].uriReference)));
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript", i, data[i].uriReference, data[i].name != 0,
+ uriRef.is());
+ if (uriRef.is()) {
+ css::uno::Reference< css::uri::XVndSunStarScriptUrlReference >
+ scriptUrl(uriRef, css::uno::UNO_QUERY_THROW);
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].uriReference),
+ scriptUrl->getUriReference());
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript", i, data[i].uriReference,
+ rtl::OUString::createFromAscii(data[i].name),
+ scriptUrl->getName());
+ rtl::OUString originalReference(uriRef->getUriReference());
+ for (std::size_t j = 0; j < parameterCount; ++j) {
+ if (data[i].parameters[j].key != 0) {
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript",
+ static_cast< double >(i)
+ + static_cast< double >(j) / 10.0,
+ data[i].uriReference,
+ data[i].parameters[j].value != 0,
+ scriptUrl->hasParameter(
+ rtl::OUString::createFromAscii(
+ data[i].parameters[j].key)));
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript",
+ static_cast< double >(i)
+ + static_cast< double >(j) / 10.0,
+ data[i].uriReference,
+ rtl::OUString::createFromAscii(
+ data[i].parameters[j].value),
+ scriptUrl->getParameter(
+ rtl::OUString::createFromAscii(
+ data[i].parameters[j].key)));
+
+ // setting the parameter to its original value should not change
+ // the overall uri reference (provided it was normalized before)
+ if ( data[i].normalized ) {
+ if ( scriptUrl->hasParameter(rtl::OUString::createFromAscii(
+ data[i].parameters[j].key)) ) {
+ scriptUrl->setParameter(
+ rtl::OUString::createFromAscii(
+ data[i].parameters[j].key),
+ scriptUrl->getParameter(
+ rtl::OUString::createFromAscii(
+ data[i].parameters[j].key)));
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript",
+ static_cast< double >(i)
+ + static_cast< double >(j) / 10.0,
+ ::rtl::OUString::createFromAscii("setParameter"),
+ originalReference,
+ uriRef->getUriReference());
+ }
+ }
+ }
+ }
+ if ( data[i].normalized ) {
+ scriptUrl->setName(scriptUrl->getName());
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript",
+ i,
+ ::rtl::OUString::createFromAscii("setName"),
+ originalReference,
+ uriRef->getUriReference());
+ }
+ }
+ }
+
+ css::uno::Reference< css::uri::XUriReference > uriRef(
+ m_uriFactory->parse(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "vnd.sun.star.script:Hello?location=Library.Module"))),
+ css::uno::UNO_SET_THROW);
+ css::uno::Reference< css::uri::XVndSunStarScriptUrlReference >
+ scriptUrl(uriRef, css::uno::UNO_QUERY_THROW);
+
+ scriptUrl->setParameter(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "location")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "foo")));
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript", (sal_Int32)10, (sal_Int32)1,
+ uriRef->getUriReference(),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:Hello?location=foo")));
+
+ scriptUrl->setParameter(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "language")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "StarBasic")));
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript", (sal_Int32)10, (sal_Int32)2,
+ uriRef->getUriReference(),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:Hello?location=foo&language=StarBasic")));
+
+
+ bool caughtExpected = false;
+ try {
+ scriptUrl->setName(::rtl::OUString());
+ }
+ catch( const css::lang::IllegalArgumentException& ) {
+ caughtExpected = true;
+ }
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript",
+ ::rtl::OUString::createFromAscii("illegal arguments"),
+ ::rtl::OUString::createFromAscii("name"),
+ caughtExpected,
+ true);
+
+ caughtExpected = false;
+ try {
+ scriptUrl->setParameter(
+ ::rtl::OUString(),
+ ::rtl::OUString::createFromAscii("non-empty"));
+ }
+ catch( const css::lang::IllegalArgumentException& ) {
+ caughtExpected = true;
+ }
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarScript",
+ ::rtl::OUString::createFromAscii("illegal arguments"),
+ ::rtl::OUString::createFromAscii("parameter"),
+ caughtExpected,
+ true);
+}
+
+void Test::testTranslator() {
+ struct Data {
+ char const * externalUriReference;
+ char const * internalUriReference;
+ bool toInternal;
+ };
+ Data data[] = {
+ { "", "", true },
+ { "#fragment", "#fragment", true },
+ { "segment/segment?query#fragment", "segment/segment?query#fragment",
+ true },
+ { "/segment/segment?query#fragment", "/segment/segment?query#fragment",
+ true },
+ { "//authority/segment?query#fragment",
+ "//authority/segment?query#fragment", true },
+ { "foo:bar#fragment", "foo:bar#fragment", true },
+ { "file:///abc/def", "file:///abc/def", true },
+ { "file:///abc/%FEef", "file:///abc/%feef", false },
+ { "file:///abc/%80%80ef", "file:///abc/%80%80ef", false },
+ { "file:///abc/%ED%A0%80%ED%B0%80ef",
+ "file:///abc/%ED%A0%80%ED%B0%80ef", false },
+ { "file:///abc/%25.ef", "file:///abc/%.ef", false },
+ { "file:///abc/%25ef", "file:///abc/%25ef", true } };
+ css::uno::Reference< css::uri::XExternalUriReferenceTranslator >
+ translator(css::uri::ExternalUriReferenceTranslator::create(m_context));
+ for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ if (data[i].toInternal) {
+ TEST_ASSERT_EQUAL(
+ "testTranslator, translateToInternal", i,
+ data[i].externalUriReference,
+ rtl::OUString::createFromAscii(data[i].internalUriReference),
+ translator->translateToInternal(
+ rtl::OUString::createFromAscii(
+ data[i].externalUriReference)));
+ }
+ TEST_ASSERT_EQUAL(
+ "testTranslator, translateToExternal", i,
+ data[i].internalUriReference,
+ rtl::OUString::createFromAscii(data[i].externalUriReference),
+ translator->translateToExternal(
+ rtl::OUString::createFromAscii(data[i].internalUriReference)));
+ }
+}
+
+void Test::testPkgUrlFactory() {
+ struct Data {
+ char const * authority;
+ char const * result;
+ };
+ Data data[] = {
+ { "a/b/c", 0 },
+ { "file:///#foo", 0 },
+ { "file:///a%25b%2fc/d~e&f@g?h",
+ "vnd.sun.star.pkg://file:%2F%2F%2Fa%2525b%252fc%2Fd~e&f@g%3Fh" } };
+ css::uno::Reference< css::uri::XVndSunStarPkgUrlReferenceFactory > factory(
+ css::uri::VndSunStarPkgUrlReferenceFactory::create(m_context));
+ for (std::size_t i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ css::uno::Reference< css::uri::XUriReference > url(
+ factory->createVndSunStarPkgUrlReference(
+ m_uriFactory->parse(
+ rtl::OUString::createFromAscii(data[i].authority))));
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarPkgFactory", i, data[i].authority,
+ data[i].result != 0, static_cast< bool >(url.is()));
+ if (data[i].result != 0) {
+ TEST_ASSERT_EQUAL(
+ "testVndSunStarPkgFactory", i, data[i].authority,
+ rtl::OUString::createFromAscii(data[i].result),
+ url->getUriReference());
+ }
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/stoc/test/uriproc/version.map b/stoc/test/uriproc/version.map
new file mode 100644
index 000000000000..3308588ef6f8
--- /dev/null
+++ b/stoc/test/uriproc/version.map
@@ -0,0 +1,34 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+UDK_3_0_0 {
+ global:
+ cppunitTestPlugIn;
+
+ local:
+ *;
+};