Remove dead test code

Change-Id: Iea40cee7dab736ffd954b0eae2b1dca2d9f5463b
This commit is contained in:
Stephan Bergmann 2016-12-07 22:17:24 +01:00
parent b928372073
commit 0816ec33c8
27 changed files with 0 additions and 4386 deletions

View File

@ -1,118 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <cppu/EnvDcp.hxx>
#include <cppu/helper/purpenv/Environment.hxx>
#include <cppu/helper/purpenv/Mapping.hxx>
#define LOG_LIFECYCLE_TestEnv
#ifdef LOG_LIFECYCLE_TestEnv
# include <iostream>
# define LOG_LIFECYCLE_TestEnv_emit(x) x
#else
# define LOG_LIFECYCLE_TestEnv_emit(x)
#endif
class TestEnv : public cppu::Enterable
{
int m_inCount;
virtual ~TestEnv();
public:
explicit TestEnv();
protected:
virtual void v_enter();
virtual void v_leave();
virtual void v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam);
virtual void v_callOut_v (uno_EnvCallee * pCallee, va_list * pParam);
virtual bool v_isValid (rtl::OUString * pReason);
};
TestEnv::TestEnv()
: m_inCount(0)
{
LOG_LIFECYCLE_TestEnv_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestEnv::TestEnv(...)", this));
}
TestEnv::~TestEnv()
{
LOG_LIFECYCLE_TestEnv_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestEnv::~TestEnv()", this));
}
void TestEnv::v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam)
{
++ m_inCount;
pCallee(pParam);
-- m_inCount;
}
void TestEnv::v_callOut_v(uno_EnvCallee * pCallee, va_list * pParam)
{
-- m_inCount;
pCallee(pParam);
++ m_inCount;
}
void TestEnv::v_enter()
{
++ m_inCount;
}
void TestEnv::v_leave()
{
-- m_inCount;
}
bool TestEnv::v_isValid(rtl::OUString * pReason)
{
bool result = m_inCount & 1;
if (result)
*pReason = rtl::OUString("OK");
else
*pReason = rtl::OUString("not entered/invoked");
return result;
}
extern "C" void SAL_CALL uno_initEnvironment(uno_Environment * pEnv) SAL_THROW_EXTERN_C()
{
cppu::helper::purpenv::Environment_initWithEnterable(pEnv, new TestEnv());
}
extern "C" void uno_ext_getMapping(uno_Mapping ** ppMapping,
uno_Environment * pFrom,
uno_Environment * pTo )
{
cppu::helper::purpenv::createMapping(ppMapping, pFrom, pTo);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,8 +0,0 @@
HEAPSIZE 0
EXPORTS
uno_initEnvironment
uno_ext_getMapping

View File

@ -1,278 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/main.h>
#include <osl/file.hxx>
#include <typelib/typedescription.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <cppuhelper/shlib.hxx>
#include <com/sun/star/lang/XComponent.hpp>
#include <uno/environment.hxx>
#include <uno/lbnames.h>
#include <cppu/EnvDcp.hxx>
#include <cppu/EnvGuards.hxx>
#include <iostream>
#ifndef SAL_DLLPREFIX
# define SAL_DLLPREFIX ""
#endif
using namespace com::sun::star;
static rtl::OUString s_comment;
static bool s_check_object_is_in(void * pObject)
{
uno::Environment currentEnv(uno::Environment::getCurrent());
rtl_uString * pOId = NULL;
currentEnv.get()->pExtEnv->getObjectIdentifier(currentEnv.get()->pExtEnv, &pOId, pObject);
uno::TypeDescription typeDescription(rtl::OUString("com.sun.star.uno.XInterface"));
void * pRegisteredObject = NULL;
currentEnv.get()->pExtEnv->getRegisteredInterface(currentEnv.get()->pExtEnv,
&pRegisteredObject,
pOId,
(typelib_InterfaceTypeDescription *)typeDescription.get());
if (pOId) rtl_uString_release(pOId);
bool result = pRegisteredObject != NULL;
if (result)
currentEnv.get()->pExtEnv->releaseInterface(currentEnv.get()->pExtEnv, pRegisteredObject);
return result;
}
static void s_test__loadSharedLibComponentFactory(rtl::OUString const & clientPurpose,
rtl::OUString const & servicePurpose)
{
cppu::EnvGuard envGuard(uno::Environment(UNO_LB_UNO + clientPurpose, NULL));
if (!clientPurpose.isEmpty() && !envGuard.is())
{
s_comment += "\t\tcouldn't get purpose env: \"" + clientPurpose + "\" - FAILURE\n";
return;
}
rtl::OString os_clientPurpose(rtl::OUStringToOString(clientPurpose, RTL_TEXTENCODING_ASCII_US));
uno::Reference<uno::XInterface> xItf(
cppu::loadSharedLibComponentFactory(
rtl::OUString(SAL_DLLPREFIX "TestComponent.uno" SAL_DLLEXTENSION),
#ifdef _WIN32
"",
#else
"file://../lib/",
#endif
"impl.test.TestComponent" + servicePurpose,
uno::Reference<lang::XMultiServiceFactory>(),
uno::Reference<registry::XRegistryKey>()
)
);
if (!xItf.is())
{
s_comment += rtl::OUString("\t\tgot no object - FAILURE\n");
return;
}
if (!clientPurpose.equals(servicePurpose) && !s_check_object_is_in(xItf.get()))
{
s_comment += "\t\tcouldn't find object in current purpose \"" + clientPurpose + "\" - FAILURE\n";
}
if (!cppu::EnvDcp::getPurpose(uno::Environment::getCurrent().getTypeName()).equals(clientPurpose))
{
s_comment += "\t\tdid not enter client purpose \"" + clientPurpose + "\" - FAILURE\n";
}
}
static void s_test__loadSharedLibComponentFactory__free_free()
{
s_comment += "\ts_test__loadSharedLibComponentFactory__free_free\n";
s_test__loadSharedLibComponentFactory("", "");
}
static void s_test__loadSharedLibComponentFactory__free_purpose()
{
s_comment += "\ts_test__loadSharedLibComponentFactory__free_purpose\n";
s_test__loadSharedLibComponentFactory("", ":testenv");
}
static void s_test__loadSharedLibComponentFactory__purpose_free()
{
s_comment += "\ts_test__loadSharedLibComponentFactory__purpose_free\n";
s_test__loadSharedLibComponentFactory(":testenv", "");
}
static void s_test__loadSharedLibComponentFactory__purpose_purpose()
{
s_comment += "\ts_test__loadSharedLibComponentFactory__purpose_purpose\n";
s_test__loadSharedLibComponentFactory(":testenv", ":testenv");
}
static rtl::OUString s_getSDrive()
{
rtl::OUString path;//("file://");
// FIXME no more S drive
osl::FileBase::getFileURLFromSystemPath(path, path);
return path;
}
static void s_test__createSimpleRegistry(rtl::OUString const & clientPurpose)
{
cppu::EnvGuard envGuard(uno::Environment(rtl::OUString(UNO_LB_UNO)
+ clientPurpose, NULL));
if (!clientPurpose.isEmpty() && !envGuard.is())
{
s_comment += "\t\tcouldn't get purpose env: \"" + clientPurpose + "\" - FAILURE\n";
return;
}
uno::Reference<registry::XSimpleRegistry> registry(cppu::createSimpleRegistry(
s_getSDrive()));
if (!registry.is())
{
s_comment += "\t\tgot no object - FAILURE\n";
return;
}
if (!clientPurpose.isEmpty() && !s_check_object_is_in(registry.get()))
{
s_comment += "\t\tcouldn't find object in current purpose \"" + clientPurpose + "\" - FAILURE\n";
}
}
static void s_test__createSimpleRegistry__free()
{
s_comment += "\ts_test__createSimpleRegistry__free\n";
s_test__createSimpleRegistry(rtl::OUString());
}
static void s_test__createSimpleRegistry__purpose()
{
s_comment += "\ts_test__createSimpleRegistry__purpose\n";
s_test__createSimpleRegistry(":testenv");
}
static void s_test__bootstrap_InitialComponentContext(rtl::OUString const & clientPurpose)
{
cppu::EnvGuard envGuard(uno::Environment(rtl::OUString(UNO_LB_UNO)
+ clientPurpose, NULL));
if (!clientPurpose.isEmpty() && !envGuard.is())
{
s_comment += "\t\tcouldn't get purpose env: \"" + clientPurpose + "\" - FAILURE\n";
return;
}
uno::Reference<uno::XComponentContext> xContext(
cppu::bootstrap_InitialComponentContext(
uno::Reference<registry::XSimpleRegistry>(),
s_getSDrive())
);
if (!xContext.is())
{
s_comment += "\t\tgot no object - FAILURE\n";
return;
}
if (!clientPurpose.isEmpty() && !s_check_object_is_in(xContext.get()))
{
s_comment += "\t\tcouldn't find object in current purpose \"" + clientPurpose + "\" - FAILURE\n";
}
uno::Reference<lang::XComponent> xComponent(xContext, uno::UNO_QUERY_THROW);
xComponent->dispose();
}
static void s_test__bootstrap_InitialComponentContext__free()
{
s_comment += "\ts_test__bootstrap_InitialComponentContext__free\n";
s_test__bootstrap_InitialComponentContext(rtl::OUString());
}
static void s_test__bootstrap_InitialComponentContext__purpose()
{
s_comment += "\ts_test__bootstrap_InitialComponentContext__purpose\n";
s_test__bootstrap_InitialComponentContext(":testenv");
}
SAL_IMPLEMENT_MAIN_WITH_ARGS(/*argc*/, argv)
{
s_test__createSimpleRegistry__free();
s_test__createSimpleRegistry__purpose();
s_test__loadSharedLibComponentFactory__free_free();
s_test__loadSharedLibComponentFactory__free_purpose();
s_test__loadSharedLibComponentFactory__purpose_free();
s_test__loadSharedLibComponentFactory__purpose_purpose();
s_test__bootstrap_InitialComponentContext__free();
s_test__bootstrap_InitialComponentContext__purpose();
int ret;
if (s_comment.indexOf("FAILURE") == -1)
{
s_comment += "TESTS PASSED\n";
ret = 0;
}
else
{
s_comment += "TESTS _NOT_ PASSED\n";
ret = -1;
}
std::cerr
<< argv[0]
<< std::endl
<< rtl::OUStringToOString(s_comment, RTL_TEXTENCODING_ASCII_US).getStr()
<< std::endl;
return ret;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,51 +0,0 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
PRJ := ..$/..
PRJNAME := cppuhelper
TARGET := bootstrap.test
ENABLE_EXCEPTIONS := TRUE
USE_DEFFILE := TRUE
.INCLUDE : settings.mk
.IF "$(OS)"!="WNT"
PURPENVHELPERLIB := -luno_purpenvhelper$(COMID)
.ELSE
PURPENVHELPERLIB := $(LIBPRE) ipurpenvhelper$(UDK_MAJOR)$(COMID).lib
.ENDIF
APP1TARGET := $(TARGET)
APP1OBJS := $(OBJ)$/bootstrap.test.obj
APP1STDLIBS := $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB)
SHL1TARGET := testenv_uno_uno
SHL1IMPLIB := i$(SHL1TARGET)
SHL1OBJS := $(SLO)$/TestEnv.obj
SHL1STDLIBS := $(PURPENVHELPERLIB) $(SALHELPERLIB) $(SALLIB)
SHL1DEF := TestEnv.def
.INCLUDE : target.mk

View File

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<components cfg:package="uno"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:cfg="http://openoffice.org/2000/registry/instance"
xmlns="http://openoffice.org/2000/uno/Components">
<services cfg:type="set" cfg:element-type="service">
<service cfg:name="com.sun.star.script.Converter">
<available-implementations cfg:type="string" cfg:derivedBy="list">
com.sun.star.comp.stoc.TypeConverter
</available-implementations>
</service>
<service cfg:name="com.sun.star.bootstrap.TestComponent0">
<available-implementations cfg:type="string" cfg:derivedBy="list">
com.sun.star.comp.bootstrap.TestComponent0
</available-implementations>
<context-properties cfg:type="set" cfg:element-type="cfg:any">
<cfg:any cfg:name="serviceprop0" cfg:type="int">13</cfg:any>
<cfg:any cfg:name="serviceprop1" cfg:type="string">value of serviceprop1</cfg:any>
</context-properties>
</service>
</services>
<implementations cfg:type="set" cfg:element-type="implementation">
<implementation cfg:name="com.sun.star.comp.stoc.TypeConverter">
<activator cfg:type="string">com.sun.star.loader.SharedLibrary</activator>
<url cfg:type="string">tcv.dll</url>
<supported-services cfg:type="string" cfg:derivedBy="list">com.sun.star.script.Converter</supported-services>
</implementation>
<implementation cfg:name="com.sun.star.comp.bootstrap.TestComponent0">
<activator cfg:type="string">com.sun.star.loader.SharedLibrary</activator>
<url cfg:type="string">cfg_test.dll</url>
<supported-services cfg:type="string" cfg:derivedBy="list">com.sun.star.bootstrap.TestComponent0</supported-services>
<context-properties cfg:type="set" cfg:element-type="cfg:any">
<cfg:any cfg:name="implprop0" cfg:type="int">15</cfg:any>
<cfg:any cfg:name="implprop1" cfg:type="string">value of implprop1</cfg:any>
</context-properties>
</implementation>
</implementations>
<singletons cfg:type="set" cfg:element-type="singleton">
<singleton cfg:name="com.sun.star.script.theConverter">
<used-service cfg:type="string">com.sun.star.script.Converter</used-service>
</singleton>
<singleton cfg:name="com.sun.star.bootstrap.theTestComponent0">
<used-service cfg:type="string">com.sun.star.bootstrap.TestComponent0</used-service>
<initial-arguments cfg:type="set" cfg:element-type="cfg:any">
<cfg:any cfg:name="0" cfg:type="string">first argument</cfg:any>
<cfg:any cfg:name="1" cfg:type="string">second argument</cfg:any>
<cfg:any cfg:name="2" cfg:type="string">third argument</cfg:any>
</initial-arguments>
</singleton>
</singletons>
<global-context-properties cfg:type="set" cfg:element-type="cfg:any">
<cfg:any cfg:name="TestValue" cfg:type="int">5</cfg:any>
</global-context-properties>
</components>

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<components cfg:package="uno"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:cfg="http://openoffice.org/2000/registry/instance">
<service>
<available-implementations cfg:type="string" cfg:derivedBy="list"/>
<context-properties cfg:type="set" cfg:element-type="cfg:any"/>
</service>
<implementation>
<activator cfg:type="string"/>
<url cfg:type="string"/>
<supported-services cfg:type="string" cfg:derivedBy="list"/>
<context-properties cfg:type="set" cfg:element-type="cfg:any"/>
</implementation>
<singleton>
<used-service cfg:type="string"/>
<initial-arguments cfg:type="set" cfg:element-type="cfg:any"/>
</singleton>
</components>

View File

@ -1,275 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// starting the executable:
// -env:UNO_CFG_URL=local;<absolute_path>..\\..\\test\\cfg_data;<absolute_path>\\cfg_update
// -env:UNO_TYPES=cpputest.rdb
#include <sal/main.h>
#include <stdio.h>
#include <rtl/strbuf.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/registry/XImplementationRegistration.hpp>
using namespace ::cppu;
using namespace ::osl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
namespace cfg_test
{
static Sequence< OUString > impl0_getSupportedServiceNames()
{
OUString str("com.sun.star.bootstrap.TestComponent0");
return Sequence< OUString >( &str, 1 );
}
static OUString impl0_getImplementationName()
{
return OUString("com.sun.star.comp.bootstrap.TestComponent0");
}
static Sequence< OUString > impl1_getSupportedServiceNames()
{
OUString str("com.sun.star.bootstrap.TestComponent1");
return Sequence< OUString >( &str, 1 );
}
static OUString impl1_getImplementationName()
{
return OUString("com.sun.star.comp.bootstrap.TestComponent1");
}
class ServiceImpl0
: public WeakImplHelper2< lang::XServiceInfo, lang::XInitialization >
{
Reference< XComponentContext > m_xContext;
public:
explicit ServiceImpl0( Reference< XComponentContext > const & xContext );
// XInitialization
virtual void SAL_CALL initialize( const Sequence< Any >& rArgs ) throw (Exception, RuntimeException);
// XServiceInfo
virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException);
virtual OUString SAL_CALL getImplementationName() throw (RuntimeException);
virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw (RuntimeException);
};
ServiceImpl0::ServiceImpl0( Reference< XComponentContext > const & xContext )
: m_xContext( xContext )
{
sal_Int32 n;
OUString val;
// service properties
OSL_VERIFY( m_xContext->getValueByName(
"/services/com.sun.star.bootstrap.TestComponent0/context-properties/serviceprop0" ) >>= n );
OSL_VERIFY( n == 13 );
OSL_VERIFY( m_xContext->getValueByName(
"/services/com.sun.star.bootstrap.TestComponent0/context-properties/serviceprop1" ) >>= val );
OSL_VERIFY( val == "value of serviceprop1" );
// impl properties
OSL_VERIFY( m_xContext->getValueByName(
"/implementations/com.sun.star.comp.bootstrap.TestComponent0/context-properties/implprop0" ) >>= n );
OSL_VERIFY( n == 15 );
OSL_VERIFY( m_xContext->getValueByName(
"/implementations/com.sun.star.comp.bootstrap.TestComponent0/context-properties/implprop1" ) >>= val );
OSL_VERIFY( val == "value of implprop1" );
}
// XInitialization
void ServiceImpl0::initialize( const Sequence< Any >& rArgs )
throw (Exception, RuntimeException)
{
// check args
OUString val;
OSL_VERIFY( rArgs.getLength() == 3 );
OSL_VERIFY( rArgs[ 0 ] >>= val );
OSL_VERIFY( val == "first argument" );
OSL_VERIFY( rArgs[ 1 ] >>= val );
OSL_VERIFY( val == "second argument" );
OSL_VERIFY( rArgs[ 2 ] >>= val );
OSL_VERIFY( val == "third argument" );
}
// XServiceInfo
OUString ServiceImpl0::getImplementationName()
throw(css::uno::RuntimeException)
{
return impl0_getImplementationName();
}
Sequence< OUString > ServiceImpl0::getSupportedServiceNames()
throw(css::uno::RuntimeException)
{
return impl0_getSupportedServiceNames();
}
sal_Bool ServiceImpl0::supportsService( const OUString & rServiceName )
throw(css::uno::RuntimeException)
{
return cppu::supportsService(this, rServiceName);
}
class ServiceImpl1 : public ServiceImpl0
{
public:
explicit ServiceImpl1( Reference< XComponentContext > const & xContext )
: ServiceImpl0( xContext )
{
}
// XServiceInfo
virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException);
virtual OUString SAL_CALL getImplementationName() throw (RuntimeException);
};
OUString ServiceImpl1::getImplementationName()
throw(css::uno::RuntimeException)
{
return impl1_getImplementationName();
}
Sequence< OUString > ServiceImpl1::getSupportedServiceNames()
throw(css::uno::RuntimeException)
{
return impl1_getSupportedServiceNames();
}
static Reference< XInterface > SAL_CALL ServiceImpl0_create(
Reference< XComponentContext > const & xContext )
{
return (OWeakObject *)new ServiceImpl0( xContext );
}
static Reference< XInterface > SAL_CALL ServiceImpl1_create(
Reference< XComponentContext > const & xContext )
{
return (OWeakObject *)new ServiceImpl1( xContext );
}
} // namespace cfg_test
static const struct ImplementationEntry g_entries[] =
{
{
::cfg_test::ServiceImpl0_create, ::cfg_test::impl0_getImplementationName,
::cfg_test::impl0_getSupportedServiceNames, createSingleComponentFactory,
0, 0
},
{
::cfg_test::ServiceImpl1_create, ::cfg_test::impl1_getImplementationName,
::cfg_test::impl1_getSupportedServiceNames, createSingleComponentFactory,
0, 0
},
{ 0, 0, 0, 0, 0, 0 }
};
// component exports
extern "C"
{
sal_Bool SAL_CALL component_writeInfo(
void * pServiceManager, void * pRegistryKey )
{
return component_writeInfoHelper(
pServiceManager, pRegistryKey, g_entries );
}
SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
{
return component_getFactoryHelper(
pImplName, pServiceManager, pRegistryKey , g_entries );
}
}
SAL_IMPLEMENT_MAIN()
{
try
{
Reference< XComponentContext > xContext( defaultBootstrap_InitialComponentContext() );
Reference< lang::XMultiComponentFactory > xMgr( xContext->getServiceManager() );
// show what is in context
xContext->getValueByName( "dump_maps" );
sal_Int32 n(0);
OSL_VERIFY( xContext->getValueByName( "/global-context-properties/TestValue" ) >>= n );
::fprintf( stderr, "> n=%d\n", n );
Reference< XInterface > x;
OSL_VERIFY( !(xContext->getValueByName( "/singletons/my_converter" ) >>= x) );
OSL_VERIFY( xContext->getValueByName( "/singletons/com.sun.star.script.theConverter" ) >>= x );
OSL_VERIFY( xContext->getValueByName( "/singletons/com.sun.star.bootstrap.theTestComponent0" ) >>= x );
::fprintf( stderr, "> registering service...\n");
#if defined(SAL_W32)
OUString libName( "cfg_test.dll" );
#elif defined(SAL_UNX)
OUString libName( "libcfg_test.so" );
#endif
Reference< registry::XImplementationRegistration > xImplReg( xMgr->createInstanceWithContext(
"com.sun.star.registry.ImplementationRegistration", xContext ), UNO_QUERY );
OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
xImplReg->registerImplementation(
"com.sun.star.loader.SharedLibrary", libName,
Reference< registry::XSimpleRegistry >() );
OSL_VERIFY( (x = xMgr->createInstanceWithContext( "com.sun.star.bootstrap.TestComponent0", xContext )).is() );
OSL_VERIFY( (x = xMgr->createInstanceWithContext( "com.sun.star.bootstrap.TestComponent1", xContext )).is() );
Reference< lang::XComponent > xComp( xContext, UNO_QUERY );
if (xComp.is())
{
xComp->dispose();
}
return 0;
}
catch (Exception & exc)
{
OString str( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
::fprintf( stderr, "# caught exception: %s\n", str.getStr() );
return 1;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,78 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef _TEST_CPPUTEST_IDL_
#define _TEST_CPPUTEST_IDL_
#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/uno/TypeClass.idl>
module test
{
interface A : com::sun::star::uno::XInterface
{
string a();
};
interface BA : A
{
string ba();
};
interface CA : A
{
string ca();
};
interface DBA : BA
{
string dba();
};
interface E : com::sun::star::uno::XInterface
{
string e();
};
interface FE : E
{
string fe();
};
interface G : com::sun::star::uno::XInterface
{
string g();
string a();
};
interface H : com::sun::star::uno::XInterface
{
string h();
};
interface I : com::sun::star::uno::XInterface
{
string i();
};
}; //module test
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,198 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/main.h>
#include <cppuhelper/shlib.hxx>
#include <cppuhelper/implbase1.hxx>
#include <cppu/EnvDcp.hxx>
#include "../testcmp/TestComponent.hxx"
#include <iostream>
#include <cstring>
#ifndef SAL_DLLPREFIX
# define SAL_DLLPREFIX ""
#endif
using namespace ::com::sun::star;
class MyKey : public cppu::WeakImplHelper1<registry::XRegistryKey>
{
public:
virtual rtl::OUString SAL_CALL getKeyName() throw (uno::RuntimeException) { return rtl::OUString(); };
// Methods
virtual sal_Bool SAL_CALL isReadOnly( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return sal_False;};
virtual sal_Bool SAL_CALL isValid( ) throw (uno::RuntimeException) {return sal_False;};
virtual registry::RegistryKeyType SAL_CALL getKeyType( const rtl::OUString& /*rKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return registry::RegistryKeyType_KEY;};
virtual registry::RegistryValueType SAL_CALL getValueType( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return registry::RegistryValueType_NOT_DEFINED;};
virtual sal_Int32 SAL_CALL getLongValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return 0;};
virtual void SAL_CALL setLongValue( sal_Int32 /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {};
virtual uno::Sequence< sal_Int32 > SAL_CALL getLongListValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) { return uno::Sequence<sal_Int32>(); };
virtual void SAL_CALL setLongListValue( const uno::Sequence< sal_Int32 >& /*seqValue*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {};
virtual rtl::OUString SAL_CALL getAsciiValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return rtl::OUString();};
virtual void SAL_CALL setAsciiValue( const rtl::OUString& /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {};
virtual uno::Sequence< rtl::OUString > SAL_CALL getAsciiListValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return uno::Sequence<rtl::OUString>();};
virtual void SAL_CALL setAsciiListValue( const uno::Sequence< rtl::OUString >& /*seqValue*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {};
virtual rtl::OUString SAL_CALL getStringValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return rtl::OUString();};
virtual void SAL_CALL setStringValue( const rtl::OUString& /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {};
virtual uno::Sequence< rtl::OUString > SAL_CALL getStringListValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return uno::Sequence<rtl::OUString>();};
virtual void SAL_CALL setStringListValue( const uno::Sequence< rtl::OUString >& /*seqValue*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {};
virtual uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return uno::Sequence<sal_Int8>();};
virtual void SAL_CALL setBinaryValue( const uno::Sequence< sal_Int8 >& /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {};
virtual uno::Reference< registry::XRegistryKey > SAL_CALL openKey( const rtl::OUString& /*aKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Reference<registry::XRegistryKey>();};
virtual uno::Reference< registry::XRegistryKey > SAL_CALL createKey( const rtl::OUString& /*aKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Reference<registry::XRegistryKey>();};
virtual void SAL_CALL closeKey( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {};
virtual void SAL_CALL deleteKey( const rtl::OUString& /*rKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {};
virtual uno::Sequence< uno::Reference< registry::XRegistryKey > > SAL_CALL openKeys( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Sequence<uno::Reference<registry::XRegistryKey> >();};
virtual uno::Sequence< rtl::OUString > SAL_CALL getKeyNames( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Sequence<rtl::OUString>();};
virtual sal_Bool SAL_CALL createLink( const rtl::OUString& /*aLinkName*/, const rtl::OUString& /*aLinkTarget*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return sal_False;};
virtual void SAL_CALL deleteLink( const rtl::OUString& /*rLinkName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {};
virtual rtl::OUString SAL_CALL getLinkTarget( const rtl::OUString& /*rLinkName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return rtl::OUString();};
virtual rtl::OUString SAL_CALL getResolvedName( const rtl::OUString& /*aKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return rtl::OUString();};
};
static rtl::OUString s_test__cppu_loadSharedLibComponentFactory(char const * pServicePurpose)
{
rtl::OUString result;
rtl::OUString servicePurpose = rtl::OUString(pServicePurpose,
rtl_str_getLength(pServicePurpose),
RTL_TEXTENCODING_ASCII_US);
result += rtl::OUString("\ts_test__cppu_loadSharedLibComponentFactory ");
result += rtl::OUString("(\"");
result += servicePurpose;
result += rtl::OUString("\") - ");
try {
uno::Reference<uno::XInterface> xObject(
cppu::loadSharedLibComponentFactory(
rtl::OUString(SAL_DLLPREFIX "TestComponent.uno" SAL_DLLEXTENSION),
rtl::OUString(),
rtl::OUString("impl.test.TestComponent") + servicePurpose,
uno::Reference<lang::XMultiServiceFactory>(),
uno::Reference<registry::XRegistryKey>())
);
rtl::OUString envDcp_purpose(cppu::EnvDcp::getPurpose(g_envDcp));
if (envDcp_purpose == servicePurpose)
result += rtl::OUString("passed\n");
else
{
result += rtl::OUString("FAILED - got: \"");
result += envDcp_purpose;
result += rtl::OUString("\"\n");
}
}
catch(uno::Exception & exception) {
result += rtl::OUString("FAILED - got: \"");
result += exception.Message;
result += rtl::OUString("\"\n");
}
return result;
}
static rtl::OUString s_test__cppu_writeSharedLibComponentInfo(char const * pServicePurpose)
{
rtl::OUString result;
rtl::OUString servicePurpose = rtl::OUString(pServicePurpose,
rtl_str_getLength(pServicePurpose),
RTL_TEXTENCODING_ASCII_US);
result += rtl::OUString("\ts_test__cppu_writeSharedLibComponentInfo ");
result += rtl::OUString("(\"");
result += servicePurpose;
result += rtl::OUString("\") - ");
char buff[256];
strcpy(buff, "TestComponent.uno=");
strcat(buff, pServicePurpose);
putenv(buff);
try {
cppu::writeSharedLibComponentInfo(
rtl::OUString(SAL_DLLPREFIX "TestComponent.uno" SAL_DLLEXTENSION),
rtl::OUString(),
uno::Reference<lang::XMultiServiceFactory>(),
uno::Reference<registry::XRegistryKey>(new MyKey)
);
rtl::OUString envDcp_purpose(cppu::EnvDcp::getPurpose(g_envDcp));
if (envDcp_purpose == servicePurpose)
result += rtl::OUString("passed\n");
else
{
result += rtl::OUString("FAILED - got: \"");
result += envDcp_purpose;
result += rtl::OUString("\"\n");
}
}
catch(uno::Exception & exception) {
result += rtl::OUString("FAILED - got: \"");
result += exception.Message;
result += rtl::OUString("\"\n");
}
return result;
}
SAL_IMPLEMENT_MAIN_WITH_ARGS(/*argc*/, argv)
{
int result = 0;
rtl::OUString message;
message += rtl::OUString(argv[0], rtl_str_getLength(argv[0]), RTL_TEXTENCODING_ASCII_US);
message += rtl::OUString("\n");
message += s_test__cppu_loadSharedLibComponentFactory(":unsafe");
message += s_test__cppu_loadSharedLibComponentFactory(":affine");
message += s_test__cppu_loadSharedLibComponentFactory("");
message += s_test__cppu_writeSharedLibComponentInfo(":unsafe");
message += s_test__cppu_writeSharedLibComponentInfo(":affine");
message += s_test__cppu_writeSharedLibComponentInfo("");
if (message.indexOf("FAILED") == -1)
message += rtl::OUString("TESTS PASSED\n");
else
{
message += rtl::OUString("TESTS _NOT_ PASSED\n");
result = -1;
}
std::cout << rtl::OUStringToOString(message, RTL_TEXTENCODING_ASCII_US).getStr();
return result;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,42 +0,0 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
PRJ := ..$/..
PRJNAME := cppuhelper
TARGET := loader.test
ENABLE_EXCEPTIONS := TRUE
USE_DEFFILE := TRUE
.INCLUDE : settings.mk
ENVINCPRE := -I$(OUT)$/inc$/$(TARGET)
APP1TARGET := $(TARGET)
APP1OBJS := $(OBJ)$/loader.test.obj
.IF "$(OS)"=="WNT"
APP1STDLIBS := iTestComponent.uno.lib
.ELSE
APP1STDLIBS := -lTestComponent.uno
.ENDIF
APP1STDLIBS += $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB)
.INCLUDE : target.mk

View File

@ -1,159 +0,0 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
PRJ=..
PRJNAME=cppuhelper
TARGET=testhelper
ENABLE_EXCEPTIONS=TRUE
USE_DEFFILE=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
# --- Files --------------------------------------------------------
UNOUCRDEP= $(SOLARBINDIR)$/udkapi.rdb
UNOUCRRDB= $(SOLARBINDIR)$/udkapi.rdb
UNOUCROUT= $(OUT)$/inc$/test
INCPRE+= $(OUT)$/inc$/test
OBJFILES= \
$(OBJ)$/testhelper.obj \
$(OBJ)$/testpropshlp.obj \
$(OBJ)$/testidlclass.obj \
$(OBJ)$/testproptyphlp.obj \
$(OBJ)$/testimplhelper.obj \
$(OBJ)$/testcontainer.obj
APP1TARGET=$(TARGET)
APP1OBJS=$(OBJFILES)
APP1STDLIBS+= \
$(CPPULIB) \
$(CPPUHELPERLIB) \
$(SALLIB)
APP1DEF= $(MISC)$/$(APP1TARGET).def
#############################################
APP2OBJS = $(OBJ)$/testdefaultbootstrapping.obj
APP2STDLIBS += $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB)
APP2TARGET = testdefaultbootstrapping
#############################################
SLOFILES= \
$(SLO)$/cfg_test.obj
LIB1TARGET=$(SLB)$/cfg_test.lib
LIB1OBJFILES=$(SLOFILES)
APP3OBJS = $(OBJ)$/cfg_test.obj
APP3STDLIBS += $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB)
APP3TARGET = test_cfg
#############################################
ALLIDLFILES:= helpertest.idl
# --- Targets ------------------------------------------------------
.IF "$(depend)" == ""
ALL: $(BIN)$/cpputest.rdb \
unoheader \
$(BIN)$/testrc \
$(BIN)$/testdefaultbootstrapping.pl \
ALLTAR \
$(BIN)$/$(APP2TARGET).bin \
$(BIN)$/$(APP2TARGET).Bin \
$(BIN)$/$(APP2TARGET).Exe
.IF "$(OS)"!="WNT"
ALL: $(BIN)$/$(APP2TARGET).exe
$(BIN)$/$(APP2TARGET).exe : $(APP2TARGETN)
cp $(APP2TARGETN) $@
.ENDIF
$(BIN)$/$(APP2TARGET).bin : $(APP2TARGETN)
cp $(APP2TARGETN) $@
$(BIN)$/$(APP2TARGET).Bin : $(APP2TARGETN)
cp $(APP2TARGETN) $@
$(BIN)$/$(APP2TARGET).Exe : $(APP2TARGETN)
cp $(APP2TARGETN) $@
.ELSE
ALL: ALLDEP
.ENDIF
.INCLUDE : target.mk
CPPUMAKERFLAGS =
.IF "$(COM)" == "MSC"
CPPUMAKERFLAGS = -L
.ENDIF
TYPES:=test.A;test.BA;test.CA;test.DBA;test.E;test.FE;test.G;test.H;test.I
HELPERTYPES:=com.sun.star.uno.XReference;com.sun.star.uno.XAdapter;com.sun.star.uno.XAggregation;com.sun.star.uno.XWeak;com.sun.star.lang.XComponent;com.sun.star.lang.XTypeProvider;com.sun.star.lang.XEventListener;com.sun.star.lang.XSingleServiceFactory;com.sun.star.lang.XMultiServiceFactory;com.sun.star.registry.XRegistryKey;com.sun.star.lang.XInitialization;com.sun.star.lang.XServiceInfo;com.sun.star.loader.XImplementationLoader;com.sun.star.lang.IllegalAccessException;com.sun.star.beans.XVetoableChangeListener;com.sun.star.beans.XPropertySet;com.sun.star.uno.XComponentContext
FACTORYTYPES:=com.sun.star.lang.XComponent;com.sun.star.registry.XSimpleRegistry;com.sun.star.lang.XInitialization;com.sun.star.lang.XMultiServiceFactory;com.sun.star.loader.XImplementationLoader;com.sun.star.registry.XImplementationRegistration;com.sun.star.container.XSet;com.sun.star.lang.XSingleServiceFactory;com.sun.star.lang.XSingleComponentFactory;com.sun.star.lang.XMultiComponentFactory
.IF "$(OS)" == "WNT"
UNO_PATH := $(SOLARBINDIR)
UNO_OUT := $(OUT)$/bin
EXT_SO := .dll
.ELSE
UNO_PATH := $(SOLARLIBDIR)
UNO_OUT := $(OUT)$/lib
EXT_SO := .so
.ENDIF
$(UNO_OUT)$/%$(EXT_SO): $(UNO_PATH)$/%$(EXT_SO)
$(COPY) $^ $@
$(BIN)$/cpputest.rdb: $(ALLIDLFILES) $(UNO_OUT)$/invocadapt.uno$(EXT_SO) $(UNO_OUT)$/bootstrap.uno$(EXT_SO)
$(IDLC) -I$(PRJ) -I$(SOLARIDLDIR) -O$(BIN) $(ALLIDLFILES)
$(REGMERGE) $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)}
$(REGMERGE) $@ / $(UNOUCRRDB)
$(REGCOMP) -register -r $@ -c reflection.uno$(DLLPOST)
$(TOUCH) $@
unoheader: $(BIN)$/cpputest.rdb
$(CPPUMAKER) $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TYPES);$(HELPERTYPES)" $(BIN)$/cpputest.rdb
$(CPPUMAKER) $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(FACTORYTYPES)" $(BIN)$/cpputest.rdb
$(BIN)$/testdefaultbootstrapping.pl: testdefaultbootstrapping.pl
cp testdefaultbootstrapping.pl $@
$(BIN)$/testrc: makefile.mk
.IF "$(OS)"=="WNT"
echo [Tests] > $@
echo TestKey1=com.sun.star.uno.NamingService.rdb >> $@
.ELSE
echo '[Tests]' > $@
echo 'TestKey1=file:///'$(PWD)/$(BIN)'/com.sun.star.uno.NamingService.rdb' >> $@
.ENDIF

View File

@ -1,227 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#define CPPUHELPER_TEST_COMPONENT_IMPL
#include "TestComponent.hxx"
#include <string.h>
#include <osl/thread.h>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppu/EnvDcp.hxx>
#include <uno/environment.hxx>
#include <uno/lbnames.h>
using namespace ::com::sun::star;
#define LOG_LIFECYCLE_TestComponent
#ifdef LOG_LIFECYCLE_TestComponent
# include <iostream>
# define LOG_LIFECYCLE_TestComponent_emit(x) x
#else
# define LOG_LIFECYCLE_TestComponent_emit(x)
#endif
class TestComponent: public cppu::WeakImplHelper1<lang::XServiceInfo>
{
rtl::OUString m_implName;
public:
static uno::Reference<uno::XInterface> create(
uno::Reference<uno::XComponentContext> const & xCtx
);
static uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames_Static();
explicit TestComponent(uno::Reference<uno::XComponentContext> const & xCtx);
virtual ~TestComponent();
uno::Any SAL_CALL queryInterface(uno::Type const & rType ) throw (css::uno::RuntimeException);
void SAL_CALL release() throw ();
void SAL_CALL acquire() throw ();
// lang::XServiceInfo
virtual rtl::OUString SAL_CALL getImplementationName() throw (uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
throw (uno::RuntimeException);
virtual uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames()
throw (uno::RuntimeException);
protected:
uno::Reference<uno::XComponentContext> m_xComponentContext;
};
uno::Reference<uno::XInterface> SAL_CALL TestComponent::create(
uno::Reference<uno::XComponentContext> const & xCtx)
{
try
{
return static_cast<cppu::OWeakObject *>(new TestComponent(xCtx));
}
catch (std::bad_alloc &)
{
throw uno::RuntimeException("std::bad_alloc");
}
}
uno::Sequence<rtl::OUString> SAL_CALL TestComponent::getSupportedServiceNames_Static()
{
uno::Sequence<OUString> serviceNames { rtl::OUString("com.sun.star.lang.ServiceInfo") };
return serviceNames;
}
TestComponent::TestComponent(uno::Reference<uno::XComponentContext> const & xCtx)
: m_xComponentContext(xCtx)
{
LOG_LIFECYCLE_TestComponent_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestComponent::TestComponent()", this));
}
TestComponent::~TestComponent()
{
LOG_LIFECYCLE_TestComponent_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestComponent::~TestComponent", this));
}
rtl::OUString SAL_CALL TestComponent::getImplementationName()
throw (uno::RuntimeException)
{
return m_implName;
}
void SAL_CALL TestComponent::acquire() throw ()
{
cppu::WeakImplHelper1<lang::XServiceInfo>::acquire();
}
void SAL_CALL TestComponent::release() throw ()
{
cppu::WeakImplHelper1<lang::XServiceInfo>::release();
}
uno::Any SAL_CALL TestComponent::queryInterface(uno::Type const & rType ) throw (css::uno::RuntimeException)
{
return cppu::WeakImplHelper1<lang::XServiceInfo>::queryInterface(rType);
}
sal_Bool SAL_CALL TestComponent::supportsService(rtl::OUString const & ServiceName)
throw (uno::RuntimeException)
{
return cppu::supportsService(this, ServiceName);
}
uno::Sequence<rtl::OUString> SAL_CALL TestComponent::getSupportedServiceNames()
throw (uno::RuntimeException)
{
return getSupportedServiceNames_Static();
}
extern "C" sal_Bool SAL_CALL component_writeInfo(
void * /*serviceManager*/,
void * /*registryKey*/
)
{
g_envDcp = uno::Environment::getCurrent().getTypeName();
return true;
}
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
char const * pImplName,
void * /*serviceManager*/,
void * /*registryKey*/
)
{
g_envDcp = uno::Environment::getCurrent().getTypeName();
uno::Reference< lang::XSingleComponentFactory > xFactory;
rtl::OUString uTmp(pImplName, rtl_str_getLength(pImplName), RTL_TEXTENCODING_ASCII_US);
rtl::OUString uImplName(cppu::EnvDcp::getTypeName(uTmp));
rtl::OUString cmpName("impl.test.TestComponent");
if (uImplName.equals(cmpName))
{
xFactory = cppu::createSingleComponentFactory(
TestComponent::create,
uImplName,
TestComponent::getSupportedServiceNames_Static());
xFactory->acquire();
}
return xFactory.get();
}
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironmentExt(
sal_Char const ** envTypeName,
uno_Environment ** /*ppEnv*/,
sal_Char const * pImplName,
uno_Environment * /*pSrcEnv*/
)
{
rtl::OString purpose;
if (pImplName) // this is the purpose for a specified impl
{
rtl::OUString uImplName(pImplName, rtl_str_getLength(pImplName), RTL_TEXTENCODING_ASCII_US);
purpose = rtl::OUStringToOString(cppu::EnvDcp::getPurpose(uImplName), RTL_TEXTENCODING_ASCII_US);
}
if (!purpose.getLength())
{
char * pPurpose = getenv("TestComponent.uno");
if (pPurpose)
purpose = rtl::OString(pPurpose);
}
if (purpose.getLength() == 0)
*envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
else
{
char buff[256];
strcpy(buff, CPPU_CURRENT_LANGUAGE_BINDING_NAME);
strcat(buff, purpose.getStr());
*envTypeName = strdup(buff);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CPPUHELPER_TEST_TESTCMP_TESTCOMPONENT_HXX
#define INCLUDED_CPPUHELPER_TEST_TESTCMP_TESTCOMPONENT_HXX
#include <sal/types.h>
#include <rtl/ustring.hxx>
#ifdef CPPUHELPER_TEST_COMPONENT_IMPL
# define CPPUHELPER_TEST_COMPONENT_EXPORT SAL_DLLPUBLIC_EXPORT
#elif defined(CPPUHELPER_TEST_COMPONENT_LIB)
# define CPPUHELPER_TEST_COMPONENT_EXPORT extern
#elif defined(__GNUC__)
# define CPPUHELPER_TEST_COMPONENT_EXPORT extern __attribute__ ((weak))
#else
# define CPPUHELPER_TEST_COMPONENT_EXPORT SAL_DLLPUBLIC_IMPORT
#endif
CPPUHELPER_TEST_COMPONENT_EXPORT rtl::OUString g_envDcp;
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,11 +0,0 @@
HEAPSIZE 0
EXPORTS
component_getImplementationEnvironmentExt;
component_getFactory;
component_writeInfo;
?g_envDcp@@3VOUString@rtl@@A;

View File

@ -1,40 +0,0 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
PRJ := ..$/..
PRJNAME := cppuhelper
TARGET := TestComponent.uno
ENABLE_EXCEPTIONS := TRUE
.INCLUDE: settings.mk
SHL1TARGET := $(TARGET)
SHL1OBJS := $(SLO)$/TestComponent.obj
SHL1STDLIBS := $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB)
SHL1IMPLIB := i$(SHL1TARGET)
.IF "$(OS)"=="WNT"
SHL1DEF := TestComponent.uno.def
.ELSE
DEF1NAME := $(SHL1TARGET)
.ENDIF
.INCLUDE: target.mk

View File

@ -1,145 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <osl/mutex.hxx>
#include <cppuhelper/interfacecontainer.hxx>
#include <cppuhelper/implbase1.hxx>
#include <com/sun/star/beans/XVetoableChangeListener.hpp>
using namespace ::cppu;
using namespace ::osl;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
class TestListener : public WeakImplHelper1< XVetoableChangeListener >
{
public:
// Methods
virtual void SAL_CALL disposing( const css::lang::EventObject& /*Source*/ ) throw(css::uno::RuntimeException)
{
}
virtual void SAL_CALL vetoableChange( const css::beans::PropertyChangeEvent& /*aEvent*/ )
throw(css::beans::PropertyVetoException, css::uno::RuntimeException)
{
}
};
void test_interfacecontainer()
{
Mutex mutex;
{
OInterfaceContainerHelper helper( mutex );
Reference< XVetoableChangeListener > r1 = new TestListener();
Reference< XVetoableChangeListener > r2 = new TestListener();
Reference< XVetoableChangeListener > r3 = new TestListener();
helper.addInterface( r1 );
helper.addInterface( r2 );
helper.addInterface( r3 );
helper.disposeAndClear( EventObject() );
}
{
OInterfaceContainerHelper helper( mutex );
Reference< XVetoableChangeListener > r1 = new TestListener();
Reference< XVetoableChangeListener > r2 = new TestListener();
Reference< XVetoableChangeListener > r3 = new TestListener();
helper.addInterface( r1 );
helper.addInterface( r2 );
helper.addInterface( r3 );
OInterfaceIteratorHelper iterator( helper );
while( iterator.hasMoreElements() )
((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() );
helper.disposeAndClear( EventObject() );
}
{
OInterfaceContainerHelper helper( mutex );
Reference< XVetoableChangeListener > r1 = new TestListener();
Reference< XVetoableChangeListener > r2 = new TestListener();
Reference< XVetoableChangeListener > r3 = new TestListener();
helper.addInterface( r1 );
helper.addInterface( r2 );
helper.addInterface( r3 );
OInterfaceIteratorHelper iterator( helper );
((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() );
iterator.remove();
((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() );
iterator.remove();
((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() );
iterator.remove();
OSL_ASSERT( helper.getLength() == 0 );
helper.disposeAndClear( EventObject() );
}
{
OInterfaceContainerHelper helper( mutex );
Reference< XVetoableChangeListener > r1 = new TestListener();
Reference< XVetoableChangeListener > r2 = new TestListener();
Reference< XVetoableChangeListener > r3 = new TestListener();
helper.addInterface( r1 );
helper.addInterface( r2 );
helper.addInterface( r3 );
{
OInterfaceIteratorHelper iterator( helper );
while( iterator.hasMoreElements() )
{
Reference< XVetoableChangeListener > r = ((XVetoableChangeListener*)iterator.next());
if( r == r1 )
iterator.remove();
}
}
OSL_ASSERT( helper.getLength() == 2 );
{
OInterfaceIteratorHelper iterator( helper );
while( iterator.hasMoreElements() )
{
Reference< XVetoableChangeListener > r = ((XVetoableChangeListener*)iterator.next());
OSL_ASSERT( r != r1 && ( r == r2 || r == r3 ) );
}
}
helper.disposeAndClear( EventObject() );
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/main.h>
#include <cstdio>
#include <rtl/process.h>
#include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
using namespace ::cppu;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
SAL_IMPLEMENT_MAIN()
{
sal_Bool result = sal_True;
try {
Reference<XComponentContext> xComponentContext = defaultBootstrap_InitialComponentContext();
Reference<XMultiServiceFactory> smgr(xComponentContext->getServiceManager(), UNO_QUERY);
for(sal_uInt32 i = 0; i < rtl_getAppCommandArgCount(); ++ i) {
OUString arg;
rtl_getAppCommandArg(i, &arg.pData);
if (!arg.isEmpty())
{
Reference<XInterface> xInterface = smgr->createInstance(arg);
SAL_INFO("cppuhelper", "got the " << arg << " service " << xInterface.get());
result = result && (xInterface.get() != 0);
}
}
}
catch(Exception & exception) {
OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
fprintf(stderr, "an exception occurred: %s\n", message.getStr());
}
SAL_INFO("extensions", "---------------------------------- " << result);
return result;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,268 +0,0 @@
:
eval 'exec perl -wS $0 ${1+"$@"}'
if 0;
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
#
# deliver.pl - copy from module output tree to solver
#
my $progname = "testdefaultbootstrapping";
my $defExeExt;
if ($ENV{OS} eq "WNT") {
%services = (
'com.sun.star.uno.NamingService' => 'namingservice.uno.dll',
'com.sun.star.reflection.CoreReflection' => 'reflection.uno.dll',
'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.dll',
);
$defExeExt = ".exe";
}
else {
%services = (
'com.sun.star.uno.NamingService' => 'namingservice.uno.so',
'com.sun.star.reflection.CoreReflection' => 'reflection.uno.so',
'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.so'
);
$defExeExt = "";
}
sub extendProgName($) {
my $_extension = shift;
my $_result;
if ($ENV{OS} eq "WNT") {
$_result = $progname . $_extension;
}
else {
$_result = $ENV{PWD} . "/" . $progname . $_extension;
}
return $_result;
}
sub rmDefRDB() {
unlink $progname . "_services.rdb";
}
sub unregisterService($){
my $service_name = shift;
my $rdb_name = $service_name . '.rdb';
unlink $rdb_name;
return 1;
}
sub testForServices($$$) {
my $_services = shift;
my $_pars = shift;
my $_testexe = shift;
# my $_rc = system 'echo', $_testexe, @{$_services}, $_pars;
my $_rc = system $_testexe, @{$_services}, $_pars;
return $_rc >> 8;
}
sub registerService($$){
my $service_lib = shift;
my $rdb_name = shift;
# system 'echo', "regcomp -register -r " . $rdb_name . " -c $service_lib";
my $rc = system "regcomp -register -r " . $rdb_name . " -c $service_lib";
return ! ( $rc >> 8 );
}
my $state = 1;
my @allservices;
my $allservices_rdbs="";
my $rc;
my $comment;
my $testexe;
sub registerServices() {
use Cwd;
# ensure that services can not be instantiated
foreach $service ( keys %services ) {
# ensure that the current service is not reachable
unregisterService($service);
$rc = !testForServices([$service], "", $testexe);
if(!$rc) {
$comment = $comment . "\tcouldn't unregister service " . $service . "\n";
$state = 0;
}
# register the service and ensure that it is reachable
$rc = registerService($services{$service}, $service . '.rdb');
if(!$rc) {
$comment = $comment . "\tcouldn't register service " . $service . "\n";
$state = 0;
}
$rc = testForServices([$service], "-env:UNO_SERVICES=" . $service . ".rdb", $testexe);
if(!$rc) {
$comment = $comment . "\tcouldn't reach service " . $service . "\n";
$state = 0;
}
# memorize all services
if (length($allservices_rdbs)) {
$allservices_rdbs = $allservices_rdbs . " ";
}
$allservices_rdbs = $allservices_rdbs . "file://" . getcwd() . "/" . $service . ".rdb";
push @allservices, $service;
}
}
sub testIndirection() {
#test indirection
$rc = testForServices(['com.sun.star.uno.NamingService'], '-env:UNO_SERVICES=${testrc:Tests:TestKey1}', $testexe);
if (!$rc) {
$comment = $comment . "\tindirection test not passed\n";
$state = 0;
}
}
sub testBeneathExe() {
my $service = 'com.sun.star.reflection.CoreReflection';
my $_testexe;
my @_exes = (extendProgName(".exe"),
extendProgName(".Exe"),
extendProgName(".bin"),
extendProgName(".Bin"));
foreach $_testexe ( @_exes ) {
#test rdb found beneath executable
registerService($services{$service}, $progname . "_services.rdb");
my $_rc = testForServices([$service], "", $_testexe);
if (!$_rc) {
$comment = $comment . "\tbeneath executable test not passed: " . $_testexe . "\n";
$state = 0;
}
}
}
sub testBeneathLib_rdb() {
my $_service = 'com.sun.star.uno.NamingService';
use UNO;
my $_rdb_name;
if ($ENV{OS} eq "WNT") {
$_rdb_name = "UNO" . "_services.rdb";
}
else {
$_rdb_name = "../lib/UNO" . "_services.rdb";
}
registerService($services{$_service}, $_rdb_name);
my $_rc = UNO::tryService($_service);
if (!$_rc) {
$comment = $comment . "\tbeneath lib test not passed\n";
$state = 0;
}
unlink $_rdb_name;
}
sub testBeneathLib_rc() {
my $_service = 'com.sun.star.uno.NamingService';
use UNO;
my $_rc_name;
if ($ENV{OS} eq "WNT") {
$_rc_name = "UNO.ini";
}
else {
$_rc_name = "../lib/UNOrc";
}
my $_rdb_name = "../lib/test.rdb";
my $_handle;
open $_handle, ">" . $_rc_name;
print $_handle "UNO_SERVICES=" . $_rdb_name . "\n";
close $_handle;
registerService($services{$_service}, $_rdb_name);
my $_rc = UNO::tryService($_service);
if (!$_rc) {
$comment = $comment . "\tbeneath lib rc test not passed\n";
$state = 0;
}
unlink $_rdb_name;
unlink $_rc_name;
}
sub testAllAvailable() {
# test that all services are reachable through different rdbs
# change the directory to ensure, that all paths become expanded
chdir "..";
$rc = testForServices(\@allservices, "-env:UNO_SERVICES=" . $allservices_rdbs, $testexe);
if (!$rc) {
$comment = $comment . "\tmulti rdb test not passed\n";
$state = 0;
}
}
$testexe = extendProgName($defExeExt);
rmDefRDB();
registerServices();
#print "alls:", @allservices, $allservices_rdbs, "\n";
testIndirection();
testBeneathExe();
testBeneathLib_rc();
testBeneathLib_rdb();
testAllAvailable();
print "**************************\n";
if($state) {
print "****** tests passed ******\n";
}
else {
print "**** tests NOT passed ****\n";
print "Commnent:\n", $comment, "\n";
}
print "**************************\n";

View File

@ -1,99 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0
# undef OSL_DEBUG_LEVEL
# define OSL_DEBUG_LEVEL 2
#endif
#include <sal/main.h>
#include <stdio.h>
#include <rtl/ustrbuf.hxx>
#include <osl/diagnose.h>
#include <cppuhelper/component_context.hxx>
#include <cppuhelper/servicefactory.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/registry/XSimpleRegistry.hpp>
#include <com/sun/star/registry/XImplementationRegistration.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include "testhelper.hxx"
using namespace cppu;
using namespace com::sun::star::uno;
using namespace com::sun::star;
using namespace com::sun::star::lang;
using namespace com::sun::star::registry;
using ::rtl::OUString;
using ::rtl::OString;
using ::rtl::OUStringToOString;
SAL_IMPLEMENT_MAIN()
{
try
{
Reference< XMultiComponentFactory > xMgr( createRegistryServiceFactory(
OUString("cpputest.rdb") ), UNO_QUERY );
Reference< XComponentContext > xInitialContext;
OSL_VERIFY( Reference< beans::XPropertySet >( xMgr, UNO_QUERY )->getPropertyValue(
OUString("DefaultContext") ) >>= xInitialContext );
ContextEntry_Init aEntry;
aEntry.bLateInitService = false;
aEntry.name = "bla, bla";
aEntry.value = makeAny( (sal_Int32)5 );
Reference< XComponentContext > xContext( createComponentContext( &aEntry, 1, xInitialContext ) );
OSL_ASSERT( xContext->getServiceManager() != xMgr ); // must be wrapped one
OSL_ASSERT(
Reference< beans::XPropertySet >(
xContext->getServiceManager(), UNO_QUERY )->getPropertyValue(
OUString("DefaultContext") ) != xInitialContext );
Reference< XMultiServiceFactory > x( xMgr, UNO_QUERY );
test_ImplHelper( x );
testPropertyTypeHelper();
testidlclass( x );
test_PropertySetHelper();
test_interfacecontainer();
OSL_VERIFY( xContext->getValueByName(
OUString("bla, bla") ) == (sal_Int32)5 );
OSL_VERIFY( ! xInitialContext->getValueByName(
OUString("bla, bla") ).hasValue() );
Reference< XComponent >( xInitialContext, UNO_QUERY )->dispose();
xMgr.clear();
xContext.clear();
xInitialContext.clear();
}
catch (Exception & exc)
{
OString cstr_msg( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
OSL_ENSURE( ! "exception occurred: ", cstr_msg.getStr() );
}
printf( "Test finished\n" );
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,31 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CPPUHELPER_TEST_TESTHELPER_HXX
#define INCLUDED_CPPUHELPER_TEST_TESTHELPER_HXX
void testidlclass( const css::uno::Reference < css::lang::XMultiServiceFactory > &r);
void testPropertyTypeHelper();
void test_PropertySetHelper();
void test_ImplHelper( const css::uno::Reference < css::lang::XMultiServiceFactory > & xSF );
void test_interfacecontainer();
#endif // INCLUDED_CPPUHELPER_TEST_TESTHELPER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,569 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0
# undef OSL_DEBUG_LEVEL
# define OSL_DEBUG_LEVEL 2
#endif
#include <stdio.h>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/implbase5.hxx>
#include <cppuhelper/implbase6.hxx>
#include <cppuhelper/implbase7.hxx>
#include <cppuhelper/implbase8.hxx>
#include <cppuhelper/implbase9.hxx>
#include <cppuhelper/implbase10.hxx>
#include <cppuhelper/implbase11.hxx>
#include <cppuhelper/implbase12.hxx>
#include <cppuhelper/compbase1.hxx>
#include <cppuhelper/compbase2.hxx>
#include <cppuhelper/compbase3.hxx>
#include <cppuhelper/compbase4.hxx>
#include <cppuhelper/compbase5.hxx>
#include <cppuhelper/compbase6.hxx>
#include <cppuhelper/compbase7.hxx>
#include <cppuhelper/compbase8.hxx>
#include <cppuhelper/compbase9.hxx>
#include <cppuhelper/compbase10.hxx>
#include <cppuhelper/compbase11.hxx>
#include <cppuhelper/compbase12.hxx>
#include <osl/diagnose.h>
#include <cppuhelper/servicefactory.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <test/A.hpp>
#include <test/BA.hpp>
#include <test/CA.hpp>
#include <test/DBA.hpp>
#include <test/E.hpp>
#include <test/FE.hpp>
#include <test/G.hpp>
#include <test/H.hpp>
#include <test/I.hpp>
#include <com/sun/star/lang/IllegalAccessException.hpp>
using namespace test;
using namespace osl;
using namespace cppu;
using namespace com::sun::star;
using namespace com::sun::star::uno;
using ::rtl::OUString;
using ::rtl::OUStringToOString;
using ::rtl::OString;
struct TestImpl : public ImplHelper4< CA, DBA, FE, G >
{
sal_Int32 nRef;
virtual ~TestImpl()
{ OSL_TRACE( "> TestImpl dtor called... <\n" ); }
virtual Any SAL_CALL queryInterface( const Type & rType ) throw(RuntimeException)
{ return ImplHelper4< CA, DBA, FE, G >::queryInterface( rType ); }
virtual void SAL_CALL acquire( ) throw()
{ ++nRef; }
virtual void SAL_CALL release( ) throw()
{ if (! --nRef) delete this; }
// A
virtual OUString SAL_CALL a() throw(RuntimeException)
{ return OUString("a"); }
// BA
virtual OUString SAL_CALL ba() throw(RuntimeException)
{ return OUString("ba"); }
// CA
virtual OUString SAL_CALL ca() throw(RuntimeException)
{ return OUString("ca"); }
// DBA
virtual OUString SAL_CALL dba() throw(RuntimeException)
{ return OUString("dba"); }
// E
virtual OUString SAL_CALL e() throw(RuntimeException)
{ return OUString("e"); }
// FE
virtual OUString SAL_CALL fe() throw(RuntimeException)
{ return OUString("fe"); }
// G
virtual OUString SAL_CALL g() throw(RuntimeException)
{ return OUString("g"); }
};
struct TestWeakAggImpl : public WeakAggImplHelper4< CA, DBA, FE, G >
{
virtual ~TestWeakAggImpl()
{ OSL_TRACE( "> TestWeakAggImpl dtor called... <\n" ); }
// A
virtual OUString SAL_CALL a() throw(RuntimeException)
{ return OUString("a"); }
// BA
virtual OUString SAL_CALL ba() throw(RuntimeException)
{ return OUString("ba"); }
// CA
virtual OUString SAL_CALL ca() throw(RuntimeException)
{ return OUString("ca"); }
// DBA
virtual OUString SAL_CALL dba() throw(RuntimeException)
{ return OUString("dba"); }
// E
virtual OUString SAL_CALL e() throw(RuntimeException)
{ return OUString("e"); }
// FE
virtual OUString SAL_CALL fe() throw(RuntimeException)
{ return OUString("fe"); }
// G
virtual OUString SAL_CALL g() throw(RuntimeException)
{ return OUString("g"); }
};
struct TestWeakImpl : public WeakImplHelper4< CA, DBA, FE, G >
{
TestWeakImpl() {}
virtual ~TestWeakImpl()
{ OSL_TRACE( "> TestWeakImpl dtor called... <\n" ); }
// A
virtual OUString SAL_CALL a() throw(RuntimeException)
{ return OUString("a"); }
// BA
virtual OUString SAL_CALL ba() throw(RuntimeException)
{ return OUString("ba"); }
// CA
virtual OUString SAL_CALL ca() throw(RuntimeException)
{ return OUString("ca"); }
// DBA
virtual OUString SAL_CALL dba() throw(RuntimeException)
{ return OUString("dba"); }
// E
virtual OUString SAL_CALL e() throw(RuntimeException)
{ return OUString("e"); }
// FE
virtual OUString SAL_CALL fe() throw(RuntimeException)
{ return OUString("fe"); }
// G
virtual OUString SAL_CALL g() throw(RuntimeException)
{ return OUString("g"); }
protected:
explicit TestWeakImpl(int) {}
TestWeakImpl(int, int) {}
TestWeakImpl(int, int, int) {}
TestWeakImpl(int, int, int, int) {}
TestWeakImpl(int, int, int, int, int) {}
TestWeakImpl(int, int, int, int, int, int, int = 0) {}
};
struct TestWeakComponentImpl : public WeakComponentImplHelper4< CA, DBA, FE, G >
{
Mutex m;
TestWeakComponentImpl()
: WeakComponentImplHelper4< CA, DBA, FE, G >( m )
{}
virtual ~TestWeakComponentImpl()
{ OSL_TRACE( "> TestWeakComponentImpl dtor called... <\n" ); }
void SAL_CALL disposing()
{ OSL_TRACE( "> TestWeakComponentImpl disposing called... <\n" ); }
// A
virtual OUString SAL_CALL a() throw(RuntimeException)
{ return OUString("a"); }
// BA
virtual OUString SAL_CALL ba() throw(RuntimeException)
{ return OUString("ba"); }
// CA
virtual OUString SAL_CALL ca() throw(RuntimeException)
{ return OUString("ca"); }
// DBA
virtual OUString SAL_CALL dba() throw(RuntimeException)
{ return OUString("dba"); }
// E
virtual OUString SAL_CALL e() throw(RuntimeException)
{ return OUString("e"); }
// FE
virtual OUString SAL_CALL fe() throw(RuntimeException)
{ return OUString("fe"); }
// G
virtual OUString SAL_CALL g() throw(RuntimeException)
{ return OUString("g"); }
};
struct TestWeakAggComponentImpl : public WeakAggComponentImplHelper4< CA, DBA, FE, G >
{
Mutex m;
TestWeakAggComponentImpl()
: WeakAggComponentImplHelper4< CA, DBA, FE, G >( m )
{}
virtual ~TestWeakAggComponentImpl()
{ OSL_TRACE( "> TestWeakAggComponentImpl dtor called... <\n" ); }
void SAL_CALL disposing()
{ OSL_TRACE( "> TestWeakAggComponentImpl disposing called... <\n" ); }
// A
virtual OUString SAL_CALL a() throw(RuntimeException)
{ return OUString("a"); }
// BA
virtual OUString SAL_CALL ba() throw(RuntimeException)
{ return OUString("ba"); }
// CA
virtual OUString SAL_CALL ca() throw(RuntimeException)
{ return OUString("ca"); }
// DBA
virtual OUString SAL_CALL dba() throw(RuntimeException)
{ return OUString("dba"); }
// E
virtual OUString SAL_CALL e() throw(RuntimeException)
{ return OUString("e"); }
// FE
virtual OUString SAL_CALL fe() throw(RuntimeException)
{ return OUString("fe"); }
// G
virtual OUString SAL_CALL g() throw(RuntimeException)
{ return OUString("g"); }
};
struct TestImplInh : public ImplInheritanceHelper2< TestWeakImpl, H, I >
{
TestImplInh() {}
explicit TestImplInh(int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1) {}
TestImplInh(int, int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2) {}
TestImplInh(int, int, int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3) {}
TestImplInh(int, int, int, int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4) {}
TestImplInh(int, int, int, int, int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5) {}
TestImplInh(int, int, int, int, int, int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5, 6) {}
virtual ~TestImplInh()
{ OSL_TRACE( "> TestWeakImplInh dtor called... <\n" ); }
// H
virtual OUString SAL_CALL h() throw(RuntimeException)
{ return OUString("h"); }
// I
virtual OUString SAL_CALL i() throw(RuntimeException)
{ return OUString("i"); }
};
struct TestAggImplInh : public AggImplInheritanceHelper2< TestWeakAggImpl, H, I >
{
virtual ~TestAggImplInh()
{ OSL_TRACE( "> TestAggImplInh dtor called... <\n" ); }
// H
virtual OUString SAL_CALL h() throw(RuntimeException)
{ return OUString("h2"); }
// I
virtual OUString SAL_CALL i() throw(RuntimeException)
{ return OUString("i2"); }
};
static bool isIn( Sequence< Type > const & rTypes, char const * name )
{
OUString str( OUString::createFromAscii( name ) );
Type const * pTypes = rTypes.getConstArray();
for ( sal_Int32 nPos = rTypes.getLength(); nPos--; )
{
if (pTypes[ nPos ].getTypeName().equals( str ))
return true;
}
return false;
}
static void dotest( const Reference< XInterface > & xOriginal )
{
Reference< lang::XTypeProvider > xTP( xOriginal, UNO_QUERY );
Sequence< sal_Int8 > id( xTP->getImplementationId() );
Sequence< Type > types( xTP->getTypes() );
::fprintf( stderr, "> supported types: " );
long n = 0;
for ( ; n < types.getLength(); ++n )
{
OString str( OUStringToOString( types[ n ].getTypeName(), RTL_TEXTENCODING_ASCII_US ) );
::fprintf( stderr, (n < (types.getLength()-1)) ? "%s, " : "%s; type-id=\n", str.getStr() );
}
for ( n = 0; n < 16; ++n )
{
::fprintf( stderr, n < 15 ? "%x " : "%x \n", id[ n ] );
}
Reference< A > xa( xOriginal, UNO_QUERY );
OSL_ENSURE( xa->a() == "a", "### A failed!" );
Reference< BA > xba( xa, UNO_QUERY );
OSL_ENSURE( xba->ba() == "ba", "### BA failed!" );
OSL_ENSURE( xba->a() == "a", "### BA failed!" );
Reference< CA > xca( xba, UNO_QUERY );
OSL_ENSURE( xca->ca() == "ca", "### CA failed!" );
OSL_ENSURE( xca->a() == "a", "### CA failed!" );
Reference< DBA > xdba( xca, UNO_QUERY );
OSL_ENSURE( xdba->dba() == "dba", "### DBA failed!" );
OSL_ENSURE( xdba->ba() == "ba", "### DBA failed!" );
OSL_ENSURE( xdba->a() == "a", "### DBA failed!" );
Reference< E > xe( xdba, UNO_QUERY );
OSL_ENSURE( xe->e() == "e", "### E failed!" );
Reference< FE > xfe( xe, UNO_QUERY );
OSL_ENSURE( xfe->fe() == "fe", "### FE failed!" );
Reference< G > xg( xfe, UNO_QUERY );
OSL_ENSURE( xg->g() == "g", "### G failed!" );
OSL_ENSURE( xg->a() == "a", "### G failed!" );
// type provider
Reference< lang::XTypeProvider > xProv( xg, UNO_QUERY );
Sequence< Type > aTypes( xProv->getTypes() );
// CA, DBA, FE, G, XTypeProvider
OSL_ASSERT( isIn( aTypes, "test.CA" ) );
OSL_ASSERT( isIn( aTypes, "test.DBA" ) );
OSL_ASSERT( isIn( aTypes, "test.FE") );
OSL_ASSERT( isIn( aTypes, "test.G") );
OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XTypeProvider") );
Reference< XWeak > xWeak( xg, UNO_QUERY );
if (xWeak.is())
{
OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XWeak") );
}
Reference< lang::XComponent > xComp( xg, UNO_QUERY );
if (xComp.is())
{
OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XComponent") );
}
Reference< XAggregation > xAgg( xg, UNO_QUERY );
if (xAgg.is())
{
OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XAggregation") );
}
Reference< H > xH( xg, UNO_QUERY );
if (xH.is())
{
OSL_ASSERT( isIn( aTypes, "test.H") );
}
Reference< I > xI( xg, UNO_QUERY );
if (xI.is())
{
OSL_ASSERT( isIn( aTypes, "test.I") );
}
OSL_ENSURE( xg == xOriginal, "### root!" );
}
void rethrow()
{
throw;
}
void throw_one(
lang::IllegalAccessException exc )
{
try
{
throw exc;
}
catch (...)
{
rethrow();
}
}
void test_ImplHelper( const Reference< lang::XMultiServiceFactory > & /*xSF*/ )
{
Reference< XInterface > xImpl( (lang::XTypeProvider *)new TestImpl() );
Reference< lang::XTypeProvider > xTP1( xImpl, UNO_QUERY );
Reference< XInterface > xWeakImpl( (OWeakObject *)new TestWeakImpl() );
Reference< lang::XTypeProvider > xTP2( xWeakImpl, UNO_QUERY );
Reference< XInterface > xWeakAggImpl( (OWeakObject *)new TestWeakAggImpl() );
Reference< lang::XTypeProvider > xTP3( xWeakAggImpl, UNO_QUERY );
Reference< XInterface > xWeakComponentImpl( (OWeakObject *)new TestWeakComponentImpl() );
Reference< lang::XTypeProvider > xTP4( xWeakComponentImpl, UNO_QUERY );
Reference< XInterface > xWeakAggComponentImpl( (OWeakObject *)new TestWeakAggComponentImpl() );
Reference< lang::XTypeProvider > xTP5( xWeakAggComponentImpl, UNO_QUERY );
OSL_ASSERT(
xTP1->getImplementationId() != xTP2->getImplementationId() &&
xTP1->getImplementationId() != xTP3->getImplementationId() &&
xTP1->getImplementationId() != xTP4->getImplementationId() &&
xTP1->getImplementationId() != xTP5->getImplementationId() &&
xTP2->getImplementationId() != xTP3->getImplementationId() &&
xTP2->getImplementationId() != xTP4->getImplementationId() &&
xTP2->getImplementationId() != xTP5->getImplementationId() &&
xTP3->getImplementationId() != xTP4->getImplementationId() &&
xTP3->getImplementationId() != xTP5->getImplementationId() &&
xTP4->getImplementationId() != xTP5->getImplementationId() );
dotest( xImpl );
dotest( xWeakImpl );
dotest( xWeakAggImpl );
dotest( xWeakComponentImpl );
dotest( xWeakAggComponentImpl );
xWeakImpl = (OWeakObject *)new TestImplInh();
Reference< lang::XTypeProvider > xTP6( xWeakImpl, UNO_QUERY );
dotest( xWeakImpl );
Reference< H > xH( xWeakImpl, UNO_QUERY );
Reference< I > xI( xH, UNO_QUERY );
OSL_ASSERT( xH->h() == "h" );
OSL_ASSERT( xI->i() == "i" );
xWeakAggImpl = (OWeakObject *)new TestAggImplInh();
Reference< lang::XTypeProvider > xTP7( xWeakAggImpl, UNO_QUERY );
dotest( xWeakAggImpl );
xH.set( xWeakAggImpl, UNO_QUERY );
xI.set( xH, UNO_QUERY );
OSL_ASSERT( xH->h() == "h2" );
OSL_ASSERT( xI->i() == "i2" );
OSL_ASSERT(
xTP6->getImplementationId() != xTP1->getImplementationId() &&
xTP6->getImplementationId() != xTP2->getImplementationId() &&
xTP6->getImplementationId() != xTP3->getImplementationId() &&
xTP6->getImplementationId() != xTP4->getImplementationId() &&
xTP6->getImplementationId() != xTP5->getImplementationId() &&
xTP6->getImplementationId() != xTP7->getImplementationId() &&
xTP7->getImplementationId() != xTP1->getImplementationId() &&
xTP7->getImplementationId() != xTP2->getImplementationId() &&
xTP7->getImplementationId() != xTP3->getImplementationId() &&
xTP7->getImplementationId() != xTP4->getImplementationId() &&
xTP7->getImplementationId() != xTP5->getImplementationId() );
bool exc_succ = false;
lang::IllegalAccessException exc(
OUString("testtest"),
xWeakAggImpl );
// exception helper tests
try
{
throw exc;
}
catch (Exception &)
{
Any a( getCaughtException() );
OSL_ASSERT( a == exc );
try
{
throwException( a );
}
catch (lang::IllegalAccessException & e)
{
OSL_ASSERT( exc.Message == e.Message && exc.Context == e.Context );
try
{
throw_one( exc );
}
catch (Exception &)
{
Any a2( getCaughtException() );
OSL_ASSERT( (a2 == a) && (a2 == exc) );
try
{
throw_one( exc );
}
catch (lang::IllegalAccessException &)
{
Any a3( getCaughtException() );
OSL_ASSERT( (a3 == a) && (a3 == a2) && (a3 == exc) );
exc_succ = true;
}
}
}
}
OSL_ASSERT( exc_succ );
try
{
throwException( makeAny( RuntimeException(
OUString("runtime exc"), xImpl ) ) );
}
catch (RuntimeException & rExc)
{
OSL_ENSURE( rExc.Message == "runtime exc" && rExc.Context == xImpl, "### unexpected exception content!" );
try
{
throwException( makeAny( Exception(
OUString("exc"), rExc.Context ) ) );
}
catch (lang::IllegalAccessException &)
{
OSL_FAIL( "### unexpected IllegalAccessException exception caught!" );
}
catch (Exception & rExc2)
{
OSL_ENSURE( rExc2.Message == "exc" && rExc2.Context == xImpl, "### unexpected exception content!" );
try
{
throwException( makeAny( lang::IllegalAccessException(
OUString("axxess exc"), rExc2.Context ) ) );
}
catch (lang::IllegalAccessException & rExc3)
{
OSL_ENSURE( rExc3.Message == "axxess exc" && rExc3.Context == xImpl, "### unexpected exception content!" );
return;
}
}
}
catch (...)
{
}
OSL_FAIL( "### exception test failed!" );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,85 +0,0 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
package UNO;
require 5.005_62;
use strict;
use warnings;
require Exporter;
require DynaLoader;
our @ISA = qw(Exporter DynaLoader);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
# This allows declaration use UNO ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw(
) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
);
our $VERSION = '0.01';
bootstrap UNO $VERSION;
# Preloaded methods go here.
1;
__END__
# Below is stub documentation for your module. You better edit it!
=head1 NAME
UNO - Perl extension for blah blah blah
=head1 SYNOPSIS
use UNO;
blah blah blah
=head1 DESCRIPTION
Stub documentation for UNO, created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.
Blah blah blah.
=head2 EXPORT
None by default.
=head1 AUTHOR
A. U. Thor, a.u.thor@a.galaxy.far.far.away
=head1 SEE ALSO
perl(1).
=cut

View File

@ -1,26 +0,0 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
UDK_3_0_0 {
global:
boot_UNO;
local:
*;
};

View File

@ -1,101 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <cstdio>
#include <osl/module.hxx>
#include <rtl/process.h>
#include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
using namespace ::cppu;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
static sal_Bool tryService(const char * serviceName)
{
// use micro deployment to create initial context
OUString libraryFileUrl;
::osl::Module::getUrlFromAddress((void *)tryService, libraryFileUrl);
OUString iniName = libraryFileUrl.copy(0, libraryFileUrl.lastIndexOf((sal_Unicode)'.')); // cut the library extension
iniName += SAL_CONFIGFILE(""); // add the rc file extension
SAL_INFO("cppuhelper", "using ini: " << iniName);
sal_Bool result = sal_True;
try {
Reference<XComponentContext> xComponentContext = defaultBootstrap_InitialComponentContext(iniName);
Reference<XMultiServiceFactory> smgr(xComponentContext->getServiceManager(), UNO_QUERY);
OUString arg = OUString::createFromAscii(serviceName);
Reference<XInterface> xInterface = smgr->createInstance(arg);
SAL_INFO("cppuhelper", "got the " << serviceName << " service " << xInterface.get());
result = result && (xInterface.get() != 0);
}
catch(Exception & exception) {
OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
fprintf(stderr, "an exception occurred: %s\n", message.getStr());
}
SAL_INFO("cppuhelper", "---------------------------------- " << result);
return result;
}
XS(XS_UNO_tryService)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: UNO::tryService(input)");
{
const char * input = (const char *)SvPV(ST(0),PL_na);
int RETVAL;
dXSTARG;
RETVAL = tryService(input);
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
extern "C" {
XS(boot_UNO)
{
dXSARGS;
char* file = __FILE__;
/* XS_VERSION_BOOTCHECK ;*/
newXS("UNO::tryService", XS_UNO_tryService, file);
XSRETURN_YES;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,92 +0,0 @@
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
LINKFLAGSDEFS=""
PRJ=..$/..
PRJNAME=cppuhelper
TARGET=defbootstrap
ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
PERLINST1:=$(shell @+$(PERL) -V:installarchlib)
PERLINST2:=$(subst,installarchlib=, $(PERLINST1))
PERLINST3:=$(PERLINST2:s/'//)
PERLINST :=$(PERLINST3:s/;//)
PERLLIBS:=$(PERLINST)$/CORE
PERLINCS:=$(PERLINST)$/CORE
CFLAGS += -I$(PERLINCS)
.IF "$(OS)"=="WNT"
PERLLIB=perl58.lib
LIB!:=$(LIB);$(PERLLIBS)
.EXPORT : LIB
.ENDIF
# --- Files --------------------------------------------------------
SLOFILES= $(SLO)$/defbootstrap_lib.obj
SHL1TARGET=$(TARGET)
SHL1STDLIBS= \
$(PERLLIB) \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(SALLIB)
SHL1DEPN=
SHL1IMPLIB=i$(TARGET)
SHL1LIBS=$(SLB)$/$(TARGET).lib
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
DEF1NAME=$(SHL1TARGET)
SHL1VERSIONMAP=defbootstrap.map
.IF "$(OS)"=="WNT"
UNODLL=$(DLLDEST)$/UNO.dll
.ELSE
UNODLL=$(DLLDEST)$/UNO.so
.ENDIF
# --- Targets ------------------------------------------------------
.IF "$(depend)" == ""
ALL: \
ALLTAR \
$(UNODLL) \
$(BIN)$/UNO.pm
.ENDIF
$(BIN)$/UNO.pm: UNO.pm
cp UNO.pm $@
$(UNODLL): $(SHL1TARGETN)
cp $(SHL1TARGETN) $@
.INCLUDE : target.mk

File diff suppressed because it is too large Load Diff

View File

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <cppuhelper/proptypehlp.hxx>
#include <com/sun/star/beans/Property.hpp>
using namespace ::com::sun::star::uno;
using namespace ::cppu;
void testPropertyTypeHelper()
{
Any a;
a <<= ( sal_Int8 ) 25;
sal_Int32 i;
convertPropertyValue( i , a );
OSL_ASSERT( 25 == i );
sal_Int16 i16;
convertPropertyValue( i16 , a );
OSL_ASSERT( 25 == i16 );
sal_Int8 i8;
convertPropertyValue( i8 , a );
OSL_ASSERT( 25 == i8 );
sal_uInt32 i32;
convertPropertyValue( i32 , a );
OSL_ASSERT( 25 == i32 );
double d;
convertPropertyValue( d , a );
OSL_ASSERT( 25. == d );
float f;
convertPropertyValue( f , a );
OSL_ASSERT( 25. == f );
css::beans::Property prop;
prop.Name = rtl::OUString("Huhu");
prop.Handle = 5;
prop.Attributes = 3;
a <<= prop;
css::beans::Property prop2;
convertPropertyValue( prop2 , a );
OSL_ASSERT( prop.Handle == prop2.Handle && prop.Name == prop2.Name && prop.Attributes == prop2.Attributes );
::rtl::OUString ow;
a <<= prop.Name;
convertPropertyValue( ow , a );
OSL_ASSERT( ow == prop.Name );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */