From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../test/ole/AxTestComponents/AxTestComponents.cpp | 77 + .../test/ole/AxTestComponents/AxTestComponents.def | 9 + .../test/ole/AxTestComponents/AxTestComponents.dsp | 325 ++++ .../test/ole/AxTestComponents/AxTestComponents.idl | 251 +++ .../test/ole/AxTestComponents/AxTestComponents.rc | 155 ++ .../test/ole/AxTestComponents/AxTestComponents.sln | 31 + .../ole/AxTestComponents/AxTestComponents.vcproj | 819 ++++++++ extensions/test/ole/AxTestComponents/Basic.cpp | 1356 ++++++++++++++ extensions/test/ole/AxTestComponents/Basic.h | 259 +++ extensions/test/ole/AxTestComponents/Basic.rgs | 50 + extensions/test/ole/AxTestComponents/Foo.cpp | 30 + extensions/test/ole/AxTestComponents/Foo.h | 54 + extensions/test/ole/AxTestComponents/StdAfx.cpp | 26 + extensions/test/ole/AxTestComponents/StdAfx.h | 46 + extensions/test/ole/AxTestComponents/readme.txt | 3 + extensions/test/ole/AxTestComponents/resource.h | 38 + .../test/ole/DCOM/Clients/WriterDemo/Module1.bas | 25 + .../DCOM/Clients/WriterDemo/client_writerdemo.vbp | 33 + .../DCOM/Clients/WriterDemo/client_writerdemo.vbw | 1 + .../test/ole/DCOM/Clients/WriterDemo/readme.txt | 4 + extensions/test/ole/DCOM/dcom_test/Module1.bas | 55 + extensions/test/ole/DCOM/dcom_test/dcom_test.vbp | 37 + extensions/test/ole/DCOM/dcom_test/dcom_test.vbw | 1 + extensions/test/ole/DCOM/dcom_test/readme.txt | 5 + .../test/ole/DCOM/scriptComponents/WriterDemo.wsc | 186 ++ .../test/ole/DCOM/scriptComponents/readme.txt | 12 + .../EventListener/EventListener.cpp | 76 + .../EventListener/EventListener.def | 9 + .../EventListener/EventListener.idl | 60 + .../EventListener/EventListener.rc | 154 ++ .../EventListener/EventListener.sln | 31 + .../EventListener/EventListener.vcproj | 927 ++++++++++ .../EventListener/EvtListener.cpp | 38 + .../EventListener/EvtListener.h | 52 + .../EventListener/EvtListener.rgs | 26 + .../EventListenerSample/EventListener/StdAfx.cpp | 32 + .../ole/EventListenerSample/EventListener/StdAfx.h | 44 + .../EventListenerSample/EventListener/resource.h | 37 + .../VBEventListener/Module1.bas | 9 + .../VBEventListener/VBEventListener.cls | 69 + .../VBEventListener/VBasicEventListener.vbp | 38 + .../VBEventListener/VBasicEventListener.vbw | 2 + .../EventListenerSample/VBEventListener/readme.txt | 7 + extensions/test/ole/EventListenerSample/events.htm | 115 ++ extensions/test/ole/EventListenerSample/readme.txt | 20 + extensions/test/ole/JScriptNewStyle.htm | 1071 +++++++++++ extensions/test/ole/MfcControl/MfcControl.cpp | 90 + extensions/test/ole/MfcControl/MfcControl.def | 9 + extensions/test/ole/MfcControl/MfcControl.dsp | 265 +++ extensions/test/ole/MfcControl/MfcControl.h | 52 + extensions/test/ole/MfcControl/MfcControl.odl | 82 + extensions/test/ole/MfcControl/MfcControl.rc | 163 ++ extensions/test/ole/MfcControl/MfcControl.sln | 25 + extensions/test/ole/MfcControl/MfcControl.vcproj | 581 ++++++ extensions/test/ole/MfcControl/MfcControlCtl.cpp | 364 ++++ extensions/test/ole/MfcControl/MfcControlCtl.h | 116 ++ extensions/test/ole/MfcControl/MfcControlCtl.png | Bin 0 -> 204 bytes extensions/test/ole/MfcControl/MfcControlPpg.cpp | 96 + extensions/test/ole/MfcControl/MfcControlPpg.h | 66 + extensions/test/ole/MfcControl/Resource.h | 40 + extensions/test/ole/MfcControl/StdAfx.cpp | 25 + extensions/test/ole/MfcControl/StdAfx.h | 50 + extensions/test/ole/OleClient/OleClient.ini | 5 + extensions/test/ole/OleClient/axhost.cxx | 39 + extensions/test/ole/OleClient/axhost.hxx | 51 + extensions/test/ole/OleClient/clientTest.cxx | 1291 +++++++++++++ extensions/test/ole/OleClient/funcs.cxx | 345 ++++ extensions/test/ole/OleClient/readme.txt | 10 + extensions/test/ole/OleConverterVar1/convTest.cxx | 647 +++++++ extensions/test/ole/OleConverterVar1/makefile.mk | 57 + extensions/test/ole/OleConverterVar1/readme.txt | 10 + extensions/test/ole/OleConverterVar1/smartarray.h | 222 +++ extensions/test/ole/OleTest.htm | 1080 +++++++++++ extensions/test/ole/ScriptTest.html | 1555 ++++++++++++++++ .../test/ole/StarBasic_OleClient/oleclient.bas | 622 +++++++ extensions/test/ole/StarBasic_OleClient/readme.txt | 10 + extensions/test/ole/VisualBasic/AssemblyInfo.vb | 51 + extensions/test/ole/VisualBasic/Module1.vb | 871 +++++++++ extensions/test/ole/VisualBasic/Project1.sln | 19 + extensions/test/ole/VisualBasic/Project1.vbproj | 90 + extensions/test/ole/VisualBasic/readme.txt | 18 + extensions/test/ole/callUnoToJava.htm | 552 ++++++ extensions/test/ole/cpnt/cpnt.cxx | 1955 ++++++++++++++++++++ extensions/test/ole/cpnt/exports.dxp | 2 + extensions/test/ole/cpnt/makefile.mk | 66 + extensions/test/ole/cpnt/readme.txt | 21 + extensions/test/ole/cppToUno/makefile.mk | 56 + extensions/test/ole/cppToUno/readme.txt | 8 + extensions/test/ole/cppToUno/testcppuno.cxx | 206 +++ extensions/test/ole/cpptest/cpptest.cxx | 101 + extensions/test/ole/cpptest/makefile.mk | 55 + extensions/test/ole/cpptest/readme.txt | 4 + extensions/test/ole/idl/oletest.idl | 301 +++ extensions/test/ole/unloading/makefile.mk | 61 + extensions/test/ole/unloading/readme.txt | 6 + extensions/test/ole/unloading/unloadTest.cxx | 199 ++ extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp | 28 + extensions/test/ole/unoTocomCalls/Test/StdAfx.h | 47 + extensions/test/ole/unoTocomCalls/Test/Test.cpp | 240 +++ extensions/test/ole/unoTocomCalls/Test/Test.dsp | 114 ++ extensions/test/ole/unoTocomCalls/Test/Test.sln | 19 + extensions/test/ole/unoTocomCalls/Test/Test.vcproj | 247 +++ .../ole/unoTocomCalls/XCallback_Impl/Basic.rgs | 27 + .../ole/unoTocomCalls/XCallback_Impl/BasicTest.rgs | 27 + .../ole/unoTocomCalls/XCallback_Impl/Callback.cpp | 505 +++++ .../ole/unoTocomCalls/XCallback_Impl/Callback.h | 126 ++ .../ole/unoTocomCalls/XCallback_Impl/Callback.rgs | 27 + .../ole/unoTocomCalls/XCallback_Impl/Simple.cpp | 73 + .../test/ole/unoTocomCalls/XCallback_Impl/Simple.h | 55 + .../ole/unoTocomCalls/XCallback_Impl/Simple.rgs | 27 + .../ole/unoTocomCalls/XCallback_Impl/StdAfx.cpp | 32 + .../test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h | 45 + .../XCallback_Impl/XCallback_Impl.cpp | 78 + .../XCallback_Impl/XCallback_Impl.def | 10 + .../XCallback_Impl/XCallback_Impl.dsp | 337 ++++ .../XCallback_Impl/XCallback_Impl.idl | 144 ++ .../unoTocomCalls/XCallback_Impl/XCallback_Impl.rc | 154 ++ .../XCallback_Impl/XCallback_Impl.sln | 31 + .../XCallback_Impl/XCallback_Impl.vcproj | 816 ++++++++ .../ole/unoTocomCalls/XCallback_Impl/resource.h | 39 + extensions/test/ole/unoTocomCalls/readme.txt | 9 + 121 files changed, 22572 insertions(+) create mode 100644 extensions/test/ole/AxTestComponents/AxTestComponents.cpp create mode 100644 extensions/test/ole/AxTestComponents/AxTestComponents.def create mode 100644 extensions/test/ole/AxTestComponents/AxTestComponents.dsp create mode 100644 extensions/test/ole/AxTestComponents/AxTestComponents.idl create mode 100644 extensions/test/ole/AxTestComponents/AxTestComponents.rc create mode 100644 extensions/test/ole/AxTestComponents/AxTestComponents.sln create mode 100644 extensions/test/ole/AxTestComponents/AxTestComponents.vcproj create mode 100644 extensions/test/ole/AxTestComponents/Basic.cpp create mode 100644 extensions/test/ole/AxTestComponents/Basic.h create mode 100644 extensions/test/ole/AxTestComponents/Basic.rgs create mode 100644 extensions/test/ole/AxTestComponents/Foo.cpp create mode 100644 extensions/test/ole/AxTestComponents/Foo.h create mode 100644 extensions/test/ole/AxTestComponents/StdAfx.cpp create mode 100644 extensions/test/ole/AxTestComponents/StdAfx.h create mode 100644 extensions/test/ole/AxTestComponents/readme.txt create mode 100644 extensions/test/ole/AxTestComponents/resource.h create mode 100644 extensions/test/ole/DCOM/Clients/WriterDemo/Module1.bas create mode 100644 extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbp create mode 100644 extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbw create mode 100644 extensions/test/ole/DCOM/Clients/WriterDemo/readme.txt create mode 100644 extensions/test/ole/DCOM/dcom_test/Module1.bas create mode 100644 extensions/test/ole/DCOM/dcom_test/dcom_test.vbp create mode 100644 extensions/test/ole/DCOM/dcom_test/dcom_test.vbw create mode 100644 extensions/test/ole/DCOM/dcom_test/readme.txt create mode 100644 extensions/test/ole/DCOM/scriptComponents/WriterDemo.wsc create mode 100644 extensions/test/ole/DCOM/scriptComponents/readme.txt create mode 100644 extensions/test/ole/EventListenerSample/EventListener/EventListener.cpp create mode 100644 extensions/test/ole/EventListenerSample/EventListener/EventListener.def create mode 100644 extensions/test/ole/EventListenerSample/EventListener/EventListener.idl create mode 100644 extensions/test/ole/EventListenerSample/EventListener/EventListener.rc create mode 100644 extensions/test/ole/EventListenerSample/EventListener/EventListener.sln create mode 100644 extensions/test/ole/EventListenerSample/EventListener/EventListener.vcproj create mode 100644 extensions/test/ole/EventListenerSample/EventListener/EvtListener.cpp create mode 100644 extensions/test/ole/EventListenerSample/EventListener/EvtListener.h create mode 100644 extensions/test/ole/EventListenerSample/EventListener/EvtListener.rgs create mode 100644 extensions/test/ole/EventListenerSample/EventListener/StdAfx.cpp create mode 100644 extensions/test/ole/EventListenerSample/EventListener/StdAfx.h create mode 100644 extensions/test/ole/EventListenerSample/EventListener/resource.h create mode 100644 extensions/test/ole/EventListenerSample/VBEventListener/Module1.bas create mode 100644 extensions/test/ole/EventListenerSample/VBEventListener/VBEventListener.cls create mode 100644 extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbp create mode 100644 extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbw create mode 100644 extensions/test/ole/EventListenerSample/VBEventListener/readme.txt create mode 100644 extensions/test/ole/EventListenerSample/events.htm create mode 100644 extensions/test/ole/EventListenerSample/readme.txt create mode 100644 extensions/test/ole/JScriptNewStyle.htm create mode 100644 extensions/test/ole/MfcControl/MfcControl.cpp create mode 100644 extensions/test/ole/MfcControl/MfcControl.def create mode 100644 extensions/test/ole/MfcControl/MfcControl.dsp create mode 100644 extensions/test/ole/MfcControl/MfcControl.h create mode 100644 extensions/test/ole/MfcControl/MfcControl.odl create mode 100644 extensions/test/ole/MfcControl/MfcControl.rc create mode 100644 extensions/test/ole/MfcControl/MfcControl.sln create mode 100644 extensions/test/ole/MfcControl/MfcControl.vcproj create mode 100644 extensions/test/ole/MfcControl/MfcControlCtl.cpp create mode 100644 extensions/test/ole/MfcControl/MfcControlCtl.h create mode 100644 extensions/test/ole/MfcControl/MfcControlCtl.png create mode 100644 extensions/test/ole/MfcControl/MfcControlPpg.cpp create mode 100644 extensions/test/ole/MfcControl/MfcControlPpg.h create mode 100644 extensions/test/ole/MfcControl/Resource.h create mode 100644 extensions/test/ole/MfcControl/StdAfx.cpp create mode 100644 extensions/test/ole/MfcControl/StdAfx.h create mode 100644 extensions/test/ole/OleClient/OleClient.ini create mode 100644 extensions/test/ole/OleClient/axhost.cxx create mode 100644 extensions/test/ole/OleClient/axhost.hxx create mode 100644 extensions/test/ole/OleClient/clientTest.cxx create mode 100644 extensions/test/ole/OleClient/funcs.cxx create mode 100644 extensions/test/ole/OleClient/readme.txt create mode 100644 extensions/test/ole/OleConverterVar1/convTest.cxx create mode 100644 extensions/test/ole/OleConverterVar1/makefile.mk create mode 100644 extensions/test/ole/OleConverterVar1/readme.txt create mode 100644 extensions/test/ole/OleConverterVar1/smartarray.h create mode 100644 extensions/test/ole/OleTest.htm create mode 100644 extensions/test/ole/ScriptTest.html create mode 100644 extensions/test/ole/StarBasic_OleClient/oleclient.bas create mode 100644 extensions/test/ole/StarBasic_OleClient/readme.txt create mode 100644 extensions/test/ole/VisualBasic/AssemblyInfo.vb create mode 100644 extensions/test/ole/VisualBasic/Module1.vb create mode 100644 extensions/test/ole/VisualBasic/Project1.sln create mode 100644 extensions/test/ole/VisualBasic/Project1.vbproj create mode 100644 extensions/test/ole/VisualBasic/readme.txt create mode 100644 extensions/test/ole/callUnoToJava.htm create mode 100644 extensions/test/ole/cpnt/cpnt.cxx create mode 100644 extensions/test/ole/cpnt/exports.dxp create mode 100644 extensions/test/ole/cpnt/makefile.mk create mode 100644 extensions/test/ole/cpnt/readme.txt create mode 100644 extensions/test/ole/cppToUno/makefile.mk create mode 100644 extensions/test/ole/cppToUno/readme.txt create mode 100644 extensions/test/ole/cppToUno/testcppuno.cxx create mode 100644 extensions/test/ole/cpptest/cpptest.cxx create mode 100644 extensions/test/ole/cpptest/makefile.mk create mode 100644 extensions/test/ole/cpptest/readme.txt create mode 100644 extensions/test/ole/idl/oletest.idl create mode 100644 extensions/test/ole/unloading/makefile.mk create mode 100644 extensions/test/ole/unloading/readme.txt create mode 100644 extensions/test/ole/unloading/unloadTest.cxx create mode 100644 extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp create mode 100644 extensions/test/ole/unoTocomCalls/Test/StdAfx.h create mode 100644 extensions/test/ole/unoTocomCalls/Test/Test.cpp create mode 100644 extensions/test/ole/unoTocomCalls/Test/Test.dsp create mode 100644 extensions/test/ole/unoTocomCalls/Test/Test.sln create mode 100644 extensions/test/ole/unoTocomCalls/Test/Test.vcproj create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/Basic.rgs create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/BasicTest.rgs create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.cpp create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.h create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.rgs create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.cpp create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.h create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.rgs create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.cpp create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.cpp create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.def create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.dsp create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.idl create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.rc create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.sln create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.vcproj create mode 100644 extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h create mode 100644 extensions/test/ole/unoTocomCalls/readme.txt (limited to 'extensions/test/ole') diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.cpp b/extensions/test/ole/AxTestComponents/AxTestComponents.cpp new file mode 100644 index 000000000..ca7d37457 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.cpp @@ -0,0 +1,77 @@ +/* -*- 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 . + */ + +// Note: Proxy/Stub Information +// To build a separate proxy/stub DLL, +// run nmake -f AxTestComponentsps.mk in the project directory. + +#include "stdafx.h" +#include "resource.h" +#include + +#include "Basic.h" +#include "Foo.h" + +CComModule _Module; + +BEGIN_OBJECT_MAP(ObjectMap) +OBJECT_ENTRY(CLSID_Basic, CBasic) +OBJECT_ENTRY(CLSID_Foo, CFoo) +END_OBJECT_MAP() + +// DLL Entry Point + +extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) +{ + if (dwReason == DLL_PROCESS_ATTACH) + { + _Module.Init(ObjectMap, hInstance, &LIBID_AXTESTCOMPONENTSLib); + DisableThreadLibraryCalls(hInstance); + } + else if (dwReason == DLL_PROCESS_DETACH) + _Module.Term(); + return TRUE; // ok +} + +// Used to determine whether the DLL can be unloaded by OLE + +STDAPI DllCanUnloadNow(void) { return (_Module.GetLockCount() == 0) ? S_OK : S_FALSE; } + +// Returns a class factory to create an object of the requested type + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) +{ + return _Module.GetClassObject(rclsid, riid, ppv); +} + +// DllRegisterServer - Adds entries to the system registry + +STDAPI DllRegisterServer(void) +{ + // registers object, typelib and all interfaces in typelib + return _Module.RegisterServer(TRUE); +} + +// DllUnregisterServer - Removes entries from the system registry + +STDAPI DllUnregisterServer(void) { return _Module.UnregisterServer(TRUE); } + +//VT_I4 size_t V_ERROR VARIANT VARIANT_FALSE CComVariant FADF_EMBEDDED + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.def b/extensions/test/ole/AxTestComponents/AxTestComponents.def new file mode 100644 index 000000000..5d8c019ad --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.def @@ -0,0 +1,9 @@ +; AxTestComponents.def : Declares the module parameters. + +LIBRARY "AxTestComponents.DLL" + +EXPORTS + DllCanUnloadNow PRIVATE + DllGetClassObject PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.dsp b/extensions/test/ole/AxTestComponents/AxTestComponents.dsp new file mode 100644 index 000000000..43fbbe53d --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.dsp @@ -0,0 +1,325 @@ +# Microsoft Developer Studio Project File - Name="AxTestComponents" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=AxTestComponents - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "AxTestComponents.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "AxTestComponents.mak" CFG="AxTestComponents - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "AxTestComponents - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "AxTestComponents - Win32 Unicode Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "AxTestComponents - Win32 Release MinSize" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "AxTestComponents - Win32 Release MinDependency" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "AxTestComponents - Win32 Unicode Release MinSize" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "AxTestComponents - Win32 Unicode Release MinDependency" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "AxTestComponents - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# Begin Custom Build - Performing registration +OutDir=.\Debug +TargetPath=.\Debug\AxTestComponents.dll +InputPath=.\Debug\AxTestComponents.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + +# End Custom Build + +!ELSEIF "$(CFG)" == "AxTestComponents - Win32 Unicode Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugU" +# PROP BASE Intermediate_Dir "DebugU" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugU" +# PROP Intermediate_Dir "DebugU" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# Begin Custom Build - Performing registration +OutDir=.\DebugU +TargetPath=.\DebugU\AxTestComponents.dll +InputPath=.\DebugU\AxTestComponents.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + goto end + :NOTNT + echo Warning : Cannot register Unicode DLL on Windows 95 + :end + +# End Custom Build + +!ELSEIF "$(CFG)" == "AxTestComponents - Win32 Release MinSize" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseMinSize" +# PROP BASE Intermediate_Dir "ReleaseMinSize" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseMinSize" +# PROP Intermediate_Dir "ReleaseMinSize" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# Begin Custom Build - Performing registration +OutDir=.\ReleaseMinSize +TargetPath=.\ReleaseMinSize\AxTestComponents.dll +InputPath=.\ReleaseMinSize\AxTestComponents.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + +# End Custom Build + +!ELSEIF "$(CFG)" == "AxTestComponents - Win32 Release MinDependency" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseMinDependency" +# PROP BASE Intermediate_Dir "ReleaseMinDependency" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseMinDependency" +# PROP Intermediate_Dir "ReleaseMinDependency" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# Begin Custom Build - Performing registration +OutDir=.\ReleaseMinDependency +TargetPath=.\ReleaseMinDependency\AxTestComponents.dll +InputPath=.\ReleaseMinDependency\AxTestComponents.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + +# End Custom Build + +!ELSEIF "$(CFG)" == "AxTestComponents - Win32 Unicode Release MinSize" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseUMinSize" +# PROP BASE Intermediate_Dir "ReleaseUMinSize" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseUMinSize" +# PROP Intermediate_Dir "ReleaseUMinSize" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# Begin Custom Build - Performing registration +OutDir=.\ReleaseUMinSize +TargetPath=.\ReleaseUMinSize\AxTestComponents.dll +InputPath=.\ReleaseUMinSize\AxTestComponents.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + goto end + :NOTNT + echo Warning : Cannot register Unicode DLL on Windows 95 + :end + +# End Custom Build + +!ELSEIF "$(CFG)" == "AxTestComponents - Win32 Unicode Release MinDependency" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseUMinDependency" +# PROP BASE Intermediate_Dir "ReleaseUMinDependency" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseUMinDependency" +# PROP Intermediate_Dir "ReleaseUMinDependency" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# Begin Custom Build - Performing registration +OutDir=.\ReleaseUMinDependency +TargetPath=.\ReleaseUMinDependency\AxTestComponents.dll +InputPath=.\ReleaseUMinDependency\AxTestComponents.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + goto end + :NOTNT + echo Warning : Cannot register Unicode DLL on Windows 95 + :end + +# End Custom Build + +!ENDIF + +# Begin Target + +# Name "AxTestComponents - Win32 Debug" +# Name "AxTestComponents - Win32 Unicode Debug" +# Name "AxTestComponents - Win32 Release MinSize" +# Name "AxTestComponents - Win32 Release MinDependency" +# Name "AxTestComponents - Win32 Unicode Release MinSize" +# Name "AxTestComponents - Win32 Unicode Release MinDependency" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\AxTestComponents.cpp +# End Source File +# Begin Source File + +SOURCE=.\AxTestComponents.def +# End Source File +# Begin Source File + +SOURCE=.\AxTestComponents.idl +# ADD MTL /tlb ".\AxTestComponents.tlb" /h "AxTestComponents.h" /iid "AxTestComponents_i.c" /Oicf +# End Source File +# Begin Source File + +SOURCE=.\AxTestComponents.rc +# End Source File +# Begin Source File + +SOURCE=.\Basic.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Basic.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\Basic.rgs +# End Source File +# End Group +# End Target +# End Project + + diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.idl b/extensions/test/ole/AxTestComponents/AxTestComponents.idl new file mode 100644 index 000000000..6649483a7 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.idl @@ -0,0 +1,251 @@ +/* -*- 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 . + */ +// AxTestComponents.idl : IDL source for AxTestComponents.dll + + +// This file will be processed by the MIDL tool to +// produce the type library (AxTestComponents.tlb) and marshalling code. +// next id 86 +import "oaidl.idl"; +import "ocidl.idl"; + [ + object, + uuid(BFE10EBD-8584-11D4-8335-005004526AB4), + dual, + helpstring("IBasic Interface"), + pointer_default(unique) + ] + interface IBasic : IDispatch + { + [id(82), helpstring("method inBool")] HRESULT inBool([in]VARIANT_BOOL val); + [id(1), helpstring("method inByte")] HRESULT inByte([in] unsigned char val); + [id(2), helpstring("method inShort")] HRESULT inShort([in] short val); + [id(3), helpstring("method inLong")] HRESULT inLong([in] long val); + [id(4), helpstring("method inString")] HRESULT inString([in] BSTR val); + [id(5), helpstring("method inFloat")] HRESULT inFloat([in] float val); + [id(6), helpstring("method inDouble")] HRESULT inDouble([in] double val); + [id(7), helpstring("method inVariant")] HRESULT inVariant([in] VARIANT val); + [id(8), helpstring("method inArray")] HRESULT inArray([in] SAFEARRAY(VARIANT) val); + [id(9), helpstring("method inObject")] HRESULT inObject([in] IDispatch* val); + [id(83), helpstring("method inoutBool")] HRESULT inoutBool([in,out]VARIANT_BOOL* val); + [id(12), helpstring("method inoutByte")] HRESULT inoutByte([in,out] unsigned char* val); + [id(13), helpstring("method inoutShort")] HRESULT inoutShort([in,out] short* val); + [id(14), helpstring("method inoutLong")] HRESULT inoutLong([in,out] long * val); + [id(15), helpstring("method inoutString")] HRESULT inoutString([in, out] BSTR* val); + [id(16), helpstring("method inoutFloat")] HRESULT inoutFloat([in,out] float * val); + [id(17), helpstring("method inoutDouble")] HRESULT inoutDouble([in,out] double * val); + [id(18), helpstring("method inoutVariant")] HRESULT inoutVariant([in,out] VARIANT * val); + [id(19), helpstring("method inoutArray")] HRESULT inoutArray([in,out] SAFEARRAY(VARIANT) * val); + [id(20), helpstring("method inoutObject")] HRESULT inoutObject([in,out] IDispatch** val); + [id(84), helpstring("method outBool")] HRESULT outBool([out] VARIANT_BOOL* val); + [id(23), helpstring("method outByte")] HRESULT outByte([out] unsigned char* val); + [id(24), helpstring("method outShort")] HRESULT outShort([out] short* val); + [id(25), helpstring("method outLong")] HRESULT outLong([out] long* val); + [id(26), helpstring("method outString")] HRESULT outString([out] BSTR* val); + [id(27), helpstring("method outFloat")] HRESULT outFloat([out] float* val); + [id(28), helpstring("method outDouble")] HRESULT outDouble([out] double* val); + [id(29), helpstring("method outVariant")] HRESULT outVariant([out] VARIANT* val); + [id(30), helpstring("method outArray")] HRESULT outArray([out] SAFEARRAY(VARIANT) * val); + [id(31), helpstring("method outObject")] HRESULT outObject([out] IDispatch** val); + [propget, id(85), helpstring("property prpBool")] HRESULT prpBool([out, retval] VARIANT_BOOL *pVal); + [propput, id(85), helpstring("property prpBool")] HRESULT prpBool([in] VARIANT_BOOL newVal); + [propget, id(34), helpstring("property prpByte")] HRESULT prpByte([out, retval] unsigned char *pVal); + [propput, id(34), helpstring("property prpByte")] HRESULT prpByte([in] unsigned char newVal); + [propget, id(35), helpstring("property prpShort")] HRESULT prpShort([out, retval] short *pVal); + [propput, id(35), helpstring("property prpShort")] HRESULT prpShort([in] short newVal); + [propget, id(36), helpstring("property prpLong")] HRESULT prpLong([out, retval] long *pVal); + [propput, id(36), helpstring("property prpLong")] HRESULT prpLong([in] long newVal); + [propget, id(37), helpstring("property prpString")] HRESULT prpString([out, retval] BSTR *pVal); + [propput, id(37), helpstring("property prpString")] HRESULT prpString([in] BSTR newVal); + [propget, id(38), helpstring("property prpFloat")] HRESULT prpFloat([out, retval] float *pVal); + [propput, id(38), helpstring("property prpFloat")] HRESULT prpFloat([in] float newVal); + [propget, id(39), helpstring("property prpDouble")] HRESULT prpDouble([out, retval] double *pVal); + [propput, id(39), helpstring("property prpDouble")] HRESULT prpDouble([in] double newVal); + [propget, id(40), helpstring("property prpVariant")] HRESULT prpVariant([out, retval] VARIANT *pVal); + [propput, id(40), helpstring("property prpVariant")] HRESULT prpVariant([in] VARIANT newVal); + [propget, id(41), helpstring("property prpArray")] HRESULT prpArray([out, retval]SAFEARRAY(VARIANT) *pVal); + [propput, id(41), helpstring("property prpArray")] HRESULT prpArray([in] SAFEARRAY(VARIANT) newVal); + [propget, id(42), helpstring("property prpObject")] HRESULT prpObject([out, retval] IDispatch* *pVal); + [propput, id(42), helpstring("property prpObject")] HRESULT prpObject([in] IDispatch* newVal); + [id(43), helpstring("method mixed1")] HRESULT mixed1( + [in, out] unsigned char* aChar, + [in, out] float *aFloat, + [in,out] VARIANT* inoutVar); + [id(44), helpstring("method inSequenceLong")] HRESULT inSequenceLong([in] SAFEARRAY(long) ar); + [id(45), helpstring("method inSequenceByte")] HRESULT inSequenceByte([in] SAFEARRAY(byte) ar); + [id(46), helpstring("method inSequenceShort")] HRESULT inSequenceShort([in] SAFEARRAY(short) ar); + [id(47), helpstring("method inSequenceString")] HRESULT inSequenceString([in] SAFEARRAY( BSTR) ar); + [id(48), helpstring("method inSequenceFloat")] HRESULT inSequenceFloat([in] SAFEARRAY(float) ar); + [id(49), helpstring("method inSequenceDouble")] HRESULT inSequenceDouble([in] SAFEARRAY(double) ar); + [id(50), helpstring("method inSequenceObject")] HRESULT inSequenceObject([in] SAFEARRAY(IDispatch*) ar); + [id(51), helpstring("method outSequenceByte")] HRESULT outSequenceByte([out] SAFEARRAY(unsigned char)* val); + [id(52), helpstring("method outSequenceShort")] HRESULT outSequenceShort([out] SAFEARRAY(short)* val); + [id(53), helpstring("method outSequenceLong")] HRESULT outSequenceLong([out] SAFEARRAY(long )*val); + [id(54), helpstring("method outSequenceString")] HRESULT outSequenceString([out] SAFEARRAY(BSTR)* val); + [id(55), helpstring("method outSequenceFloat")] HRESULT outSequenceFloat([out] SAFEARRAY(float)* val); + [id(56), helpstring("method outSequenceDouble")] HRESULT outSequenceDouble([out] SAFEARRAY(double)* val); + [id(57), helpstring("method outSequenceObject")] HRESULT outSequenceObject([out] SAFEARRAY(IDispatch*)* val); + [id(58), helpstring("method inoutSequenceByte")] HRESULT inoutSequenceByte([in,out] SAFEARRAY(unsigned char)* val); + [id(59), helpstring("method inoutSequenceShort")] HRESULT inoutSequenceShort([in,out] SAFEARRAY(short)* val); + [id(60), helpstring("method inoutSequenceLong")] HRESULT inoutSequenceLong([in,out] SAFEARRAY( long)*val); + [id(61), helpstring("method inoutSequenceString")] HRESULT inoutSequenceString([in,out] SAFEARRAY(BSTR)* val); + [id(62), helpstring("method inoutSequenceFloat")] HRESULT inoutSequenceFloat([in,out] SAFEARRAY(float)* val); + [id(63), helpstring("method inoutSequenceDouble")] HRESULT inoutSequenceDouble([in,out] SAFEARRAY(double)* val); + [id(64), helpstring("method inoutSequenceObject")] HRESULT inoutSequenceObject([in,out] SAFEARRAY(IDispatch*)* val); + [id(65), helpstring("method inMulDimArrayLong")] HRESULT inMulDimArrayLong([in] SAFEARRAY(long) val ); + [id(66), helpstring("method inMulDimArrayVariant")] HRESULT inMulDimArrayVariant([in] SAFEARRAY(VARIANT) val); + [id(67), helpstring("method inMulDimArrayLong2")] HRESULT inMulDimArrayLong2([in] SAFEARRAY(long) val); + [id(68), helpstring("method inMulDimArrayVariant2")] HRESULT inMulDimArrayVariant2([in] SAFEARRAY(VARIANT) val); + [id(69), helpstring("method inMulDimArrayByte")] HRESULT inMulDimArrayByte([in] SAFEARRAY(unsigned char) val); + [id(70), helpstring("method inMulDimArrayByte2")] HRESULT inMulDimArrayByte2([in] SAFEARRAY(unsigned char) val); + [id(71), helpstring("method outMore")] HRESULT outMore([out]long* val1, [out]long* val2); + + [id(72), helpstring("method optional1")] + HRESULT optional1([in] long val1, [in, optional] VARIANT* val2); + [id(73), helpstring("method optional2")] + HRESULT optional2([out] long* val1, [out, optional] VARIANT* val2); + [id(74), helpstring("method optional3")] + HRESULT optional3([in, optional] VARIANT* val1, [in, optional] VARIANT* val2); + [id(75), helpstring("method optional4")] + HRESULT optional4([in, out, optional] VARIANT* val1, [in, out, optional] VARIANT* val2); + [id(76), helpstring("method optional5")] + HRESULT optional5([out, optional] VARIANT* val1, [out, optional] VARIANT* val2); + //midl creates for val4 a BSTR "4" as default value in the TLB. The midl complains + //but the error message seems to be not for this case. + //in defaultvalue2 val4 has a VT_I4 in the TLB. This must be a bug! + [id(77), helpstring("method defaultvalue1")] + HRESULT defaultvalue1([in, defaultvalue(1)] long val1, + [in, defaultvalue(2)] double* val2, + // [in, defaultvalue(3)] VARIANT val3, //ok + [in, defaultvalue(4)] VARIANT* val4); + + // bug in midl: when val3 and val4 are pointers then the generated header creates + // for all params default values: + //HRESULT STDMETHODCALLTYPE defaultvalue2( + // /* [defaultvalue][in] */ long *val1 = 10, + // /* [defaultvalue][in] */ double *val2 = 3.14, + // /* [defaultvalue][in] */ VARIANT *val3 = 10, + // /* [defaultvalue][in] */ VARIANT *val4 = 100) = 0; + // And that does not compile. + //Therefore we must not include the midl generated header, instead use + // #import to create the interface header + [id(78), helpstring("method defaultvalue2")] + HRESULT defaultvalue2([in, out, defaultvalue(1)]long* val1, + [in, out, defaultvalue(2)] double* val2, + // [in, out, defaultvalue(3)] VARIANT *val3, + [in, out, defaultvalue(4)] VARIANT *val4); + + [id(79), helpstring("method varargfunc1"),vararg] + HRESULT varargfunc1([in] long val1, [in] SAFEARRAY(VARIANT) val2); + [id(80), helpstring("method varargfunc2")] + HRESULT varargfunc2([out] long* val1, [out] SAFEARRAY(VARIANT)* val2); + + + [id(86), helpstring("method inSequenceByteDim2")] HRESULT inSequenceByteDim2([in] SAFEARRAY(byte) val); + [id(87), helpstring("method inCurrency")] HRESULT inCurrency([in] CY val); + [id(88), helpstring("method outCurrency")] HRESULT outCurrency([out] CY* val); + [id(89), helpstring("method inoutCurrency")] HRESULT inoutCurrency([in,out] CY* val); + [id(90), helpstring("method inDate")] HRESULT inDate([in] DATE val); + [id(91), helpstring("method outDate")] HRESULT outDate([out] DATE* val); + [id(92), helpstring("method inoutDate")] HRESULT inoutDate([in,out] DATE* val); + [propget, id(93), helpstring("property prpCY")] HRESULT prpCurrency([out, retval] CY* pVal); + [propput, id(93), helpstring("property prpCY")] HRESULT prpCurrency([in] CY newVal); + [propget, id(94), helpstring("property prpDate")] HRESULT prpDate([out, retval] DATE* pVal); + [propput, id(94), helpstring("property prpDate")] HRESULT prpDate([in] DATE newVal); + [id(95), helpstring("method inDecimal")] HRESULT inDecimal([in] DECIMAL val); + [id(96), helpstring("method outDecimal")] HRESULT outDecimal([out] DECIMAL* val); + [id(97), helpstring("method inoutDecimal")] HRESULT inoutDecimal([in,out] DECIMAL* val); + [propget, id(98), helpstring("property prpDecimal")] HRESULT prpDecimal([out, retval] DECIMAL* pVal); + [propput, id(98), helpstring("property prpDecimal")] HRESULT prpDecimal([in] DECIMAL newVal); + [id(99), helpstring("method inSCode")] HRESULT inSCode([in] SCODE val); + [id(100), helpstring("method outScode")] HRESULT outScode([out] SCODE* val); + [id(101), helpstring("method inoutSCode")] HRESULT inoutSCode([in,out] SCODE* val); + [propget, id(102), helpstring("property prpSCode")] HRESULT prpSCode([out, retval] SCODE* pVal); + [propput, id(102), helpstring("property prpSCode")] HRESULT prpSCode([in] SCODE newVal); + [id(103), helpstring("method inrefLong")] HRESULT inrefLong([in] LONG* val); + [id(104), helpstring("method inrefVARIANT")] HRESULT inrefVariant([in] VARIANT* val); + [id(105), helpstring("method inrefDecimal")] HRESULT inrefDecimal(DECIMAL* val); + [propget, id(106), helpstring("property prpRefLong")] HRESULT prpRefLong([out, retval] long* pVal); + [propputref, id(106), helpstring("property prpRefLong")] HRESULT prpRefLong([in] long* newVal); + [propget, id(107), helpstring("property prprefVariant")] HRESULT prprefVariant([out, retval] VARIANT* pVal); + [propputref, id(107), helpstring("property prprefVariant")] HRESULT prprefVariant([in] VARIANT* newVal); + [propget, id(108), helpstring("property prprefDecimal")] HRESULT prprefDecimal([out, retval] DECIMAL* pVal); + [propputref, id(108), helpstring("property prprefDecimal")] HRESULT prprefDecimal([in] DECIMAL* newVal); + [id(109), helpstring("method optional6")] HRESULT optional6([in,optional] VARIANT* val1, + [in,optional] VARIANT * val2, [in,optional] VARIANT* val3, [in,optional] VARIANT* val4); + [id(110), helpstring("method optional7")] HRESULT optional7([out,optional] VARIANT* val1, + [out,optional] VARIANT * val2, [out,optional] VARIANT* val3, [out,optional] VARIANT* val4); + + [propget, id(111), helpstring("property prpMultiArg1")] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [out, optional, retval] VARIANT* pVal); + [propput, id(111), helpstring("property prpMultiArg1")] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [in] VARIANT* newVal); + [propget, id(112), helpstring("property prpMultiArg2")] HRESULT prpMultiArg2([in] VARIANT val1, [out, retval] VARIANT* pVal); + [propput, id(112), helpstring("property prpMultiArg2")] HRESULT prpMultiArg2([in] VARIANT val1, [in] VARIANT newVal); + [id(113), helpstring("method prpMultiArg2GetValues")] HRESULT prpMultiArg2GetValues([out] VARIANT* val1, [out] VARIANT* valProperty); + [propget, id(114), helpstring("property prpMultiArg3")] HRESULT prpMultiArg3([in,out] LONG* val1, [out, retval] LONG* pVal); + [propput, id(114), helpstring("property prpMultiArg3")] HRESULT prpMultiArg3([in,out] LONG* val1, [in] LONG newVal); + [id(115), helpstring("method inUnknown")] HRESULT inUnknown([in] IUnknown* val); + [id(116), helpstring("method outUnknown")] HRESULT outUnknown([out] IUnknown** val); + [id(117), helpstring("method inoutUnknown")] HRESULT inoutUnknown([in,out] IUnknown** val); + [propget, id(118), helpstring("property prpUnknown")] HRESULT prpUnknown([out, retval] IUnknown** pVal); + [propput, id(118), helpstring("property prpUnknown")] HRESULT prpUnknown([in] IUnknown* newVal); +}; + +[ + object, + uuid(96E6105A-A436-48b3-BFE7-C9302D927CCF), + dual, + helpstring("IFoo Interface"), + pointer_default(unique) +] +interface IFoo : IUnknown +{ + HRESULT Foo([in] IUnknown* val); +}; + +[ + uuid(BFE10EB1-8584-11D4-8335-005004526AB4), + version(1.0), + helpstring("AxTestComponents 1.0 Type Library") +] +library AXTESTCOMPONENTSLib +{ + importlib("stdole32.tlb"); + importlib("stdole2.tlb"); + + [ + uuid(BFE10EBE-8584-11D4-8335-005004526AB4), + helpstring("Basic Class") + ] + coclass Basic + { + [default] interface IBasic; + }; + + [ + uuid(14DE9D5D-EB9D-4091-8E1B-A1B1672D8C1D), + helpstring("Foo Class") + ] + coclass Foo + { + [default] interface IFoo; + }; + +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.rc b/extensions/test/ole/AxTestComponents/AxTestComponents.rc new file mode 100644 index 000000000..da5d58f65 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.rc @@ -0,0 +1,155 @@ +/* + * 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 . + */ + +//Microsoft Developer Studio generated resource script. + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + + +// Generated from the TEXTINCLUDE 2 resource. + +#include "winres.h" + + +#undef APSTUDIO_READONLY_SYMBOLS + + +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + + + +// REGISTRY + + +IDR_BASIC REGISTRY DISCARDABLE "Basic.rgs" +IDR_FOO REGISTRY DISCARDABLE "Basic.rgs" +#endif // German (Germany) resources + + + + +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED + + +// TEXTINCLUDE + + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "1 TYPELIB ""AxTestComponents.tlb""\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC + + +// Version + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "AxTestComponents Module\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "AxTestComponents\0" + VALUE "LegalCopyright", "Copyright 2000\0" + VALUE "OriginalFilename", "AxTestComponents.DLL\0" + VALUE "ProductName", "AxTestComponents Module\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + VALUE "OLESelfRegister", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + + + +// String Table + + +STRINGTABLE DISCARDABLE +BEGIN + IDS_PROJNAME "AxTestComponents" +END + +#endif // English (U.S.) resources + + + + +#ifndef APSTUDIO_INVOKED + + +// Generated from the TEXTINCLUDE 3 resource. + +1 TYPELIB "AxTestComponents.tlb" + + +#endif // not APSTUDIO_INVOKED + diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.sln b/extensions/test/ole/AxTestComponents/AxTestComponents.sln new file mode 100644 index 000000000..eadaa373e --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.sln @@ -0,0 +1,31 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AxTestComponents", "AxTestComponents.vcproj", "{CF6DC513-B04E-420A-A0F9-6D1F4046D098}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release MinDependency|Win32 = Release MinDependency|Win32 + Release MinSize|Win32 = Release MinSize|Win32 + Unicode Debug|Win32 = Unicode Debug|Win32 + Unicode Release MinDependency|Win32 = Unicode Release MinDependency|Win32 + Unicode Release MinSize|Win32 = Unicode Release MinSize|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Debug|Win32.ActiveCfg = Debug|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Debug|Win32.Build.0 = Debug|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Release MinDependency|Win32.ActiveCfg = Release MinDependency|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Release MinDependency|Win32.Build.0 = Release MinDependency|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Release MinSize|Win32.ActiveCfg = Release MinSize|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Release MinSize|Win32.Build.0 = Release MinSize|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Debug|Win32.ActiveCfg = Unicode Debug|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Debug|Win32.Build.0 = Unicode Debug|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Release MinDependency|Win32.ActiveCfg = Unicode Release MinDependency|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Release MinDependency|Win32.Build.0 = Unicode Release MinDependency|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Release MinSize|Win32.ActiveCfg = Unicode Release MinSize|Win32 + {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Release MinSize|Win32.Build.0 = Unicode Release MinSize|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.vcproj b/extensions/test/ole/AxTestComponents/AxTestComponents.vcproj new file mode 100644 index 000000000..078daba3d --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.vcproj @@ -0,0 +1,819 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/test/ole/AxTestComponents/Basic.cpp b/extensions/test/ole/AxTestComponents/Basic.cpp new file mode 100644 index 000000000..8aad56e8a --- /dev/null +++ b/extensions/test/ole/AxTestComponents/Basic.cpp @@ -0,0 +1,1356 @@ +/* -*- 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 "stdafx.h" +#include "Basic.h" + + + +// CBasic +CBasic::CBasic(): m_cPrpByte(0),m_nPrpShort(0),m_lPrpLong(0),m_fPrpFloat(0), m_dPrpDouble(0),m_PrpArray(0), +m_safearray(NULL), m_bool(VARIANT_FALSE), +m_arByte(0), m_arShort(0), m_arLong(0), m_arString(0), m_arVariant(0), m_arFloat(0), +m_arDouble(0), m_arObject(0), m_arByteDim2(0), m_date(0.), m_scode(0) + +{ + memset(&m_cy, 0, sizeof(CY)); + memset(&m_decimal, 0, sizeof(DECIMAL)); +} + +CBasic::~CBasic() +{ + SafeArrayDestroy(m_safearray); + SafeArrayDestroy(m_arByte); + SafeArrayDestroy(m_arShort); + SafeArrayDestroy(m_arLong); + SafeArrayDestroy(m_arString); + SafeArrayDestroy(m_arVariant); + SafeArrayDestroy(m_arFloat); + SafeArrayDestroy(m_arDouble); + SafeArrayDestroy(m_arObject); + SafeArrayDestroy(m_arByteDim2); + +} +STDMETHODIMP CBasic::inBool(VARIANT_BOOL val) +{ + m_bool = val; + return S_OK; +} +STDMETHODIMP CBasic::inByte(unsigned char val) +{ + m_byte = val; + return S_OK; +} + +STDMETHODIMP CBasic::inShort(short val) +{ + m_short = val; + return S_OK; +} + +STDMETHODIMP CBasic::inLong(long val) +{ + m_long = val; + return S_OK; +} + +STDMETHODIMP CBasic::inString(BSTR val) +{ + m_bstr = val; + return S_OK; +} + +STDMETHODIMP CBasic::inFloat(float val) +{ + m_float = val; + return S_OK; +} + +STDMETHODIMP CBasic::inDouble(double val) +{ + m_double = val; + + CComVariant varDest; + CComVariant varSource(val); + HRESULT hr = VariantChangeType(&varDest, &varSource, 0, VT_BSTR); + return S_OK; +} + +STDMETHODIMP CBasic::inVariant(VARIANT val) +{ + m_var1 = val; + return S_OK; +} + +STDMETHODIMP CBasic::inArray(LPSAFEARRAY val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_safearray))) + return hr; + if (FAILED(hr = SafeArrayCopy(val, &m_safearray))) + return hr; + return S_OK; +} + +STDMETHODIMP CBasic::inObject(IDispatch *val) +{ + m_obj = val; + return S_OK; +} + +STDMETHODIMP CBasic::inoutBool(VARIANT_BOOL* val) +{ + VARIANT_BOOL aBool = *val; + *val = m_bool; + m_bool = aBool; + return S_OK; +} + + +STDMETHODIMP CBasic::inoutByte(unsigned char* val) +{ + unsigned char aByte = *val; + *val = m_byte; + m_byte = aByte; + return S_OK; +} + +STDMETHODIMP CBasic::inoutShort(short *val) +{ + short aShort = *val; + *val = m_short; + m_short = aShort; + return S_OK; +} + +STDMETHODIMP CBasic::inoutLong(long *val) +{ + long aLong = *val; + *val = m_long; + m_long = aLong; + return S_OK; +} + +STDMETHODIMP CBasic::inoutString(BSTR *val) +{ + CComBSTR aStr = *val; + HRESULT hr = S_OK; + if (FAILED( hr = m_bstr.CopyTo(val))) + return hr; + m_bstr = aStr; + return S_OK; +} + +STDMETHODIMP CBasic::inoutFloat(float *val) +{ + float aFloat = *val; + *val = m_float; + m_float = aFloat; + return S_OK; +} + +STDMETHODIMP CBasic::inoutDouble(double *val) +{ + double aDouble = *val; + *val = m_double; + m_double = aDouble; + return S_OK; +} + +STDMETHODIMP CBasic::inoutVariant(VARIANT *val) +{ + CComVariant aVar = *val; + HRESULT hr = S_OK; + if (FAILED(hr = VariantCopy(val, &m_var1))) + return hr; + m_var1 = aVar; + return S_OK; +} + +/* The array contains VARIANT according to IDL. + If the VARIANTs contain strings then we append "out" to each string. +*/ +STDMETHODIMP CBasic::inoutArray(LPSAFEARRAY *val) +{ + SAFEARRAY* aAr = NULL; + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayCopy(*val, &aAr))) + return hr; + if (FAILED(hr = SafeArrayCopy(m_safearray, val))) + return hr; + if (FAILED(hr = SafeArrayCopy(aAr, & m_safearray))) + return hr; + return S_OK; +} + +STDMETHODIMP CBasic::inoutObject(IDispatch **val) +{ + CComPtr disp = *val; + if (*val) + (*val)->Release(); + *val = m_obj; + if (*val) + (*val)->AddRef(); + m_obj = disp; + return S_OK; +} + + +STDMETHODIMP CBasic::outBool(VARIANT_BOOL* val) +{ + *val = m_bool; + return S_OK; +} + +STDMETHODIMP CBasic::outByte(unsigned char *val) +{ + *val= m_byte; + return S_OK; +} + +STDMETHODIMP CBasic::outShort(short *val) +{ + *val= m_short; + return S_OK; +} + +STDMETHODIMP CBasic::outLong(long *val) +{ + *val= m_long; + return S_OK; +} + +STDMETHODIMP CBasic::outString(BSTR *val) +{ + *val= SysAllocString(m_bstr); + return S_OK; +} + +STDMETHODIMP CBasic::outFloat(float *val) +{ + *val= m_float; + return S_OK; +} + +STDMETHODIMP CBasic::outDouble(double *val) +{ + *val= m_double; + return S_OK; +} + +STDMETHODIMP CBasic::outVariant(VARIANT *val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = VariantCopy(val, &m_var1))) + return hr; + return S_OK; +} + +STDMETHODIMP CBasic::outArray(LPSAFEARRAY *val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayCopy(m_safearray, val))) + return false; + return S_OK; +} + +STDMETHODIMP CBasic::outObject(IDispatch* *val) +{ + *val = m_obj; + if (m_obj) + (*val)->AddRef(); + + return S_OK; +} + + +STDMETHODIMP CBasic::get_prpBool(VARIANT_BOOL* pVal) +{ + if (!pVal) return E_POINTER; + *pVal = m_bool; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpBool(VARIANT_BOOL val) +{ + m_bool = val; + return S_OK; +} + + +STDMETHODIMP CBasic::get_prpByte(unsigned char *pVal) +{ + if( !pVal) + return E_POINTER; + *pVal= m_cPrpByte; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpByte(unsigned char newVal) +{ + m_cPrpByte= newVal; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpShort(short *pVal) +{ + if( !pVal) + return E_POINTER; + *pVal= m_nPrpShort; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpShort(short newVal) +{ + m_nPrpShort= newVal; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpLong(long *pVal) +{ + if( !pVal) + return E_POINTER; + *pVal= m_lPrpLong; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpLong(long newVal) +{ + m_lPrpLong= newVal; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpString(BSTR *pVal) +{ + if( !pVal) + return E_POINTER; + m_bstrPrpString.CopyTo( pVal ); + return S_OK; +} + +STDMETHODIMP CBasic::put_prpString(BSTR newVal) +{ + m_bstrPrpString= newVal; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpFloat(float *pVal) +{ + if( !pVal) + return E_POINTER; + *pVal= m_fPrpFloat; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpFloat(float newVal) +{ + m_fPrpFloat= newVal; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpDouble(double *pVal) +{ + if( !pVal) + return E_POINTER; + *pVal= m_dPrpDouble; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpDouble(double newVal) +{ + m_dPrpDouble= newVal; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpVariant(VARIANT *pVal) +{ + if( !pVal) + return E_POINTER; + HRESULT hr = S_OK; + if (FAILED(hr = VariantCopy( pVal, &m_PropVariant))) + return hr; + return hr; +} + +STDMETHODIMP CBasic::put_prpVariant(VARIANT newVal) +{ + m_PropVariant= newVal; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpArray(LPSAFEARRAY *pVal) +{ + if( !pVal) + return E_POINTER; + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayCopy( m_PrpArray, pVal))) + return hr; + return hr; +} + +STDMETHODIMP CBasic::put_prpArray(LPSAFEARRAY newVal) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy( m_PrpArray))) + return hr; + if (FAILED(hr = SafeArrayCopy( newVal, &m_PrpArray))) + return hr; + return hr; +} + +STDMETHODIMP CBasic::get_prpObject(IDispatch **pVal) +{ + if( !pVal) + return E_POINTER; + *pVal= m_PrpObject; + if( *pVal != NULL) + (*pVal)->AddRef(); + return S_OK; +} + +STDMETHODIMP CBasic::put_prpObject(IDispatch *newVal) +{ + m_PrpObject= newVal; + return S_OK; +} + +STDMETHODIMP CBasic::mixed1( + /* [out][in] */ unsigned char *aChar, + /* [out][in] */ float *aFloat, + /* [out][in] */ VARIANT *aVar) + +{ + HRESULT hr= S_OK; + inoutByte(aChar); + inoutFloat(aFloat); + inoutVariant(aVar); + return hr; +} + + + + +// VT_UI1 + +STDMETHODIMP CBasic::inSequenceLong(LPSAFEARRAY val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_arLong))) + return hr; + if (FAILED(hr = SafeArrayCopy(val, & m_arLong))) + return hr; + return hr; +} + +STDMETHODIMP CBasic::inSequenceByte( LPSAFEARRAY val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_arByte))) + return hr; + if (FAILED(hr = SafeArrayCopy(val, & m_arByte))) + return hr; + return hr; +} + +STDMETHODIMP CBasic::inSequenceShort(LPSAFEARRAY val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_arShort))) + return hr; + if (FAILED(hr = SafeArrayCopy(val, & m_arShort))) + return hr; + return hr; +} + +STDMETHODIMP CBasic::inSequenceString(LPSAFEARRAY val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_arString))) + return hr; + if (FAILED(hr = SafeArrayCopy(val, & m_arString))) + return hr; + return hr; +} + +STDMETHODIMP CBasic::inSequenceFloat(LPSAFEARRAY val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_arFloat))) + return hr; + if (FAILED(hr = SafeArrayCopy(val, & m_arFloat))) + return hr; + return hr; +} + +STDMETHODIMP CBasic::inSequenceDouble(LPSAFEARRAY val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_arDouble))) + return hr; + if (FAILED(hr = SafeArrayCopy(val, & m_arDouble))) + return hr; + return hr; +} + +STDMETHODIMP CBasic::inSequenceObject(LPSAFEARRAY val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_arObject))) + return hr; + if (FAILED(hr = SafeArrayCopy(val, & m_arObject))) + return hr; + return hr; +} + +void CBasic::printArray( LPSAFEARRAY val, BSTR message, VARTYPE type) +{ + + HRESULT hr= S_OK; + USES_CONVERSION; + long lbound=0; + long ubound= 0; + hr= SafeArrayGetLBound( val, 1, &lbound); + hr= SafeArrayGetUBound( val, 1, &ubound); + long length= ubound - lbound +1; + + CComVariant varElement; + char buf[1024]; + sprintf( buf,"%s", W2A(message)); + + for( long i= 0; i < length ; i++) + { + char tmp[1024]; + long data=0; + CComVariant var; + switch( type) + { + case VT_UI1: + case VT_I2: + case VT_I4: + case VT_ERROR: + hr= SafeArrayGetElement( val, &i, (void*)&data); + sprintf( tmp, "%ld \n", *(long*)&data); + break; + case VT_BSTR: + hr= SafeArrayGetElement( val, &i, (void*)&data); + sprintf( tmp, "%S \n", (BSTR)data); + break; + case VT_VARIANT: + hr= SafeArrayGetElement( val, &i, &var); + sprintf( tmp, "%x \n", var.byref); + break; + case VT_R4: + hr= SafeArrayGetElement( val, &i, (void*)&data); + sprintf( tmp, "%f \n", *(float*) &data); + break; + case VT_R8: ; + hr= SafeArrayGetElement( val, &i, (void*)&data); + sprintf( tmp, "%f \n", *(double*) &data); + break; + case VT_DISPATCH: + // we assume the objects are instances of this component and have the + // property prpString set. + hr= SafeArrayGetElement( val, &i, (void*)&data); + IDispatch* pdisp= ( IDispatch*) data; + CComDispatchDriver driver( pdisp); + CComVariant var; + if( pdisp) + { + driver.GetPropertyByName(L"prpString", &var); + sprintf( tmp, "%x : %S \n", *(long*)&data, var.bstrVal); + } + else + sprintf( tmp, "%x\n", *(long*)&data); + } + + strcat( buf, tmp); + } + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + +} +// V_ERROR OLECHAR VARIANT VT_UI1 + +STDMETHODIMP CBasic::outSequenceByte(LPSAFEARRAY* val) +{ + HRESULT hr= S_OK; + hr = SafeArrayCopy(m_arByte, val); + return hr; +} + +STDMETHODIMP CBasic::outSequenceShort(LPSAFEARRAY* val) +{ + HRESULT hr= S_OK; + hr = SafeArrayCopy(m_arShort, val); + return hr; +} + +STDMETHODIMP CBasic::outSequenceLong(LPSAFEARRAY* val) +{ + HRESULT hr= S_OK; + hr = SafeArrayCopy(m_arLong, val); + return hr; +} + +STDMETHODIMP CBasic::outSequenceString(LPSAFEARRAY* val) +{ + HRESULT hr= S_OK; + hr = SafeArrayCopy(m_arString, val); + return hr; +} + +STDMETHODIMP CBasic::outSequenceFloat(LPSAFEARRAY* val) +{ + HRESULT hr= S_OK; + hr = SafeArrayCopy(m_arFloat, val); + return hr; +} + +STDMETHODIMP CBasic::outSequenceDouble(LPSAFEARRAY* val) +{ + HRESULT hr= S_OK; + hr = SafeArrayCopy(m_arDouble, val); + return hr; +} + +STDMETHODIMP CBasic::outSequenceObject(LPSAFEARRAY* val) +{ + HRESULT hr = S_OK; + hr = SafeArrayCopy(m_arObject, val); + return S_OK; +} + +STDMETHODIMP CBasic::inoutSequenceByte(LPSAFEARRAY* val) +{ + HRESULT hr = S_OK; + SAFEARRAY *arTemp = NULL; + if (FAILED(hr = SafeArrayCopy(*val, &arTemp))) + return hr; + if (FAILED(hr = SafeArrayCopy(m_arByte, val))) + return hr; + m_arByte = arTemp; + return hr; +} + +STDMETHODIMP CBasic::inoutSequenceShort(LPSAFEARRAY* val) +{ + HRESULT hr = S_OK; + SAFEARRAY *arTemp = NULL; + if (FAILED(hr = SafeArrayCopy(*val, &arTemp))) + return hr; + if (FAILED(hr = SafeArrayCopy(m_arShort, val))) + return hr; + m_arShort = arTemp; + return hr; +} + +STDMETHODIMP CBasic::inoutSequenceLong(LPSAFEARRAY* val) +{ + HRESULT hr = S_OK; + SAFEARRAY *arTemp = NULL; + if (FAILED(hr = SafeArrayCopy(*val, &arTemp))) + return hr; + if (FAILED(hr = SafeArrayCopy(m_arLong, val))) + return hr; + m_arLong = arTemp; + return hr; +} + +STDMETHODIMP CBasic::inoutSequenceString(LPSAFEARRAY* val) +{ + HRESULT hr = S_OK; + SAFEARRAY *arTemp = NULL; + if (FAILED(hr = SafeArrayCopy(*val, &arTemp))) + return hr; + if (FAILED(hr = SafeArrayCopy(m_arString, val))) + return hr; + m_arString = arTemp; + return hr; +} + +STDMETHODIMP CBasic::inoutSequenceFloat(LPSAFEARRAY* val) +{ + HRESULT hr = S_OK; + SAFEARRAY *arTemp = NULL; + if (FAILED(hr = SafeArrayCopy(*val, &arTemp))) + return hr; + if (FAILED(hr = SafeArrayCopy(m_arFloat, val))) + return hr; + m_arFloat = arTemp; + return hr; +} + +STDMETHODIMP CBasic::inoutSequenceDouble(LPSAFEARRAY* val) +{ + HRESULT hr = S_OK; + SAFEARRAY *arTemp = NULL; + if (FAILED(hr = SafeArrayCopy(*val, &arTemp))) + return hr; + if (FAILED(hr = SafeArrayCopy(m_arDouble, val))) + return hr; + m_arDouble = arTemp; + return hr; +} + +STDMETHODIMP CBasic::inoutSequenceObject(LPSAFEARRAY* val) +{ + HRESULT hr = S_OK; + SAFEARRAY *arTemp = NULL; + if (FAILED(hr = SafeArrayCopy(*val, &arTemp))) + return hr; + if (FAILED(hr = SafeArrayCopy(m_arObject, val))) + return hr; + m_arObject = arTemp; + return hr; +} + +// 2-dimensional Array +STDMETHODIMP CBasic::inMulDimArrayLong(LPSAFEARRAY val) +{ + printMulArray( val, VT_I4); + return S_OK; +} +// 2-dimensional Array +STDMETHODIMP CBasic::inMulDimArrayVariant(LPSAFEARRAY val) +{ + printMulArray( val, VT_VARIANT); + return S_OK; +} +// 3-dimensional Array +STDMETHODIMP CBasic::inMulDimArrayLong2(LPSAFEARRAY val) +{ + printMulArray( val, VT_I4); + return S_OK; +} +// 3-dimensional Array +STDMETHODIMP CBasic::inMulDimArrayVariant2(LPSAFEARRAY val) +{ + return S_OK; +} + + +STDMETHODIMP CBasic::inMulDimArrayByte(LPSAFEARRAY val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_arByteDim2))) + return hr; + if (FAILED(hr = SafeArrayCopy(val, & m_arByteDim2))) + return hr; + return hr; +} +// 3-dimensionales array +STDMETHODIMP CBasic::inMulDimArrayByte2(LPSAFEARRAY val) +{ + + // TODO: Add your implementation code here + //printMulArray( val, VT_UI1); + return S_OK; +} + +// supports 2 and 3 dimensional SAFEARRAY with elements of long or VARIANT +void CBasic::printMulArray( SAFEARRAY* val, VARTYPE type) +{ + HRESULT hr= S_OK; + UINT dims= SafeArrayGetDim( val); + long lbound1; + long ubound1; + long lbound2; + long ubound2; + long lbound3; + long ubound3; + long length1; + long length2; + + char buff[4096]; + buff[0]=0; + + if( dims == 2) + { + hr= SafeArrayGetLBound( val, 1, &lbound1); + hr= SafeArrayGetUBound( val, 1, &ubound1); + length1= ubound1 - lbound1 +1; + + hr= SafeArrayGetLBound( val, 2, &lbound2); + hr= SafeArrayGetUBound( val, 2, &ubound2); + length2= ubound2 - lbound2 + 1; + char tmpBuf[1024]; + tmpBuf[0]=0; + long index[2]; + for( long i= 0; i< length2; i++) + { + for( long j= 0; jvt != VT_ERROR) + m_var1 = *val2; + return S_OK; +} + +STDMETHODIMP CBasic::optional2(/*[out]*/ long* val1,/*[out, optional]*/ VARIANT* val2) +{ + HRESULT hr = S_OK; + *val1 = m_long; + + if (val2->vt != VT_ERROR) + hr = VariantCopy(val2, & m_var1); + return hr; +} + +STDMETHODIMP CBasic::optional3(/*[in, optional]*/ VARIANT* val1,/*[in, optional]*/ VARIANT* val2) +{ + //if (val1->vt != VT_ERROR) + m_var1 = *val1; + + //if (val2->vt != VT_ERROR) + m_var2 = *val2; + return S_OK; +} + +STDMETHODIMP CBasic::optional4(/*[in, out, optional]*/ VARIANT* val1, + /*[in, out, optional]*/ VARIANT* val2) +{ + HRESULT hr = S_OK; + //return the previously set in values + if (val1->vt != VT_ERROR) + { + CComVariant var1(*val1); + if (FAILED(hr = VariantCopy(val1, & m_var1))) + return hr; + m_var1 = var1; + } + if (val2->vt != VT_ERROR) + { + CComVariant var2(*val2); + if (FAILED(hr = VariantCopy(val2, & m_var2))) + return hr; + m_var2 = var2; + } + return hr; +} + +STDMETHODIMP CBasic::optional5(/*[out, optional]*/ VARIANT* val1, + /*[out, optional]*/ VARIANT* val2) +{ + HRESULT hr = S_OK; + if (FAILED(hr = VariantCopy(val1, &m_var1))) + return hr; + if (FAILED(hr = VariantCopy(val2, &m_var2))) + return hr; + return hr; +} + +STDMETHODIMP CBasic::defaultvalue1(/*[in, defaultvalue(10)]*/ long val1, + /*[in, defaultvalue(3.14)]*/ double* val2, + // /*[in, defaultvalue(10)]*/ VARIANT val3, + /*[in, defaultvalue(100)]*/ VARIANT* val4) +{ + m_long = val1; + m_double = *val2; +// m_var1 = val3; + m_var2 = *val4; + return S_OK; +} +STDMETHODIMP CBasic::defaultvalue2(/*[in, out, defaultvalue(10)]*/ long* val1, + /*[in, out, defaultvalue(3.14)]*/ double* val2, + // /*[in, out, defaultvalue(10)]*/ VARIANT* val3, + /*[in, out, defaultvalue(100)]*/ VARIANT* val4) +{ + HRESULT hr = S_OK; + long aLong = *val1; + double aDouble = *val2; +// CComVariant var1(*val3); + CComVariant var2(*val4); + *val1 = m_long; + *val2 = m_double; + //if (FAILED(hr = VariantCopy(val3, &m_var1))) + // return hr; + if (FAILED(hr = VariantCopy(val4, &m_var2))) + return hr; + m_long = aLong; + m_double = aDouble; +// m_var1 = var1; + m_var2 = var2; + return hr; +} +/* val2 contains the variable argument list. If no such arguments are supplied + then the safearray is invalid. SafeArrayCopy then returns E_INVALIDARG +*/ +STDMETHODIMP CBasic::varargfunc1(/*[in]*/ long val1,/*[in]*/ LPSAFEARRAY val2) +{ + m_long = val1; + + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_safearray))) + return hr; + if (FAILED(hr = SafeArrayCopy(val2, & m_safearray))) + { + if (hr != E_INVALIDARG) + return hr; + } + return S_OK; +} + +STDMETHODIMP CBasic::varargfunc2(/*[out]*/ long* val1, /*[out]*/ SAFEARRAY ** val2) +{ + *val1 = m_long; + HRESULT hr = SafeArrayCopy(m_safearray, val2); + return hr; +} + +STDMETHODIMP CBasic::inSequenceByteDim2(LPSAFEARRAY val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = SafeArrayDestroy(m_arByteDim2))) + return hr; + if (FAILED(hr = SafeArrayCopy(val, & m_arByteDim2))) + return hr; + return hr; +} + + +STDMETHODIMP CBasic::inCurrency(CY val) +{ + m_cy = val; + return S_OK; +} + +STDMETHODIMP CBasic::outCurrency(CY* val) +{ + *val = m_cy; + return S_OK; +} + +STDMETHODIMP CBasic::inoutCurrency(CY* val) +{ + CY tmp = *val; + *val = m_cy; + m_cy = tmp; + return S_OK; +} + +STDMETHODIMP CBasic::inDate(DATE val) +{ + m_date = val; + return S_OK; +} + +STDMETHODIMP CBasic::outDate(DATE* val) +{ + *val = m_date; + return S_OK; +} + +STDMETHODIMP CBasic::inoutDate(DATE* val) +{ + DATE tmp = *val; + *val = m_date; + m_date = tmp; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpCurrency(CY* pVal) +{ + *pVal = m_cy; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpCurrency(CY newVal) +{ + m_cy = newVal; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpDate(DATE* pVal) +{ + *pVal = m_date; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpDate(DATE newVal) +{ + m_date = newVal; + return S_OK; +} + +//VT_I4 DECIMAL_NEG //tagVARIANT DISPATCH_PROPERTYPUT +STDMETHODIMP CBasic::inDecimal(DECIMAL val) +{ + m_decimal = val; + return S_OK; +} + +STDMETHODIMP CBasic::outDecimal(DECIMAL* val) +{ + * val = m_decimal; + return S_OK; +} + +STDMETHODIMP CBasic::inoutDecimal(DECIMAL* val) +{ + DECIMAL tmp; + tmp = * val; + * val = m_decimal; + m_decimal = tmp; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpDecimal(DECIMAL* pVal) +{ + * pVal = m_decimal; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpDecimal(DECIMAL newVal) +{ + m_decimal = newVal; + return S_OK; +} + +STDMETHODIMP CBasic::inSCode(SCODE val) +{ + m_scode = val; + return S_OK; +} + +STDMETHODIMP CBasic::outScode(SCODE* val) +{ + * val = m_scode; + return S_OK; +} + +STDMETHODIMP CBasic::inoutSCode(SCODE* val) +{ + SCODE tmp = *val; + * val = m_scode; + m_scode = tmp; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpSCode(SCODE* pVal) +{ + * pVal = m_scode; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpSCode(SCODE newVal) +{ + m_scode = newVal; + return S_OK; +} + +STDMETHODIMP CBasic::inrefLong(LONG* val) +{ + m_long = * val; + return S_OK; +} + +STDMETHODIMP CBasic::inrefVariant(VARIANT* val) +{ + HRESULT hr = S_OK; + if (FAILED(hr = VariantCopy( & m_var1, val))) + return hr; + return S_OK; +} + +STDMETHODIMP CBasic::inrefDecimal(DECIMAL* val) +{ + m_decimal = * val; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpRefLong(long* pVal) +{ + *pVal = m_long; + return S_OK; +} + +STDMETHODIMP CBasic::putref_prpRefLong(long* newVal) +{ + m_long = * newVal; + return S_OK; +} + +STDMETHODIMP CBasic::get_prprefVariant(VARIANT* pVal) +{ + HRESULT hr = S_OK; + hr = VariantCopy(pVal, & m_var1); + return hr; +} + +STDMETHODIMP CBasic::putref_prprefVariant(VARIANT* newVal) +{ + m_var1 = * newVal; + return S_OK; +} + +STDMETHODIMP CBasic::get_prprefDecimal(DECIMAL* pVal) +{ + * pVal = m_decimal; + return S_OK; +} + +STDMETHODIMP CBasic::putref_prprefDecimal(DECIMAL* newVal) +{ + m_decimal = *newVal; + return S_OK; +} + + +STDMETHODIMP CBasic::optional6(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4) +{ + HRESULT hr = S_OK; + if (FAILED(hr = m_var1.Copy(val1))) + return hr; + if (FAILED(hr = m_var2.Copy(val2))) + return hr; + if (FAILED(hr = m_var3.Copy(val3))) + return hr; + if (FAILED(hr = m_var4.Copy(val4))) + return hr; + return S_OK; +} + +STDMETHODIMP CBasic::optional7(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4) +{ + HRESULT hr = S_OK; + if (FAILED(hr = VariantCopy(val1, & m_var1))) + return hr; + if (FAILED(hr = VariantCopy(val2, & m_var2))) + return hr; + if (FAILED(hr = VariantCopy(val3, & m_var3))) + return hr; + if (FAILED(hr = VariantCopy(val4, & m_var4))) + return hr; + + return S_OK; +} + +STDMETHODIMP CBasic::get_prpMultiArg1(VARIANT* val1, VARIANT* val2, VARIANT* pVal) +{ + HRESULT hr = S_OK; + CComVariant tmp1(*val1); + CComVariant tmp2(*val2); + + if (FAILED(hr = VariantCopy(val1, & m_var1))) + return hr; + if (FAILED(hr = VariantCopy(val2, & m_var2))) + return hr; + m_var1 = tmp1; + m_var2 = tmp2; + if (FAILED(hr = VariantCopy(pVal, & m_var3))) + return hr; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpMultiArg1(VARIANT* val1, VARIANT* val2, VARIANT* newVal) +{ + HRESULT hr = S_OK; + CComVariant tmp1( * val1); + CComVariant tmp2( * val2); + + if (FAILED(hr = VariantCopy(val1, & m_var1))) + return hr; + if (FAILED(hr = VariantCopy(val2, & m_var2))) + return hr; + m_var1 = tmp1; + m_var2 = tmp2; + + m_var3 = *newVal; + return S_OK; +} + +// tagVARIANT DISPATCH_PROPERTYPUT DISPID_PROPERTYPUT VARIANTARG LOCALE_USER_DEFAULT + +STDMETHODIMP CBasic::get_prpMultiArg2(VARIANT val1, VARIANT* pVal) +{ + HRESULT hr = S_OK; + m_var1 = val1; + + if (FAILED(hr = VariantCopy(pVal, & m_var2))) + return hr; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpMultiArg2(VARIANT val1, VARIANT newVal) +{ + m_var1 = val1; + m_var2 = newVal; + return S_OK; +} + +// returns the values set by prpMultiArg2 +STDMETHODIMP CBasic::prpMultiArg2GetValues(VARIANT* val1, VARIANT* valProperty) +{ + HRESULT hr = S_OK; + if (FAILED(VariantCopy(val1, & m_var1))) + return hr; + if (FAILED(VariantCopy(valProperty, & m_var2))) + return hr; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpMultiArg3(LONG* val1, LONG* pVal) +{ + long aLong = *val1; + *val1 = m_long; + m_long = aLong; + + * pVal = m_long2; + return S_OK; +} + +STDMETHODIMP CBasic::put_prpMultiArg3(LONG* val1, LONG newVal) +{ + long aLong = *val1; + *val1 = m_long; + m_long = aLong; + + m_long2 = newVal; + return S_OK; +} + +STDMETHODIMP CBasic::inUnknown(IUnknown* val) +{ + m_unknown = val; + + return S_OK; +} + +STDMETHODIMP CBasic::outUnknown(IUnknown** val) +{ + m_unknown.CopyTo(val); + return S_OK; +} + +STDMETHODIMP CBasic::inoutUnknown(IUnknown** val) +{ + CComPtr tmp = *val; + m_unknown.CopyTo(val); + m_unknown = tmp; + return S_OK; +} + +STDMETHODIMP CBasic::get_prpUnknown(IUnknown** pVal) +{ + m_prpUnknown.CopyTo(pVal); + return S_OK; +} + +STDMETHODIMP CBasic::put_prpUnknown(IUnknown* newVal) +{ + m_prpUnknown = newVal; + return S_OK; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/AxTestComponents/Basic.h b/extensions/test/ole/AxTestComponents/Basic.h new file mode 100644 index 000000000..eec04aa08 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/Basic.h @@ -0,0 +1,259 @@ +/* -*- 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 . + */ +// Basic.h : Declaration of the CBasic + +#ifndef __BASIC_H_ +#define __BASIC_H_ + +#include "resource.h" +#import "AxTestComponents.tlb" no_namespace no_implementation raw_interfaces_only named_guids + + +// CBasic +class ATL_NO_VTABLE CBasic : + public CComObjectRootEx, + public CComCoClass, + public IDispatchImpl + { +public: + CBasic(); + ~CBasic(); + + DECLARE_REGISTRY_RESOURCEID(IDR_BASIC) + + DECLARE_PROTECT_FINAL_CONSTRUCT() + + BEGIN_COM_MAP(CBasic) + COM_INTERFACE_ENTRY(IBasic) + COM_INTERFACE_ENTRY(IDispatch) + END_COM_MAP() + + // IBasic +public: + STDMETHOD(outMore)(/*[out]*/long* val1, /*[out]*/long* val2); + STDMETHOD(inMulDimArrayByte2)(LPSAFEARRAY val); + STDMETHOD(inMulDimArrayByte)(LPSAFEARRAY val); + STDMETHOD(inMulDimArrayVariant2)(LPSAFEARRAY val); + STDMETHOD(inMulDimArrayLong2)(LPSAFEARRAY val); + STDMETHOD(inMulDimArrayVariant)(LPSAFEARRAY val); + STDMETHOD(inMulDimArrayLong)( LPSAFEARRAY val); + STDMETHOD(inoutSequenceObject)(LPSAFEARRAY* val); + STDMETHOD(inoutSequenceDouble)(LPSAFEARRAY * val); + STDMETHOD(inoutSequenceFloat)(LPSAFEARRAY * val); + STDMETHOD(inoutSequenceString)(LPSAFEARRAY* val); + STDMETHOD(inoutSequenceLong)(LPSAFEARRAY * val); + STDMETHOD(inoutSequenceShort)(LPSAFEARRAY * val); + STDMETHOD(inoutSequenceByte)(LPSAFEARRAY * val); + STDMETHOD(outSequenceObject)(/*[out]*/ LPSAFEARRAY* val); + STDMETHOD(outSequenceDouble)(/*[out]*/ LPSAFEARRAY* val); + STDMETHOD(outSequenceFloat)(/*[out]*/ LPSAFEARRAY* val); + STDMETHOD(outSequenceString)(/*[out]*/ LPSAFEARRAY* val); + STDMETHOD(outSequenceLong)(/*[out]*/ LPSAFEARRAY* val); + STDMETHOD(outSequenceShort)(/*[out]*/ LPSAFEARRAY* val); + STDMETHOD(outSequenceByte)(/*[out]*/ LPSAFEARRAY* val); + STDMETHOD(inSequenceObject)(LPSAFEARRAY ar); + STDMETHOD(inSequenceDouble)(LPSAFEARRAY ar); + STDMETHOD(inSequenceFloat)(LPSAFEARRAY ar); + STDMETHOD(inSequenceString)(LPSAFEARRAY ar); + STDMETHOD(inSequenceShort)(LPSAFEARRAY ar); + STDMETHOD(inSequenceByte)(LPSAFEARRAY ar); + STDMETHOD(inSequenceLong)(LPSAFEARRAY ar); + STDMETHOD(mixed1)( + /* [out][in] */ unsigned char *aChar, + /* [out][in] */ float *aFloat, + /* [out][in] */ VARIANT *aVar); + STDMETHOD(get_prpObject)(/*[out, retval]*/ IDispatch* *pVal); + STDMETHOD(put_prpObject)(/*[in]*/ IDispatch* newVal); + STDMETHOD(get_prpArray)(/*[out, retval]*/ LPSAFEARRAY *pVal); + STDMETHOD(put_prpArray)(/*[in]*/ LPSAFEARRAY newVal); + STDMETHOD(get_prpVariant)(/*[out, retval]*/ VARIANT *pVal); + STDMETHOD(put_prpVariant)(/*[in]*/ VARIANT newVal); + STDMETHOD(get_prpDouble)(/*[out, retval]*/ double *pVal); + STDMETHOD(put_prpDouble)(/*[in]*/ double newVal); + STDMETHOD(get_prpFloat)(/*[out, retval]*/ float *pVal); + STDMETHOD(put_prpFloat)(/*[in]*/ float newVal); + STDMETHOD(get_prpString)(/*[out, retval]*/ BSTR *pVal); + STDMETHOD(put_prpString)(/*[in]*/ BSTR newVal); + STDMETHOD(get_prpLong)(/*[out, retval]*/ long *pVal); + STDMETHOD(put_prpLong)(/*[in]*/ long newVal); + STDMETHOD(get_prpShort)(/*[out, retval]*/ short *pVal); + STDMETHOD(put_prpShort)(/*[in]*/ short newVal); + STDMETHOD(get_prpByte)(/*[out, retval]*/ unsigned char *pVal); + STDMETHOD(put_prpByte)(/*[in]*/ unsigned char newVal); + STDMETHOD(get_prpBool)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_prpBool)(/*[in]*/ VARIANT_BOOL newVal); + + STDMETHOD(outObject)(/*[out]*/ IDispatch* *val); + STDMETHOD(outArray)(/*[out]*/ LPSAFEARRAY * val); + STDMETHOD(outVariant)(/*[out]*/ VARIANT* val); + STDMETHOD(outDouble)(/*[out]*/ double* val); + STDMETHOD(outFloat)(/*[out]*/ float* val); + STDMETHOD(outString)(/*[out]*/ BSTR* val); + STDMETHOD(outLong)(/*[out]*/ long* val); + STDMETHOD(outShort)(/*[out]*/ short* val); + STDMETHOD(outByte)(/*[out]*/ unsigned char* val); + STDMETHOD(outBool)(/*[out]*/ VARIANT_BOOL* val); + + STDMETHOD(inoutObject)(/*[in,out]*/ IDispatch* *val); + STDMETHOD(inoutArray)(/*[in,out]*/ LPSAFEARRAY * val); + STDMETHOD(inoutVariant)(/*[in,out]*/ VARIANT * val); + STDMETHOD(inoutDouble)(/*[in,out]*/ double * val); + STDMETHOD(inoutFloat)(/*[in,out]*/ float * val); + STDMETHOD(inoutString)(/*[in, out]*/ BSTR* val); + STDMETHOD(inoutLong)(/*[in,out]*/ long * val); + STDMETHOD(inoutShort)(/*[in,out]*/ short* val); + STDMETHOD(inoutByte)(/*[in,out]*/ unsigned char* val); + STDMETHOD(inoutBool)(/*[in,out]*/ VARIANT_BOOL* val); + + + STDMETHOD(inObject)(/*[in]*/ IDispatch* val); + STDMETHOD(inArray)(/*[in]*/ LPSAFEARRAY val); + STDMETHOD(inVariant)(/*[in]*/ VARIANT val); + STDMETHOD(inDouble)(/*[in]*/ double val); + STDMETHOD(inFloat)(/*[in]*/ float val); + STDMETHOD(inString)(/*[in]*/ BSTR val); + STDMETHOD(inLong)(/*[in]*/ long val); + STDMETHOD(inShort)(/*[in]*/ short val); + STDMETHOD(inByte)(/*[in]*/ unsigned char val); + STDMETHOD(inBool)(/*[in]*/ VARIANT_BOOL val); + + + STDMETHOD(optional1)(/*[in]*/ long val1, /*[in, optional]*/ VARIANT* val2); + STDMETHOD(optional2)(/*[out]*/ long* val1,/*[out, optional]*/ VARIANT* val2); + STDMETHOD(optional3)(/*[in, optional]*/ VARIANT* val1,/*[in, optional]*/ VARIANT* val2); + STDMETHOD(optional4)(/*[in, out, optional]*/ VARIANT* val1,/*[in, out, optional]*/ VARIANT* val2); + STDMETHOD(optional5)(/*[out, optional]*/ VARIANT* val1,/*[out, optional]*/ VARIANT* val2); + + + STDMETHOD(defaultvalue1)(/*[in, defaultvalue(10)]*/ long val1, + /*[in, defaultvalue(3.14)]*/ double* val2, + /*[in, defaultvalue(100)]*/ VARIANT* val4); + + STDMETHOD(defaultvalue2)(/*[in, out, defaultvalue(10)]*/ long* val1, + /*[in, out, defaultvalue(3.14)]*/ double* val2, + /*[in, out, defaultvalue(100)]*/ VARIANT* val4); + + STDMETHOD(varargfunc1)(/*[in]*/ long val1,/*[in]*/ LPSAFEARRAY val2); + + STDMETHOD(varargfunc2)(/*[out]*/ long* val1, /*[out]*/ SAFEARRAY ** val2); + + + // members for property implementations + unsigned char m_cPrpByte; + short m_nPrpShort; + long m_lPrpLong; + float m_fPrpFloat; + double m_dPrpDouble; + CComPtr m_PrpObject; + CComPtr m_prpUnknown; + + CComBSTR m_bstrPrpString; + CComVariant m_PropVariant; + LPSAFEARRAY m_PrpArray; +protected: + VARIANT_BOOL m_bool; + unsigned char m_byte; + short m_short; + long m_long; + long m_long2; + float m_float; + double m_double; + CComVariant m_var1; + CComVariant m_var2; + CComVariant m_var3; + CComVariant m_var4; + CComBSTR m_bstr; + CY m_cy; + DATE m_date; + DECIMAL m_decimal; + SCODE m_scode; + SAFEARRAY * m_safearray; + CComPtr m_obj; + CComPtr m_unknown; + + SAFEARRAY * m_arByte; + SAFEARRAY * m_arShort; + SAFEARRAY * m_arLong; + SAFEARRAY * m_arString; + SAFEARRAY * m_arVariant; + SAFEARRAY * m_arFloat; + SAFEARRAY * m_arDouble; + SAFEARRAY * m_arObject; + SAFEARRAY * m_arByteDim2; + + static void printArray(LPSAFEARRAY val, BSTR message, VARTYPE type); + static void printMulArray(LPSAFEARRAY val, VARTYPE type); + + +public: + STDMETHOD(inSequenceByteDim2)(LPSAFEARRAY val); + STDMETHOD(inCurrency)(CY val); + STDMETHOD(outCurrency)(CY* val); + STDMETHOD(inoutCurrency)(CY* val); + STDMETHOD(inDate)(DATE val); + STDMETHOD(outDate)(DATE* val); + STDMETHOD(inoutDate)(DATE* val); + STDMETHOD(get_prpCurrency)(CY* pVal); + STDMETHOD(put_prpCurrency)(CY newVal); + STDMETHOD(get_prpDate)(DATE* pVal); + STDMETHOD(put_prpDate)(DATE newVal); + STDMETHOD(inDecimal)(DECIMAL val); + STDMETHOD(outDecimal)(DECIMAL* val); + STDMETHOD(inoutDecimal)(DECIMAL* val); + STDMETHOD(get_prpDecimal)(DECIMAL* pVal); + STDMETHOD(put_prpDecimal)(DECIMAL newVal); + STDMETHOD(inSCode)(SCODE val); + STDMETHOD(outScode)(SCODE* val); + STDMETHOD(inoutSCode)(SCODE* val); + STDMETHOD(get_prpSCode)(SCODE* pVal); + STDMETHOD(put_prpSCode)(SCODE newVal); + STDMETHOD(inrefLong)(LONG* val); + STDMETHOD(inrefVariant)(VARIANT* val); + STDMETHOD(inrefDecimal)(DECIMAL* val); + STDMETHOD(get_prpRefLong)(long* pVal); + STDMETHOD(putref_prpRefLong)(long* newVal); + STDMETHOD(get_prprefVariant)(VARIANT* pVal); + STDMETHOD(putref_prprefVariant)(VARIANT* newVal); + STDMETHOD(get_prprefDecimal)(DECIMAL* pVal); + STDMETHOD(putref_prprefDecimal)(DECIMAL* newVal); + STDMETHOD(optional6)(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4); + STDMETHOD(optional7)(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4); + + STDMETHOD(get_prpMultiArg1)(VARIANT* val1, VARIANT* val2, VARIANT* pVal); + //STDMETHOD(get_prpMultiArg1)(VARIANT* val1, VARIANT* pVal); + STDMETHOD(put_prpMultiArg1)(VARIANT* val1, VARIANT* val2, VARIANT* newVal); + //STDMETHOD(put_prpMultiArg1)(VARIANT* val1, VARIANT* newVal); + STDMETHOD(get_prpMultiArg2)(VARIANT val1, VARIANT* pVal); + STDMETHOD(put_prpMultiArg2)(VARIANT val1, VARIANT newVal); + STDMETHOD(prpMultiArg2GetValues)(VARIANT* val1, VARIANT* valProperty); + STDMETHOD(get_prpMultiArg3)(LONG* val1, LONG* pVal); + STDMETHOD(put_prpMultiArg3)(LONG* val1, LONG newVal); + + // IFoo Methods +public: + STDMETHOD(inUnknown)(IUnknown* val); + STDMETHOD(outUnknown)(IUnknown** val); + STDMETHOD(inoutUnknown)(IUnknown** val); + STDMETHOD(get_prpUnknown)(IUnknown** pVal); + STDMETHOD(put_prpUnknown)(IUnknown* newVal); +}; + +#endif //__BASIC_H_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/AxTestComponents/Basic.rgs b/extensions/test/ole/AxTestComponents/Basic.rgs new file mode 100644 index 000000000..67fa86008 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/Basic.rgs @@ -0,0 +1,50 @@ +HKCR +{ + AxTestComponents.Basic.1 = s 'Basic Class' + { + CLSID = s '{BFE10EBE-8584-11D4-8335-005004526AB4}' + } + AxTestComponents.Basic = s 'Basic Class' + { + CLSID = s '{BFE10EBE-8584-11D4-8335-005004526AB4}' + CurVer = s 'AxTestComponents.Basic.1' + } + NoRemove CLSID + { + ForceRemove {BFE10EBE-8584-11D4-8335-005004526AB4} = s 'Basic Class' + { + ProgID = s 'AxTestComponents.Basic.1' + VersionIndependentProgID = s 'AxTestComponents.Basic' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{BFE10EB1-8584-11D4-8335-005004526AB4}' + } + } + AxTestComponents.Foo.1 = s 'Foo Class' + { + CLSID = s '{14DE9D5D-EB9D-4091-8E1B-A1B1672D8C1D}' + } + AxTestComponents.Foo = s 'Foo Class' + { + CLSID = s '{14DE9D5D-EB9D-4091-8E1B-A1B1672D8C1D}' + CurVer = s 'AxTestComponents.Foo.1' + } + NoRemove CLSID + { + ForceRemove {14DE9D5D-EB9D-4091-8E1B-A1B1672D8C1D} = s 'Foo Class' + { + ProgID = s 'AxTestComponents.Foo.1' + VersionIndependentProgID = s 'AxTestComponents.Foo' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{BFE10EB1-8584-11D4-8335-005004526AB4}' + } + } + +} diff --git a/extensions/test/ole/AxTestComponents/Foo.cpp b/extensions/test/ole/AxTestComponents/Foo.cpp new file mode 100644 index 000000000..9faefd393 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/Foo.cpp @@ -0,0 +1,30 @@ +/* -*- 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 "stdafx.h" +#include "Foo.h" + +// CBasic +CFoo::CFoo() {} + +CFoo::~CFoo() {} + +STDMETHODIMP CFoo::Foo(IUnknown* pVal) { return S_OK; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/AxTestComponents/Foo.h b/extensions/test/ole/AxTestComponents/Foo.h new file mode 100644 index 000000000..3d0dc5bb5 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/Foo.h @@ -0,0 +1,54 @@ +/* -*- 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 . + */ +// Basic.h : Declaration of the CBasic + +#pragma once + +#include "resource.h" +#import "AxTestComponents.tlb" no_namespace no_implementation raw_interfaces_only named_guids + + +// CBasic +class ATL_NO_VTABLE CFoo : + public CComObjectRootEx, + public CComCoClass, + public IFoo + +// public IDispatchImpl +{ +public: + CFoo(); + ~CFoo(); + + DECLARE_REGISTRY_RESOURCEID(IDR_BASIC) + + DECLARE_PROTECT_FINAL_CONSTRUCT() + + BEGIN_COM_MAP(CFoo) + COM_INTERFACE_ENTRY(IFoo) + END_COM_MAP() + + +STDMETHOD(Foo)(IUnknown* val); + + // IFoo Methods +public: +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/AxTestComponents/StdAfx.cpp b/extensions/test/ole/AxTestComponents/StdAfx.cpp new file mode 100644 index 000000000..71ebbdb6b --- /dev/null +++ b/extensions/test/ole/AxTestComponents/StdAfx.cpp @@ -0,0 +1,26 @@ +/* -*- 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 "stdafx.h" + +#ifdef _ATL_STATIC_REGISTRY +#include +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/AxTestComponents/StdAfx.h b/extensions/test/ole/AxTestComponents/StdAfx.h new file mode 100644 index 000000000..211943ce4 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/StdAfx.h @@ -0,0 +1,46 @@ +/* -*- 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 . + */ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#if !defined(AFX_STDAFX_H__BFE10EB4_8584_11D4_8335_005004526AB4__INCLUDED_) +#define AFX_STDAFX_H__BFE10EB4_8584_11D4_8335_005004526AB4__INCLUDED_ + +#ifdef _MSC_VER +#pragma once +#endif + +#define STRICT +#define _ATL_APARTMENT_THREADED + +#include +//You may derive a class from CComModule and use it if you want to override +//something, but do not change the name of _Module +extern CComModule _Module; +#include +#include +#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__BFE10EB4_8584_11D4_8335_005004526AB4__INCLUDED) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/AxTestComponents/readme.txt b/extensions/test/ole/AxTestComponents/readme.txt new file mode 100644 index 000000000..6f19ea610 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/readme.txt @@ -0,0 +1,3 @@ +The component does not use the AxTestComponent.h created by the midl +compiler. Instead #import is used. This is because of a bug when +using attribute "defaultvalue" in idl. diff --git a/extensions/test/ole/AxTestComponents/resource.h b/extensions/test/ole/AxTestComponents/resource.h new file mode 100644 index 000000000..e741826b5 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/resource.h @@ -0,0 +1,38 @@ +/* -*- 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 . + */ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by AxTestComponents.rc + +#define IDS_PROJNAME 100 +#define IDR_BASIC 101 +//#define IDR_FOO 501 + +// Next default values for new objects + +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_COMMAND_VALUE 32768 +#define _APS_NEXT_CONTROL_VALUE 201 +#define _APS_NEXT_SYMED_VALUE 102 +#endif +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/DCOM/Clients/WriterDemo/Module1.bas b/extensions/test/ole/DCOM/Clients/WriterDemo/Module1.bas new file mode 100644 index 000000000..88153b174 --- /dev/null +++ b/extensions/test/ole/DCOM/Clients/WriterDemo/Module1.bas @@ -0,0 +1,25 @@ +rem +rem This file is part of the LibreOffice project. +rem +rem This Source Code Form is subject to the terms of the Mozilla Public +rem License, v. 2.0. If a copy of the MPL was not distributed with this +rem file, You can obtain one at http://mozilla.org/MPL/2.0/. +rem +rem This file incorporates work covered by the following license notice: +rem +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed +rem with this work for additional information regarding copyright +rem ownership. The ASF licenses this file to you under the Apache +rem License, Version 2.0 (the "License"); you may not use this file +rem except in compliance with the License. You may obtain a copy of +rem the License at http://www.apache.org/licenses/LICENSE-2.0 . +rem +Attribute VB_Name = "Module1" +Option Explicit + +Sub main() + Dim obj As Object + Set obj = CreateObject("dcomtest.writerdemo.wsc") + obj.run +End Sub diff --git a/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbp b/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbp new file mode 100644 index 000000000..ca477cff6 --- /dev/null +++ b/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbp @@ -0,0 +1,33 @@ +Type=Exe +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINNT\System32\stdole2.tlb#OLE Automation +Module=Module1; Module1.bas +Startup="Sub Main" +HelpFile="" +Command32="" +Name="client_writerdemo" +HelpContextID="0" +CompatibleMode="0" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +VersionCompanyName="StarOffice" +CompilationType=0 +OptimizationType=0 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=0 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=0 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 + +[MS Transaction Server] +AutoRefresh=1 diff --git a/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbw b/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbw new file mode 100644 index 000000000..067d7529e --- /dev/null +++ b/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbw @@ -0,0 +1 @@ +Module1 = 108, 108, 685, 544, diff --git a/extensions/test/ole/DCOM/Clients/WriterDemo/readme.txt b/extensions/test/ole/DCOM/Clients/WriterDemo/readme.txt new file mode 100644 index 000000000..1d5a63492 --- /dev/null +++ b/extensions/test/ole/DCOM/Clients/WriterDemo/readme.txt @@ -0,0 +1,4 @@ +Visual Basic client that instantiates a Windows Script Component +,dcomtest.writerdemo.wsc. That component is located in +extensions/test/ole/DCOM/scriptComponents/WriterDemo.wsc. Don't forget to +register that component (right-click,select register). diff --git a/extensions/test/ole/DCOM/dcom_test/Module1.bas b/extensions/test/ole/DCOM/dcom_test/Module1.bas new file mode 100644 index 000000000..27908068c --- /dev/null +++ b/extensions/test/ole/DCOM/dcom_test/Module1.bas @@ -0,0 +1,55 @@ +rem +rem This file is part of the LibreOffice project. +rem +rem This Source Code Form is subject to the terms of the Mozilla Public +rem License, v. 2.0. If a copy of the MPL was not distributed with this +rem file, You can obtain one at http://mozilla.org/MPL/2.0/. +rem +rem This file incorporates work covered by the following license notice: +rem +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed +rem with this work for additional information regarding copyright +rem ownership. The ASF licenses this file to you under the Apache +rem License, Version 2.0 (the "License"); you may not use this file +rem except in compliance with the License. You may obtain a copy of +rem the License at http://www.apache.org/licenses/LICENSE-2.0 . +rem +Attribute VB_Name = "Module1" +Option Explicit + +Sub main() + +MsgBox "hallo" + +'The service manager is always the starting point +'If there is no office running then an office is started up +Dim objServiceManager As Object +Set objServiceManager = CreateObject("com.sun.star.ServiceManager") + +'Create the CoreReflection service that is later used to create structs +Set objCoreReflection = objServiceManager.createInstance("com.sun.star.reflection.CoreReflection") + +'Create the Desktop +Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop") + +'Open a new empty writer document + +Set objCoreReflection = objServiceManager.createInstance("com.sun.star.reflection.CoreReflection") +'get a type description class for Size +Set propClass = objCoreReflection.forName("com.sun.star.beans.PropertyValue") + +Dim prop +propClass.CreateObject prop +prop.Name = "Hidden" +prop.Value = True + +'create the actual object +Dim args(0) +Set args(0) = prop + +Dim args2() +'Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args) +Set objDocument = objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args2) + +End Sub diff --git a/extensions/test/ole/DCOM/dcom_test/dcom_test.vbp b/extensions/test/ole/DCOM/dcom_test/dcom_test.vbp new file mode 100644 index 000000000..5b896434f --- /dev/null +++ b/extensions/test/ole/DCOM/dcom_test/dcom_test.vbp @@ -0,0 +1,37 @@ +Type=Exe +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINNT\System32\stdole2.tlb#OLE Automation +Module=Module1; ..\..\..\..\..\..\Projects\VBasic\dcom_test\Module1.bas +Startup="Sub Main" +HelpFile="" +Title="dcom_test" +ExeName32="dcom_test.exe" +Path32="..\..\..\..\..\..\Projects\VBasic\dcom_test" +Command32="" +Name="dcom_test" +HelpContextID="0" +CompatibleMode="0" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +VersionCompanyName="StarOffice" +CompilationType=0 +OptimizationType=0 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=0 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=0 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 +DebugStartupOption=0 + +[MS Transaction Server] +AutoRefresh=1 diff --git a/extensions/test/ole/DCOM/dcom_test/dcom_test.vbw b/extensions/test/ole/DCOM/dcom_test/dcom_test.vbw new file mode 100644 index 000000000..dfe34e0d1 --- /dev/null +++ b/extensions/test/ole/DCOM/dcom_test/dcom_test.vbw @@ -0,0 +1 @@ +Module1 = 1, 1, 849, 604, Z diff --git a/extensions/test/ole/DCOM/dcom_test/readme.txt b/extensions/test/ole/DCOM/dcom_test/readme.txt new file mode 100644 index 000000000..215d6f409 --- /dev/null +++ b/extensions/test/ole/DCOM/dcom_test/readme.txt @@ -0,0 +1,5 @@ +The program creates the com.sun.star.Servicemanager on a remote machine: + +Set objServiceManager = CreateObject("com.sun.star.ServiceManager", "\\jl-1036") + +creates a document and writes in it. \ No newline at end of file diff --git a/extensions/test/ole/DCOM/scriptComponents/WriterDemo.wsc b/extensions/test/ole/DCOM/scriptComponents/WriterDemo.wsc new file mode 100644 index 000000000..51419022f --- /dev/null +++ b/extensions/test/ole/DCOM/scriptComponents/WriterDemo.wsc @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + diff --git a/extensions/test/ole/DCOM/scriptComponents/readme.txt b/extensions/test/ole/DCOM/scriptComponents/readme.txt new file mode 100644 index 000000000..5fa3a8bb7 --- /dev/null +++ b/extensions/test/ole/DCOM/scriptComponents/readme.txt @@ -0,0 +1,12 @@ +WriterDemo.wsc +================================================================================= +Register the component by right-clicking on the file in the file explorer and select +register. +The component registered as being remotable.That is, it has got an AppID entry (with +a DllSurrogate subkey).That enables us to use dcomcnfg.exe in order to set AccessPermissions,etc. +which is necessary because of the use of the JScript Array object. The automation +bridge will query for IDispatchEx,which is a call from server to client.Hence the server +needs the proper right within the client. + +The component implements a run function, which runs the demo example that is written +in JScript. diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.cpp b/extensions/test/ole/EventListenerSample/EventListener/EventListener.cpp new file mode 100644 index 000000000..ad42dda62 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.cpp @@ -0,0 +1,76 @@ +/* -*- 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 . + */ +// EventListener.cpp : Implementation of DLL Exports. + +// Note: Proxy/Stub Information +// To build a separate proxy/stub DLL, +// run nmake -f EventListenerps.mk in the project directory. + +#include "stdafx.h" +#include "resource.h" +#include +#include "EventListener.h" + +#include "EventListener_i.c" +#include "EvtListener.h" + +CComModule _Module; + +BEGIN_OBJECT_MAP(ObjectMap) +OBJECT_ENTRY(CLSID_EvtListener, CEvtListener) +END_OBJECT_MAP() + +// DLL Entry Point + +extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) +{ + if (dwReason == DLL_PROCESS_ATTACH) + { + _Module.Init(ObjectMap, hInstance, &LIBID_EVENTLISTENERLib); + DisableThreadLibraryCalls(hInstance); + } + else if (dwReason == DLL_PROCESS_DETACH) + _Module.Term(); + return TRUE; // ok +} + +// Used to determine whether the DLL can be unloaded by OLE + +STDAPI DllCanUnloadNow(void) { return (_Module.GetLockCount() == 0) ? S_OK : S_FALSE; } + +// Returns a class factory to create an object of the requested type + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) +{ + return _Module.GetClassObject(rclsid, riid, ppv); +} + +// DllRegisterServer - Adds entries to the system registry + +STDAPI DllRegisterServer(void) +{ + // registers object, typelib and all interfaces in typelib + return _Module.RegisterServer(TRUE); +} + +// DllUnregisterServer - Removes entries from the system registry + +STDAPI DllUnregisterServer(void) { return _Module.UnregisterServer(TRUE); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.def b/extensions/test/ole/EventListenerSample/EventListener/EventListener.def new file mode 100644 index 000000000..9d88a68f7 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.def @@ -0,0 +1,9 @@ +; EventListener.def : Declares the module parameters. + +LIBRARY "EventListener.DLL" + +EXPORTS + DllCanUnloadNow PRIVATE + DllGetClassObject PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.idl b/extensions/test/ole/EventListenerSample/EventListener/EventListener.idl new file mode 100644 index 000000000..3ed514074 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.idl @@ -0,0 +1,60 @@ +/* -*- 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 . + */ + +// EventListener.idl : IDL source for EventListener.dll + + +// This file will be processed by the MIDL tool to +// produce the type library (EventListener.tlb) and marshalling code. + +import "oaidl.idl"; +import "ocidl.idl"; + [ + object, + uuid(86653399-24C6-4C2B-9E8A-564175250CB2), + dual, + helpstring("IEvtListener interface"), + pointer_default(unique) + ] + interface IEvtListener : IDispatch + { + [id(1), helpstring("Method disposing")] HRESULT disposing([in] IDispatch* source); + }; + +[ + uuid(E3E61535-3262-45E6-BFD9-EE8AED051BD1), + version(1.0), + helpstring("EventListener 1.0 Type Library") +] +library EVENTLISTENERLib +{ + importlib("stdole32.tlb"); + importlib("stdole2.tlb"); + + [ + uuid(830E0743-87C1-4C99-A77A-5FBA0C2EBD9A), + helpstring("EvtListener Class") + ] + coclass EvtListener + { + [default] interface IEvtListener; + }; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.rc b/extensions/test/ole/EventListenerSample/EventListener/EventListener.rc new file mode 100644 index 000000000..2de599591 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.rc @@ -0,0 +1,154 @@ +/* + * 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 . + */ + +// Microsoft Developer Studio generated resource script. + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + + +// Generated from the TEXTINCLUDE 2 resource. + +#include "winres.h" + + +#undef APSTUDIO_READONLY_SYMBOLS + + +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED + + +// TEXTINCLUDE + + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "1 TYPELIB ""EventListener.tlb""\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC + + +// Version + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "EventListener Module\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "EventListener\0" + VALUE "LegalCopyright", "Copyright 2001\0" + VALUE "OriginalFilename", "EventListener.DLL\0" + VALUE "ProductName", "EventListener Module\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + VALUE "OLESelfRegister", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + + + +// String Table + + +STRINGTABLE DISCARDABLE +BEGIN + IDS_PROJNAME "EventListener" +END + +#endif // German (Germany) resources + + + + +// English (USA) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + + + +// REGISTRY + + +IDR_EVTLISTENER REGISTRY DISCARDABLE "EvtListener.rgs" +#endif // English (USA) resources + + + + +#ifndef APSTUDIO_INVOKED + + +// Generated from the TEXTINCLUDE 3 resource. + +1 TYPELIB "EventListener.tlb" + + +#endif // not APSTUDIO_INVOKED + diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.sln b/extensions/test/ole/EventListenerSample/EventListener/EventListener.sln new file mode 100644 index 000000000..3837163ef --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.sln @@ -0,0 +1,31 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EventListener", "EventListener.vcproj", "{055137B6-A402-4913-AC11-9A096E866F5B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release MinDependency|Win32 = Release MinDependency|Win32 + Release MinSize|Win32 = Release MinSize|Win32 + Unicode Debug|Win32 = Unicode Debug|Win32 + Unicode Release MinDependency|Win32 = Unicode Release MinDependency|Win32 + Unicode Release MinSize|Win32 = Unicode Release MinSize|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {055137B6-A402-4913-AC11-9A096E866F5B}.Debug|Win32.ActiveCfg = Debug|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Debug|Win32.Build.0 = Debug|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Release MinDependency|Win32.ActiveCfg = Release MinDependency|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Release MinDependency|Win32.Build.0 = Release MinDependency|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Release MinSize|Win32.ActiveCfg = Release MinSize|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Release MinSize|Win32.Build.0 = Release MinSize|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Debug|Win32.ActiveCfg = Unicode Debug|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Debug|Win32.Build.0 = Unicode Debug|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Release MinDependency|Win32.ActiveCfg = Unicode Release MinDependency|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Release MinDependency|Win32.Build.0 = Unicode Release MinDependency|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Release MinSize|Win32.ActiveCfg = Unicode Release MinSize|Win32 + {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Release MinSize|Win32.Build.0 = Unicode Release MinSize|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.vcproj b/extensions/test/ole/EventListenerSample/EventListener/EventListener.vcproj new file mode 100644 index 000000000..e8aef5532 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.vcproj @@ -0,0 +1,927 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/test/ole/EventListenerSample/EventListener/EvtListener.cpp b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.cpp new file mode 100644 index 000000000..677981749 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.cpp @@ -0,0 +1,38 @@ +/* -*- 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 . + */ +// EvtListener.cpp : Implementation of CEvtListener +#include "stdafx.h" +#include "EventListener.h" +#include "EvtListener.h" + + +// CEvtListener + +STDMETHODIMP CEvtListener::disposing( IDispatch* source) +{ + ::MessageBox(NULL,_T("XEventListener::disposing"), + _T("EventListener.EvtListener component"), MB_OK); + return S_OK; +} + +CEvtListener::~CEvtListener() +{ + +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/EventListenerSample/EventListener/EvtListener.h b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.h new file mode 100644 index 000000000..6705864db --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.h @@ -0,0 +1,52 @@ +/* -*- 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 . + */ +// EvtListener.h : Declaration of CEvtListener + +#pragma once + +#include "resource.h" + + +// CEvtListener +class ATL_NO_VTABLE CEvtListener : + public CComObjectRootEx, + public CComCoClass, + public IDispatchImpl +{ +public: + CEvtListener() + { + } + ~CEvtListener(); + +DECLARE_REGISTRY_RESOURCEID(IDR_EVTLISTENER) + +DECLARE_PROTECT_FINAL_CONSTRUCT() + +BEGIN_COM_MAP(CEvtListener) + COM_INTERFACE_ENTRY(IEvtListener) + COM_INTERFACE_ENTRY(IDispatch) +END_COM_MAP() + +// IEvtListener +public: + STDMETHOD(disposing)(IDispatch* source); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/EventListenerSample/EventListener/EvtListener.rgs b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.rgs new file mode 100644 index 000000000..e0aa9bbb7 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.rgs @@ -0,0 +1,26 @@ +HKCR +{ + EventListener.EvtListener.1 = s 'EvtListener Class' + { + CLSID = s '{830E0743-87C1-4C99-A77A-5FBA0C2EBD9A}' + } + EventListener.EvtListener = s 'EvtListener Class' + { + CLSID = s '{830E0743-87C1-4C99-A77A-5FBA0C2EBD9A}' + CurVer = s 'EventListener.EvtListener.1' + } + NoRemove CLSID + { + ForceRemove {830E0743-87C1-4C99-A77A-5FBA0C2EBD9A} = s 'EvtListener Class' + { + ProgID = s 'EventListener.EvtListener.1' + VersionIndependentProgID = s 'EventListener.EvtListener' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{E3E61535-3262-45E6-BFD9-EE8AED051BD1}' + } + } +} diff --git a/extensions/test/ole/EventListenerSample/EventListener/StdAfx.cpp b/extensions/test/ole/EventListenerSample/EventListener/StdAfx.cpp new file mode 100644 index 000000000..da0608bfd --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/StdAfx.cpp @@ -0,0 +1,32 @@ +/* -*- 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 . + */ +// stdafx.cpp : source file that includes just the standard includes +// stdafx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +#ifdef _ATL_STATIC_REGISTRY +#include +#include +#endif + +#include + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/EventListenerSample/EventListener/StdAfx.h b/extensions/test/ole/EventListenerSample/EventListener/StdAfx.h new file mode 100644 index 000000000..c901a6dbe --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/StdAfx.h @@ -0,0 +1,44 @@ +/* -*- 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 . + */ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#if !defined(AFX_STDAFX_H__E275407A_804A_477E_9A28_F5CA84E711C3__INCLUDED_) +#define AFX_STDAFX_H__E275407A_804A_477E_9A28_F5CA84E711C3__INCLUDED_ + +#ifdef _MSC_VER +#pragma once +#endif + +#define STRICT +#define _ATL_APARTMENT_THREADED + +#include +//You may derive a class from CComModule and use it if you want to override +//something, but do not change the name of _Module +extern CComModule _Module; +#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__E275407A_804A_477E_9A28_F5CA84E711C3__INCLUDED) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/EventListenerSample/EventListener/resource.h b/extensions/test/ole/EventListenerSample/EventListener/resource.h new file mode 100644 index 000000000..783a14507 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/EventListener/resource.h @@ -0,0 +1,37 @@ +/* -*- 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 . + */ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by EventListener.rc + +#define IDS_PROJNAME 100 +#define IDR_EVTLISTENER 101 + +// Next default values for new objects + +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_COMMAND_VALUE 32768 +#define _APS_NEXT_CONTROL_VALUE 201 +#define _APS_NEXT_SYMED_VALUE 102 +#endif +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/Module1.bas b/extensions/test/ole/EventListenerSample/VBEventListener/Module1.bas new file mode 100644 index 000000000..aafd265a0 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/VBEventListener/Module1.bas @@ -0,0 +1,9 @@ +Attribute VB_Name = "Module1" +Option Explicit + + +Sub Main() + +End Sub + + diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/VBEventListener.cls b/extensions/test/ole/EventListenerSample/VBEventListener/VBEventListener.cls new file mode 100644 index 000000000..f3c09aa4d --- /dev/null +++ b/extensions/test/ole/EventListenerSample/VBEventListener/VBEventListener.cls @@ -0,0 +1,69 @@ +' +' 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 . +' + +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True + Persistable = 0 'NotPersistable + DataBindingBehavior = 0 'vbNone + DataSourceBehavior = 0 'vbNone + MTSTransactionMode = 0 'NotAnMTSObject +END +Attribute VB_Name = "VBEventListener" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = True +Attribute VB_PredeclaredId = False +Attribute VB_Exposed = True +Option Explicit +Private interfaces(0) As String +Private bDisposingCalled As Boolean +Private bQuiet As Boolean + +Public Property Get Bridge_ImplementedInterfaces() As Variant + Bridge_ImplementedInterfaces = interfaces +End Property + +Private Sub Class_Initialize() +interfaces(0) = "com.sun.star.lang.XEventListener" +bDisposingCalled = False +bQuiet = False +End Sub + +Private Sub Class_Terminate() + On Error Resume Next + Debug.Print "Terminate VBEventListener" +End Sub + +Public Sub disposing(ByVal source As Object) + If bQuiet = False Then + MsgBox "disposing called" + End If + bDisposingCalled = True +End Sub + +Public Sub setQuiet(quiet As Boolean) + bQuiet = quiet +End Sub + +Public Sub resetDisposing() + bDisposingCalled = False +End Sub + +Public Function disposingCalled() + disposingCalled = bDisposingCalled +End Function diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbp b/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbp new file mode 100644 index 000000000..f89b866be --- /dev/null +++ b/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbp @@ -0,0 +1,38 @@ +Type=OleDll +Class=VBEventListener; VBEventListener.cls +Module=Module1; Module1.bas +Startup="Sub Main" +HelpFile="" +ExeName32="VBasicEventListener.dll" +Command32="" +Name="VBasicEventListener" +HelpContextID="0" +Description="Implementation of UNO XEventListener" +CompatibleMode="1" +CompatibleEXE32="VBasicEventListener.dll" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +VersionCompanyName="StarOffice" +CompilationType=0 +OptimizationType=0 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=0 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=1 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 +ThreadingModel=1 +DebugStartupOption=0 + +[MS Transaction Server] +AutoRefresh=1 diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbw b/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbw new file mode 100644 index 000000000..76699ee81 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbw @@ -0,0 +1,2 @@ +VBEventListener = 132, 132, 732, 748, +Module1 = 64, 33, 849, 530, diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/readme.txt b/extensions/test/ole/EventListenerSample/VBEventListener/readme.txt new file mode 100644 index 000000000..417c102b0 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/VBEventListener/readme.txt @@ -0,0 +1,7 @@ +VBasicEventListener.dll is an ActiveX component written with VisualBasic. The +component registers on the system with a particular ID. When the library is build +this ID is generated, unless a previously build library exists. Then the ID of that +library is used. In order to use always the same ID, the library must be as binary in +the cvs. + +The library can be used under the licences noted in VBEventListener.cls. diff --git a/extensions/test/ole/EventListenerSample/events.htm b/extensions/test/ole/EventListenerSample/events.htm new file mode 100644 index 000000000..0fae7eee9 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/events.htm @@ -0,0 +1,115 @@ + + + + + +Document Title + + + + + + +

+The script on this page creates a new StarOffice document and connects an event listener +to it. When the document is closed then the XEventListener::disposing method is called on the +listener object. How the listener is set up depends on the button being clicked. +

+

+The button will run JScript code and that adds a JScript event listener to the document. +The listener is also implemented in JScript and is on this page. +

+ +

+ +The button runs JScript code that creates the ActiveX component EventListener.EvtListener that +is written in C++ and housed in a DLL. Then the event listener is added to the document. +

+ +

+The button runs VBScript code that creates the components EventListener.EvtListener and adds it +to the document. +

+ +

+Runs VBScript code that creates VBasicEventListener.VBEventListener ActiveX component which was +written with VB. +

+ + + + + + diff --git a/extensions/test/ole/EventListenerSample/readme.txt b/extensions/test/ole/EventListenerSample/readme.txt new file mode 100644 index 000000000..0e7b1f646 --- /dev/null +++ b/extensions/test/ole/EventListenerSample/readme.txt @@ -0,0 +1,20 @@ +EventListener +======================================== + +The folder EventListener contains an MSDEV project that builds a DLL that +contains the EventListener.EvtListener ActiveX component. The component +implements the XEventListener interface according to the rules of the +OleBridge. The component will be used from the HTML page events.htm. + + +VBEventListener: +======================================== + +Contains a Visual Basic project that builds an ActiveX component that implements +com.sun.star.lang.XEventListener. Its ProgId is +VBasicEventListener.VBEventListener. The DLL should also be checked in. VB needs +its TLB, so it uses the same CLSIDs on the next build. The component will create +a message box when its disposing function has been called. + +The project also contains a client that builds a Project1.exe (in the same +folder) that creates VBEventListener and adds it to a StarOffice document. diff --git a/extensions/test/ole/JScriptNewStyle.htm b/extensions/test/ole/JScriptNewStyle.htm new file mode 100644 index 000000000..28b928630 --- /dev/null +++ b/extensions/test/ole/JScriptNewStyle.htm @@ -0,0 +1,1071 @@ + + + + + +Document Title + + + + + + + +
+ + + +

JScript with _GetValueObject

+Tests Array/Sequence conversion.
+All methods receive a Sequence as Parameter. The element type of the Sequence is written on the buttons. +
+ + + + + + + + + + + + +

+ + +Out Parameter
+ + + + + + + + + + + + + + + + + +

+In Out Parameter
+ + + + + + + + + + + + + +

+ +Tests Array/Sequence conversion with Attributes. All params are of type Sequence and + the element type of the Sequence is written on the buttons.
+ + + + + + + + + + + + + +

+ + + +

Visual Basic Tests

+Test array /Sequence conversion and return value
+Template: Sequence < type > method( Sequence< type > ) +

+ + + + +

+ + +Out parameter
+Template: void method( Sequence < type > )
+ + +

+ + + + diff --git a/extensions/test/ole/MfcControl/MfcControl.cpp b/extensions/test/ole/MfcControl/MfcControl.cpp new file mode 100644 index 000000000..7ae701349 --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControl.cpp @@ -0,0 +1,90 @@ +/* -*- 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 . + */ +// MfcControl.cpp : Implementation of CMfcControlApp and DLL registration. + +#include "stdafx.h" +#include "MfcControl.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +CMfcControlApp theApp; + +const GUID CDECL BASED_CODE _tlid + = { 0xac221fb3, 0xa0d8, 0x11d4, { 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4 } }; +const WORD _wVerMajor = 1; +const WORD _wVerMinor = 0; + +// CMfcControlApp::InitInstance - DLL initialization + +BOOL CMfcControlApp::InitInstance() +{ + BOOL bInit = COleControlModule::InitInstance(); + + if (bInit) + { + // TODO: Add your own module initialization code here. + } + + return bInit; +} + +// CMfcControlApp::ExitInstance - DLL termination + +int CMfcControlApp::ExitInstance() +{ + // TODO: Add your own module termination code here. + + return COleControlModule::ExitInstance(); +} + +// DllRegisterServer - Adds entries to the system registry + +STDAPI DllRegisterServer(void) +{ + AFX_MANAGE_STATE(_afxModuleAddrThis); + + if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid)) + return ResultFromScode(SELFREG_E_TYPELIB); + + if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE)) + return ResultFromScode(SELFREG_E_CLASS); + + return NOERROR; +} + +// DllUnregisterServer - Removes entries from the system registry + +STDAPI DllUnregisterServer(void) +{ + AFX_MANAGE_STATE(_afxModuleAddrThis); + + if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor)) + return ResultFromScode(SELFREG_E_TYPELIB); + + if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE)) + return ResultFromScode(SELFREG_E_CLASS); + + return NOERROR; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/MfcControl/MfcControl.def b/extensions/test/ole/MfcControl/MfcControl.def new file mode 100644 index 000000000..8c164a7b5 --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControl.def @@ -0,0 +1,9 @@ +; MfcControl.def : Declares the module parameters. + +LIBRARY "MFCCONTROL.OCX" + +EXPORTS + DllCanUnloadNow PRIVATE + DllGetClassObject PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE diff --git a/extensions/test/ole/MfcControl/MfcControl.dsp b/extensions/test/ole/MfcControl/MfcControl.dsp new file mode 100644 index 000000000..f327a9893 --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControl.dsp @@ -0,0 +1,265 @@ +# Microsoft Developer Studio Project File - Name="MfcControl" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=MfcControl - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "MfcControl.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "MfcControl.mak" CFG="MfcControl - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "MfcControl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "MfcControl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "MfcControl - Win32 Unicode Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "MfcControl - Win32 Unicode Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "MfcControl - Win32 Release" + +# PROP BASE Use_MFC 2 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Ext "ocx" +# PROP BASE Target_Dir "" +# PROP Use_MFC 2 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Ext "ocx" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" +# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 +# Begin Custom Build - Registering ActiveX Control... +OutDir=.\Release +TargetPath=.\Release\MfcControl.ocx +InputPath=.\Release\MfcControl.ocx +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + +# End Custom Build + +!ELSEIF "$(CFG)" == "MfcControl - Win32 Debug" + +# PROP BASE Use_MFC 2 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Ext "ocx" +# PROP BASE Target_Dir "" +# PROP Use_MFC 2 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Ext "ocx" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" +# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# Begin Custom Build - Registering ActiveX Control... +OutDir=.\Debug +TargetPath=.\Debug\MfcControl.ocx +InputPath=.\Debug\MfcControl.ocx +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + +# End Custom Build + +!ELSEIF "$(CFG)" == "MfcControl - Win32 Unicode Debug" + +# PROP BASE Use_MFC 2 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugU" +# PROP BASE Intermediate_Dir "DebugU" +# PROP BASE Target_Ext "ocx" +# PROP BASE Target_Dir "" +# PROP Use_MFC 2 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugU" +# PROP Intermediate_Dir "DebugU" +# PROP Target_Ext "ocx" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" +# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# Begin Custom Build - Registering ActiveX Control... +OutDir=.\DebugU +TargetPath=.\DebugU\MfcControl.ocx +InputPath=.\DebugU\MfcControl.ocx +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + +# End Custom Build + +!ELSEIF "$(CFG)" == "MfcControl - Win32 Unicode Release" + +# PROP BASE Use_MFC 2 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseU" +# PROP BASE Intermediate_Dir "ReleaseU" +# PROP BASE Target_Ext "ocx" +# PROP BASE Target_Dir "" +# PROP Use_MFC 2 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseU" +# PROP Intermediate_Dir "ReleaseU" +# PROP Target_Ext "ocx" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" +# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 +# Begin Custom Build - Registering ActiveX Control... +OutDir=.\ReleaseU +TargetPath=.\ReleaseU\MfcControl.ocx +InputPath=.\ReleaseU\MfcControl.ocx +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + +# End Custom Build + +!ENDIF + +# Begin Target + +# Name "MfcControl - Win32 Release" +# Name "MfcControl - Win32 Debug" +# Name "MfcControl - Win32 Unicode Debug" +# Name "MfcControl - Win32 Unicode Release" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\MfcControl.cpp +# End Source File +# Begin Source File + +SOURCE=.\MfcControl.def +# End Source File +# Begin Source File + +SOURCE=.\MfcControl.odl +# End Source File +# Begin Source File + +SOURCE=.\MfcControl.rc +# End Source File +# Begin Source File + +SOURCE=.\MfcControlCtl.cpp +# End Source File +# Begin Source File + +SOURCE=.\MfcControlPpg.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\MfcControl.h +# End Source File +# Begin Source File + +SOURCE=.\MfcControlCtl.h +# End Source File +# Begin Source File + +SOURCE=.\MfcControlPpg.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\MfcControlCtl.bmp +# End Source File +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project + diff --git a/extensions/test/ole/MfcControl/MfcControl.h b/extensions/test/ole/MfcControl/MfcControl.h new file mode 100644 index 000000000..49ef5e72f --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControl.h @@ -0,0 +1,52 @@ +/* -*- 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(AFX_MFCCONTROL_H__AC221FBC_A0D8_11D4_833B_005004526AB4__INCLUDED_) +#define AFX_MFCCONTROL_H__AC221FBC_A0D8_11D4_833B_005004526AB4__INCLUDED_ + +#ifdef _MSC_VER +#pragma once +#endif + +// MfcControl.h : main header file for MFCCONTROL.DLL + +#if !defined(__AFXCTL_H__) +#error include 'afxctl.h' before including this file +#endif + +#include "resource.h" + +// CMfcControlApp : See MfcControl.cpp for implementation. + +class CMfcControlApp : public COleControlModule +{ +public: + BOOL InitInstance(); + int ExitInstance(); +}; + +extern const GUID CDECL _tlid; +extern const WORD _wVerMajor; +extern const WORD _wVerMinor; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MFCCONTROL_H__AC221FBC_A0D8_11D4_833B_005004526AB4__INCLUDED) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/MfcControl/MfcControl.odl b/extensions/test/ole/MfcControl/MfcControl.odl new file mode 100644 index 000000000..f00ebe518 --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControl.odl @@ -0,0 +1,82 @@ +// MfcControl.odl : type library source for ActiveX Control project. + +// This file will be processed by the Make Type Library (mktyplib) tool to +// produce the type library (MfcControl.tlb) that will become a resource in +// MfcControl.ocx. + +#include +#include + +[ uuid(AC221FB3-A0D8-11D4-833B-005004526AB4), version(1.0), + helpfile("MfcControl.hlp"), + helpstring("MfcControl ActiveX Control module"), + control ] +library MFCCONTROLLib +{ + importlib(STDOLE_TLB); + importlib(STDTYPE_TLB); + + // Primary dispatch interface for CMfcControlCtrl + + [ uuid(AC221FB4-A0D8-11D4-833B-005004526AB4), + helpstring("Dispatch interface for MfcControl Control"), hidden ] + dispinterface _DMfcControl + { + properties: + // NOTE - ClassWizard will maintain property information here. + // Use extreme caution when editing this section. + //{{AFX_ODL_PROP(CMfcControlCtrl) + //}}AFX_ODL_PROP + + methods: + // NOTE - ClassWizard will maintain method information here. + // Use extreme caution when editing this section. + //{{AFX_ODL_METHOD(CMfcControlCtrl) + [id(1)] short inShort(short val); + [id(2)] long inLong(long val); + [id(3)] BSTR inString(BSTR* val); + [id(4)] float inFloat(float val); + [id(5)] double inDouble(double val); + [id(6)] VARIANT inVariant(VARIANT val); + [id(7)] IDispatch* inObject(IDispatch* val); + [id(8)] void outShort([out] short* val); + [id(9)] void outLong([out] long* val); + [id(10)] void outString([out] BSTR* val); + [id(11)] void outFloat([out] float* val); + [id(12)] void outDouble([out] double* val); + [id(13)] void outVariant([out] VARIANT* val); + [id(14)] void outObject([out] IDispatch** val); + //}}AFX_ODL_METHOD + }; + + // Event dispatch interface for CMfcControlCtrl + + [ uuid(AC221FB5-A0D8-11D4-833B-005004526AB4), + helpstring("Event interface for MfcControl Control") ] + dispinterface _DMfcControlEvents + { + properties: + // Event interface has no properties + + methods: + // NOTE - ClassWizard will maintain event information here. + // Use extreme caution when editing this section. + //{{AFX_ODL_EVENT(CMfcControlCtrl) + //}}AFX_ODL_EVENT + }; + + // Class information for CMfcControlCtrl + + [ uuid(AC221FB6-A0D8-11D4-833B-005004526AB4), + helpstring("MfcControl Control"), control ] + coclass MfcControl + { + [default] dispinterface _DMfcControl; + [default, source] dispinterface _DMfcControlEvents; + }; + + + //{{AFX_APPEND_ODL}} + //}}AFX_APPEND_ODL}} +}; +//VT_I2 diff --git a/extensions/test/ole/MfcControl/MfcControl.rc b/extensions/test/ole/MfcControl/MfcControl.rc new file mode 100644 index 000000000..49831c231 --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControl.rc @@ -0,0 +1,163 @@ +/* + * 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 . + */ + +//Microsoft Visual C++ generated resource script. + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + + +// Generated from the TEXTINCLUDE 2 resource. + +#include "afxres.h" + + +#undef APSTUDIO_READONLY_SYMBOLS + +#ifdef APSTUDIO_INVOKED + + +// TEXTINCLUDE + + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "1 TYPELIB ""MfcControl.tlb""\r\n" + "\0" +END + + +#endif // APSTUDIO_INVOKED + + + + +// Version + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "Star Office Entwicklungs GmbH\0" + VALUE "FileDescription", "MfcControl ActiveX Control Module\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "MfcControl\0" + VALUE "LegalCopyright", "Copyright (C) 2000\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "MfcControl.OCX\0" + VALUE "ProductName", "MfcControl ActiveX Control Module\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + VALUE "OLESelfRegister", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + + +// Bitmap + + +//IDB_MFCCONTROL BITMAP DISCARDABLE "MfcControlCtl.bmp" + + + +// Dialog + + + +IDD_PROPPAGE_MFCCONTROL DIALOG DISCARDABLE 0, 0, 250, 62 +STYLE WS_CHILD +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "TODO: Place controls to manipulate properties of MfcControl Control on this dialog.", + IDC_STATIC,7,25,229,16 +END + + + + +// DESIGNINFO + + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_PROPPAGE_MFCCONTROL, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 243 + TOPMARGIN, 7 + BOTTOMMARGIN, 55 + END +END +#endif // APSTUDIO_INVOKED + + + +// String Table + + +STRINGTABLE DISCARDABLE +BEGIN + IDS_MFCCONTROL "MfcControl Control" + IDS_MFCCONTROL_PPG "MfcControl Property Page" + IDS_MFCCONTROL_PPG_CAPTION "General" + +END + + +#ifndef APSTUDIO_INVOKED + + +// Generated from the TEXTINCLUDE 3 resource. + +1 TYPELIB "MfcControl.tlb" + + +#endif // not APSTUDIO_INVOKED + diff --git a/extensions/test/ole/MfcControl/MfcControl.sln b/extensions/test/ole/MfcControl/MfcControl.sln new file mode 100644 index 000000000..24e646c86 --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControl.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MfcControl", "MfcControl.vcproj", "{07D59661-3519-4F10-AE9F-22DB0479E25A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + Unicode Debug|Win32 = Unicode Debug|Win32 + Unicode Release|Win32 = Unicode Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {07D59661-3519-4F10-AE9F-22DB0479E25A}.Debug|Win32.ActiveCfg = Debug|Win32 + {07D59661-3519-4F10-AE9F-22DB0479E25A}.Debug|Win32.Build.0 = Debug|Win32 + {07D59661-3519-4F10-AE9F-22DB0479E25A}.Release|Win32.ActiveCfg = Release|Win32 + {07D59661-3519-4F10-AE9F-22DB0479E25A}.Release|Win32.Build.0 = Release|Win32 + {07D59661-3519-4F10-AE9F-22DB0479E25A}.Unicode Debug|Win32.ActiveCfg = Unicode Debug|Win32 + {07D59661-3519-4F10-AE9F-22DB0479E25A}.Unicode Debug|Win32.Build.0 = Unicode Debug|Win32 + {07D59661-3519-4F10-AE9F-22DB0479E25A}.Unicode Release|Win32.ActiveCfg = Unicode Release|Win32 + {07D59661-3519-4F10-AE9F-22DB0479E25A}.Unicode Release|Win32.Build.0 = Unicode Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/extensions/test/ole/MfcControl/MfcControl.vcproj b/extensions/test/ole/MfcControl/MfcControl.vcproj new file mode 100644 index 000000000..6099d8242 --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControl.vcproj @@ -0,0 +1,581 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/test/ole/MfcControl/MfcControlCtl.cpp b/extensions/test/ole/MfcControl/MfcControlCtl.cpp new file mode 100644 index 000000000..e64ed6570 --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControlCtl.cpp @@ -0,0 +1,364 @@ +/* -*- 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 . + */ +// MfcControlCtl.cpp : Implementation of the CMfcControlCtrl ActiveX Control class. + +#include "stdafx.h" +#include "MfcControl.h" +#include "MfcControlCtl.h" +#include "MfcControlPpg.h" + + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + + +IMPLEMENT_DYNCREATE(CMfcControlCtrl, COleControl) + + + +// Message map + +BEGIN_MESSAGE_MAP(CMfcControlCtrl, COleControl) + //{{AFX_MSG_MAP(CMfcControlCtrl) + // NOTE - ClassWizard will add and remove message map entries + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG_MAP + ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties) +END_MESSAGE_MAP() + + + +// Dispatch map + +BEGIN_DISPATCH_MAP(CMfcControlCtrl, COleControl) + //{{AFX_DISPATCH_MAP(CMfcControlCtrl) + DISP_FUNCTION(CMfcControlCtrl, "inShort", inShort, VT_I2, VTS_I2) + DISP_FUNCTION(CMfcControlCtrl, "inLong", inLong, VT_I4, VTS_I4) + DISP_FUNCTION(CMfcControlCtrl, "inString", inString, VT_BSTR, VTS_PBSTR) + DISP_FUNCTION(CMfcControlCtrl, "inFloat", inFloat, VT_R4, VTS_R4) + DISP_FUNCTION(CMfcControlCtrl, "inDouble", inDouble, VT_R8, VTS_R8) + DISP_FUNCTION(CMfcControlCtrl, "inVariant", inVariant, VT_VARIANT, VTS_VARIANT) + DISP_FUNCTION(CMfcControlCtrl, "inObject", inObject, VT_DISPATCH, VTS_DISPATCH) + DISP_FUNCTION(CMfcControlCtrl, "outShort", outShort, VT_EMPTY, VTS_PI2) + DISP_FUNCTION(CMfcControlCtrl, "outLong", outLong, VT_EMPTY, VTS_PI4) + DISP_FUNCTION(CMfcControlCtrl, "outString", outString, VT_EMPTY, VTS_PBSTR) + DISP_FUNCTION(CMfcControlCtrl, "outFloat", outFloat, VT_EMPTY, VTS_PR4) + DISP_FUNCTION(CMfcControlCtrl, "outDouble", outDouble, VT_EMPTY, VTS_PR8) + DISP_FUNCTION(CMfcControlCtrl, "outVariant", outVariant, VT_EMPTY, VTS_PVARIANT) + DISP_FUNCTION(CMfcControlCtrl, "outObject", outObject, VT_EMPTY, VTS_PDISPATCH) + //}}AFX_DISPATCH_MAP +END_DISPATCH_MAP() + + + +// Event map + +BEGIN_EVENT_MAP(CMfcControlCtrl, COleControl) + //{{AFX_EVENT_MAP(CMfcControlCtrl) + // NOTE - ClassWizard will add and remove event map entries + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_EVENT_MAP +END_EVENT_MAP() + + + +// Property pages + +// TODO: Add more property pages as needed. Remember to increase the count! +BEGIN_PROPPAGEIDS(CMfcControlCtrl, 1) + PROPPAGEID(CMfcControlPropPage::guid) +END_PROPPAGEIDS(CMfcControlCtrl) + + + +// Initialize class factory and guid + +IMPLEMENT_OLECREATE_EX(CMfcControlCtrl, "MFCCONTROL.MfcControlCtrl.1", + 0xac221fb6, 0xa0d8, 0x11d4, 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4) + + + +// Type library ID and version + +IMPLEMENT_OLETYPELIB(CMfcControlCtrl, _tlid, _wVerMajor, _wVerMinor) + + + +// Interface IDs + +const IID BASED_CODE IID_DMfcControl = + { 0xac221fb4, 0xa0d8, 0x11d4, { 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4 } }; +const IID BASED_CODE IID_DMfcControlEvents = + { 0xac221fb5, 0xa0d8, 0x11d4, { 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4 } }; + + + +// Control type information + +static const DWORD BASED_CODE _dwMfcControlOleMisc = + OLEMISC_ACTIVATEWHENVISIBLE | + OLEMISC_SETCLIENTSITEFIRST | + OLEMISC_INSIDEOUT | + OLEMISC_CANTLINKINSIDE | + OLEMISC_RECOMPOSEONRESIZE; + +IMPLEMENT_OLECTLTYPE(CMfcControlCtrl, IDS_MFCCONTROL, _dwMfcControlOleMisc) + + + +// CMfcControlCtrl::CMfcControlCtrlFactory::UpdateRegistry - +// Adds or removes system registry entries for CMfcControlCtrl + +BOOL CMfcControlCtrl::CMfcControlCtrlFactory::UpdateRegistry(BOOL bRegister) +{ + // TODO: Verify that your control follows apartment-model threading rules. + // Refer to MFC TechNote 64 for more information. + // If your control does not conform to the apartment-model rules, then + // you must modify the code below, changing the 6th parameter from + // afxRegApartmentThreading to 0. + + if (bRegister) + return AfxOleRegisterControlClass( + AfxGetInstanceHandle(), + m_clsid, + m_lpszProgID, + IDS_MFCCONTROL, + IDB_MFCCONTROL, + afxRegApartmentThreading, + _dwMfcControlOleMisc, + _tlid, + _wVerMajor, + _wVerMinor); + else + return AfxOleUnregisterClass(m_clsid, m_lpszProgID); +} + + + +// CMfcControlCtrl::CMfcControlCtrl - Constructor + +CMfcControlCtrl::CMfcControlCtrl() +{ + InitializeIIDs(&IID_DMfcControl, &IID_DMfcControlEvents); + + // TODO: Initialize your control's instance data here. +} + + + +// CMfcControlCtrl::~CMfcControlCtrl - Destructor + +CMfcControlCtrl::~CMfcControlCtrl() +{ + // TODO: Cleanup your control's instance data here. +} + + + +// CMfcControlCtrl::OnDraw - Drawing function + +void CMfcControlCtrl::OnDraw( + CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid) +{ + // TODO: Replace the following code with your own drawing code. + pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH))); + pdc->Ellipse(rcBounds); +} + + + +// CMfcControlCtrl::DoPropExchange - Persistence support + +void CMfcControlCtrl::DoPropExchange(CPropExchange* pPX) +{ + ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor)); + COleControl::DoPropExchange(pPX); + + // TODO: Call PX_ functions for each persistent custom property. + +} + + + +// CMfcControlCtrl::OnResetState - Reset control to default state + +void CMfcControlCtrl::OnResetState() +{ + COleControl::OnResetState(); // Resets defaults found in DoPropExchange + + // TODO: Reset any other control state here. +} + + + +// CMfcControlCtrl message handlers + + +short CMfcControlCtrl::inShort(short val) +{ + char buf[256]; + sprintf( buf, "inByte: value= %d", val); + ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK); + return val+1; +} + +long CMfcControlCtrl::inLong(long val) +{ + char buf[256]; + sprintf( buf, "inLong: value= %d", val); + ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK); + return val+1; +} + +BSTR CMfcControlCtrl::inString(BSTR* val) +{ + CString strResult; + strResult= *val; + char buf[256]; + sprintf( buf, "inString: value= %S", *val); + ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK); + strResult += L" an appended string"; + return strResult.AllocSysString(); +} + +float CMfcControlCtrl::inFloat(float val) +{ + char buf[256]; + sprintf( buf, "inFloat: value= %f", val); + ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK); + return val+1; +} + +double CMfcControlCtrl::inDouble(double val) +{ + char buf[256]; + sprintf( buf, "inDouble: value= %g", val); + ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK); + return val+1; +} + +VARIANT CMfcControlCtrl::inVariant(const VARIANT& val) +{ + VARIANT vaResult; + VariantInit(&vaResult); + VariantCopyInd( &vaResult, const_cast(&val)); + if( vaResult.vt == VT_BSTR) + { + char buf[256]; + sprintf( buf, "inVariant: value= %S", vaResult.bstrVal); + ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK); + + } + return _variant_t( L" a string from CMfcControlCtrl::inVariant"); +} + +LPDISPATCH CMfcControlCtrl::inObject(LPDISPATCH val) +{ + char buf[256]; + _bstr_t bstr; + HRESULT hr= S_OK; + COleVariant var; + DISPID id; + OLECHAR* name=L"prpString"; + if( SUCCEEDED(hr= val->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &id))) + { + DISPPARAMS params={0,0,0,0}; + hr= val->Invoke( id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, ¶ms, &var,0,0); + + } + + if( var.vt== VT_BSTR) + bstr= var.bstrVal; + sprintf( buf, "inObject: value= %S", (wchar_t*)bstr); + ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK); + + return NULL; +} + + +void CMfcControlCtrl::outShort(short* val) +{ + *val= 123; +} + +void CMfcControlCtrl::outLong(long* val) +{ + *val= 1234; +} + +void CMfcControlCtrl::outString(BSTR* val) +{ + *val= SysAllocString(L"A string from CMfcControlCtrl::outString "); +} + +void CMfcControlCtrl::outFloat(float* val) +{ + *val= 3.14f; +} + +void CMfcControlCtrl::outDouble(double* val) +{ + *val= 3.145; +} + +void CMfcControlCtrl::outVariant(VARIANT* val) +{ + VariantInit( val); + val->vt= VT_BSTR; + val->bstrVal= SysAllocString( L"a string in a VARIANT"); +} + +void CMfcControlCtrl::outObject(LPDISPATCH* val) +{ + //{BFE10EBE-8584-11D4-005004526AB4} + HRESULT hr= S_OK; + CLSID clsTestControl; + hr= CLSIDFromProgID( L"AxTestComponents.Basic", &clsTestControl); + + IDispatch* pDisp= NULL; + hr= CoCreateInstance( clsTestControl, NULL, CLSCTX_ALL, __uuidof(IDispatch), (void**)&pDisp); + + if( SUCCEEDED( hr) && val) + { + COleVariant var; + DISPID id; + OLECHAR* name=L"prpString"; + if( SUCCEEDED(hr= pDisp->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &id))) + { + COleVariant vaParam1(_T("this is property prpString of AxTestComponents.Basic")); + DISPID dispidPut= DISPID_PROPERTYPUT; + DISPPARAMS params; + params.cArgs= 1; + params.cNamedArgs= 1; + params.rgdispidNamedArgs= &dispidPut; + params.rgvarg= &vaParam1; + + hr= pDisp->Invoke( id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, ¶ms, &var,0,0); + *val= pDisp; + } + + } + +} +// VT_I1 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/MfcControl/MfcControlCtl.h b/extensions/test/ole/MfcControl/MfcControlCtl.h new file mode 100644 index 000000000..b1d74270b --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControlCtl.h @@ -0,0 +1,116 @@ +/* -*- 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(AFX_MFCCONTROLCTL_H__AC221FC3_A0D8_11D4_833B_005004526AB4__INCLUDED_) +#define AFX_MFCCONTROLCTL_H__AC221FC3_A0D8_11D4_833B_005004526AB4__INCLUDED_ + +#ifdef _MSC_VER +#pragma once +#endif + +// MfcControlCtl.h : Declaration of the CMfcControlCtrl ActiveX Control class. + + +// CMfcControlCtrl : See MfcControlCtl.cpp for implementation. + +class CMfcControlCtrl : public COleControl +{ + DECLARE_DYNCREATE(CMfcControlCtrl) + +// Constructor +public: + CMfcControlCtrl(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMfcControlCtrl) + public: + virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid); + virtual void DoPropExchange(CPropExchange* pPX); + virtual void OnResetState(); + //}}AFX_VIRTUAL + +// Implementation +protected: + ~CMfcControlCtrl(); + + DECLARE_OLECREATE_EX(CMfcControlCtrl) // Class factory and guid + DECLARE_OLETYPELIB(CMfcControlCtrl) // GetTypeInfo + DECLARE_PROPPAGEIDS(CMfcControlCtrl) // Property page IDs + DECLARE_OLECTLTYPE(CMfcControlCtrl) // Type name and misc status + +// Message maps + //{{AFX_MSG(CMfcControlCtrl) + // NOTE - ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + +// Dispatch maps + //{{AFX_DISPATCH(CMfcControlCtrl) + afx_msg short inShort(short val); + afx_msg long inLong(long val); + afx_msg BSTR inString(BSTR* val); + afx_msg float inFloat(float val); + afx_msg double inDouble(double val); + afx_msg VARIANT inVariant(const VARIANT& val); + afx_msg LPDISPATCH inObject(LPDISPATCH val); + afx_msg void outShort(short* val); + afx_msg void outLong(long* val); + afx_msg void outString(BSTR* val); + afx_msg void outFloat(float* val); + afx_msg void outDouble(double* val); + afx_msg void outVariant(VARIANT* val); + afx_msg void outObject(LPDISPATCH* val); + //}}AFX_DISPATCH + DECLARE_DISPATCH_MAP() + +// Event maps + //{{AFX_EVENT(CMfcControlCtrl) + //}}AFX_EVENT + DECLARE_EVENT_MAP() + +// Dispatch and event IDs +public: + enum { + //{{AFX_DISP_ID(CMfcControlCtrl) + dispidInShort = 1L, + dispidInLong = 2L, + dispidInString = 3L, + dispidInFloat = 4L, + dispidInDouble = 5L, + dispidInVariant = 6L, + dispidInObject = 7L, + dispidOutShort = 8L, + dispidOutLong = 9L, + dispidOutString = 10L, + dispidOutFloat = 11L, + dispidOutDouble = 12L, + dispidOutVariant = 13L, + dispidOutObject = 14L, + //}}AFX_DISP_ID + }; +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MFCCONTROLCTL_H__AC221FC3_A0D8_11D4_833B_005004526AB4__INCLUDED) +// BYTE + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/MfcControl/MfcControlCtl.png b/extensions/test/ole/MfcControl/MfcControlCtl.png new file mode 100644 index 000000000..77c4758c1 Binary files /dev/null and b/extensions/test/ole/MfcControl/MfcControlCtl.png differ diff --git a/extensions/test/ole/MfcControl/MfcControlPpg.cpp b/extensions/test/ole/MfcControl/MfcControlPpg.cpp new file mode 100644 index 000000000..367122363 --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControlPpg.cpp @@ -0,0 +1,96 @@ +/* -*- 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 . + */ +// MfcControlPpg.cpp : Implementation of the CMfcControlPropPage property page class. + +#include "stdafx.h" +#include "MfcControl.h" +#include "MfcControlPpg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + + +IMPLEMENT_DYNCREATE(CMfcControlPropPage, COlePropertyPage) + + + +// Message map + +BEGIN_MESSAGE_MAP(CMfcControlPropPage, COlePropertyPage) + //{{AFX_MSG_MAP(CMfcControlPropPage) + // NOTE - ClassWizard will add and remove message map entries + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + + +// Initialize class factory and guid + +IMPLEMENT_OLECREATE_EX(CMfcControlPropPage, "MFCCONTROL.MfcControlPropPage.1", + 0xac221fb7, 0xa0d8, 0x11d4, 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4) + + + +// CMfcControlPropPage::CMfcControlPropPageFactory::UpdateRegistry - +// Adds or removes system registry entries for CMfcControlPropPage + +BOOL CMfcControlPropPage::CMfcControlPropPageFactory::UpdateRegistry(BOOL bRegister) +{ + if (bRegister) + return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(), + m_clsid, IDS_MFCCONTROL_PPG); + else + return AfxOleUnregisterClass(m_clsid, NULL); +} + + + +// CMfcControlPropPage::CMfcControlPropPage - Constructor + +CMfcControlPropPage::CMfcControlPropPage() : + COlePropertyPage(IDD, IDS_MFCCONTROL_PPG_CAPTION) +{ + //{{AFX_DATA_INIT(CMfcControlPropPage) + // NOTE: ClassWizard will add member initialization here + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_DATA_INIT +} + + + +// CMfcControlPropPage::DoDataExchange - Moves data between page and properties + +void CMfcControlPropPage::DoDataExchange(CDataExchange* pDX) +{ + //{{AFX_DATA_MAP(CMfcControlPropPage) + // NOTE: ClassWizard will add DDP, DDX, and DDV calls here + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_DATA_MAP + DDP_PostProcessing(pDX); +} + + + +// CMfcControlPropPage message handlers + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/MfcControl/MfcControlPpg.h b/extensions/test/ole/MfcControl/MfcControlPpg.h new file mode 100644 index 000000000..cb7cd7164 --- /dev/null +++ b/extensions/test/ole/MfcControl/MfcControlPpg.h @@ -0,0 +1,66 @@ +/* -*- 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(AFX_MFCCONTROLPPG_H__AC221FC5_A0D8_11D4_833B_005004526AB4__INCLUDED_) +#define AFX_MFCCONTROLPPG_H__AC221FC5_A0D8_11D4_833B_005004526AB4__INCLUDED_ + +#ifdef _MSC_VER +#pragma once +#endif + +// MfcControlPpg.h : Declaration of the CMfcControlPropPage property page class. + + +// CMfcControlPropPage : See MfcControlPpg.cpp.cpp for implementation. + +class CMfcControlPropPage : public COlePropertyPage +{ + DECLARE_DYNCREATE(CMfcControlPropPage) + DECLARE_OLECREATE_EX(CMfcControlPropPage) + +// Constructor +public: + CMfcControlPropPage(); + +// Dialog Data + //{{AFX_DATA(CMfcControlPropPage) + enum { IDD = IDD_PROPPAGE_MFCCONTROL }; + // NOTE - ClassWizard will add data members here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_DATA + +// Implementation +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + +// Message maps +protected: + //{{AFX_MSG(CMfcControlPropPage) + // NOTE - ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MFCCONTROLPPG_H__AC221FC5_A0D8_11D4_833B_005004526AB4__INCLUDED) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/MfcControl/Resource.h b/extensions/test/ole/MfcControl/Resource.h new file mode 100644 index 000000000..598d26ba3 --- /dev/null +++ b/extensions/test/ole/MfcControl/Resource.h @@ -0,0 +1,40 @@ +/* -*- 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 . + */ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by MfcControl.rc + + +#define IDS_MFCCONTROL 1 +#define IDS_MFCCONTROL_PPG 2 + +#define IDS_MFCCONTROL_PPG_CAPTION 200 + +#define IDD_PROPPAGE_MFCCONTROL 200 + + +#define IDB_MFCCONTROL 1 + + +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_CONTROL_VALUE 201 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32768 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/MfcControl/StdAfx.cpp b/extensions/test/ole/MfcControl/StdAfx.cpp new file mode 100644 index 000000000..13bae5702 --- /dev/null +++ b/extensions/test/ole/MfcControl/StdAfx.cpp @@ -0,0 +1,25 @@ +/* -*- 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 . + */ +// stdafx.cpp : source file that includes just the standard includes +// stdafx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/MfcControl/StdAfx.h b/extensions/test/ole/MfcControl/StdAfx.h new file mode 100644 index 000000000..6e8059a1b --- /dev/null +++ b/extensions/test/ole/MfcControl/StdAfx.h @@ -0,0 +1,50 @@ +/* -*- 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(AFX_STDAFX_H__AC221FBA_A0D8_11D4_833B_005004526AB4__INCLUDED_) +#define AFX_STDAFX_H__AC221FBA_A0D8_11D4_833B_005004526AB4__INCLUDED_ + +#ifdef _MSC_VER +#pragma once +#endif + +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include +#include +#include +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include +#endif // _AFX_NO_AFXCMN_SUPPORT + +// Delete the two includes below if you do not wish to use the MFC +// database classes +#include +#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#include +#endif // !defined(AFX_STDAFX_H__AC221FBA_A0D8_11D4_833B_005004526AB4__INCLUDED_) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/OleClient/OleClient.ini b/extensions/test/ole/OleClient/OleClient.ini new file mode 100644 index 000000000..fa1ac118f --- /dev/null +++ b/extensions/test/ole/OleClient/OleClient.ini @@ -0,0 +1,5 @@ +[Bootstrap] +UNO_TYPES=types.rdb +UNO_SERVICES=services.rdb + + diff --git a/extensions/test/ole/OleClient/axhost.cxx b/extensions/test/ole/OleClient/axhost.cxx new file mode 100644 index 000000000..47709f383 --- /dev/null +++ b/extensions/test/ole/OleClient/axhost.cxx @@ -0,0 +1,39 @@ +/* -*- 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 "axhost.hxx" + +HostWin::HostWin(LPWSTR progid) +{ + controlName = progid; + RECT rcPos = { 0, 0, 200, 200 }; + Create(0, rcPos, _T("HostWin")); +} +HostWin::~HostWin() { DestroyWindow(); } + +LRESULT HostWin::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +{ + CAxWindow wnd(m_hWnd); + + HRESULT hr = wnd.CreateControlEx(controlName, NULL, NULL, &spControl.p); + + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/OleClient/axhost.hxx b/extensions/test/ole/OleClient/axhost.hxx new file mode 100644 index 000000000..68a9069fb --- /dev/null +++ b/extensions/test/ole/OleClient/axhost.hxx @@ -0,0 +1,51 @@ +/* -*- 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 . + */ + +#pragma once + +#include +extern CComModule _Module; +#include +#include + + +class HostWin: public CWindowImpl > +{ + CComBSTR controlName; + CComPtr spControl; +public: + explicit HostWin(LPWSTR progid); + + ~HostWin(); + + + BEGIN_MSG_MAP(HostWin) + MESSAGE_HANDLER( WM_CREATE, OnCreate) + END_MSG_MAP() + + IUnknown* GetHostedControl(){ + return spControl; + } + + LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/OleClient/clientTest.cxx b/extensions/test/ole/OleClient/clientTest.cxx new file mode 100644 index 000000000..00a78034d --- /dev/null +++ b/extensions/test/ole/OleClient/clientTest.cxx @@ -0,0 +1,1291 @@ +/* -*- 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 + +CComModule _Module; +#include +#include + +#include "axhost.hxx" + +#include +#include "typelib/typedescription.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +BEGIN_OBJECT_MAP(ObjectMap) +END_OBJECT_MAP() + +using namespace com::sun::star::lang; +using namespace com::sun::star::uno; +using namespace com::sun::star::script; +using namespace com::sun::star::bridge::oleautomation; +using namespace cppu; + + +Reference convertComObject( IUnknown* pUnk); +Reference getComObject( OUString progId); +bool checkOutArgs(const Sequence & outArgs, + const Sequence & indices, const Sequence & values); + +bool doSimpleTest(const Reference & inv); +bool doSimpleSequenceTest(const Reference & inv); +bool doParameterTest(const Reference & inv); +bool doPropertyWithArgumentTest(const Reference & inv); +bool equalSequences(const Any& orig, const Any& returned); +HRESULT doTest(); +HRESULT doTest2( Reference &); +Reference getComObject(OUString& ); + +HRESULT InitializeParameter(); +void printResultVariantArray( VARIANT & var); +void printVariant( VARIANT & var); +void printSequence( Sequence& val); + +extern "C" int SAL_CALL main( int , char **) +{ + HRESULT hr; + if( FAILED( hr=CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) + { + _tprintf(_T("CoInitializeEx failed \n")); + return -1; + } + + + _Module.Init( ObjectMap, GetModuleHandle( NULL)); + + if( FAILED(hr=doTest())) + { + _com_error err( hr); + const TCHAR * errMsg= err.ErrorMessage(); + MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR); + } + else + { + MessageBox( NULL,NULL , "Test succeeded", MB_ICONINFORMATION); + } + + + _Module.Term(); + CoUninitialize(); + return 0; +} +//Also supports named args + +bool doParameterTest(const Reference & inv) +{ + Sequence< sal_Int16> seqIndices; + Sequence seqOut; + + Any arArgs[2]; + Any arArgs1[4]; + + NamedArgument arg1(OUString(L"val1"), makeAny((sal_Int32) 123)); + NamedArgument arg2(OUString(L"val2"), makeAny((sal_Int32) 456)); + NamedArgument arg3(OUString(L"val3"), makeAny((sal_Int32) 0xff)); + NamedArgument arg4(OUString(L"val4"), makeAny((sal_Int32) 0xffff)); + + NamedArgument argOut1(OUString(L"val1"), Any()); + NamedArgument argOut2(OUString(L"val2"), Any()); + Sequence seqNoArgs; + arArgs[0] <<= (sal_Int32) 0; + arArgs[1] <<= (sal_Int32) 0; + Sequence seqPositional0(arArgs, 2); + + + arArgs[0] <<= arg1; + arArgs[1] <<= arg2; + Sequence seqNamed(arArgs, 2); + arArgs[0] <<= arg2; + arArgs[1] <<= arg1; + Sequence seqNamed2(arArgs, 2); + arArgs[0] <<= argOut1; + arArgs[1] <<= argOut2; + Sequence seqNamed3(arArgs, 2); + arArgs[0] <<= argOut2; + arArgs[1] <<= argOut1; + Sequence seqNamed4(arArgs, 2); + + arArgs[0] <<= arg1; + Sequence seqNamed5(arArgs, 1); + arArgs[0] <<= arg2; + Sequence seqNamed6(arArgs, 1); + + arArgs[0] <<= (sal_Int32) 123; + arArgs[1] <<= (sal_Int32) 456; + Sequence seqPositional(arArgs, 2); + arArgs[0] <<= (sal_Int32) 123; + Sequence seqPositional2(arArgs, 1); + + arArgs[0].clear(); + arArgs[1].clear(); + Sequence seqPositional3(arArgs, 2); + + arArgs[0] <<= (sal_Int32) 123; + arArgs[1] <<= SCode(DISP_E_PARAMNOTFOUND); + Sequence seqOutOpt1(arArgs, 2); + + arArgs[0] <<= SCode(DISP_E_PARAMNOTFOUND); + arArgs[1] <<= SCode(DISP_E_PARAMNOTFOUND); + Sequence seqOutOpt2(arArgs, 2); + + arArgs[0] <<= SCode(DISP_E_PARAMNOTFOUND); + arArgs[1] <<= (sal_Int32) 456; + Sequence seqOutOpt3(arArgs, 2); + + arArgs1[0] <<= (sal_Int32) 0; + arArgs1[1] <<= (sal_Int32) 0; + arArgs1[2] <<= (sal_Int32) 0; + arArgs1[3] <<= (sal_Int32) 0; + Sequence seqMix0(arArgs1, 4); + + arArgs1[0] <<= (sal_Int32) 123; + arArgs1[1] <<= (sal_Int32) 456; + arArgs1[2] <<= arg3; + arArgs1[3] <<= arg4; + Sequence seqMix(arArgs1, 4); + + arArgs1[0].clear(); + arArgs1[1] <<= (sal_Int32) 456; + arArgs1[2] <<= arg4; + Sequence seqMix2(arArgs1, 3); + + arArgs1[0] <<= SCode(DISP_E_PARAMNOTFOUND); + arArgs1[1] <<= (sal_Int32) 456; + arArgs1[2] <<= SCode(DISP_E_PARAMNOTFOUND); + arArgs1[3] <<= arg4.Value; + Sequence seqMixOut(arArgs1, 4); + + arArgs1[0] <<= SCode(DISP_E_PARAMNOTFOUND); + arArgs1[1].clear(); + arArgs1[2] <<= arg4; + Sequence seqMix2Out(arArgs1, 3); + + + //in args + out, optional, positional----------------------------------------- + //first general test + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqPositional, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqPositional)) + return false; + + //2 optional args, 1 provided + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqPositional2, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt1)) + return false; + + //2 optional args, 0 provided + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqNoArgs, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional5"), seqPositional3, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt2)) + return false; + + //named args -------------------------------------------- + + // 2 named args, correct position + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional5"), seqPositional0, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqPositional)) + return false; + + // 2named args, position differs + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqNamed2, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqPositional)) + return false; + + //named out args, 2 named args with correct position + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut); + seqIndices.realloc(0); + seqIndices.realloc(0); + inv->invoke(OUString(L"optional5"), seqNamed3, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqNamed )) + return false; + + //named out args, 2 named args with different position + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut); + seqIndices.realloc(0); + seqIndices.realloc(0); + inv->invoke(OUString(L"optional5"), seqNamed4, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqNamed2 )) + return false; + + + //2 args, 1 provided (correct order) + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqNamed5, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt1)) + return false; + //2 args, 1 provided (incorrect order) + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional3"), seqNamed6, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt3)) + return false; + + //2position + 2 2named args, correct order + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional6"), seqMix0, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional6"), seqMix, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional7"), seqMix, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqMix)) + return false; + + // 4 in args, 1 positional, 1 named, 1 positional omitted + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional6"), seqMix0, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional6"), seqMix2, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional7"), seqMix0, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqMixOut)) + return false; + + // 4 out args, 1 positional, 1 named, 1 positional omitted + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional6"), seqMix2, seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"optional7"), seqMix2Out, seqIndices, seqOut); + if ( ! checkOutArgs(seqOut, seqIndices, seqMix2Out)) + return false; + + + return true; +} +bool doPropertyTest(const Reference & inv) +{ + Sequence< sal_Int16> seqIndices; + Sequence seqOut; + + Any inBool, outBool; + Any inByte, outByte; + Any inShort, outShort; + Any inLong, outLong; + Any inString, outString; + Any inFloat, outFloat; + Any inDouble, outDouble; + Any inVariant, outVariant; + Any inObject, outObject; + Any inUnknown, outUnknown; + Any inCY, outCY; + Any inDate, outDate; + Any inDecimal, outDecimal; + Any inSCode, outSCode; + Any inrefLong, outrefLong; + Any inrefVariant, outrefVariant; + Any inrefDecimal, outrefDecimal; + Any inParamsLong, outParamsLong; + Reference xintUnknown(getComObject(L"AxTestComponents.Foo")); + + inBool <<= (sal_Bool) sal_True; + inv->setValue(OUString(L"prpBool"), inBool); + outBool = inv->getValue(OUString(L"prpBool")); + + inByte <<= (sal_Int8) 100; + inv->setValue(OUString(L"prpByte"), inByte); + outByte = inv->getValue(OUString(L"prpByte")); + + inShort <<= static_cast( -1); + inv->setValue(OUString(L"prpShort"), inShort); + outShort = inv->getValue(OUString(L"prpShort")); + + inLong <<= ( sal_Int32) 1234567; + inv->setValue(OUString(L"prpLong"), inLong // TODO: Add your implementation code here +); + outLong = inv->getValue(OUString(L"prpLong")); + + inString <<= OUString(L" this is clientTest.exe"); + inv->setValue(OUString(L"prpString"), inString); + outString = inv->getValue(OUString(L"prpString")); + + inFloat <<= 3.14f; + inv->setValue(OUString(L"prpFloat"), inFloat); + outFloat = inv->getValue(OUString(L"prpFloat")); + + inDouble <<= ( double) 3.145; + inv->setValue(OUString(L"prpDouble"), inDouble); + outDouble = inv->getValue(OUString(L"prpDouble")); + + inVariant <<= OUString(L"A string in an any"); + inv->setValue(OUString(L"prpVariant"), inVariant); + outVariant = inv->getValue(OUString(L"prpVariant")); + + inObject <<= inv; + inv->setValue(OUString(L"prpObject"), inObject); + outObject = inv->getValue(OUString(L"prpObject")); + + inUnknown <<= xintUnknown; + inv->setValue(OUString(L"prpUnknown"), inUnknown); + outUnknown = inv->getValue(OUString(L"prpUnknown")); + + Currency cur(99999); + inCY <<= cur; + inv->setValue(OUString(L"prpCurrency"), inCY); + outCY = inv->getValue(OUString(L"prpCurrency")); + + Date d(37889.0); + inDate <<= d; + inv->setValue(OUString(L"prpDate"), inDate); + outDate = inv->getValue(OUString(L"prpDate")); + + Decimal dec(20, 0, 0xffffffff, 0xffffffff, 0x0fffffff); + inDecimal <<= dec; + inv->setValue(OUString(L"prpDecimal"), inDecimal); + outDecimal = inv->getValue(OUString(L"prpDecimal")); + + SCode code(DISP_E_BADVARTYPE); + inSCode <<= code; + inv->setValue(OUString(L"prpSCode"), inSCode); + outSCode = inv->getValue(OUString(L"prpSCode")); + + inrefLong <<= (sal_Int32) 123456; + inv->setValue(OUString(L"prprefLong"), inrefLong); + outrefLong = inv->getValue(OUString(L"prprefLong")); + + inrefVariant <<= OUString(L"A string in an any"); + inv->setValue(OUString(L"prprefVariant"), inrefVariant); + outrefVariant = inv->getValue(OUString(L"prprefVariant")); + + Decimal decref(20, 0, 0xffffffff, 0xffffffff, 0x0fffffff); + inrefDecimal <<= decref; + inv->setValue(OUString(L"prprefDecimal"), inrefDecimal); + outrefDecimal = inv->getValue(OUString(L"prprefDecimal")); + + if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong + || inFloat != outFloat || inDouble != outDouble || inString != outString + || inVariant != outVariant || inObject != outObject + || inUnknown != outUnknown || inCY != outCY + || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode + || inrefLong != outrefLong ||inrefVariant != outrefVariant + || inrefDecimal != outrefDecimal) + return false; + return true; +} + +bool doPropertyWithArgumentTest(const Reference & inv) +{ + Sequence< sal_Int16> seqIndices; + Sequence seqOut; + + Any arMultiArgs[3]; + arMultiArgs[0] = makeAny((sal_Int32) 0); + arMultiArgs[1] = makeAny((sal_Int32) 0); + arMultiArgs[2] <<= PropertyPutArgument(makeAny((sal_Int32) 0)); + Sequence seqMultiArgPut0(arMultiArgs, 3); + + arMultiArgs[0] = makeAny((sal_Int32) 1); + arMultiArgs[1] = makeAny((sal_Int32) 2); + arMultiArgs[2] <<= PropertyPutArgument(makeAny((sal_Int32) 3)); + Sequence seqMultiArgPut1(arMultiArgs, 3); + + arMultiArgs[0] = makeAny((sal_Int32) 1); + arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 3)); + Sequence seqMultiArgPut2(arMultiArgs, 2); + + arMultiArgs[0] <<= NamedArgument(OUString(L"val2"), makeAny((sal_Int32) 1)); + arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 3)); + Sequence seqMultiArgPut3(arMultiArgs, 2); + + arMultiArgs[0] <<= NamedArgument(OUString(L"val2"), makeAny((sal_Int32) 1)); + arMultiArgs[1] <<= NamedArgument(OUString(L"val3"), makeAny((sal_Int32) 3)); + Sequence seqMultiArgPut4(arMultiArgs, 2); + + arMultiArgs[0] = makeAny((sal_Int32) 0); + arMultiArgs[1] = makeAny((sal_Int32) 0); + Sequence seqMultiArgGet0(arMultiArgs, 2); + + arMultiArgs[0] = makeAny((sal_Int32) 1); + arMultiArgs[1] = makeAny((sal_Int32) 2); + Sequence seqMultiArgGet1(arMultiArgs, 2); + Sequence seqMultiArgGet2(arMultiArgs, 1); + + + arMultiArgs[0] = makeAny((sal_Int32) 0); + arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 0)); + Sequence seqMultiArgPut5(arMultiArgs, 2); + + arMultiArgs[0] = makeAny((sal_Int32) 1); + arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 2)); + Sequence seqMultiArgPut6(arMultiArgs, 2); + + arMultiArgs[0].clear(); + arMultiArgs[1].clear(); + Sequence seqMultiVoid(arMultiArgs, 2); + + arMultiArgs[0] = makeAny((sal_Int32) 0); + arMultiArgs[1] = makeAny((sal_Int32) 0); + Sequence seqMultiVoid2(arMultiArgs, 2); + + //[propput, ...] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [in] VARIANT* newVal); + //[propget, ...] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [out, optional, retval] VARIANT* pVal); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut1, seqIndices, seqOut); + //check in/out args + seqIndices.realloc( 0); + seqOut.realloc(0); + Any anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0, + seqIndices, seqOut); + + if (anyRet != ((PropertyPutArgument const *)seqMultiArgPut1[2].getValue())->Value + || ! checkOutArgs(seqOut, seqIndices, Sequence(seqMultiArgPut1.getArray(), 2))) + { + return false; + } + // test optional (one arg omitted + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut2, seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0, + seqIndices, seqOut); + + arMultiArgs[0] = makeAny((sal_Int32) 1); + arMultiArgs[1] = makeAny((SCode(DISP_E_PARAMNOTFOUND))); + + if (anyRet != ((PropertyPutArgument const *) seqMultiArgPut2[1].getValue())->Value + || ! checkOutArgs(seqOut, seqIndices, Sequence(arMultiArgs, 2))) + { + return false; + } + + //test one named arg and one omitted + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut3, seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0, + seqIndices, seqOut); + + arMultiArgs[0] = makeAny((SCode(DISP_E_PARAMNOTFOUND))); + arMultiArgs[1] = ((NamedArgument const*) seqMultiArgPut3[0].getValue())->Value; + if (anyRet != ((PropertyPutArgument const*) seqMultiArgPut3[1].getValue())->Value + || ! checkOutArgs(seqOut, seqIndices, Sequence(arMultiArgs, 2))) + { + return false; + } + +// [propget,...] HRESULT prpMultiArg2([in] VARIANT val1, [out, retval] VARIANT* pVal); +// [propput,...] HRESULT prpMultiArg2([in] VARIANT val1, [in] VARIANT newVal); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"prpMultiArg2"), seqMultiArgPut5, seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"prpMultiArg2GetValues"), seqMultiVoid, seqIndices, seqOut); + + if ( ! checkOutArgs(seqOut, seqIndices, seqMultiVoid2)) + return false; + seqIndices.realloc( 0); + seqOut.realloc(0); + anyRet = inv->invoke(OUString(L"prpMultiArg2"), seqMultiArgPut6, + seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + anyRet = inv->invoke(OUString(L"prpMultiArg2GetValues"), seqMultiVoid, + seqIndices, seqOut); + +// [propget,...] HRESULT prpMultiArg3([in,out] LONG* val1, [out, retval] LONG* pVal); +// [propput,...] HRESULT prpMultiArg3([in,out] LONG* val1, [in] LONG newVal); + + if ( ! checkOutArgs(seqOut, seqIndices, seqMultiArgGet1 )) + return false; + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgPut5, seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgPut6, seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + anyRet = inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgGet2, seqIndices, seqOut); + + if ( anyRet != ((PropertyPutArgument const*) seqMultiArgPut6[1].getValue())->Value + || !checkOutArgs(seqOut, seqIndices, seqMultiArgGet2)) + return false; + + + //hasProperty, hasMethod + if (inv->hasProperty("prpMultiArg1")) + return false; + if ( ! inv->hasMethod("prpMultiArg1")) + return false; + if ( ! inv->hasProperty("prprefLong")) + return false; + if (inv->hasMethod("prprefLong")) + return false; + if ( ! inv->hasMethod("inLong")) + return false; + + return true; +} +bool doSimpleTest(const Reference & inv) +{ + Sequence< sal_Int16> seqIndices; + Sequence seqOut; + + Any inBool, outBool; + Any inByte, outByte; + Any inShort, outShort; + Any inLong, outLong; + Any inString, outString; + Any inFloat, outFloat; + Any inDouble, outDouble; + Any inVariant, outVariant; + Any inObject, outObject; + Any inUnknown, outUnknown; + Any inCY, outCY; + Any inDate, outDate; + Any inDecimal, outDecimal; + Any inSCode, outSCode; + Any inrefLong, outrefLong; + Any inrefVariant, outrefVariant; + Any inrefDecimal, outrefDecimal; + + Reference xIntFoo(getComObject(L"AxTestComponents.Foo")); + + // in and out parameter + + sal_Bool aBool = sal_True; + inBool.setValue(&aBool, cppu::UnoType::get()); + inv->invoke(OUString(L"inBool"), Sequence< Any > ( &inBool, 1), seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"outBool"), Sequence< Any > ( & outBool, 1), seqIndices, seqOut); + outBool <<= seqOut[0]; + + inByte <<= (sal_Int8) 127; + inv->invoke(OUString(L"inByte"), Sequence< Any > ( & inByte, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outByte"), Sequence< Any > ( & outByte, 1), seqIndices, seqOut); + outByte <<= seqOut[0]; + + inShort <<= static_cast(-1); + inv->invoke(OUString(L"inShort"), Sequence< Any > ( & inShort, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outShort"), Sequence< Any > ( & outShort, 1), seqIndices, seqOut); + outShort <<= seqOut[0]; + + inLong <<= ( sal_Int32) 1234567; + inv->invoke(OUString(L"inLong"), Sequence< Any > ( & inLong, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outLong"), Sequence< Any > ( & outLong, 1 ), seqIndices, seqOut); + outLong <<= seqOut[0]; + + inString <<= OUString(L" this is clientTest.exe"); + inv->invoke(OUString(L"inString"), Sequence< Any > ( & inString, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outString"), Sequence< Any > ( & outString, 1 ), seqIndices, seqOut); + outString <<= seqOut[0]; + + inFloat <<= 3.14f; + inv->invoke(OUString(L"inFloat"), Sequence< Any > ( & inFloat, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outFloat"), Sequence< Any > ( & outFloat, 1 ), seqIndices, seqOut); + outFloat <<= seqOut[0]; + + inDouble <<= ( double) 3.145; + inv->invoke(OUString(L"inDouble"), Sequence< Any > ( & inDouble, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outDouble"), Sequence< Any > ( & outDouble, 1 ), seqIndices, seqOut); + outDouble <<= seqOut[0]; + + inVariant <<= OUString(L" A string in an any"); + inv->invoke(OUString(L"inVariant"), Sequence< Any > ( & inVariant, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outVariant"), Sequence< Any > (&outVariant, 1), seqIndices, seqOut); + outVariant <<= seqOut[0]; + + inObject <<= inv; + inv->invoke(OUString(L"inObject"), Sequence< Any > ( & inObject, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outObject"), Sequence< Any > (& outObject, 1), seqIndices, seqOut); + outObject <<= seqOut[0]; + + inUnknown <<= xIntFoo; + inv->invoke(OUString(L"inUnknown"), Sequence< Any > ( & inUnknown, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outUnknown"), Sequence< Any > (& outUnknown, 1), seqIndices, seqOut); + outUnknown <<= seqOut[0]; + + Currency cur(999999); + inCY <<= cur; + inv->invoke(OUString(L"inCurrency"), Sequence( & inCY, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outCurrency"), Sequence< Any > (& outCY, 1), seqIndices, seqOut); + outCY <<= seqOut[0]; + + Date dDate(37889.0); + inDate <<= dDate; + inv->invoke(OUString(L"inDate"), Sequence( & inDate, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outDate"), Sequence< Any > (& outDate, 1), seqIndices, seqOut); + outDate <<= seqOut[0]; + + Decimal dec(3, 0, 0xffffffff, 0xffffffff, 0xfffffff0); + inDecimal <<= dec; + inv->invoke(OUString(L"inDecimal"), Sequence( & inDecimal, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outDecimal"), Sequence< Any > (& outDecimal, 1), seqIndices, seqOut); + outDecimal <<= seqOut[0]; + + SCode code(DISP_E_BADVARTYPE); + inSCode <<= code; + inv->invoke(OUString(L"inSCode"), Sequence( & inSCode, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outSCode"), Sequence< Any > (& outSCode, 1), seqIndices, seqOut); + outSCode <<= seqOut[0]; + + if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong + || inFloat != outFloat || inDouble != outDouble || inString != outString + || inVariant != outVariant || inObject != outObject || inUnknown != outUnknown + || inCY != outCY + || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode) + return false; + + // in/out parameter + + outBool = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutBool"), Sequence< Any > ( & inBool, 1), seqIndices, seqOut); + outBool <<= seqOut[0]; + + outByte = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutByte"), Sequence< Any > ( & inByte, 1), seqIndices, seqOut); + outByte <<= seqOut[0]; + + outShort = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutShort"), Sequence< Any > ( & inShort, 1), seqIndices, seqOut); + outShort <<= seqOut[0]; + + outLong = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutLong"), Sequence< Any > ( & inLong, 1), seqIndices, seqOut); + outLong <<= seqOut[0]; + + outString = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutString"), Sequence< Any > ( & inString, 1), seqIndices, seqOut); + outString <<= seqOut[0]; + + outFloat = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutFloat"), Sequence< Any > ( & inFloat, 1), seqIndices, seqOut); + outFloat <<= seqOut[0]; + + outDouble = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutDouble"), Sequence< Any > ( &inDouble, 1), seqIndices, seqOut); + outDouble <<= seqOut[0]; + + outVariant = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutVariant"), Sequence< Any > ( & inVariant, 1), seqIndices, seqOut); + outVariant <<= seqOut[0]; + + outObject = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutObject"), Sequence< Any > ( & inObject, 1), seqIndices, seqOut); + outObject <<= seqOut[0]; + + outCY = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutCurrency"), Sequence< Any > ( & inCY, 1), seqIndices, seqOut); + outCY <<= seqOut[0]; + + outDate = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutDate"), Sequence< Any > ( & inDate, 1), seqIndices, seqOut); + outDate <<= seqOut[0]; + + outDecimal = Any(); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutDecimal"), Sequence< Any > (& inDecimal, 1), seqIndices, seqOut); + outDecimal <<= seqOut[0]; + + outSCode = Any(); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutSCode"), Sequence< Any > (& inSCode, 1), seqIndices, seqOut); + outSCode <<= seqOut[0]; + + if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong + || inFloat != outFloat || inDouble != outDouble || inString != outString + || inVariant != outVariant || inObject != outObject || inCY != outCY + || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode) + return false; + + + // in byref parameters + + + inrefLong <<= (sal_Int32) 1234; + inv->invoke(OUString(L"inrefLong"), Sequence( & inrefLong, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outLong"), Sequence< Any > (& outrefLong, 1), seqIndices, seqOut); + outrefLong <<= seqOut[0]; + + inrefVariant <<= OUString(L" A string in an any"); + inv->invoke(OUString(L"inrefVariant"), Sequence< Any > ( & inrefVariant, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outVariant"), Sequence< Any > (&outrefVariant, 1), seqIndices, seqOut); + outrefVariant <<= seqOut[0]; + + Decimal refdec(5, 1, 0xffff, 0xff, 0x1); + inrefDecimal <<= refdec; + inv->invoke(OUString(L"inrefDecimal"), Sequence< Any > ( & inrefDecimal, 1), seqIndices, seqOut); + seqIndices.realloc( 0); + seqOut.realloc(0); + inv->invoke(OUString(L"outDecimal"), Sequence< Any > (&outrefDecimal, 1), seqIndices, seqOut); + outrefDecimal <<= seqOut[0]; + + if (inrefLong != outrefLong || inrefVariant != outrefVariant + || inrefDecimal != outrefDecimal) + return false; + + + // mixed parameter + + // mixed1 + seqIndices.realloc( 0); + seqOut.realloc(0); + Any param[3]; + param[0] = inByte; + param[1] = inFloat; + param[2] = inVariant; + inv->invoke(OUString(L"mixed1"), Sequence< Any >(param, 3), seqIndices, seqOut); + + if (seqOut.getLength() != 3 || inByte != seqOut[0] || inFloat != seqOut[1] + || inVariant != seqOut[2]) + return false; + return true; +} + +bool doSimpleSequenceTest(const Reference & inv) +{ + bool ret = true; + Sequence seqIndices; + Sequence seqOut; + Any voidAny; + Any inArAny; + Any outArray; + Any inArBool, outArBool; + Any inArByte, outArByte; + Any inArShort, outArShort; + Any inArLong, outArLong; + Any inArString, outArString; + Any inArFloat, outArFloat; + Any inArDouble, outArDouble; + Any inArObject, outArObject; + Any outVariant; + + //Initialize arrays + OUString arStr[]= {L"string0", L"string1", L"string2"}; + Sequence seq( arStr, 3); + inArString <<= seq; + + Any arAnyStrTmp[3]; + arAnyStrTmp[0]<<= arStr[0]; + arAnyStrTmp[1]<<= arStr[1]; + arAnyStrTmp[2]<<= arStr[2]; + Sequence seq_1( arAnyStrTmp, 3); + inArAny <<= seq_1; + + // in, out Sequences + + //Test sequence containing Anys of Strings + inv->invoke(OUString(L"inArray"), Sequence< Any > ( & inArAny, 1), seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"outArray"), Sequence( & voidAny, 1), seqIndices, seqOut); + if (inArAny != seqOut[0]) + return false; + + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"inArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut); + inv->invoke(OUString(L"outArray"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut); + outArray <<= seqOut[0]; + + sal_Int8 arByte[]={1,2,3}; + Sequence seqByte(arByte, 3); + inArByte <<= seqByte; + inv->invoke(OUString(L"inSequenceByte"),Sequence( & inArByte, 1), seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"outSequenceByte"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut); + outArByte <<= seqOut[0]; + + sal_Int16 arShort[]={4,5,6}; + Sequence seqShort(arShort, 3); + inArShort<<= seqShort; + inv->invoke(OUString(L"inSequenceShort"),Sequence< Any >( & inArShort, 1), seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"outSequenceShort"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut); + outArShort <<= seqOut[0]; + + sal_Int32 arLong[] = {7,8,9}; + Sequence seqLong(arLong, 3); + inArLong <<= seqLong; + inv->invoke(OUString(L"inSequenceLong"),Sequence< Any > ( & inArLong, 1), seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"outSequenceLong"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut); + outArLong <<= seqOut[0]; + + inv->invoke(OUString(L"inSequenceLong"),Sequence< Any > ( & inArLong, 1), seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"outSequenceLong"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut); + outArLong <<= seqOut[0]; + + inv->invoke( OUString(L"inSequenceString"),Sequence< Any > ( & inArString, 1), seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"outSequenceString"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut); + outArString <<= seqOut[0]; + + float arFloat[]={3.14f, 31.4f, 314.f}; + Sequence seqFloat( arFloat, 3); + inArFloat <<= seqFloat; + inv->invoke( OUString(L"inSequenceFloat"),Sequence< Any > ( & inArFloat, 1), seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"outSequenceFloat"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut); + outArFloat <<= seqOut[0]; + + double arDouble[]={3.145, 31.45, 3145.}; + Sequence seqDouble( arDouble, 3); + inArDouble <<= seqDouble; + inv->invoke(OUString(L"inSequenceDouble"),Sequence< Any >( & inArDouble, 1), seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"outSequenceDouble"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut); + outArDouble <<= seqOut[0]; + + Sequence > seqObj(2); + seqObj[0]= getComObject(L"AxTestComponents.Basic"); + seqObj[1]= getComObject(L"AxTestComponents.Basic"); + inArObject <<= seqObj; + inv->invoke(OUString(L"inSequenceObject"),Sequence< Any >( & inArObject, 1), seqIndices, seqOut); + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"outSequenceObject"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut); + outArObject <<= seqOut[0]; + + if ( ! equalSequences(inArByte, outArByte) || ! equalSequences(inArShort, outArShort) + || ! equalSequences(inArLong, outArLong) || ! equalSequences(inArString, outArray) + || ! equalSequences(inArFloat, outArFloat) || ! equalSequences(inArDouble, outArDouble) + || ! equalSequences(inArString, outArString) || ! equalSequences(inArObject, outArObject)) + return false; + + + // in/out Sequences + + seqIndices.realloc(0); + seqOut.realloc(0); + inv->invoke(OUString(L"inoutArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut); + inv->invoke(OUString(L"inoutArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut); + outArray <<= seqOut[0]; + + inv->invoke(OUString(L"inoutSequenceByte"), Sequence( & inArByte, 1), seqIndices, seqOut); + inv->invoke(OUString(L"inoutSequenceByte"), Sequence( & inArByte, 1), seqIndices, seqOut); + outArByte <<= seqOut[0]; + + inv->invoke(OUString(L"inoutSequenceShort"), Sequence( & inArShort, 1), seqIndices, seqOut); + inv->invoke(OUString(L"inoutSequenceShort"), Sequence( & inArShort, 1), seqIndices, seqOut); + outArShort <<= seqOut[0]; + + inv->invoke(OUString(L"inoutSequenceLong"), Sequence( & inArLong, 1), seqIndices, seqOut); + inv->invoke(OUString(L"inoutSequenceLong"), Sequence< Any >( & inArLong, 1), seqIndices, seqOut); + outArLong <<= seqOut[0]; + + inv->invoke(OUString(L"inoutSequenceString"), Sequence( & inArString, 1), seqIndices, seqOut); + inv->invoke(OUString(L"inoutSequenceString"), Sequence( & inArString, 1), seqIndices, seqOut); + outArString <<= seqOut[0]; + + inv->invoke(OUString(L"inoutSequenceFloat"), Sequence( & inArFloat, 1), seqIndices, seqOut); + inv->invoke(OUString(L"inoutSequenceFloat"), Sequence( & inArFloat, 1), seqIndices, seqOut); + outArFloat <<= seqOut[0]; + + inv->invoke(OUString(L"inoutSequenceDouble"), Sequence( & inArDouble, 1), seqIndices, seqOut); + inv->invoke(OUString(L"inoutSequenceDouble"), Sequence( & inArDouble, 1), seqIndices, seqOut); + outArDouble <<= seqOut[0]; + + inv->invoke(OUString(L"inoutSequenceObject"), Sequence( & inArObject, 1), seqIndices, seqOut); + inv->invoke(OUString(L"inoutSequenceObject"), Sequence( & inArObject, 1), seqIndices, seqOut); + outArObject <<= seqOut[0]; + + if ( ! equalSequences(inArByte, outArByte) || ! equalSequences(inArShort, outArShort) + || ! equalSequences(inArLong, outArLong) || ! equalSequences(inArString, outArray) + || ! equalSequences(inArFloat, outArFloat) || ! equalSequences(inArDouble, outArDouble) + || ! equalSequences(inArString, outArString) || ! equalSequences(inArObject, outArObject)) + return false; + + return ret; +} + +HRESULT doTest() +{ + HRESULT hr= S_OK; + USES_CONVERSION; + Reference inv= getComObject( L"AxTestComponents.Basic"); + + HostWin* pWin= new HostWin( L"MFCCONTROL.MfcControlCtrl.1"); + CComPtr spUnk= pWin->GetHostedControl(); + Reference invMfc= convertComObject( spUnk.p); + + Sequence< sal_Int16> seqIndices; + Sequence seqOut; + + Any aAny; + Any anyOut; + char buff[1024]; + Any seqAny; + + if (! doSimpleTest(inv)) + { + fprintf(stdout, "### Test failed!\n"); + return E_FAIL; + } + + if (! doPropertyTest(inv)) + { + fprintf(stdout, "### Test failed!\n"); + return E_FAIL; + } + + if ( ! doSimpleSequenceTest(inv)) + { + fprintf(stdout, "### Test failed! \n"); + return E_FAIL; + } + + if ( ! doParameterTest(inv)) + { + fprintf(stdout, "### Test failed! \n"); + return E_FAIL; + } + + if ( ! doPropertyWithArgumentTest(inv)) + { + fprintf(stdout, "### Test failed! \n"); + return E_FAIL; + } + + +// // in multi Sequences + +// // inMulDimArrayLong + sal_Int32 arLongi[]={1,2,3}; + sal_Int32 arLongi2[]={4,5,6,7}; + sal_Int32 arLongi3[]={8,9,10,11,12}; + + Sequence seqLongi1( arLongi, 3); + Sequence seqLongi2( arLongi2, 4); + Sequence seqLongi3( arLongi3, 5); + + Sequence< Sequence< sal_Int32 > > seq2i(3); + seq2i[0]= seqLongi1; + seq2i[1]= seqLongi2; + seq2i[2]= seqLongi3; + seqAny<<= seq2i; + // dimension length 3,5 + inv->invoke( OUString(L"inMulDimArrayLong"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut); + + //inMulDimArrayVariant + inv->invoke( OUString(L"inMulDimArrayVariant"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut); + + //inMulDimArrayLong2 + sal_Int32 arLongii1[]={1,2,3}; + sal_Int32 arLongii2[]={4,5,6,7}; + sal_Int32 arLongii3[]={8,9,10,11,12}; + sal_Int32 arLongii4[]={13,14,15,16}; + sal_Int32 arLongii5[]={17,18,19}; + + Sequence seqLongii1( arLongii1, 3); + Sequence seqLongii2( arLongii2, 4); + Sequence seqLongii3( arLongii3, 5); + Sequence seqLongii4( arLongii4, 4); + Sequence seqLongii5( arLongii5, 3); + + Sequence< Sequence< sal_Int32 > > seq2ii(3); + Sequence< Sequence< sal_Int32> > seq2ii2(2); + seq2ii[0]= seqLongii1; + seq2ii[1]= seqLongii2; + seq2ii[2]= seqLongii3; + + seq2ii2[0]= seqLongii4; + seq2ii2[1]= seqLongii5; + + Sequence< Sequence< Sequence< sal_Int32> > > seq3ii(2); + seq3ii[0]=seq2ii; + seq3ii[1]=seq2ii2; + seqAny<<= seq3ii; + inv->invoke( OUString(L"inMulDimArrayLong2"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut); + + // inMulDimArrayByte2 + sal_Int8 arByteii1[]={1,2,3}; + sal_Int8 arByteii2[]={4,5,6,7}; + sal_Int8 arByteii3[]={8,9,10,11,12}; + sal_Int8 arByteii4[]={13,14,15,16}; + sal_Int8 arByteii5[]={17,18,19}; + + Sequence seqByteii1( arByteii1, 3); + Sequence seqByteii2( arByteii2, 4); + Sequence seqByteii3( arByteii3, 5); + Sequence seqByteii4( arByteii4, 4); + Sequence seqByteii5( arByteii5, 3); + + Sequence< Sequence< sal_Int8 > > seq2Byteii(3); + Sequence< Sequence< sal_Int8> > seq2Byteii2(2); + seq2Byteii[0]= seqByteii1; + seq2Byteii[1]= seqByteii2; + seq2Byteii[2]= seqByteii3; + + seq2Byteii2[0]= seqByteii4; + seq2Byteii2[1]= seqByteii5; + + Sequence< Sequence< Sequence< sal_Int8> > > seq3Byteii(2); + seq3Byteii[0]=seq2Byteii; + seq3Byteii[1]=seq2Byteii2; + seqAny<<= seq3Byteii; + inv->invoke( OUString(L"inMulDimArrayByte2"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut); + + + // Tests with a MFC ActiveX control, ( pure dispinterface) + + + // in parameter MFC ActiveX + + // unsigned char is not supported by MFC + // aAny <<= ( sal_Int8) 127; + // invMfc->invoke( OUString(L"inByte"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + if ( ! invMfc.is()) + return hr; + aAny <<= static_cast(-1); + aAny= invMfc->invoke( OUString(L"inShort"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + + + aAny <<= ( sal_Int32) 1234567; + aAny=invMfc->invoke( OUString(L"inLong"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + sal_Int32 retLong= *(sal_Int32*)aAny.getValue(); + + OUString str_1(L" this is clientTest.exe"); + aAny <<= str_1; + aAny=invMfc->invoke( OUString(L"inString"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + aAny>>= str_1; + + aAny <<= ( float) 3.14; + aAny=invMfc->invoke( OUString(L"inFloat"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + + aAny <<= ( double) 3.145; + aAny=invMfc->invoke( OUString(L"inDouble"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + + aAny <<= OUString( L" A string in an any"); + aAny=invMfc->invoke( OUString(L"inVariant"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + + + Reference < XInvocation > inv5= getComObject(L"AxTestComponents.Basic"); + Any anyVal4; + anyVal4 <<= OUString(L"this is the value of prpString"); + inv5->setValue( OUString(L"prpString"), anyVal4); + aAny <<= inv5; + aAny=invMfc->invoke( OUString(L"inObject"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + + +// // out parameter MFC ActiveX + + +// // outShort + aAny= invMfc->invoke( OUString(L"outShort"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + anyOut<<= seqOut[0]; + sprintf(buff, "MFC outShort %d", *(sal_Int16*)anyOut.getValue()); + MessageBox( NULL, buff, _T("clientTest"), MB_OK); + + // outLong + aAny= invMfc->invoke( OUString(L"outLong"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + anyOut<<= seqOut[0]; + sprintf(buff, "MFC outLong %d", *(sal_Int32*)anyOut.getValue()); + MessageBox( NULL, buff, _T("clientTest"), MB_OK); + + // outString + aAny= invMfc->invoke( OUString(L"outString"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + anyOut<<= seqOut[0]; + sprintf(buff, "MFC outString %S", ((OUString*)anyOut.getValue())->getStr()); + MessageBox( NULL, buff, _T("clientTest"), MB_OK); + + // outFloat + aAny= invMfc->invoke( OUString(L"outFloat"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + anyOut<<= seqOut[0]; + sprintf(buff, "MFC outFloat %f", *(float*)anyOut.getValue()); + MessageBox( NULL, buff, _T("clientTest"), MB_OK); + + // outDouble + aAny= invMfc->invoke( OUString(L"outDouble"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + anyOut<<= seqOut[0]; + sprintf(buff, "MFC outFloat %f", *(double*)anyOut.getValue()); + MessageBox( NULL, buff, _T("clientTest"), MB_OK); + + // outVariant + // we expect a string!! ( VT_BSTR) + aAny= invMfc->invoke( OUString(L"outVariant"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + anyOut<<= seqOut[0]; + sprintf(buff, "MFC outVariant %S", ((OUString*)anyOut.getValue())->getStr()); + MessageBox( NULL, buff, _T("clientTest"), MB_OK); + + // outDouble + aAny= invMfc->invoke( OUString(L"outObject"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + Reference invOut5; + seqOut[0]>>= invOut5; + // we assume that an object of AxTestControls.Basic is being returned. + anyOut= invOut5->getValue( OUString(L"prpString")); + OUString tmpStr; + anyOut>>=tmpStr; + sprintf(buff, "MFC outObject, property: %S", tmpStr.getStr()); + MessageBox( NULL, buff, _T("clientTest"), MB_OK); + + + // Sequence parameter MFC ActiveX + + // Sequences are not directly supported. + + + delete pWin; + return hr; + +} + + +//VARIANT_TRUE VT_UI1 + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/OleClient/funcs.cxx b/extensions/test/ole/OleClient/funcs.cxx new file mode 100644 index 000000000..a72c7c49e --- /dev/null +++ b/extensions/test/ole/OleClient/funcs.cxx @@ -0,0 +1,345 @@ +/* -*- 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 +#include +#include "cppuhelper/bootstrap.hxx" +#include "rtl/process.h" +#include "typelib/typedescription.hxx" + +#include "com/sun/star/bridge/ModelDependent.hpp" +#include "com/sun/star/bridge/XBridgeSupplier2.hpp" +#include "com/sun/star/uno/TypeClass.hpp" +#include "com/sun/star/script/XInvocation.hpp" +#include "com/sun/star/lang/XMultiServiceFactory.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include +#include "rtl/ustring.hxx" + +using namespace com::sun::star::bridge; +using namespace com::sun::star::bridge::ModelDependent; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::script; +using namespace com::sun::star::bridge::oleautomation; +using namespace cppu; + + +template< class T > +bool equalSequences(const Sequence& seqIn, const Sequence & returned); + + +Reference< XMultiServiceFactory > objectFactory; + + +Reference getMultiServiceFactory() +{ + static Reference< XMultiServiceFactory > factory; + if( ! objectFactory.is() ) + { + Reference context = defaultBootstrap_InitialComponentContext(); + factory.set(context->getServiceManager(), UNO_QUERY); + + } + return factory; +} + +Reference getComObject( OUString progId) +{ + HRESULT hr= S_OK; + Reference< XInvocation > ret; + if( ! objectFactory.is()) + { Reference mgr= getMultiServiceFactory(); + Reference xInt= mgr->createInstance( + "com.sun.star.bridge.oleautomation.Factory"); + objectFactory.set(xInt, UNO_QUERY); + } + + if( objectFactory.is()) + { + Reference xIntAx= objectFactory->createInstance( progId.getStr()); + if( xIntAx.is() ) + { + Reference< XInvocation > xInv( xIntAx, UNO_QUERY); + ret= xInv; + } + } + return ret; +} + +Reference convertComObject( IUnknown* pUnk) +{ + Reference< XMultiServiceFactory > mgr= getMultiServiceFactory(); + Reference< XInterface > xIntSupplier= mgr->createInstance("com.sun.star.bridge.OleBridgeSupplier2"); + Reference< XBridgeSupplier2 > xSuppl( xIntSupplier, UNO_QUERY); + + Any any; + CComVariant var( pUnk); + any <<= (sal_uIntPtr) &var; + sal_uInt8 arId[16]; + rtl_getGlobalProcessId( arId); + Any target= xSuppl->createBridge( any, Sequence( (sal_Int8*)arId, 16), OLE, UNO ); + + Reference ret; + target>>= ret; + return ret; +} + +/* + Parameter values contains the expected return values. The value at index 0 + correspond to parameter 0 (left - most). For parameters which are not out or + in/out the value must be a void any. + + The number of items in value must be the + same as the number of provided parameter during the call on the method. + + The parameter outArgs, indices correspond to the sequences which are + arguments to XInvocation::invoke + */ +bool checkOutArgs(const Sequence & outArgs, + const Sequence & indices, const Sequence & values) +{ + if (values.getLength() != outArgs.getLength()) + return false; + //iterate over all parameters. i represents the parameter index + for (int i = 0; i < values.getLength(); i++) + { + if (values[i].getValueType() == cppu::UnoType::get()) + continue; + //out parameter + //Based on the parameter index find the correspondent out value + int indexOutSeq = -1; + for (int iIndices = indices.getLength() - 1; iIndices >= 0; iIndices --) + { + if (indices[iIndices] == i) + { + indexOutSeq = iIndices; + break; + } + } + if (indexOutSeq == -1) + return false; + + Any value; + Any out; + values[i] >>= value; + outArgs[indexOutSeq] >>=out; + NamedArgument naVal; + NamedArgument naOut; + value >>= naVal; + out >>= naOut; + if (values[i].getValueType() == cppu::UnoType::get()) + { + NamedArgument inNamed; + values[i] >>= inNamed; + value <<= inNamed.Value; + } + if (value != outArgs[indexOutSeq]) + return false; + } + return true; +} + +/* The returned sequence always contains Any elements +*/ +bool equalSequences(const Any& orig, const Any& returned) +{ + if (orig.getValueTypeClass() != TypeClass_SEQUENCE) + { + OSL_ASSERT(0); + return false; + } + TypeDescription td(orig.getValueTypeRef()); + typelib_IndirectTypeDescription * indirect_td = (typelib_IndirectTypeDescription *) td.get(); + + switch (indirect_td->pType->eTypeClass) + { + case TypeClass_CHAR: + { + Sequence seq; + orig >>= seq; + Sequence seq2; + returned >>= seq2; + return equalSequences(seq, seq2); + } + case TypeClass_BOOLEAN: + { + Sequence seq; + orig >>= seq; + Sequence seq2; + returned >>= seq2; + return equalSequences(seq, seq2); + } + case TypeClass_BYTE: + { + Sequence seq; + orig >>= seq; + Sequence seq2; + returned >>= seq2; + return equalSequences(seq, seq2); + } + case TypeClass_SHORT: + { + Sequence seq; + orig >>= seq; + Sequence seq2; + returned >>= seq2; + return equalSequences(seq, seq2); + } + case TypeClass_LONG: + { + Sequence seq; + orig >>= seq; + Sequence seq2; + returned >>= seq2; + return equalSequences(seq, seq2); + } + case TypeClass_FLOAT: + { + Sequence seq; + orig >>= seq; + Sequence seq2; + returned >>= seq2; + return equalSequences(seq, seq2); + } + case TypeClass_DOUBLE: + { + Sequence seq; + orig >>= seq; + Sequence seq2; + returned >>= seq2; + return equalSequences(seq, seq2); + } + case TypeClass_STRING: + { + Sequence seq; + orig >>= seq; + Sequence seq2; + returned >>= seq2; + return equalSequences(seq, seq2); + } + case TypeClass_ANY: + { + Sequence seq; + orig >>= seq; + Sequence seq2; + returned >>= seq2; + return equalSequences(seq, seq2); + } + case TypeClass_SEQUENCE: + { + //Sequence seq; + //orig >>= seq; + //Sequence seq2; + //returned >>= seq2; + //return equalSequences(seq, seq2); + break; + } + case TypeClass_INTERFACE: + { + Sequence > seq; + orig >>= seq; + Sequence seq2; + returned >>= seq2; + return equalSequences(seq, seq2); + } + default: + return false; + } + return false; +} + +template< class T > +bool equalSequences(const Sequence& seqIn, const Sequence & seqOut) +{ + if (seqIn.getLength() != seqOut.getLength()) + return false; + int len = seqIn.getLength(); + for (int i = 0; i < len; i++) + { + Any anyIn; + anyIn <<= seqIn[i]; + Any anyOut = seqOut[i]; + if (anyIn != anyOut) + return false; + } + + return true; +} + +void printSequence( Sequence& val) +{ + +// typelib_TypeDescription* desc; +// val.getValueTypeDescription( &desc); +// typelib_typedescription_release( desc); + + USES_CONVERSION; + char buff[1024]; + buff[0]=0; + char tmpBuf[1024]; + tmpBuf[0]=0; + sal_Int32 i; + + for( i=0; i< val.getLength(); i++) + { + Any& elem= val[i]; + switch ( elem.getValueTypeClass()) + { + case TypeClass_BYTE: + sprintf( tmpBuf, "sal_Int8 %d \n", *(sal_Int8*)elem.getValue()); + break; + case TypeClass_SHORT: + sprintf( tmpBuf, "sal_Int16 %d \n", *(sal_Int16*)elem.getValue()); + break; + case TypeClass_LONG: + sprintf( tmpBuf, "sal_Int32 %d \n", *(sal_Int32*)elem.getValue()); + break; + case TypeClass_DOUBLE: + sprintf( tmpBuf, "double %f \n", *(double*)elem.getValue()); + break; + case TypeClass_FLOAT: + sprintf( tmpBuf, "float %f \n", *(float*)elem.getValue()); + break; + case TypeClass_STRING: + sprintf( tmpBuf, "%S \n", (*(OUString*)elem.getValue()).getStr()); + break; + case TypeClass_INTERFACE: + { + // we assume that the interface is XInvocation of an AxTestControls.Basic component. + Reference inv; + elem>>= inv; + if( inv.is()) + { + Any prpVal= inv->getValue( OUString( L"prpString")); + sprintf( tmpBuf, "Property prpString: %S \n", (*(OUString*)prpVal.getValue()).getStr()); + } + break; + } + default:break; + } + strcat( buff, tmpBuf); + + } + + MessageBox( NULL, A2T(buff), _T("clientTest: printing Sequence elements"), MB_OK); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/OleClient/readme.txt b/extensions/test/ole/OleClient/readme.txt new file mode 100644 index 000000000..bcee8edde --- /dev/null +++ b/extensions/test/ole/OleClient/readme.txt @@ -0,0 +1,10 @@ +The program tests the OleObjectFactory service which enables to use COM components +through XInvocation. + +Requirements: + +types.rdb and services.rdb and OleClient.ini have to be next to the executable. +COM component: XCallback_Impl.Simple ( extensions/test/ole/unotocomcalls/XCallback_Impl ) +ActiveX controls: AxTestComponent.Basic ( extensions/test/ole/AxTestComponents) + MFCCONTROL.MfcControlCtrl.1 (extensions/test/ole/MfcControl) + diff --git a/extensions/test/ole/OleConverterVar1/convTest.cxx b/extensions/test/ole/OleConverterVar1/convTest.cxx new file mode 100644 index 000000000..8fc27177e --- /dev/null +++ b/extensions/test/ole/OleConverterVar1/convTest.cxx @@ -0,0 +1,647 @@ +/* -*- 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 . + */ + + +#pragma warning (disable: 4917) +#if !defined WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +extern CComModule _Module; +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +CComModule _Module; +BEGIN_OBJECT_MAP(ObjectMap) +END_OBJECT_MAP() + +#include "smartarray.h" +using namespace com::sun::star::bridge; +using namespace com::sun::star::bridge::ModelDependent; +using namespace com::sun::star::lang; +using namespace com::sun::star::uno; +using namespace oletest; +using namespace cppu; + + +HRESULT doTest(); +HRESULT InitializeParameter(); +void printResultVariantArray( VARIANT & var); +void printVariant( VARIANT & var); + + +int SAL_CALL main( int argc, char* argv[] ) +{ + HRESULT hr; + if( FAILED( hr=CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) + { + printf("CoInitializeEx failed \n"); + return -1; + } + + + _Module.Init( ObjectMap, GetModuleHandleA( NULL)); + + if( FAILED(hr=doTest())) + { + _com_error err( hr); + const CHAR * errMsg= err.ErrorMessage(); + MessageBoxA( NULL, errMsg, "Test failed", MB_ICONERROR); + } + + + _Module.Term(); + CoUninitialize(); + return 0; +} +char _c[]={ 1,2,3,4,5}; +short _short[]={0xffff, 1, 11 ,111, 1111 }; +unsigned short _ushort[]={0xffff, 1, 11 ,111, 1111 }; +long _long[]= { 0xffffffff, 11, 111 ,1111, 1111 }; +unsigned long _ulong[]= { 0xffffffff, 11, 111 ,1111, 1111 }; +float _float[]= { 12345.f, 1234.5f, 123.45f, 12.345f, 1.2345f}; +double _double[]= {12345, 1234.5, 123.45, 12.345, 1.2345}; + +CComVariant _variant[]= {L"variant 1", L"variant2", L"variant3"}; +wchar_t _wchar[]= {L'1', L'2', L'3', L'A', L' '}; +BSTR _bstr[]={L"Ich", L"bin", L"ein", L"Hamburger", L"Jung"}; +SmartArray arByte( _c, 5, VT_I1); +SmartArray< short> arShort( _short, 5, VT_I2); +//SmartArray< unsigned short> arUShort( _ushort, 5, VT_UI2); +SmartArray< long> arLong( _long, 5, VT_I4); +//SmartArray< unsigned long> arULong( _ulong, 5, VT_UI4); +//SmartArray< float> arFloat( _float, 5, VT_R4 ); +SmartArray< double> arDouble( _double, 5, VT_R8 ); +//SmartArray< unsigned short> arWChar( _wchar, 5, VT_UI2 ); +SmartArray< wchar_t* > arString( _bstr, 5, VT_BSTR); +SmartArray< VARIANT > arVariant( _variant, 3, VT_VARIANT); + + +HRESULT doTest() +{ + HRESULT hr; + USES_CONVERSION; + CComPtr spUnkMgr; + + putenv("UNO_TYPES=types.rdb"); + putenv("UNO_SERVICES=services.rdb"); + Reference xContext = defaultBootstrap_InitialComponentContext(); + + Reference< XMultiComponentFactory > mgr = xContext->getServiceManager();//createRegistryServiceFactory( OUString(L"services.rdb")); + Reference< XInterface > xIntSupplier= mgr->createInstanceWithContext( + "com.sun.star.bridge.OleBridgeSupplierVar1", xContext); + Reference< XBridgeSupplier2 > xSuppl( xIntSupplier, UNO_QUERY); + Reference xOletest= mgr->createInstanceWithContext( + "oletest.OleTest", xContext); + Any any; + any <<= xOletest; + sal_uInt8 arId[16]; + rtl_getGlobalProcessId( arId); + Any target= xSuppl->createBridge( any, Sequence( (sal_Int8*)arId, 16), UNO, OLE); + CComDispatchDriver oletest; + if (target.getValueTypeClass() == cppu::UnoType::get().getTypeClass()) + { + VARIANT* pVariant = *(VARIANT**)target.getValue(); + + oletest= pVariant->pdispVal; + + VariantClear(pVariant); + CoTaskMemFree(pVariant); + } + + CComVariant varRet; + CComVariant varParam1; + CComVariant varParam2; + CComVariant varParam3; + CComVariant varParam4; + + long value= 100; + varParam1.vt= VT_I1 | VT_BYREF; + varParam1.plVal= &value; + + // Testing the caching of DISPIDs and the process of acquiring member information + // on demand in IDispatch::Invoke + // Step through the corresponding IDispatch implementation of the ole bridge + hr= oletest.Invoke1(static_cast(L"testinout_methodByte"), &varParam1, &varRet); + hr= oletest.Invoke1(static_cast(L"testinout_methodByte"), &varParam1, &varRet); + // Name ok but different case + hr= oletest.Invoke1(static_cast(L"Testinout_methodByte"), &varParam1, &varRet); + hr= oletest.Invoke1(static_cast(L"Testinout_methodByte"), &varParam1, &varRet); + // not existing member + hr= oletest.Invoke1(static_cast(L"Testinout"), &varParam1, &varRet); + hr= oletest.Invoke1(static_cast(L"Testinout"), &varParam1, &varRet); + + // Property + varParam1.vt= VT_ARRAY | VT_I1; + varParam1.parray= (SAFEARRAY*)arByte; + hr= oletest.PutPropertyByName( static_cast(L"AttrByte"), &varParam1); + hr= oletest.PutPropertyByName( static_cast(L"AttrByte"), &varParam1); + // Name ok but different case + hr= oletest.PutPropertyByName( static_cast(L"attrByte"), &varParam1); + hr= oletest.PutPropertyByName( static_cast(L"attrByte"), &varParam1); + // not existing member + hr= oletest.PutPropertyByName( static_cast(L"attr"), &varParam1); + hr= oletest.PutPropertyByName( static_cast(L"attr"), &varParam1); + + // PropertyGet + hr= oletest.GetPropertyByName( static_cast(L"AttrByte"), &varRet); + + hr= oletest.GetPropertyByName( static_cast(L"attrByte"), &varRet); + hr= oletest.GetPropertyByName( static_cast(L"attrByte"), &varRet); + //not existing member + hr= oletest.GetPropertyByName( static_cast(L"attrBy"), &varRet); + hr= oletest.GetPropertyByName( static_cast(L"attrBy"), &varRet); + + DISPID dispid; + LPOLESTR method= L"methodByte"; + hr = oletest.p->GetIDsOfNames(IID_NULL, &method, 1, LOCALE_USER_DEFAULT, &dispid); + + + CComVariant arg[1]; + arg[0].vt= VT_ARRAY | VT_I1; + arg[0].parray= (SAFEARRAY*)arByte; + DISPPARAMS params={ arg,0,1,0}; + + hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD | DISPATCH_PROPERTYPUT, ¶ms, &varRet, NULL, NULL); + + hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD | DISPATCH_PROPERTYPUT, ¶ms, &varRet, NULL, NULL); + + // different case + LPOLESTR method2= L"MEthodByte"; + hr = oletest.p->GetIDsOfNames(IID_NULL, &method2, 1, LOCALE_USER_DEFAULT, &dispid); + + hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD | DISPATCH_PROPERTYPUT, ¶ms, &varRet, NULL, NULL); + + hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD | DISPATCH_PROPERTYPUT, ¶ms, &varRet, NULL, NULL); + + LPOLESTR attrib= L"AttrByte"; + hr = oletest.p->GetIDsOfNames(IID_NULL, &attrib, 1, LOCALE_USER_DEFAULT, &dispid); + + hr = oletest.p->Invoke( dispid, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD | DISPATCH_PROPERTYPUTREF, ¶ms, &varRet, NULL, NULL); + + hr = oletest.p->Invoke( dispid, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD | DISPATCH_PROPERTYGET, ¶ms, &varRet, NULL, NULL); + + + CComVariant varByteArray; + varByteArray.vt= VT_ARRAY | VT_I1; + varByteArray.parray= (SAFEARRAY*)arByte; + CComVariant varShortArray; + varShortArray.vt= VT_ARRAY | VT_I2; + varShortArray.parray= (SAFEARRAY*)arShort; + CComVariant varLongArray; + varLongArray.vt= VT_ARRAY | VT_I4; + varLongArray.parray= (SAFEARRAY*)arLong; + CComVariant varDoubleArray; + varDoubleArray.vt= VT_ARRAY | VT_R8; + varDoubleArray.parray= (SAFEARRAY*)arDouble; + CComVariant varStringArray; + varStringArray.vt= VT_ARRAY | VT_BSTR; + varStringArray.parray= (SAFEARRAY*)arString; + CComVariant varArray; + varArray.vt= VT_ARRAY | VT_VARIANT; + varArray.parray= (SAFEARRAY*)arVariant; + + FONTDESC fd={ sizeof( fd), L"ARIAL", 10, FW_NORMAL, 0, 0, 0, 0}; + + + CComPtr< IUnknown > unk1; + CComPtr< IUnknown > unk2; + CComPtr< IUnknown > unk3; + + IUnknown* _unknown[3]; + hr= OleCreateFontIndirect( &fd, __uuidof( IUnknown), (void**)&unk1.p); + hr= OleCreateFontIndirect( &fd, __uuidof( IUnknown), (void**)&unk2.p); + hr= OleCreateFontIndirect( &fd, __uuidof( IUnknown), (void**)&unk3.p); + _unknown[0]= unk1; + _unknown[1]= unk2; + _unknown[2]= unk3; + SmartArray arUnknown( _unknown, 3, VT_UNKNOWN); + + CComVariant varUnkArray; + varUnkArray.vt= VT_ARRAY | VT_UNKNOWN; + varUnkArray.parray= (SAFEARRAY*)arUnknown; + + // preparing out parameter; + char byteOut; + CComVariant varOutByte; + varOutByte.vt= VT_BYREF | VT_UI1; + V_I1REF(&varOutByte)= &byteOut; + short shortOut; + CComVariant varOutShort; + varOutShort.vt= VT_BYREF | VT_I2; + V_I2REF( &varOutShort)= &shortOut; + long longOut; + CComVariant varOutLong; + varOutLong.vt= VT_BYREF | VT_I4; + V_I4REF( &varOutLong)= &longOut; + double doubleOut; + CComVariant varOutDouble; + varOutDouble.vt= VT_BYREF | VT_R8; + V_R8REF( &varOutDouble)= &doubleOut; + BSTR bstrOut= NULL; + CComVariant varOutString; + varOutString.vt= VT_BYREF | VT_BSTR; + V_BSTRREF(&varOutString)= &bstrOut; + CComVariant variantOut; + CComVariant varOutAny; + varOutAny.vt= VT_BYREF | VT_VARIANT; + V_VARIANTREF(&varOutAny)= &variantOut; + + CComPtr dispOut; + CComVariant varOutXInterface; + varOutXInterface.vt= VT_BYREF |VT_DISPATCH; + V_DISPATCHREF(&varOutXInterface)= &dispOut.p; + + // In Parameter ( all of type Sequence ########################################################### + OutputDebugStringA( "In parameter of type Sequence ###########################################\n" + "The functions return the Sequence parameter \n\n"); + + OutputDebugStringA("methodByte | Params: \n"); + printVariant( varByteArray); + hr= oletest.Invoke1(static_cast(L"methodByte"), &varByteArray, &varRet); + OutputDebugStringA("methodByte | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodShort | Params: \n"); + printVariant( varShortArray); + hr= oletest.Invoke1(static_cast(L"methodShort"), &varShortArray, &varRet); + OutputDebugStringA("methodShort | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodLong | Params: \n"); + printVariant( varLongArray); + hr= oletest.Invoke1(static_cast(L"methodLong"), &varLongArray, &varRet); + OutputDebugStringA("methodLong | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodDouble | Params: \n"); + printVariant( varDoubleArray); + hr= oletest.Invoke1(static_cast(L"methodDouble"), &varDoubleArray, &varRet); + OutputDebugStringA("methodDouble | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodString | Params: \n"); + printVariant( varStringArray); + hr= oletest.Invoke1(static_cast(L"methodString"), &varStringArray, &varRet); + OutputDebugStringA("methodString | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodAny | Params: \n"); + printVariant( varArray); + hr= oletest.Invoke1(static_cast(L"methodAny"), &varArray, &varRet); + OutputDebugStringA("methodAny | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodXInterface | Params: \n"); + printVariant( varUnkArray); + hr= oletest.Invoke1(static_cast(L"methodXInterface"), &varUnkArray, &varRet); + OutputDebugStringA("methodAny | return value \n"); + printVariant( varRet); + + // Out Parameter ########################################################################### + OutputDebugStringA("Out parameter ###########################################\n\n"); + + OutputDebugStringA("testout_methodByte \n"); + hr= oletest.InvokeN(static_cast(L"testout_methodByte"), &varOutByte, 1, &varRet); + OutputDebugStringA("testout_methodByte | out value: \n"); + printVariant( varOutByte); + + OutputDebugStringA("testout_methodShort \n"); + hr= oletest.Invoke1(static_cast(L"testout_methodShort"), &varOutShort, &varRet); + OutputDebugStringA("testout_methodShort | out value: \n"); + printVariant( varOutShort); + + OutputDebugStringA("testout_methodLong \n"); + hr= oletest.Invoke1(static_cast(L"testout_methodLong"), &varOutLong, &varRet); + OutputDebugStringA("testout_methodLong | out value: \n"); + printVariant( varOutLong); + + OutputDebugStringA("testout_methodDouble \n"); + hr= oletest.Invoke1(static_cast(L"testout_methodDouble"), &varOutDouble, &varRet); + OutputDebugStringA("testout_methodDouble | out value: \n"); + printVariant( varOutDouble); + + OutputDebugStringA("testout_methodString \n"); + hr= oletest.Invoke1(static_cast(L"testout_methodString"), &varOutString, &varRet); + OutputDebugStringA("testout_methodString | out value: \n"); + printVariant( varOutString); + + OutputDebugStringA("testout_methodAny \n"); + hr= oletest.Invoke1(static_cast(L"testout_methodAny"), &varOutAny, &varRet); + OutputDebugStringA("methodAny | out value: \n"); + printVariant( varOutAny); + + OutputDebugStringA("testout_methodXInterface \n"); + hr= oletest.Invoke1(static_cast(L"testout_methodXInterface"), &varOutXInterface, &varRet); + OutputDebugStringA("methodAny | out value: \n"); + printVariant( varOutXInterface); + CComDispatchDriver outDisp( *varOutXInterface.ppdispVal); + CComVariant varAttr3; + outDisp.GetPropertyByName(L"AttrAny2", &varAttr3); + ATLTRACE("property OleTest.AttrAny2: %s", W2A(varAttr3.bstrVal)); + + OutputDebugStringA("testout_methodMulParams1 ( 2 out Parameter) \n"); + long longOut2=0; + CComVariant _params[2]; + longOut=0; + _params[0]= varOutLong; + _params[1].vt= VT_BYREF | VT_I4; + V_I4REF(& _params[1])= &longOut2; + hr= oletest.InvokeN( static_cast(L"testout_methodMulParams1"), (VARIANT*)&_params, 2); + OutputDebugStringA("testout_methodMulParams1 | out values: \n"); + printVariant( _params[1]); + printVariant( _params[0]); + + OutputDebugStringA("testout_methodMulParams2 ( 3 out Parameter) \n"); + CComVariant _params2[3]; + _params2[2]= varOutLong; + _params2[1].vt= VT_BYREF | VT_I4; + V_I4REF(& _params2[1])= &longOut2; + _params2[0]= varOutString; + hr= oletest.InvokeN( static_cast( L"testout_methodMulParams2"), (VARIANT*)&_params2, 3); + OutputDebugStringA("testout_methodMulParams2 | out values: \n"); + printVariant( _params2[2]); + printVariant( _params2[1]); + printVariant( _params2[0]); + + OutputDebugStringA("testout_methodMulParams3 ( 1 in and 1 out Parameter) \n"); + CComVariant _params3[2]; + _params3[1]= CComBSTR(L" In string"); + _params3[0]= varOutString; + hr= oletest.InvokeN( static_cast( L"testout_methodMulParams3"), (VARIANT*)&_params3, 2); + OutputDebugStringA("testout_methodMulParams3 | out values: \n"); + printVariant( _params3[1]); + printVariant( _params3[0]); + + //In Out Parameter ########################################################################### + OutputDebugStringA("In Out parameter ###########################################\n\n"); + + *V_I1REF(&varOutByte)= 5; + ATLTRACE("testinout_methodByte | in value: %d \n", *V_I1REF(&varOutByte)); + hr= oletest.InvokeN(static_cast(L"testinout_methodByte"), &varOutByte, 1, &varRet); + OutputDebugStringA("testinout_methodByte | out value: \n"); + printVariant( varOutByte); + + OutputDebugStringA("testinout_methodShort | in value= 1000 \n"); + *V_UI2REF(&varOutShort)= 1000; + hr= oletest.Invoke1(static_cast(L"testinout_methodShort"), &varOutShort, &varRet); + OutputDebugStringA("testinout_methodShort | out value: \n"); + printVariant( varOutShort); + + OutputDebugStringA("testinout_methodLong | in value= 10000 \n"); + *V_UI4REF(&varOutLong)= 10000; + hr= oletest.Invoke1(static_cast(L"testinout_methodLong"), &varOutLong, &varRet); + OutputDebugStringA("testinout_methodLong | out value: \n"); + printVariant( varOutLong); + + *V_R8REF(&varOutDouble)= 3.14; + ATLTRACE("testinou_methodDouble in value: %f \n",*V_R8REF(&varOutDouble)); + hr= oletest.Invoke1(static_cast(L"testinout_methodDouble"), &varOutDouble, &varRet); + OutputDebugStringA("testinout_methodDouble | out value: \n"); + printVariant( varOutDouble); + + SysFreeString( *V_BSTRREF(&varOutString)); + *V_BSTRREF(&varOutString)= SysAllocString( L"this is a in string"); + ATLTRACE("testinout_methodString | value: %s \n", W2A(*V_BSTRREF(&varOutString))); + hr= oletest.Invoke1(static_cast(L"testinout_methodString"), &varOutString, &varRet); + OutputDebugStringA("testinout_methodString | out value: \n"); + printVariant( varOutString); + + CComVariant var1(CComBSTR(L" this is a string in a VARIANT")); + CComVariant outVar1; + outVar1.vt= VT_BYREF | VT_VARIANT; + outVar1.pvarVal= &var1; + ATLTRACE("testinout_methodAny | parameter: %s\n", W2A(var1.bstrVal)); + hr= oletest.Invoke1(static_cast(L"testinout_methodAny"), &varOutAny, &varRet); + OutputDebugStringA("testinout_methodAny | out value: \n"); + printVariant( varOutAny); + + CComPtr< IUnknown > objectIn = unk1; + CComVariant varOutIFace; + varOutIFace.vt= VT_BYREF | VT_UNKNOWN; + varOutIFace.ppunkVal= &objectIn.p; + (*varOutIFace.ppunkVal)->AddRef(); + OutputDebugStringA("testinout_methodXInterface | in value: \n"); + printVariant(varOutIFace); + hr= oletest.Invoke1(static_cast(L"testinout_methodXInterface"), &varOutIFace, &varRet); + OutputDebugStringA("testinout_methodXInterface | out value: \n"); + printVariant( varOutIFace); + + // Properties ###################################################################### + OutputDebugStringA(" Properties ###########################################\n\n"); + + OutputDebugStringA("set property \"AttrByte\" | value"); + //CComVariant propArByte; + //propArByte.vt= VT_ARRAY | VT_I1; + varParam1.parray= (SAFEARRAY*)arByte; + printVariant( varParam1); + hr= oletest.PutPropertyByName( static_cast(L"AttrByte"), &varParam1); + OutputDebugStringA("get property \"AttrByte\" | value:"); + varRet.Clear(); + hr= oletest.GetPropertyByName( static_cast(L"AttrByte"), &varRet); + printVariant( varRet); + + + return S_OK; + + +} + + +void printVariant( VARIANT & _var) +{ + HRESULT hr; + USES_CONVERSION; + CComVariant var; + hr= VariantCopyInd( &var, &_var); + if( var.vt & VT_ARRAY) + { + VARTYPE type= var.vt ^ VT_ARRAY; + SAFEARRAY * sarray= var.parray; + long lbound; + long ubound; + hr= SafeArrayGetLBound( sarray, 1, &lbound); + hr= SafeArrayGetUBound( sarray, 1, &ubound); + long count= ubound - lbound + 1; + char charValue; + BYTE byteValue; + short shortValue; + long longValue; + double doubleValue; + IUnknown* unkValue; + BSTR bstrValue; + OutputDebugStringA("# Array \n"); + for( long i= 0; i < count; i++) + { +// CComVariant variantValue; + CHAR buf[256]; + wsprintfA( buf, "%d : ", i); + OutputDebugStringA( buf); + VARIANT varTemp; + VariantInit( &varTemp); + VARIANT variantValue; + VariantInit( &variantValue); + switch( type) + { + case VT_UI1: + hr= SafeArrayGetElement( sarray, &i, &byteValue); + varTemp.vt= VT_UI1; + V_UI1( &varTemp)= byteValue; + printVariant( varTemp); + break; + case VT_I1: + hr= SafeArrayGetElement( sarray, &i, &charValue); + varTemp.vt= VT_I1; + V_I1( &varTemp)= charValue; + printVariant( varTemp); + break; + case VT_I2: + hr= SafeArrayGetElement( sarray, &i, &shortValue); + varTemp.vt= VT_I2; + V_I2( &varTemp)= shortValue; + printVariant( varTemp); + break; + + case VT_UI2: + case VT_I4: + hr= SafeArrayGetElement( sarray, &i, &longValue); + varTemp.vt= VT_I4; + V_I4( &varTemp)= longValue; + printVariant( varTemp); + break; + case VT_R8: + hr= SafeArrayGetElement( sarray, &i, &doubleValue); + varTemp.vt= VT_R8; + V_R8( &varTemp)= doubleValue; + printVariant( varTemp); + break; + case VT_BSTR: + hr= SafeArrayGetElement( sarray, &i, &bstrValue); + varTemp.vt= VT_BSTR; + varTemp.bstrVal= bstrValue; + printVariant( varTemp); + break; + case VT_VARIANT: + hr= SafeArrayGetElement( sarray, &i, &varTemp); + printVariant( varTemp); + break; + + case VT_UNKNOWN: + hr= SafeArrayGetElement( sarray, &i, &unkValue); + varTemp.vt= VT_UNKNOWN; + varTemp.punkVal= unkValue; + printVariant( varTemp); + break; + } + + VariantClear( &varTemp); + VariantClear( &variantValue); + } + + } + else + { + CHAR buf[256]; + switch (var.vt) + { + case VT_I1: wsprintfA( buf, " VT_I1: %d \n", V_I1( &var) ); + break; + case VT_UI1: wsprintfA( buf, " VT_UI1: %d \n", V_I1( &var) ); + break; + + case VT_I2: wsprintfA( buf, " VT_I2: %d \n", V_I2( &var) ); + break; + case VT_I4: wsprintfA( buf, " VT_I4: %d \n", V_I4( &var) ); + break; + case VT_R8: + { + +// int decimal, sign; +// char *buffer; +// int precision = 14; +// double source = 3.1415926535; + +// buffer = _ecvt( V_R8(&var), precision, &decimal, &sign ); + sprintf( buf, " VT_R8: %f \n",V_R8( &var) ); + break; + } + case VT_UNKNOWN: + // The object implement IFont + { + CComDispatchDriver disp( var.punkVal); + CComVariant ret; + hr= disp.GetPropertyByName( static_cast(L"Name"), &ret); + wsprintfA( buf, " VT_UNKNOWN: property \"Name\": %s \n", W2A(ret.bstrVal)); + break; + } + case VT_DISPATCH: + // The object implement IFont + { + CComDispatchDriver disp( var.punkVal); + CComVariant ret; + if( SUCCEEDED( hr= disp.GetPropertyByName( static_cast(L"Name"), &ret))) + wsprintfA( buf, " VT_DISPATCH: property \"Name\": %s \n", W2A(ret.bstrVal)); + else + wsprintfA( buf, " VT_DISPATCH \n"); + + break; + } + + + case VT_BSTR: + { + CHAR* str= W2A( var.bstrVal); + wsprintfA( buf, " VT_BSTR: %s \n", str); + } + break; + default: + wsprintfA( buf, "\n"); + + } + + OutputDebugStringA( buf); + } + + return; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/OleConverterVar1/makefile.mk b/extensions/test/ole/OleConverterVar1/makefile.mk new file mode 100644 index 000000000..d37219256 --- /dev/null +++ b/extensions/test/ole/OleConverterVar1/makefile.mk @@ -0,0 +1,57 @@ +# +# 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=extensions +TARGET=convTest +TARGETTYPE=CUI +LIBTARGET=NO + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings --- + +.INCLUDE : settings.mk + +# --- Files --- + +INCPRE+=-I$(ATL_INCLUDE) + + +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJ)$/convTest.obj + + +APP1STDLIBS= \ + $(SALLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(USER32LIB) \ + $(KERNEL32LIB) \ + $(OLE32LIB) \ + $(OLEAUT32LIB) \ + $(UUIDLIB) \ + $(COMDLG32LIB) \ + $(COMPATH)$/atlmfc$/lib$/atls.lib \ + $(ADVAPI32LIB) + +APP1DEF= $(MISC)\$(APP1TARGET).def + +# --- Targets --- +.INCLUDE : target.mk diff --git a/extensions/test/ole/OleConverterVar1/readme.txt b/extensions/test/ole/OleConverterVar1/readme.txt new file mode 100644 index 000000000..67bc8d920 --- /dev/null +++ b/extensions/test/ole/OleConverterVar1/readme.txt @@ -0,0 +1,10 @@ +Currently broken!! + +The program test the Service com.sun.star.bridge.OleBridgeSupplierVar1. +While running in debug mode it writes infos to the debug - output. + +The executable needs a services.rdb present with the registered services +com.sun.star.bridge.OleBridgeSupplierVar1, oletest.OleTest. The OleTest +component resides in extensions/test/ole/cpnt. The build creates an +oletest.rdb file that must be merged with the types.rdb and OleTest +must be registered to the services.rdb. diff --git a/extensions/test/ole/OleConverterVar1/smartarray.h b/extensions/test/ole/OleConverterVar1/smartarray.h new file mode 100644 index 000000000..1c8fbd6e6 --- /dev/null +++ b/extensions/test/ole/OleConverterVar1/smartarray.h @@ -0,0 +1,222 @@ +/* -*- 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 . + */ +#pragma once + + +template< class sourceType> +class SmartArray +{ + SAFEARRAY *m_array; +public: + + SmartArray( sourceType * parParams, int count, VARTYPE destVartype): m_array(NULL) + { + HRESULT hr= S_OK; + SAFEARRAYBOUND rgsabound[1]; + rgsabound[0].cElements= count; + rgsabound[0].lLbound= 0; + m_array= SafeArrayCreate( destVartype, 1, rgsabound); + SafeArrayLock( m_array); + + void* pData; + if( m_array && (SUCCEEDED( SafeArrayAccessData( m_array, (void**)&pData)) ) ) + { + + for( int i=0; i< count; i++) + { + CComVariant varSource( parParams[i]); + switch (destVartype) + { + case VT_I1: + { + char* p= (char*) pData; + if( SUCCEEDED( hr= varSource.ChangeType( destVartype))) + p[i]= V_I1( &varSource); + break; + } + case VT_I2: + { + short* p= (short*) pData; + if( SUCCEEDED( hr=varSource.ChangeType( destVartype))) + p[i]= V_I2( &varSource); + break; + } + case VT_UI2: + { + unsigned short* p= (unsigned short*) pData; + if( SUCCEEDED( hr=varSource.ChangeType( destVartype))) + p[i]= V_UI2( &varSource); + break; + } + case VT_I4: + { + long* p= (long*)pData; + if( SUCCEEDED( hr=varSource.ChangeType( destVartype))) + p[i]= V_I4( &varSource); + break; + } + case VT_UI4: + { + unsigned long* p= (unsigned long*)pData; + if( SUCCEEDED( hr=varSource.ChangeType( destVartype))) + p[i]= V_UI4( &varSource); + break; + } + case VT_R4: + { + float* p= (float*)pData; + if( SUCCEEDED( hr=varSource.ChangeType( destVartype))) + p[i]= V_R4( &varSource); + break; + } + case VT_R8: + { + double* p= (double*)pData; + if( SUCCEEDED( hr=varSource.ChangeType( destVartype))) + p[i]= V_R8( &varSource); + break; + } + case VT_BOOL: + { + VARIANT_BOOL* p= (VARIANT_BOOL*)pData; + if( SUCCEEDED( hr=varSource.ChangeType( destVartype))) + p[i]= V_BOOL( &varSource); + break; + } + case VT_BSTR: + { + BSTR* pBstr= ( BSTR*)pData; + if( SUCCEEDED( hr=varSource.ChangeType( destVartype))) + pBstr[i]= SysAllocString(V_BSTR( &varSource)); + break; + } + case VT_VARIANT: + { + VARIANT *pVariant= (VARIANT*)pData; + hr= VariantCopy( &pVariant[i], &varSource); break; + } +// case VT_UNKNOWN: +// { +// long* pUnk= (long*)pData; +// pUnk[i]= reinterpret_cast(parParams[i]); +// ((IUnknown*)pUnk[i])->AddRef(); break; +// } +// case VT_DISPATCH: +// { +// long* pDisp= (long*)pData; +// pDisp[i]= (long)parParams[i]; +// ((IDispatch*)pDisp[i])->AddRef(); break; +// } + default: + hr= E_FAIL; + } + } + if( FAILED( hr)) + { + SafeArrayDestroy( m_array); + m_array= NULL; + } + } + SafeArrayUnaccessData( m_array); + } + ~SmartArray(){ + SafeArrayUnlock( m_array); + SafeArrayDestroy( m_array ); + } + + operator bool (){ return m_array == NULL ? false : true; } + + operator SAFEARRAY* (){ return m_array;} + +}; + +template<> +class SmartArray +{ + SAFEARRAY *m_array; +public: + + SmartArray( sourceType * parParams, int count, VARTYPE destVartype); +// { +// ATLTRACE("SmartArray"); +// HRESULT hr= S_OK; +// SAFEARRAYBOUND rgsabound[1]; +// rgsabound[0].cElements= count; +// rgsabound[0].lLbound= 0; +// m_array= SafeArrayCreateVector( VT_UNKNOWN, 0, count); +// SafeArrayLock( m_array); + +// IUnknown* *pData; +// if( m_array && (SUCCEEDED( SafeArrayAccessData( m_array, (void**)&pData)) ) ) +// { + +// for( int i=0; i< count; i++) +// { +// CComVariant varSource( parParams[i]); +// switch (destVartype) +// { + +// case VT_UNKNOWN: +// { +// pData[i]= parParams[i]; +// pData[i]->AddRef(); +// } +// default: +// hr= E_FAIL; +// } +// } +// if( FAILED( hr)) +// { +// SafeArrayDestroy( m_array); +// m_array= NULL; +// } +// } +// SafeArrayUnaccessData( m_array); +// } + ~SmartArray(){ + SafeArrayUnlock( m_array); + SafeArrayDestroy( m_array ); + } + + operator bool (){ return m_array == NULL ? false : true; } + + operator SAFEARRAY* (){ return m_array;} + +}; + +template <> SmartArray ::SmartArray(sourceType * parParams, int count, VARTYPE destVartype):m_array(NULL) +{ + ATLTRACE("SmartArray"); + HRESULT hr= S_OK; + m_array= SafeArrayCreateVector( VT_UNKNOWN, 0, count); + SafeArrayLock( m_array); + + IUnknown* *pData; + if( m_array && (SUCCEEDED( SafeArrayAccessData( m_array, (void**)&pData)) ) ) + { + for( int i=0; i< count; i++) + { + pData[i]= parParams[i]; + pData[i]->AddRef(); + } + } + SafeArrayUnaccessData( m_array); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/OleTest.htm b/extensions/test/ole/OleTest.htm new file mode 100644 index 000000000..acca9fda0 --- /dev/null +++ b/extensions/test/ole/OleTest.htm @@ -0,0 +1,1080 @@ + + + + + +Document Title + + + + + + + +

+ + + +

JScript

+Tests Array/Sequence conversion.
+All methods receive a Sequence as Parameter. The element type of the Sequence is written on the buttons. +
+ + + + + + + + + + + + + + + + +

+ +

+Out Parameter
+ + + + + + + + + + + + + + + + + + + + +

+In Out Parameter
+ + + + + + + + + + + + + + +

+ +Tests Array/Sequence conversion with Attributes. All params are of type Sequence and + the element type of the Sequence is written on the buttons.
+ + + + + + + + + + + + + +

+ +Test of Any parameter in a method. Any contains:
+ + + + + +

+Test of Any parameter in a property. Any contains:
+ + + + + +

+Test of Struct conversions
+ + + + + + + +

+ + +

Visual Basic Tests

+Test array /Sequence conversion and return value
+Template: Sequence < type > method( Sequence< type > )
+ + + + + + + + + + +
+
+ + +IN/Out parameter
+Template: void method(type )
+ + + + + + + + + +
+ +Simple out parameter
+ + +
+ + +Tests Array/Sequence conversion with Attributes. All params are of type Sequence and + the element type of the Sequence is written on the buttons.
+ + + + + + + + + + +
+ +In Out parameter
+ +

+Structs
+ + + + + + diff --git a/extensions/test/ole/ScriptTest.html b/extensions/test/ole/ScriptTest.html new file mode 100644 index 000000000..7cf188f45 --- /dev/null +++ b/extensions/test/ole/ScriptTest.html @@ -0,0 +1,1555 @@ + + + + +Document Title + + + + + + + + + + + + + diff --git a/extensions/test/ole/StarBasic_OleClient/oleclient.bas b/extensions/test/ole/StarBasic_OleClient/oleclient.bas new file mode 100644 index 000000000..e640d434d --- /dev/null +++ b/extensions/test/ole/StarBasic_OleClient/oleclient.bas @@ -0,0 +1,622 @@ +rem +rem This file is part of the LibreOffice project. +rem +rem This Source Code Form is subject to the terms of the Mozilla Public +rem License, v. 2.0. If a copy of the MPL was not distributed with this +rem file, You can obtain one at http://mozilla.org/MPL/2.0/. +rem +rem This file incorporates work covered by the following license notice: +rem +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed +rem with this work for additional information regarding copyright +rem ownership. The ASF licenses this file to you under the Apache +rem License, Version 2.0 (the "License"); you may not use this file +rem except in compliance with the License. You may obtain a copy of +rem the License at http://www.apache.org/licenses/LICENSE-2.0 . +rem + +OPTION EXPLICIT +OPTION COMPATIBLE + +Sub Main +COMPATIBILITYMODE(true) + +If runtest = -1 Then + MsgBox "Test Failed!!!" +Else + MsgBox "Test Succeeded" +End If + +End Sub + +Function runtest() As Integer +Dim inBool As Boolean, inBool2 As Boolean, outBool As Boolean +Dim inByte As Integer, inByte2 As Integer +Dim inShort As Integer, inShort2 As Integer +Dim inLong As Long, inLong2 As Long, inLong3 As Long, inLong4 As Long +Dim inString As String, inString2 As String +Dim inFloat As Single, inFloat2 As Single +Dim inDouble As Double, inDouble2 As Double +Dim inVariant, inVariant2 +Dim inAr, inAr2 +Dim inDate As Date,inDate2 As Date, outDate As Date +Dim inCurrency As Currency, inCurrency2 As Currency, outCurrency As Currency +Dim inSCode As New com.sun.star.bridge.oleautomation.SCode +Dim inSCode2 As New com.sun.star.bridge.oleautomation.SCode +Dim inDecimal As Variant, inDecimal2 As Variant, outDecimal As Variant +Dim inrefDecimal As Variant, outrefDecimal As Variant +Dim outSCode As New com.sun.star.bridge.oleautomation.SCode +Dim outByte As Integer +Dim outShort As Integer +Dim outLong, outLong2 As Long +Dim outString As String +Dim outFloat As Single +Dim outDouble As Double +Dim outVariant +'bug #109936 causes an errOr when outObject is used As out param +Dim inObject As Object, inObject2 As Object, outObject As Object +Dim objNOTHING As Object +Dim inUnknown As Object, inUnknown2 As Object, outUnknown As Object + +Dim inArray, outArray, outArray2 +Dim len1, len2 +Dim arString(1) As String +arString(0)= "String one" +arString(1)= "String two" + +Dim factory As Object +factory= createUnoService("com.sun.star.bridge.OleObjectFactory") +Dim obj As Object +obj= factory.createInstance("AxTestComponents.Basic") + +Dim objFoo As Object +objFoo = factory.createInstance("AxTestComponents.Foo") + + +'in parameter ------------------------------------------------------------------- +inBool = true +inByte = 10 +inShort = 11 +inLong = 111 +inString = "Hello World" +inFloat = 3.14 +inDouble = 3.145 +inVariant = "bla" +inDate = NOW() +inCurrency = 12345.6789 +inSCode.Value = &h80020004 +inDecimal = CDec("-9223372036854775808") 'lowest int64 + +obj.inBool(inBool) +obj.inByte(inByte) +obj.inShort(inShort) +obj.inLong(inLong) +obj.inString(inString) +obj.inFloat(inFloat) +obj.inDouble(inDouble) +obj.inVariant(inVariant) +'obj.prpString= "a string property" +obj.inObject(obj) +obj.inArray(arString()) +obj.inDate(inDate) +obj.inCurrency(inCurrency) +obj.inSCode(inSCode) +obj.inUnknown(objFoo) +obj.inDecimal(inDecimal) + +'out parameter ------------------------------------------------------------------------- +outBool = false +obj.outBool(outBool) +outByte = 0 +obj.outByte(outByte) +outShort = 0 +obj.outShort(outShort) +outLong = 0 +obj.outLong(outLong) +outFloat = 0 +obj.outFloat(outFloat) +outDouble = 0 +obj.outDouble(outDouble) +outString = "" +obj.outString(outString) +outVariant = 0 +obj.outVariant(outVariant) +outObject = NOTHING +obj.outObject(outObject) +outArray = 0 +obj.outArray(outArray) +obj.outDate(outDate) +obj.outCurrency(outCurrency) +obj.outSCode(outSCode) +obj.outUnknown(outUnknown) +obj.outDecimal(outDecimal) + + +If inBool <> outBool Or inByte <> outByte Or inShort <> outShort Or inLong <> outLong Or _ + inFloat <> outFloat Or inDouble <> outDouble Or inString <> outString Or _ + inVariant <> outVariant Or NOT equalUnoObjects(obj, outObject) Or NOT _ + equalArrays(arString(), outArray()) Or inDate <> outDate Or inCurrency <> outCurrency Or _ + inSCode.Value <> outSCode.Value Or Not equalUnoObjects(objFoo, outUnknown) Or _ + inDecimal <> outDecimal Then + runtest = -1 + exit Function +End If + + +'in-out parameter ------------------------------------------------------------- +'implementation of inout methods returns the previously set value in out param +inBool = true +inBool2 = inBool +obj.inoutBool(inBool2) +outBool = false +obj.inoutBool(outBool) +inByte = 10 +inByte2 = inByte +obj.inoutByte(inByte2) +outByte = 0 +obj.inoutByte(outByte) +inShort = 10 +inShort2 = inShort +obj.inShort(inShort2) +outShort = 0 +obj.inoutShort(outShort) +inLong = 10 +inLong2 = inLong +obj.inoutLong(inLong2) +outLong = 0 +obj.inoutLong(outLong) +inFloat = 3.14 +inFloat2 = inFloat +obj.inoutFloat(inFloat2) +outFloat = 0 +obj.inoutFloat(outFloat) +inDouble= 3.14 +inDouble2 = inDouble +obj.inoutDouble(inDouble2) +outDouble = 0 +obj.inoutDouble(outDouble) +inString = "in" +inString2 = inString +obj.inoutString(inString2) +outString = "" +obj.inoutString(outString) +inVariant = "in" +inVariant2 = inVariant +obj.inoutVariant(inVariant2) +outVariant = 0 +obj.inoutVariant(outVariant) +inObject = factory.createInstance("AxTestComponents.Basic") +inObject2 = inObject +obj.inoutObject(inObject2) +outObject = NOTHING +obj.inoutObject(outObject) +inAr = arString() +inAr2 = inAr +obj.inoutArray(inAr2) +outArray = 0 +obj.outArray(outArray()) +inDate = NOW() +inDate2 = inDate +obj.inoutDate(inDate2) +outDate = 0 +obj.inoutDate(outDate) +inCurrency = 1234.5678 +inCurrency2 = inCurrency +obj.inoutCurrency(inCurrency2) +outCurrency = 0 +obj.inoutCurrency(outCurrency) +inSCode.Value = &h80020004 +inSCode2 = inSCode +obj.inoutSCode(inSCode2) +outSCode.Value = 0 +obj.inoutSCode(outSCode) +inUnknown = objFoo +inUnknown2 = inUnknown +obj.inoutUnknown(inUnknown2) +outUnknown = Nothing +obj.inoutUnknown(outUnknown) +inDecimal = CDec("18446744073709551615") 'highest positive value of unsigned int64 +inDecimal2 = inDecimal +obj.inoutDecimal(inDecimal2) +outDecimal = 0 +obj.inoutDecimal(outDecimal) + +If inBool <> outBool Or inByte <> outByte Or inShort <> outShort Or inLong <> outLong Or _ + inFloat <> outFloat Or inDouble <> outDouble Or inString <> outString Or _ + inVariant <> outVariant Or NOT equalUnoObjects(inObject, outObject) Or _ + NOT equalArrays(inAr, outArray) Or inDate <> outDate Or inCurrency <> outCurrency Or _ + inSCode.Value <> outSCode.Value Or Not equalUnoObjects(inUnknown, outUnknown) Or _ + inDecimal <> outDecimal Then + runtest = -1 + Exit Function +End If + +'properties ------------------------------------------------------------------------- +inBool = false +outBool = true +obj.prpBool = inBool +outBool = obj.prpBool +inByte = 11 +outByte = 0 +obj.prpByte = inByte +outByte= obj.prpByte +inShort = 127 +outShort = 0 +obj.prpShort= inShort +outShort= obj.prpShort +inLong = 1000 +outLong = 0 +obj.prpLong = inLong +outLong= obj.prpLong +inFloat = 3.14 +outFloat = 0 +obj.prpFloat = inFloat +outFloat= obj.prpFloat +inDouble = 3.123 +outDouble = 0 +obj.prpDouble = inDouble +outDouble= obj.prpDouble +inString = "bla" +outString = "" +obj.prpString = inString +outString = obj.prpString +inObject = obj +outObject = objNOTHING +obj.prpObject = inObject +outObject = obj.prpObject +inVariant = "bla" +outVariant = 0 +obj.prpVariant = inVariant +outVariant= obj.prpVariant +inArray = arString() +outArray = 0 +obj.prpArray = inArray() +outArray= obj.prpArray +inDate = NOW() +outDate = 0 +obj.prpDate = inDate +outDate = obj.prpDate +inCurrency = 1234.5678 +outCurrency = 0 +obj.prpCurrency = inCurrency +outCurrency = obj.prpCurrency +inSCode.Value = &h80020004 +outSCode.Value = 0 +obj.prpSCode = inSCode +outSCode = obj.prpSCode +inUnknown = objFoo +outUnknown= Nothing +obj.prpUnknown = inUnknown +outUnknown = obj.prpUnknown +inDecimal = CDec("18446744073709551615")' highest unsigned int64 +outDecimal = 0 +obj.prpDecimal = inDecimal +outDecimal = obj.prpDecimal + +If inBool <> outBool Or inByte <> outByte Or inShort <> outShort Or inLong <> outLong Or _ + inFloat <> outFloat Or inDouble <> outDouble Or inString <> outString Or _ + inVariant <> outVariant Or NOT equalUnoObjects(inObject, outObject) Or _ + NOT equalArrays(inArray, outArray) Or inDate <> outDate Or inCurrency <> outCurrency Or _ + inSCode.Value <> outSCode.Value Or Not equalUnoObjects(inUnknown, outUnknown) Or _ + inDecimal <> outDecimal Then + runtest = -1 + Exit Function +End If + +' ref parameter ------------------------------------------------------------------------ +obj.inLong(0) +inLong = 123 +outLong = 0 +obj.inLong(0) +obj.inrefLong(inLong) +obj.outLong(outLong) +inVariant = "bla" +outVariant = 0 +obj.inVariant(0) +obj.inrefVariant(inVariant) +obj.outVariant(outVariant) +If inLong <> outLong Or inVariant <> outVariant Then + runtest = -1 + Exit Function +End If + +outLong = 0 +obj.prprefLong = inLong +outLong = obj.prprefLong +outVariant = 0 +obj.prprefVariant = inVariant +outVariant = obj.prprefVariant +If inLong <> outLong Or inVariant <> outVariant Then + runtest = -1 + Exit Function +End If + + +'vararg -------------------------------------------------------------------------------- +inLong=1 +inLong2 = 2 +inLong3 = 3 +obj.varargfunc1(inLong) +outArray = 0 +outLong = 0 +obj.varargfunc2(outLong, outArray) +If inLong <> outLong Then + runtest = -1 + Exit Function +End If +len1 = UBound(outArray) - LBound(outArray) +1 +If len1 <> 0 Then + runtest = -1 + Exit Function +End If +outArray = 0 +obj.varargfunc1(inLong, inLong2, inLong3) +obj.varargfunc2(outLong, outArray) +len1 = UBound(outArray) - LBound(outArray) +1 +If len1 <> 2 Or outArray(0) <> inLong2 Or outArray(1) <> inLong3 Then + runtest = -1 + Exit Function +End If + + +'defaultvalue --------------------------------------------------------------------------- +inLong = 0 +inFloat = 0 +inVariant = 0 +inVariant2 = 0 +'defaults are: 1, 2, 4 +'The third parameter is a VARIANT with a default value of 4. COM gives it the type BSTR +obj.defaultvalue1() +obj.defaultvalue2(inLong, inFloat, inVariant) +If inLong <> 1 Or inFloat <> 2 Or inVariant <> "4" Then + runtest = -1 + Exit Function +End If +inLong = 10 +inFloat = 11 +inLong2 = inLong +inFloat2 = inFloat +inVariant = 0 +inVariant = 0 +obj.defaultvalue1(inLong, inFloat) +obj.defaultvalue2(inLong, inFloat, inVariant) +If inLong <> inLong2 Or inFloat <> inFloat2 Or inVariant <> "4" Then + runtest = -1 + Exit Function +End If + +'optional parameters ---------------------------------------------------------------- +inLong = 100 +outLong = 0 +obj.optional1(inLong) +obj.optional2(outLong) +If inLong <> outLong Then + runtest = -1 + Exit Function +End If + +inLong2 = 101 +outLong2 = 0 +obj.optional1(inLong, inLong2) +obj.optional2(outLong, outLong2) +If inLong <> outLong AND inLong2 <> outLong2 Then + runtest = -1 + Exit Function +End If + +inLong2 = 101 +outLong2 = 0 +obj.optional1(inLong, inLong2) +obj.optional1(inLong) +obj.optional2(outLong, outLong2) +If inLong <> outLong AND inLong2 <> outLong2 Then + runtest = -1 + Exit Function +End If + +inLong = 10 +inLong2 = 100 +outLong = 5 +outLong2 = 6 +obj.optional3() +obj.optional3(inLong, inLong2) +obj.optional4(outLong, outLong2) 'outLong = 10, outLong2 = 100 +If inLong <> outLong AND inLong2 <> outLong2 Then + runtest = -1 + Exit Function +End If +inLong = 10 +inLong2 = 100 +inLong3 = inLong +inLong4 = inLong2 +obj.optional4(inLong, inLong) +outLong = 0 +outLong2 = 0 +obj.optional5(outLong, outLong2) +If inLong3 <> outLong AND inLong4 <> outLong2 Then + runtest = -1 + Exit Function +End If + +inLong = 10 +outLong = 5 +obj.optional3(inLong) +obj.optional4(outLong) +If inLong <> outLong Then + runtest = -1 + Exit Function +End If +inLong = 10 +inLong2 = inLong +outLong = 0 +obj.optional4(inLong) +obj.optional5(outLong) +If inLong2 <> outLong Then + runtest = -1 + Exit Function +End If + +'named arguments------------------------------------------------------------------------- +'all args As named args, different order +obj.optional6(0, 0, 0, 0) +inLong = 1 +inLong2 = 2 +inLong3 = 3 +inLong4 = 4 +obj.optional6(val4:= inLong4, val3:=inLong3, val2:=inLong2, val1:= inLong) +Dim outLong3 As Long +Dim outLong4 As Long +outLong = 0 +outLong2 = 0 +outLong3 = 0 +outLong4 = 0 +obj.optional7(outLong, outLong2, outLong3, outLong4) +If inLong <> outLong Or inLong2 <> outLong2 _ + Or inLong3 <> outLong3 Or inLong4 <> outLong4 Then + runtest = -1 + Exit Function +End If + +'mixed positional and named args with omitted args +Dim scode_paramNotFound As New com.sun.star.bridge.oleautomation.SCode +scode_paramNotFound.Value = &h80020004 + +obj.optional6(0, 0, 0, 0) +'val1 and val3 will be DISP_E_PARAMNOTFOUND +obj.optional6(, inLong2, val4:=inLong4) +Dim outSCode1, outSCode2 +obj.optional7(outSCode, outLong2, outSCode2, outLong4) +If outSCode.Value <> scode_paramNotFound.Value Or inLong2 <> outLong2 _ + Or outSCode2.Value <> scode_paramNotFound.Value Or inLong4 <> outLong4 Then + runtest = -1 + Exit Function +End If + +'mixed positional and named args with omitted args as out -args +inLong = 1 +inLong2 = 2 +inLong3 = 3 +inLong4 = 4 +obj.optional6(inLong, inLong2, inLong3, inLong4) +outLong2 = 0 +outLong3 = 0 +obj.optional7(,outLong2, val3:= outLong3) +If inLong2 <> outLong2 Or inLong3 <> outLong3 Then + runtest = -1 + Exit Function +End If + +'test properties with additional arguments ------------------------------------ +inLong = 10 +inLong2 = 20 +inLong3 = 30 +outLong = 0 +outLong2 = 0 +outLong3 = 0 +obj.prpMultiArg1(0,0) = 0 +'obj.prpMultiArg1 = 0 +obj.prpMultiArg1(inLong,inLong2) = inLong3 +outLong3 = obj.prpMultiArg1(outLong, outLong2) +If outLong <> 10 Or outLong2 <> 02 Or outLong3 <> 30 Then + runtest = -1 + Exit Function +End If + +outLong = 0 +outLong2 = 0 +obj.prpMultiArg1(0,0) = 0 +obj.prpMultiArg1(1) = 3 +outLong2 = obj.prpMultiArg1(outLong) +If outLong <> 1 Or outLong2 <> 3 Then + runtest = -1 + Exit Function +End If + +outLong = 0 +outLong2 = 0 +obj.prpMultiArg1(0,0) = 0 +obj.prpMultiArg1(val2:= 1) = 3 +outLong2 = obj.prpMultiArg1(val2:=outLong) +If outLong <> 1 Or outLong2 <> 3 Then + runtest = -1 + Exit Function +End If + +outLong = -1 +outLong2 = -1 +obj.prpMultiArg2(0) = 0 +outLong = obj.prpMultiArg2GetValues(outLong, outLong2) +If outLong <> 0 Or outLong2 <> 0 Then + runtest = -1 + Exit Function +End If + + +outLong = 0 +outLong2 = 0 +obj.prpMultiArg2(1) = 2 +obj.prpMultiArg2GetValues(outLong, outLong2) +If outLong <> 1 Or outLong2 <> 2 Then + runtest = -1 + Exit Function +End If + + + +' other tests ------------------------------------------------------------------ +obj.inObject(NOTHING) +outObject = NOTHING +'bridge should return an XInterface any with null pointer +'A basic errOr should occur if this is not the case +obj.outObject(outObject) + +If Not IsNull(outObject) Then + runtest = -1 + Exit Function +End If +'Decimal passed by reference +inrefDecimal = CDec("9223372036854775807") 'highest positive value of int64 +obj.inrefDecimal(inrefDecimal) +outrefDecimal = 0 +obj.outDecimal(outrefDecimal) +If inrefDecimal <> outrefDecimal Then + runtest = -1 + Exit Function +End If + +' Test Automation object with dual interfaces ------------------------------------ +dim dispatcher as object +dim oExplorer as object +dispatcher = createUnoService("com.sun.star.bridge.OleObjectFactory") +oExplorer = dispatcher.createInstance("InternetExplorer.Application") +If Not IsNull(oExplorer) Then + oExplorer.visible = true + oExplorer.Navigate2("http://www.openoffice.org") +Else + MsgBox("Could not perform test with Internet Explorer!") +End If + + +End Function + +'One dimensional arrays with simple types. +'lower bound must be 0 +Function equalArrays(ar1, ar2) +Dim len1 +Dim len2 +len1 = UBound(ar1) - LBound(ar1) + 1 +len2 = UBound(ar2) - LBound(ar2) + 1 +If len1 <> len2 Then + equalArrays = false + Exit Function +End If +Dim counter +FOr counter = 0 To len1 - 1 + If ar1(counter) <> ar2(counter) Then + equalArrays = false + Exit Function + End If +Next +equalArrays = true +End Function diff --git a/extensions/test/ole/StarBasic_OleClient/readme.txt b/extensions/test/ole/StarBasic_OleClient/readme.txt new file mode 100644 index 000000000..d3ee22237 --- /dev/null +++ b/extensions/test/ole/StarBasic_OleClient/readme.txt @@ -0,0 +1,10 @@ +oleclient.bas is a StarBasic script that uses the +"com.sun.star.bridge.OleObjectFactory" service to instantiate +the ActiveX component "AxTestComponents.Basic" and calls +functions on it. + +------------------------------------------------------------ +Requirements: + +ActiveX component: AxTestComponent.Basic must be registered. +It is contained in extensions/test/ole/AxTestComponents diff --git a/extensions/test/ole/VisualBasic/AssemblyInfo.vb b/extensions/test/ole/VisualBasic/AssemblyInfo.vb new file mode 100644 index 000000000..c4b1d4ff5 --- /dev/null +++ b/extensions/test/ole/VisualBasic/AssemblyInfo.vb @@ -0,0 +1,51 @@ +' +' 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 . +' + +Imports System.Reflection +Imports System.Runtime.CompilerServices +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + + +' TODO: Review the values of the assembly attributes + + + + + + + + + + +' Version information for an assembly consists of the following four values: + +' Major version +' Minor Version +' Build Number +' Revision + +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + + + diff --git a/extensions/test/ole/VisualBasic/Module1.vb b/extensions/test/ole/VisualBasic/Module1.vb new file mode 100644 index 000000000..63b8bbdeb --- /dev/null +++ b/extensions/test/ole/VisualBasic/Module1.vb @@ -0,0 +1,871 @@ +' +' 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 . +' + +Option Strict Off +Option Explicit On +Module Module1 + +Private objServiceManager As Object +Private objCoreReflection As Object +Private objOleTest As Object +Private objEventListener As Object +'General counter +Dim i As Integer +Dim j As Integer +Dim sError As String +Dim outHyper, inHyper, retHyper As Object + +Public Sub Main() + objServiceManager = CreateObject("com.sun.star.ServiceManager") + objCoreReflection = objServiceManager.createInstance("com.sun.star.reflection.CoreReflection") + ' extensions/test/ole/cpnt + objOleTest = objServiceManager.createInstance("oletest.OleTest") + ' extensions/test/ole/EventListenerSample/VBEventListener + objEventListener = CreateObject("VBasicEventListener.VBEventListener") + Debug.Print(TypeName(objOleTest)) + + + testBasics() + testHyper() + testAny() + testObjects() + testGetStruct() + ''dispose not working i103353 + 'testImplementedInterfaces() + testGetValueObject() + testArrays() + testProps() + + End Sub + Function testProps() As Object + + Dim aToolbarItemProp1 As Object + aToolbarItemProp1 = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue") + Dim aToolbarItemProp2 As Object + aToolbarItemProp2 = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue") + Dim aToolbarItemProp3 As Object + aToolbarItemProp3 = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue") + Dim properties(2) As Object + + aToolbarItemProp1.Name = "CommandURL" + aToolbarItemProp1.Value = "macro:///standard.module1.TestIt" + aToolbarItemProp2.Name = "Label" + aToolbarItemProp2.Value = "Test" + aToolbarItemProp3.Name = "Type" + aToolbarItemProp3.Value = 0 + + properties(0) = aToolbarItemProp1 + properties(1) = aToolbarItemProp2 + properties(2) = aToolbarItemProp3 + + + Dim dummy(-1) As Object + + Dim Desktop As Object + Desktop = objServiceManager.createInstance("com.sun.star.frame.Desktop") + Dim Doc As Object + Doc = Desktop.loadComponentFromURL("private:factory/swriter", "_blank", 2, dummy) + Dim LayoutManager As Object + LayoutManager = Doc.currentController.Frame.LayoutManager + + LayoutManager.createElement("private:resource/toolbar/user_toolbar1") + LayoutManager.showElement("private:resource/toolbar/user_toolbar1") + Dim ToolBar As Object + ToolBar = LayoutManager.getElement("private:resource/toolbar/user_toolbar1") + Dim settings As Object + settings = ToolBar.getSettings(True) + + 'the changes are here: + Dim aany As Object + aany = objServiceManager.Bridge_GetValueObject() + Call aany.Set("[]com.sun.star.beans.PropertyValue", properties) + Call settings.insertByIndex(0, aany) + Call ToolBar.setSettings(settings) + + + End Function + + + Function testBasics() As Object + ' In Parameter, simple types + '============================================ + Dim tmpVar As Object + Dim ret As Object + Dim outByte, inByte, retByte As Byte + Dim outBool, inBool, retBool As Boolean + Dim outShort, inShort, retShort As Short + Dim outUShort, inUShort, retUShort As Short + Dim outLong, inLong, retLong As Integer + Dim outULong, inULong, retULong As Integer + Dim outHyper, inHyper, retHyper As Object + Dim outUHyper, inUHyper, retUHyper As Object + Dim outFloat, inFloat, retFloat As Single + Dim outDouble, inDouble, retDouble As Double + Dim outString, inString, retString As String + Dim retChar, inChar, outChar, retChar2 As Short + Dim outCharAsString, inCharAsString, retCharAsString As String + Dim outAny, inAny, retAny As Object + Dim outType, inType, retType As Object + Dim outXInterface, inXInterface, retXInterface As Object + Dim outXInterface2, inXInterface2, retXInterface2 As Object + + + Dim outVarByte As Object + Dim outVarBool As Object + Dim outVarShort As Object + Dim outVarUShort As Object + Dim outVarLong As Object + Dim outVarULong As Object + Dim outVarFloat As Object + Dim outVarDouble As Object + Dim outVarString As Object + Dim outVarChar As Object + Dim outVarAny As Object + Dim outVarType As Object + + inByte = 10 + inBool = True + inShort = -10 + inUShort = -100 + inLong = -1000 + inHyper = CDec("-9223372036854775808") 'lowest int64 + inUHyper = CDec("18446744073709551615") ' highest unsigned int64 + inULong = 10000 + inFloat = 3.14 + inDouble = 3.14 + inString = "Hello World!" + inChar = 65 + inCharAsString = "A" + inAny = "Hello World" + inType = objServiceManager.Bridge_CreateType("[]long") + inXInterface = objCoreReflection + inXInterface2 = objEventListener + + retByte = objOleTest.in_methodByte(inByte) + retBool = objOleTest.in_methodBool(inBool) + retShort = objOleTest.in_methodShort(inShort) + retUShort = objOleTest.in_methodUShort(inUShort) + retLong = objOleTest.in_methodLong(inLong) + retULong = objOleTest.in_methodULong(inULong) + retHyper = objOleTest.in_methodHyper(inHyper) + retUHyper = objOleTest.in_methodUHyper(inUHyper) + retFloat = objOleTest.in_methodFloat(inFloat) + retDouble = objOleTest.in_methodDouble(inDouble) + retString = objOleTest.in_methodString(inString) + retChar = objOleTest.in_methodChar(inChar) + retChar2 = objOleTest.in_methodChar(inCharAsString) + retAny = objOleTest.in_methodAny(inAny) + retType = objOleTest.in_methodType(inType) + retXInterface = objOleTest.in_methodXInterface(inXInterface) ' UNO object + retXInterface2 = objOleTest.in_methodXInterface(inXInterface2) + + If retByte <> inByte Or retBool <> inBool Or retShort <> inShort Or retUShort <> inUShort _ + Or retLong <> inLong Or retULong <> inULong Or retHyper <> inHyper _ + Or retUHyper <> inUHyper Or retFloat <> inFloat Or retDouble <> inDouble _ + Or retString <> inString Or retChar <> inChar Or retChar2 <> Asc(inCharAsString) _ + Or retAny <> inAny Or Not (retType.Name = inType.Name) _ + Or inXInterface IsNot retXInterface Or inXInterface2 IsNot retXInterface2 Then + sError = "in - parameter and return value test failed" + MsgBox(sError) + + End If + + 'Out Parameter simple types + '================================================ + + + objOleTest.testout_methodByte(outByte) + objOleTest.testout_methodFloat(outFloat) + objOleTest.testout_methodDouble(outDouble) + objOleTest.testout_methodBool(outBool) + objOleTest.testout_methodShort(outShort) + objOleTest.testout_methodUShort(outUShort) + objOleTest.testout_methodLong(outLong) + objOleTest.testout_methodULong(outULong) + objOleTest.testout_methodHyper(outHyper) + objOleTest.testout_methodUHyper(outUHyper) + objOleTest.testout_methodString(outString) + objOleTest.testout_methodChar(outChar) + 'outCharAsString is a string. Therefore the returned sal_Unicode value of 65 will be converted + 'to a string "65" + objOleTest.testout_methodChar(outCharAsString) + objOleTest.testout_methodAny(outAny) + objOleTest.testout_methodType(outType) + 'objOleTest.in_methodXInterface (inXInterface) ' UNO object + Call objOleTest.in_methodXInterface(inXInterface) ' UNO object + objOleTest.testout_methodXInterface(outXInterface) + Call objOleTest.in_methodXInterface(inXInterface2) ' COM object + objOleTest.testout_methodXInterface(outXInterface2) + + If outByte <> inByte Or outFloat <> inFloat Or outDouble <> inDouble _ + Or outBool <> inBool Or outShort <> inShort Or outUShort <> inUShort _ + Or outLong <> inLong Or outULong <> inULong Or outHyper <> inHyper _ + Or outUHyper <> inUHyper Or outString <> inString Or outChar <> inChar _ + Or Not (outCharAsString = "65") Or outAny <> inAny _ + Or Not (outType.Name = inType.Name) Or inXInterface IsNot outXInterface _ + Or inXInterface2 IsNot outXInterface2 Then + + sError = "out - parameter test failed!" + MsgBox(sError) + End If + + 'Out Parameter simple types (VARIANT var) + '==================================================== + objOleTest.testout_methodByte(outVarByte) + objOleTest.testout_methodBool(outVarBool) + objOleTest.testout_methodChar(outVarChar) + objOleTest.testout_methodShort(outVarShort) + objOleTest.testout_methodUShort(outVarUShort) + objOleTest.testout_methodLong(outVarLong) + objOleTest.testout_methodULong(outVarULong) + objOleTest.testout_methodString(outVarString) + objOleTest.testout_methodFloat(outVarFloat) + objOleTest.testout_methodDouble(outVarDouble) + objOleTest.testout_methodAny(outVarAny) + objOleTest.testout_methodType(outVarType) + + If outVarByte <> inByte Or outVarBool <> inBool Or outVarChar <> inChar _ + Or outVarShort <> inShort Or outVarUShort <> inUShort _ + Or outVarLong <> inLong Or outVarULong <> inULong Or outVarString <> inString _ + Or outVarFloat <> inFloat Or outVarDouble <> inDouble Or outVarAny <> inAny _ + Or Not (outVarType.Name = inType.Name) Then + sError = "out - parameter (VARIANT) test failed!" + MsgBox(sError) + End If + + 'In/Out simple types + '============================================ + objOleTest.in_methodByte(0) + objOleTest.in_methodBool(False) + objOleTest.in_methodShort(0) + objOleTest.in_methodUShort(0) + objOleTest.in_methodLong(0) + objOleTest.in_methodULong(0) + objOleTest.in_methodHyper(0) + objOleTest.in_methodUHyper(0) + objOleTest.in_methodFloat(0) + objOleTest.in_methodDouble(0) + objOleTest.in_methodString(0) + objOleTest.in_methodChar(0) + objOleTest.in_methodAny(0) + objOleTest.in_methodType(objServiceManager.Bridge_CreateType("boolean")) + outXInterface = Nothing + Call objOleTest.in_methodXInterface(outXInterface) + + outByte = 10 + retByte = outByte + objOleTest.testinout_methodByte(retByte) + objOleTest.testinout_methodByte(retByte) + outBool = True + retBool = outBool + objOleTest.testinout_methodBool(retBool) + objOleTest.testinout_methodBool(retBool) + outShort = 10 + retShort = outShort + objOleTest.testinout_methodShort(retShort) + objOleTest.testinout_methodShort(retShort) + outUShort = 20 + retUShort = outUShort + objOleTest.testinout_methodUShort(retUShort) + objOleTest.testinout_methodUShort(retUShort) + outLong = 30 + retLong = outLong + objOleTest.testinout_methodLong(retLong) + objOleTest.testinout_methodLong(retLong) + outULong = 40 + retULong = outULong + objOleTest.testinout_methodULong(retLong) + objOleTest.testinout_methodULong(retLong) + outHyper = CDec("9223372036854775807") 'highest positive value of int64 + retHyper = outHyper + objOleTest.testinout_methodHyper(retHyper) + objOleTest.testinout_methodHyper(retHyper) + outUHyper = CDec("18446744073709551615") 'highest value of unsigned int64 + retUHyper = outUHyper + objOleTest.testinout_methodUHyper(retUHyper) + objOleTest.testinout_methodUHyper(retUHyper) + outFloat = 3.14 + retFloat = outFloat + objOleTest.testinout_methodFloat(retFloat) + objOleTest.testinout_methodFloat(retFloat) + outDouble = 4.14 + retDouble = outDouble + objOleTest.testinout_methodDouble(retDouble) + objOleTest.testinout_methodDouble(retDouble) + outString = "Hello World!" + retString = outString + objOleTest.testinout_methodString(retString) + objOleTest.testinout_methodString(retString) + outChar = 66 + retChar = outChar + objOleTest.testinout_methodChar(retChar) + objOleTest.testinout_methodChar(retChar) + outCharAsString = "H" + retCharAsString = outCharAsString + objOleTest.testinout_methodChar(retCharAsString) + objOleTest.testinout_methodChar(retCharAsString) + outAny = "Hello World 2!" + retAny = outAny + objOleTest.testinout_methodAny(retAny) + objOleTest.testinout_methodAny(retAny) + outType = objServiceManager.Bridge_CreateType("long") + retType = outType + objOleTest.testinout_methodType(retType) + objOleTest.testinout_methodType(retType) + + outXInterface = objCoreReflection + retXInterface = outXInterface + objOleTest.testinout_methodXInterface2(retXInterface) + + If outByte <> retByte Or outBool <> retBool Or outShort <> retShort _ + Or outUShort <> retUShort Or outLong <> retLong Or outULong <> retULong _ + Or outHyper <> retHyper Or outUHyper <> outUHyper _ + Or outFloat <> retFloat Or outDouble <> retDouble _ + Or outString <> retString Or outChar <> retChar _ + Or outCharAsString <> retCharAsString _ + Or outAny <> retAny Or Not (outType.Name = retType.Name) _ + Or outXInterface IsNot retXInterface Then + sError = "in/out - parameter test failed!" + MsgBox(sError) + End If + + 'Attributes + objOleTest.AByte = inByte + retByte = 0 + retByte = objOleTest.AByte + objOleTest.AFloat = inFloat + retFloat = 0 + retFloat = objOleTest.AFloat + objOleTest.AType = inType + retType = Nothing + + retType = objOleTest.AType + + If inByte <> retByte Or inFloat <> retFloat Or Not (inType.Name = retType.Name) Then + sError = "Attributes - test failed!" + MsgBox(sError) + End If + + End Function + Function testHyper() As Object + + '====================================================================== + ' Other Hyper tests + Dim emptyVar As Object + Dim retAny As Object + + retAny = emptyVar + inHyper = CDec("9223372036854775807") 'highest positive value of int64 + retAny = objOleTest.in_methodAny(inHyper) + sError = "hyper test failed" + If inHyper <> retAny Then + MsgBox(sError) + End If + inHyper = CDec("-9223372036854775808") 'lowest negative value of int64 + retAny = objOleTest.in_methodAny(inHyper) + + If inHyper <> retAny Then + MsgBox(sError) + End If + inHyper = CDec("18446744073709551615") 'highest positive value of unsigned int64 + retAny = objOleTest.in_methodAny(inHyper) + + If inHyper <> retAny Then + MsgBox(sError) + End If + inHyper = CDec(-1) + retAny = objOleTest.in_methodAny(inHyper) + If inHyper <> retAny Then + MsgBox(sError) + End If + inHyper = CDec(0) + retAny = objOleTest.in_methodAny(inHyper) + If inHyper <> retAny Then + MsgBox(sError) + End If + + '============================================================================== + + + End Function + Function testAny() As Object + Dim outVAr As Object + + 'Any test. We pass in an any as value object. If it is not correct converted + 'then the target component throws a RuntimeException + Dim lengthInAny As Integer + + lengthInAny = 10 + Dim seqLongInAny(10) As Integer + For i = 0 To lengthInAny - 1 + seqLongInAny(i) = i + 10 + Next + Dim anySeqLong As Object + anySeqLong = objOleTest.Bridge_GetValueObject() + anySeqLong.Set("[]long", seqLongInAny) + Dim anySeqRet As Object + Err.Clear() + On Error Resume Next + anySeqRet = objOleTest.other_methodAny(anySeqLong, "[]long") + + If Err.Number <> 0 Then + MsgBox("error") + End If + End Function + + Function testObjects() As Object + ' COM obj + Dim outVAr As Object + Dim retObj As Object + 'OleTest receives a COM object that implements XEventListener + 'OleTest then calls a disposing on the object. The object then will be + 'asked if it has been called + objEventListener.setQuiet(True) + objEventListener.resetDisposing() + retObj = objOleTest.in_methodInvocation(objEventListener) + Dim ret As Object + ret = objEventListener.disposingCalled + If ret = False Then + MsgBox("Error") + End If + + 'The returned object should be objEventListener, test it by calling disposing + ' takes an IDispatch as Param ( EventObject).To provide a TypeMismatch + 'we put in another IDispatch + retObj.resetDisposing() + retObj.disposing(objEventListener) + If retObj.disposingCalled = False Then + MsgBox("Error") + End If + + ' out param gives out the OleTestComponent + 'objOleTest.testout_methodXInterface retObj + 'outVAr = Null + 'retObj.testout_methodAny outVAr + 'Debug.Print "test out Interface " & CStr(outVAr) + 'If outVAr <> "I am a string in an any" Then + ' MsgBox "error" + 'End If + + + 'in out + ' in: UNO object, the same is expected as out param + ' the function expects OleTest as parameter and sets a value + + Dim myAny As Object + + + + Dim objOleTest2 As Object + objOleTest2 = objServiceManager.createInstance("oletest.OleTest") + 'Set a value + objOleTest2.AttrAny2 = "VBString " + + 'testinout_methodXInterfaces substitutes the argument with the object set in in_methodXInterface + objOleTest.AttrAny2 = "VBString this string was written in the UNO component to the inout pararmeter" + objOleTest.in_methodXInterface(objOleTest) + objOleTest.testinout_methodXInterface2(objOleTest2) + Dim tmpVar As Object + tmpVar = System.DBNull.Value + tmpVar = objOleTest2.AttrAny2 + Debug.Print("in: Uno out: the same object // " & CStr(tmpVar)) + If tmpVar <> "VBString this string was written in the UNO component to the inout pararmeter" Then + MsgBox("error") + End If + + + 'create a struct + Dim structClass As Object + structClass = objCoreReflection.forName("oletest.SimpleStruct") + Dim structInstance As Object + structClass.CreateObject(structInstance) + structInstance.message = "Now we are in VB" + Debug.Print("struct out " & structInstance.message) + If structInstance.message <> "Now we are in VB" Then + MsgBox("error") + End If + + 'put the struct into OleTest. The same struct will be returned with an added String + Dim structRet As Object + structRet = objOleTest.in_methodStruct(structInstance) + Debug.Print("struct in - return " & structRet.message) + If structRet.message <> "Now we are in VBThis string was set in OleTest" Then + MsgBox("error") + End If + + + End Function + Function testGetStruct() As Object + 'Bridge_GetStruct + '======================================================== + Dim objDocument As Object + objDocument = createHiddenDocument() + 'dispose not working i103353 + 'objDocument.dispose() + objDocument.close(True) + End Function + + Function testImplementedInterfaces() As Object + 'Bridge_ImplementedInterfaces + '================================================= + ' call a UNO function that takes an XEventListener interface + 'We provide a COM implementation (IDispatch) as EventListener + 'Open a new empty writer document + + Dim objDocument As Object + objDocument = createHiddenDocument() + objEventListener.resetDisposing() + objDocument.addEventListener(objEventListener) + objDocument.dispose() + If objEventListener.disposingCalled = False Then + MsgBox("Error") + End If + End Function + + Function testGetValueObject() As Object + 'Bridge_GetValueObject + '================================================== + Dim objVal As Object + objVal = objOleTest.Bridge_GetValueObject() + Dim arrByte(9) As Byte + Dim countvar As Integer + For countvar = 0 To 9 + arrByte(countvar) = countvar + Next countvar + + objVal.Set("[]byte", arrByte) + Dim ret As Object + ret = 0 + ret = objOleTest.methodByte(objVal) + 'Test if ret is the same array + + Dim key As Object + key = 0 + For Each key In ret + If ret(key) <> arrByte(key) Then + MsgBox("Error") + End If + Debug.Print(ret(key)) + Next key + + Dim outByte As Byte + outByte = 77 + Dim retByte As Byte + retByte = outByte + objVal.InitInOutParam("byte", retByte) + objOleTest.testinout_methodByte(objVal) + objVal.InitInOutParam("byte", retByte) + objOleTest.testinout_methodByte(objVal) + + ret = 0 + ret = objVal.Get() + Debug.Print(ret) + If ret <> outByte Then + MsgBox("error") + End If + + objVal.InitOutParam() + Dim inChar As Short + inChar = 65 + objOleTest.in_methodChar(inChar) + objOleTest.testout_methodChar(objVal) 'Returns 'A' (65) + ret = 0 + ret = objVal.Get() + Debug.Print(ret) + If ret <> inChar Then + MsgBox("error") + End If + + End Function + + Function testArrays() As Object + 'Arrays + '======================================== + Dim arrLong(2) As Integer + Dim arrObj(2) As Object + Dim countvar As Integer + For countvar = 0 To 2 + arrLong(countvar) = countvar + 10 + Debug.Print(countvar) + arrObj(countvar) = CreateObject("VBasicEventListener.VBEventListener") + arrObj(countvar).setQuiet(True) + Next + + 'Arrays always contain VARIANTS + Dim seq() As Object + seq = objOleTest.methodLong(arrLong) + + For countvar = 0 To 2 + Debug.Print(CStr(seq(countvar))) + If arrLong(countvar) <> seq(countvar) Then + MsgBox("error") + End If + Next + seq = objOleTest.methodXInterface(arrObj) + Dim tmp As Object + For countvar = 0 To 2 + seq(countvar).resetDisposing() + seq(countvar).disposing(CObj(tmp)) + If seq(countvar).disposingCalled = False Then + MsgBox("Error") + End If + Next + + 'Array containing interfaces (element type is VT_DISPATCH) + Dim arEventListener(2) As Object + For countvar = 0 To 2 + arEventListener(countvar) = CreateObject("VBasicEventListener.VBEventListener") + arEventListener(countvar).setQuiet(True) + Next + + 'The function calls disposing on the listeners + seq = objOleTest.methodXEventListeners(arEventListener) + Dim count As Object + For countvar = 0 To 2 + If arEventListener(countvar).disposingCalled = False Then + MsgBox("Error") + End If + Next + 'Array containing interfaces (element type is VT_VARIANT which contains VT_DISPATCH + Dim arEventListener2(2) As Object + For countvar = 0 To 2 + arEventListener2(countvar) = CreateObject("VBasicEventListener.VBEventListener") + arEventListener2(countvar).setQuiet(True) + Next + seq = objOleTest.methodXEventListeners(arEventListener2) + For countvar = 0 To 2 + If arEventListener2(countvar).disposingCalled = False Then + MsgBox("Error") + End If + Next + + 'Variant containing Array containing interfaces (element type is VT_VARIANT which contains VT_DISPATCH + Dim arEventListener3(2) As Object + Dim var As Object + For countvar = 0 To 2 + arEventListener3(countvar) = CreateObject("VBasicEventListener.VBEventListener") + arEventListener3(countvar).setQuiet(True) + Next + Dim varContAr As Object + varContAr = VB6.CopyArray(arEventListener3) + seq = objOleTest.methodXEventListeners(varContAr) + For countvar = 0 To 2 + If arEventListener3(countvar).disposingCalled = False Then + MsgBox("Error") + End If + Next + + 'Get a sequence created in UNO, out param is Variant ( VT_BYREF|VT_VARIANT) + Dim seqX As Object + + objOleTest.testout_methodSequence(seqX) + Dim key As Object + For Each key In seqX + Debug.Print(CStr(seqX(key))) + If seqX(key) <> key Then + MsgBox("error") + End If + Next key + 'Get a sequence created in UNO, out param is array Variant ( VT_BYREF|VT_VARIANT|VT_ARRAY) + Dim seqX2() As Object + objOleTest.testout_methodSequence(seqX2) + + For Each key In seqX2 + Debug.Print(CStr(seqX2(key))) + Next key + + 'pass it to UNO and get it back + Dim seq7() As Object + seq7 = objOleTest.methodLong(seqX) + Dim key2 As Object + For Each key2 In seq7 + Debug.Print(CStr(seq7(key2))) + If seqX2(key) <> key Then + MsgBox("error") + End If + Next key2 + + 'array with starting index != 0 + Dim seqIndex(2) As Integer + Dim seq8() As Object + Dim longVal1, longVal2 As Integer + longVal1 = 1 + longVal2 = 2 + seqIndex(1) = longVal1 + seqIndex(2) = longVal2 + 'The bridge returns a Safearray of Variants. It does not yet convert to an _ + 'array of a particular type! + 'Comparing of elements from seq8 (Object) with long values worked without _ + 'explicit cast as is necessary in VS 2008. Also arrays in VS 2008 start at _ + 'index 0 + seq8 = objOleTest.methodLong(seqIndex) + If longVal1 <> CInt(seq8(1)) And longVal2 <> CInt(seq8(2)) Then + MsgBox("error") + End If + + 'in out Array + ' arrLong is Long Array + Dim inoutVar(2) As Object + + For countvar = 0 To 2 + inoutVar(countvar) = countvar + 10 + Next + + objOleTest.testinout_methodSequence(inoutVar) + + countvar = 0 + For countvar = 0 To 2 + Debug.Print(CStr(inoutVar(countvar))) + If inoutVar(countvar) <> countvar + 11 Then + MsgBox("error") + End If + Next + + 'Multidimensional array + '============================================================ + ' Sequence< Sequence > methodSequence( Sequence< Sequence long> >) + ' Real multidimensional array Array + ' 9 is Dim 1 (least significant) with C API + Dim mulAr(9, 1) As Integer + For i = 0 To 1 + For j = 0 To 9 + mulAr(j, i) = i * 10 + j + Next j + Next i + + Dim resMul As Object + resMul = objOleTest.methodSequence(mulAr) + + Dim countDim1 As Integer + Dim countDim2 As Integer + Dim arr As Object + For countDim2 = 0 To 1 + arr = resMul(countDim2) + For countDim1 = 0 To 9 + Debug.Print(arr(countDim1)) + If arr(countDim1) <> mulAr(countDim1, countDim2) Then + MsgBox("Error Multidimensional Array") + End If + Next countDim1 + Next countDim2 + IsArray(resMul) + + 'Array of VARIANTs containing arrays + Dim mulAr2(1) As Object + Dim arr2(9) As Integer + For i = 0 To 1 + ' Dim arr(9) As Long + For j = 0 To 9 + arr2(j) = i * 10 + j + Next j + mulAr2(i) = VB6.CopyArray(arr2) + Next i + + resMul = 0 + resMul = objOleTest.methodSequence(mulAr2) + arr = 0 + Dim tmpVar As Object + For countDim2 = 0 To 1 + arr = resMul(countDim2) + tmpVar = mulAr2(countDim2) + For countDim1 = 0 To 9 + Debug.Print(arr(countDim1)) + If arr(countDim1) <> tmpVar(countDim1) Then + MsgBox("Error Multidimensional Array") + End If + Next countDim1 + Next countDim2 + + 'Array containing interfaces (element type is VT_DISPATCH) + Dim arArEventListener(1, 2) As Object + For i = 0 To 1 + For j = 0 To 2 + arArEventListener(i, j) = CreateObject("VBasicEventListener.VBEventListener") + arArEventListener(i, j).setQuiet(True) + Next + Next + 'The function calls disposing on the listeners + seq = objOleTest.methodXEventListenersMul(arArEventListener) + For i = 0 To 1 + For j = 0 To 2 + If arArEventListener(i, j).disposingCalled = False Then + MsgBox("Error") + End If + Next + Next + + 'Array containing interfaces (element type is VT_VARIANT containing VT_DISPATCH) + Dim arArEventListener2(1, 2) As Object + For i = 0 To 1 + For j = 0 To 2 + arArEventListener2(i, j) = CreateObject("VBasicEventListener.VBEventListener") + arArEventListener2(i, j).setQuiet(True) + Next + Next + 'The function calls disposing on the listeners + seq = objOleTest.methodXEventListenersMul(arArEventListener2) + For i = 0 To 1 + For j = 0 To 2 + If arArEventListener2(i, j).disposingCalled = False Then + MsgBox("Error") + End If + Next + Next + + ' SAFEARRAY of VARIANTS containing SAFEARRAYs + 'The ultimate element type is VT_DISPATCH ( XEventListener) + Dim arEventListener4(1) As Object + Dim seq1(2) As Object + Dim seq2(2) As Object + For i = 0 To 2 + seq1(i) = CreateObject("VBasicEventListener.VBEventListener") + seq2(i) = CreateObject("VBasicEventListener.VBEventListener") + seq1(i).setQuiet(True) + seq2(i).setQuiet(True) + Next + arEventListener4(0) = VB6.CopyArray(seq1) + arEventListener4(1) = VB6.CopyArray(seq2) + 'The function calls disposing on the listeners + seq = objOleTest.methodXEventListenersMul(arEventListener4) + For i = 0 To 2 + If seq1(i).disposingCalled = False Or seq2(i).disposingCalled = False Then + MsgBox("Error") + End If + Next + + End Function + + Function createHiddenDocument() As Object + 'Try to create a hidden document + Dim objPropValue As Object + objPropValue = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue") + 'Set the members. If this fails then there is an Error + objPropValue.Name = "Hidden" + objPropValue.Handle = -1 + objPropValue.Value = True + + 'create a hidden document + 'Create the Desktop + Dim objDesktop As Object + objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop") + 'Open a new empty writer document + Dim args(0) As Object + args(0) = objPropValue + createHiddenDocument = objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args) + End Function +End Module diff --git a/extensions/test/ole/VisualBasic/Project1.sln b/extensions/test/ole/VisualBasic/Project1.sln new file mode 100644 index 000000000..bea3e0edf --- /dev/null +++ b/extensions/test/ole/VisualBasic/Project1.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Project1", "Project1.vbproj", "{F62D440E-8976-4A6D-91A8-89F09701074F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F62D440E-8976-4A6D-91A8-89F09701074F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F62D440E-8976-4A6D-91A8-89F09701074F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F62D440E-8976-4A6D-91A8-89F09701074F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F62D440E-8976-4A6D-91A8-89F09701074F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/extensions/test/ole/VisualBasic/Project1.vbproj b/extensions/test/ole/VisualBasic/Project1.vbproj new file mode 100644 index 000000000..4fd617432 --- /dev/null +++ b/extensions/test/ole/VisualBasic/Project1.vbproj @@ -0,0 +1,90 @@ + + + Local + WindowsFormsWithCustomSubMain + 9.0.21022 + 2.0 + {F62D440E-8976-4A6D-91A8-89F09701074F} + Debug + AnyCPU + Project1 + WinExe + Project1.Module1 + 1 + 0 + 0 + False + StarOffice + Project1 + + + + + .\bin\ + Project1.xml + True + True + True + Win32=True + x86 + 42016,42017,42018,42019,42032 + full + + + .\bin\ + Project1.xml + False + False + True + Win32=True + x86 + 42016,42017,42018,42019,42032 + none + + + + Microsoft.VisualBasic.Compatibility + + + System + + + System.Data + + + System.Drawing + + + System.Windows.Forms + + + System.XML + + + + + + + + + + + + + + + + Code + + + + + + + + + + + + + \ No newline at end of file diff --git a/extensions/test/ole/VisualBasic/readme.txt b/extensions/test/ole/VisualBasic/readme.txt new file mode 100644 index 000000000..0b18430fc --- /dev/null +++ b/extensions/test/ole/VisualBasic/readme.txt @@ -0,0 +1,18 @@ +Runs a test written in VisualBasic. If no error message appears then the test was ok. + +Requirements: +Installed office +Component oletest.Oletest (extensions/test/ole/cpnt) +Component VBasicEventListener.VBEventListener (extensions/test/ole/EventListenerSample/VBEventListener + + +OleTest is a UNO component. It needs to be registered with the office rdb. Also there are additional +types (oletest.rdb in wntmsci7/bin/) which must be merged with the rdb. +VBEventListener is an ActiveX component. The directory contains a Visual Basic Project and also +the binary VBasicEventListener.dll. This is necessary because the dll contains the type library +which is needed by VB. Otherwise VB would generate a new CLSID on a new build. +The dll must be registered on the system. This is done by +regsvr32 VBasicEventListener.dll +or +by a rebuild of the project. + diff --git a/extensions/test/ole/callUnoToJava.htm b/extensions/test/ole/callUnoToJava.htm new file mode 100644 index 000000000..5374adbfa --- /dev/null +++ b/extensions/test/ole/callUnoToJava.htm @@ -0,0 +1,552 @@ + + + + + +Document Title + + + + + + + +

Object in JScript

+ +This test passes a XCallback to a UNO function of the UNO test control. +XCallback is implemented by the JScript class XCallback_Impl. The function +XCallback::func1 is then called from the UNO test control. +
+ +
+On the UNO object the function testInterface is called which takes +a XCallback as parameter. XCallback is implemented in a JScript object.The function +returns a XSimple Interface. Then the UNO object calls XSimple::notify. This test shall +verify the correct conversion of the return value( IDispatch JScript object) to an XSimple object.
+ +
+

out parameter

+The a JScript object of class XCallback_Impl is passed to the UNO OleTest Control as parameter. +According to the buttons the OleTest object calls a function on XCallback_Impl that has appropriate type +as out parameter.
+ + + + + + + + + + + + + +
+Other test without parameters
+ + +

in out parameter

+ + + + + + + + + + + + + +
+

Attributes

+ +
+ +Other tests with inout parameters
+ +

in parameters

+ + +

JScript object implements several interfaces

+ + + + + + + diff --git a/extensions/test/ole/cpnt/cpnt.cxx b/extensions/test/ole/cpnt/cpnt.cxx new file mode 100644 index 000000000..3369e03d6 --- /dev/null +++ b/extensions/test/ole/cpnt/cpnt.cxx @@ -0,0 +1,1955 @@ +/* -*- 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 WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +// OPTIONAL is a constant in com.sun.star.beans.PropertyAttributes but it must be +// undef'd in some header files +#define OPTIONAL OPTIONAL +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace cppu; +using namespace osl; +using namespace oletest; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::registry; +using namespace com::sun::star::script; +using namespace com::sun::star::reflection; + + +#define IMPL_NAME L"oletest.OleTestImpl" // oletest.OleTestImpl in applicat.rdb +#define SERVICE_NAME L"oletest.OleTest" +#define KEY1 L"/oletest.OleTestImpl/UNO/SERVICES" +#define KEY2 L"oletest.OleTest" + +class OComponent : public WeakImplHelper< + XTestSequence, XTestStruct, XTestOther, XTestInterfaces, + XSimple, XTestInParameters, XIdentity > +{ + Reference m_xIntIdentity; + sal_Int32 m_arrayConstructor; + Reference m_rFactory; + + Sequence m_seqByte; + Sequence m_seqFloat; + Sequence m_seqDouble; + Sequence m_seqBool; + Sequence m_seqShort; + Sequence m_seqUShort; + Sequence m_seqLong; + Sequence m_seqULong; + Sequence m_seqChar; + Sequence m_seqString; + Sequence m_seqAny; + Sequence m_seqType; + Sequence > m_seq1; + Sequence > > m_seq2; + Any m_any; + Type m_type; + Sequence > m_seqxInterface; + + sal_Int8 m_int8; + sal_uInt8 m_uint8; + sal_Int16 m_int16; + sal_uInt16 m_uint16; + sal_Int32 m_int32; + sal_uInt32 m_uint32; + sal_Int64 m_int64; + sal_uInt64 m_uint64; + float m_float; + double m_double; + OUString m_string; + sal_Unicode m_char; + sal_Bool m_bool; + Reference m_xinterface; + + sal_Int8 m_attr_int8; + sal_uInt8 m_attr_uint8; + sal_Int16 m_attr_int16; + sal_uInt16 m_attr_uint16; + sal_Int32 m_attr_int32; + sal_uInt32 m_attr_uint32; + sal_Int64 m_attr_int64; + sal_uInt64 m_attr_uint64; + float m_attr_float; + double m_attr_double; + OUString m_attr_string; + sal_Unicode m_attr_char; + sal_Bool m_attr_bool; + Any m_attr_any; + Type m_attr_type; + Reference m_attr_xinterface; + Reference m_attr_xinvocation; + +public: + OComponent( const Reference & rFactory ) : + m_rFactory( rFactory ), m_arrayConstructor(0) {} + ~OComponent(); +public: // XTestSequence + virtual Sequence SAL_CALL methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException ); + virtual Sequence SAL_CALL methodFloat(const Sequence< float >& aSeq) throw( RuntimeException ); + virtual Sequence< double > SAL_CALL methodDouble(const Sequence< double >& aSeq) throw( RuntimeException); + virtual Sequence< sal_Bool > SAL_CALL methodBool(const Sequence< sal_Bool >& aSeq) throw( RuntimeException ); + virtual Sequence< sal_Int16 > SAL_CALL methodShort(const Sequence< sal_Int16 >& aSeq) throw( RuntimeException ); + virtual Sequence< sal_uInt16 > SAL_CALL methodUShort(const Sequence< sal_uInt16 >& aSeq) throw( RuntimeException ); + virtual Sequence< sal_Int32 > SAL_CALL methodLong(const Sequence< sal_Int32 >& aSeq) throw( RuntimeException) ; + virtual Sequence< sal_uInt32 > SAL_CALL methodULong(const Sequence< sal_uInt32 >& aSeq) throw( RuntimeException ); + virtual Sequence< OUString > SAL_CALL methodString(const Sequence< OUString >& aSeq) throw( RuntimeException ); + virtual Sequence< sal_Unicode > SAL_CALL methodChar(const Sequence< sal_Unicode >& aSeq) throw( RuntimeException ); + virtual Sequence< Any > SAL_CALL methodAny(const Sequence< Any >& aSeq) throw( RuntimeException ); + virtual Sequence< Type > SAL_CALL methodType(const Sequence< Type >& aSeq) throw( RuntimeException ); + virtual Sequence< Reference< XInterface > > SAL_CALL methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException) ; + virtual Sequence< Sequence< sal_Int32 > > SAL_CALL methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq) throw( RuntimeException ); + virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq) throw( RuntimeException ); + virtual Sequence< Reference > SAL_CALL methodXEventListeners( const Sequence >& aSeq) throw( RuntimeException); + virtual Sequence< Sequence > > SAL_CALL methodXEventListenersMul( const Sequence > >& aSeq ) throw (RuntimeException); + + virtual Sequence< sal_Int8 > SAL_CALL getAttrByte() throw( RuntimeException ); + virtual void SAL_CALL setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException ); + virtual Sequence< float > SAL_CALL getAttrFloat() throw( RuntimeException) ; + virtual void SAL_CALL setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException ); + virtual Sequence< double > SAL_CALL getAttrDouble() throw( RuntimeException) ; + virtual void SAL_CALL setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException ); + virtual Sequence< sal_Bool > SAL_CALL getAttrBool() throw( RuntimeException ); + virtual void SAL_CALL setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw( RuntimeException ); + virtual Sequence< sal_Int16 > SAL_CALL getAttrShort() throw( RuntimeException ); + virtual void SAL_CALL setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException ); + virtual Sequence< sal_uInt16 > SAL_CALL getAttrUShort() throw( RuntimeException ); + virtual void SAL_CALL setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException ); + virtual Sequence< sal_Int32 > SAL_CALL getAttrLong() throw( RuntimeException ); + virtual void SAL_CALL setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException ); + virtual Sequence< sal_uInt32 > SAL_CALL getAttrULong() throw( RuntimeException ); + virtual void SAL_CALL setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException ); + virtual Sequence< OUString > SAL_CALL getAttrString() throw(RuntimeException ); + virtual void SAL_CALL setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException ); + virtual Sequence< sal_Unicode > SAL_CALL getAttrChar() throw( RuntimeException ); + virtual void SAL_CALL setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException ); + virtual Sequence< Any > SAL_CALL getAttrAny() throw( RuntimeException ); + virtual void SAL_CALL setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException ); + virtual Sequence< Type > SAL_CALL getAttrType() throw( RuntimeException ); + virtual void SAL_CALL setAttrType( const Sequence< Type >& _attrtype ) throw (RuntimeException); + virtual Sequence< Sequence< sal_Int32 > > SAL_CALL getAttrSequence() throw( RuntimeException ); + virtual void SAL_CALL setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence_) throw( RuntimeException ); + virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL getAttrSequence2() throw( RuntimeException ); + virtual void SAL_CALL setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_) throw ( RuntimeException ); + virtual Sequence< Reference< XInterface > > SAL_CALL getAttrXInterface() throw(RuntimeException); + virtual void SAL_CALL setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface ) throw(RuntimeException); + + virtual ::sal_Int8 SAL_CALL getAByte() throw (RuntimeException); + virtual void SAL_CALL setAByte( ::sal_Int8 _abyte ) throw (RuntimeException); + virtual float SAL_CALL getAFloat() throw (RuntimeException); + virtual void SAL_CALL setAFloat( float _afloat ) throw (RuntimeException); + virtual double SAL_CALL getADouble() throw (RuntimeException); + virtual void SAL_CALL setADouble( double _adouble ) throw (RuntimeException); + virtual sal_Bool SAL_CALL getABool() throw (RuntimeException); + virtual void SAL_CALL setABool( sal_Bool _abool ) throw (RuntimeException); + virtual ::sal_Int16 SAL_CALL getAShort() throw (RuntimeException); + virtual void SAL_CALL setAShort( ::sal_Int16 _ashort ) throw (RuntimeException); + virtual ::sal_uInt16 SAL_CALL getAUShort() throw (RuntimeException); + virtual void SAL_CALL setAUShort( ::sal_uInt16 _aushort ) throw (RuntimeException); + virtual ::sal_Int32 SAL_CALL getALong() throw (RuntimeException); + virtual void SAL_CALL setALong( ::sal_Int32 _along ) throw (RuntimeException); + virtual ::sal_uInt32 SAL_CALL getAULong() throw (RuntimeException); + virtual void SAL_CALL setAULong( ::sal_uInt32 _aulong ) throw (RuntimeException); + virtual OUString SAL_CALL getAString() throw (RuntimeException); + virtual void SAL_CALL setAString( const OUString& _astring ) throw (RuntimeException); + virtual ::sal_Unicode SAL_CALL getAChar() throw (RuntimeException); + virtual void SAL_CALL setAChar( ::sal_Unicode _achar ) throw (RuntimeException); + virtual Any SAL_CALL getAAny() throw (RuntimeException); + virtual void SAL_CALL setAAny( const Any& _aany ) throw (RuntimeException); + virtual Type SAL_CALL getAType() throw (RuntimeException); + virtual void SAL_CALL setAType( const Type& _atype ) throw (RuntimeException); + virtual Reference< XInterface > SAL_CALL getAXInterface() throw (RuntimeException); + virtual void SAL_CALL setAXInterface( const Reference& _axinterface ) throw (RuntimeException); + virtual Reference SAL_CALL getAXInvocation() throw (RuntimeException); + virtual void SAL_CALL setAXInvocation( const Reference< XInvocation >& _axinvocation ) throw (RuntimeException); + + virtual void SAL_CALL testout_methodByte(sal_Int8& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodFloat(float& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodDouble(double& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodBool(sal_Bool& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodShort(sal_Int16& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodLong(sal_Int32& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodULong(sal_uInt32& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodHyper(sal_Int64& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodString(OUString& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodChar(sal_Unicode& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodAny(Any& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodType(Type& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException ); + virtual void SAL_CALL testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException ); + virtual void SAL_CALL testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException ); + virtual void SAL_CALL testout_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException ); + virtual void SAL_CALL testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 in3 ) throw(RuntimeException); + virtual void SAL_CALL testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException); + + virtual void SAL_CALL testinout_methodByte(sal_Int8& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodFloat(float& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodDouble(double& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodBool(sal_Bool& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodShort(sal_Int16& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodLong(sal_Int32& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodHyper(sal_Int64& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodString(OUString& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodAny(Any& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodType(Type& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException ); + virtual void SAL_CALL testinout_methodXInterface( Reference< XInvocation >& rOut ) throw(RuntimeException); + virtual void SAL_CALL testinout_methodXInterface2( Reference< XInterface > & rOut) throw( RuntimeException); + virtual Any SAL_CALL methodAnyTest1(const Any& rIn) throw( RuntimeException ) ; + virtual Any SAL_CALL getAttrAny2() throw( RuntimeException ) ; + virtual void SAL_CALL setAttrAny2(const Any& AttrAny2_) throw( RuntimeException ) ; + + + // XTestStruct + virtual void SAL_CALL methodStruct(const Property& aProp) throw( RuntimeException ); + + virtual Property SAL_CALL retMethodStruct() throw( RuntimeException ); + + virtual Property SAL_CALL getAttrStruct() throw( RuntimeException ); + virtual void SAL_CALL setAttrStruct(const Property& AttrStruct_) throw( RuntimeException ); + virtual Property SAL_CALL methodStruct2( const Property& aProp ) throw (RuntimeException); + + // XTestOther + virtual void SAL_CALL other_methodAnyIn(const Any& rAny) throw( RuntimeException ); + virtual void SAL_CALL other_methodAnyOut(Any& rAny) throw( RuntimeException ); + virtual Any SAL_CALL other_methodAnyRet() throw( RuntimeException ); + virtual void SAL_CALL in_float( float val) throw ( RuntimeException); + virtual Any SAL_CALL other_methodAny( const Any& rAny, const OUString& typeInAny ) + throw (RuntimeException); + + // XTestInParameters + virtual sal_Int8 SAL_CALL in_methodByte( sal_Int8 rIn ) throw (RuntimeException); + virtual float SAL_CALL in_methodFloat( float rIn ) throw (RuntimeException); + virtual double SAL_CALL in_methodDouble( double rIn ) throw (RuntimeException); + virtual sal_Bool SAL_CALL in_methodBool( sal_Bool rIn ) throw (RuntimeException); + virtual sal_Int16 SAL_CALL in_methodShort( sal_Int16 rIn ) throw (RuntimeException); + virtual sal_uInt16 SAL_CALL in_methodUShort( sal_uInt16 rIn ) throw (RuntimeException); + virtual sal_Int32 SAL_CALL in_methodLong( sal_Int32 rIn ) throw (RuntimeException); + virtual sal_uInt32 SAL_CALL in_methodULong( sal_uInt32 rIn ) throw (RuntimeException); + virtual sal_Int64 SAL_CALL in_methodHyper( sal_Int64 rIn ) throw (RuntimeException); + virtual sal_uInt64 SAL_CALL in_methodUHyper( sal_uInt64 rIn ) throw (RuntimeException); + virtual OUString SAL_CALL in_methodString( const OUString& rIn ) throw (RuntimeException); + virtual sal_Unicode SAL_CALL in_methodChar( sal_Unicode rIn ) throw (RuntimeException); + virtual Any SAL_CALL in_methodAny( const Any& rIn ) throw (RuntimeException); + virtual Type SAL_CALL in_methodType( const Type& rIn ) throw (RuntimeException); + virtual Reference SAL_CALL in_methodXInterface( const Reference< XInterface >& rIn ) throw (RuntimeException); + virtual Reference SAL_CALL in_methodInvocation( const Reference< XInvocation >& inv ) throw (RuntimeException); + virtual SimpleStruct SAL_CALL in_methodStruct( const SimpleStruct& aStruct ) throw (RuntimeException); + virtual void SAL_CALL in_methodAll( sal_Int8 b, float f, double d, sal_Bool boo, sal_Int16 sh, sal_uInt16 us, sal_Int32 l, sal_uInt32 ul, const OUString& s, sal_Unicode c, const Any& a, const Type& t, const Reference& inv ) throw (RuntimeException); + + // XTestInterfaces -------------------------------------------------------------------------- + virtual void SAL_CALL testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode ) throw(RuntimeException); + virtual void SAL_CALL testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode ) throw(RuntimeException); + // XSimple -------------------------------------------------------------------------- + void SAL_CALL func( const OUString &message) throw(css::uno::RuntimeException); + OUString SAL_CALL getName() throw(css::uno::RuntimeException); + + // XIdentity + virtual void SAL_CALL setObject( const Reference< XInterface >& val ) throw (RuntimeException); + virtual sal_Bool SAL_CALL isSame( const Reference< XInterface >& val ) throw (RuntimeException); + virtual Reference< XInterface > SAL_CALL getThis( ) throw (RuntimeException); +}; + +class EventListener: public WeakImplHelper +{ +public: + EventListener(): bCalled( sal_False) + {} + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw (RuntimeException); + + sal_Bool bCalled; +}; + + +OComponent::~OComponent() +{ +} + + +// functions ============================================================================== + +Reference SAL_CALL OComponent_CreateInstance( const Reference & rSMgr ) throw(RuntimeException) +{ +// Reference xService(static_cast(new OComponent( rSMgr )), UNO_QUERY); + OComponent* o= new OComponent( rSMgr ); + Reference xService(static_cast(o), UNO_QUERY); + return xService; +} + +Sequence OComponent_getSupportedServiceNames() +{ + Sequence aRet { SERVICE_NAME;//ODataInputStream_getImplementationName() }; + + return aRet; +} + + +extern "C" sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey ) +{ + if(pRegistryKey) + { + try + { + Reference xNewKey = + reinterpret_cast( pRegistryKey)->createKey(KEY1); + xNewKey->createKey( KEY2); + return sal_True; + + } + catch(InvalidRegistryException &) + { + TOOLS_WARN_EXCEPTION("extensions.olebridge", ""); + } + } + return sal_False; +} + +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + const char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) +{ + static void * pRet= NULL; + if( ! pRet) + { + OUString aImplName( OUString::createFromAscii( pImplName ) ); + if (pServiceManager && aImplName.equals( IMPL_NAME )) + { + Reference xMulFac( + reinterpret_cast< XMultiServiceFactory*>(pServiceManager)); + + Sequence seqServiceNames; + Reference xFactory = createOneInstanceFactory( xMulFac, SERVICE_NAME, + OComponent_CreateInstance, seqServiceNames); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + } + return pRet; +} + + +// XTestSequence ============================================================================ +Sequence SAL_CALL OComponent::methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException ) +{ + sal_Int8 _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} +Sequence SAL_CALL OComponent::methodFloat(const Sequence< float>& aSeq) throw( RuntimeException ) +{ + float _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} +Sequence SAL_CALL OComponent::methodDouble(const Sequence< double >& aSeq) throw( RuntimeException) +{ + double _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} +Sequence< sal_Bool > SAL_CALL OComponent::methodBool(const Sequence< sal_Bool >& aSeq) throw( RuntimeException) +{ + sal_Bool _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} +Sequence< sal_Int16 > SAL_CALL OComponent::methodShort(const Sequence< sal_Int16 >& aSeq) throw( RuntimeException ) +{ + sal_Int16 _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} +Sequence< sal_uInt16 > SAL_CALL OComponent::methodUShort(const Sequence< sal_uInt16 >& aSeq) throw( RuntimeException ) +{ + sal_uInt16 _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} +Sequence< sal_Int32 > SAL_CALL OComponent::methodLong(const Sequence< sal_Int32 >& aSeq) throw( RuntimeException) +{ + sal_Int32 _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++) { + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} +Sequence< sal_uInt32 > SAL_CALL OComponent::methodULong(const Sequence< sal_uInt32 >& aSeq) throw( RuntimeException) +{ + sal_uInt32 _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} +Sequence< OUString > SAL_CALL OComponent::methodString(const Sequence< OUString >& aSeq) throw( RuntimeException) +{ + OUString _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++) { + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} +Sequence< sal_Unicode > SAL_CALL OComponent::methodChar(const Sequence< sal_Unicode >& aSeq) throw( RuntimeException) +{ + sal_Unicode _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} +Sequence< Any > SAL_CALL OComponent::methodAny(const Sequence< Any >& aSeq) throw( RuntimeException) +{ + Any _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + _x= aSeq.getConstArray()[i]; + TypeClass _t= _x.getValueTypeClass(); + if( _t== TypeClass_STRING) + OUString s(* (rtl_uString**)_x.getValue()); + } + return aSeq; + +} + +Sequence< Type > SAL_CALL OComponent::methodType(const Sequence< Type >& aSeq) throw( RuntimeException ) +{ + Type _x; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + _x= aSeq.getConstArray()[i]; + } + return aSeq; +} + +Sequence< Reference< XInterface > > SAL_CALL OComponent::methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException) +{ + for( sal_Int32 i= 0; i < aSeq.getLength(); i++) + { + Reference xInt= aSeq[i]; + Reference xList( xInt, UNO_QUERY); + if( xList.is()) + xList->disposing( EventObject()); + } + return aSeq; +} + +Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq) throw( RuntimeException) +{ + sal_Int32 value; + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + const Sequence& rseq2= aSeq.getConstArray()[i]; + for (sal_Int16 j= 0; j < rseq2.getLength(); j++){ + value= rseq2.getConstArray()[j]; + } + } + return aSeq; +} +Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq) + throw( RuntimeException ) +{ + sal_Int32 value; + sal_Int32 len= aSeq.getLength(); + for( sal_Int16 i= 0; i < aSeq.getLength(); i++){ + const Sequence< Sequence >& rseq2= aSeq.getConstArray()[i]; + len= rseq2.getLength(); + + for (sal_Int16 j= 0; j < rseq2.getLength(); j++){ + const Sequence & rseq3= rseq2.getConstArray()[j]; + len= rseq3.getLength(); + + for (sal_Int16 k= 0; k < rseq3.getLength(); k++) + value= rseq3.getConstArray()[k]; + } + } + return aSeq; +} + +Sequence< Reference< XEventListener> > SAL_CALL OComponent::methodXEventListeners( const Sequence< Reference >& aSeq) throw( RuntimeException) +{ + Reference listener; + for( int i= 0; i < aSeq.getLength(); i++) + { + listener= aSeq[i]; + + listener->disposing( EventObject() ); + } + + return aSeq; +} + +Sequence< Sequence > > SAL_CALL OComponent::methodXEventListenersMul( const Sequence > >& aSeq ) throw (RuntimeException) +{ + Reference listener; + for( int i= 0; i < aSeq.getLength(); i++) + { + Sequence > seqInner= aSeq[i]; + for( int j= 0; j < seqInner.getLength(); j++) + { + listener= seqInner[j]; + listener->disposing( EventObject() ); + } + } + return aSeq; +} + + +Sequence< sal_Int8 > SAL_CALL OComponent::getAttrByte() throw( RuntimeException) +{ + return m_seqByte; +} +void SAL_CALL OComponent::setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException ) +{ + m_seqByte= AttrByte_; +} +Sequence< float > SAL_CALL OComponent::getAttrFloat() throw( RuntimeException ) +{ + return m_seqFloat; +} +void SAL_CALL OComponent::setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException ) +{ + m_seqFloat= AttrFloat_; +} + +Sequence< double > SAL_CALL OComponent::getAttrDouble() throw( RuntimeException ) +{ + return m_seqDouble; +} +void SAL_CALL OComponent::setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException ) +{ + m_seqDouble= AttrDouble_; +} + +Sequence< sal_Bool > SAL_CALL OComponent::getAttrBool() throw( RuntimeException) +{ + return m_seqBool; +} + +void SAL_CALL OComponent::setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw (RuntimeException ) +{ + m_seqBool= AttrBool_; +} + +Sequence< sal_Int16 > SAL_CALL OComponent::getAttrShort() throw( RuntimeException) +{ + return m_seqShort; +} +void SAL_CALL OComponent::setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException ) +{ + m_seqShort= AttrShort_; +} + +Sequence< sal_uInt16 > SAL_CALL OComponent::getAttrUShort() throw( RuntimeException ) +{ + return m_seqUShort; +} +void SAL_CALL OComponent::setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException ) +{ + m_seqUShort= AttrUShort_; +} + +Sequence< sal_Int32 > SAL_CALL OComponent::getAttrLong() throw( RuntimeException) +{ + return m_seqLong; +} +void SAL_CALL OComponent::setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException ) +{ + m_seqLong= AttrLong_; +} + +Sequence< sal_uInt32 > SAL_CALL OComponent::getAttrULong() throw( RuntimeException ) +{ + return m_seqULong; +} +void SAL_CALL OComponent::setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException ) +{ + m_seqULong= AttrULong_; +} + +Sequence< OUString > SAL_CALL OComponent::getAttrString() throw( RuntimeException ) +{ + return m_seqString; +} +void SAL_CALL OComponent::setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException ) +{ + m_seqString= AttrString_; +} + +Sequence< sal_Unicode > SAL_CALL OComponent::getAttrChar() throw( RuntimeException ) +{ + return m_seqChar; +} +void SAL_CALL OComponent::setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException) +{ + m_seqChar= AttrChar_; +} + +Sequence< Any > SAL_CALL OComponent::getAttrAny() throw( RuntimeException) +{ + return m_seqAny; +} +void SAL_CALL OComponent::setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException ) +{ + m_seqAny= AttrAny_; +} + +Sequence< Type > SAL_CALL OComponent::getAttrType() throw( RuntimeException ) +{ + return m_seqType; +} + +void SAL_CALL OComponent::setAttrType( const Sequence< Type >& AttrType_) throw( RuntimeException ) +{ + m_seqType = AttrType_; +} + + +Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::getAttrSequence() throw( RuntimeException) +{ + return m_seq1; +} +void SAL_CALL OComponent::setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence) throw(RuntimeException ) +{ + sal_Int32 x= 0; + for( sal_Int32 i=0; i < AttrSequence.getLength(); i++) + { + Sequence< sal_Int32 > seq= AttrSequence[i]; + + for ( sal_Int32 j=0; j < seq.getLength(); j++) + { + x= seq[j]; + } + } + + m_seq1= AttrSequence; +} + +Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::getAttrSequence2() throw( RuntimeException ) +{ + return m_seq2; +} +void SAL_CALL OComponent::setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_) + throw( RuntimeException ) +{ + m_seq2= AttrSequence2_; +} + +Sequence< Reference< XInterface > > SAL_CALL OComponent::getAttrXInterface() throw(RuntimeException) +{ + return m_seqxInterface; +} +void SAL_CALL OComponent::setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface ) throw(RuntimeException) +{ + m_seqxInterface= _attrxinterface; +} + + +::sal_Int8 SAL_CALL OComponent::getAByte() throw (RuntimeException) +{ + return m_attr_int8; +} + +void SAL_CALL OComponent::setAByte( ::sal_Int8 _abyte ) throw (RuntimeException) +{ + m_attr_int8 = _abyte; +} + +float SAL_CALL OComponent::getAFloat() throw (RuntimeException) +{ + return m_attr_float; +} + +void SAL_CALL OComponent::setAFloat( float _afloat ) throw (RuntimeException) +{ + m_attr_float = _afloat; +} + +double SAL_CALL OComponent::getADouble() throw (RuntimeException) +{ + return m_attr_double; +} + +void SAL_CALL OComponent::setADouble( double _adouble ) throw (RuntimeException) +{ + m_attr_double = _adouble; +} + +sal_Bool SAL_CALL OComponent::getABool() throw (RuntimeException) +{ + return m_attr_bool; +} + +void SAL_CALL OComponent::setABool( sal_Bool _abool ) throw (RuntimeException) +{ + m_attr_bool = _abool; +} + +::sal_Int16 SAL_CALL OComponent::getAShort() throw (RuntimeException) +{ + return m_attr_int16; +} + +void SAL_CALL OComponent::setAShort( ::sal_Int16 _ashort ) throw (RuntimeException) +{ + m_attr_int16 = _ashort; +} + +::sal_uInt16 SAL_CALL OComponent::getAUShort() throw (RuntimeException) +{ + return m_attr_uint16; +} + +void SAL_CALL OComponent::setAUShort( ::sal_uInt16 _aushort ) throw (RuntimeException) +{ + m_attr_uint16 = _aushort; +} + +::sal_Int32 SAL_CALL OComponent::getALong() throw (RuntimeException) +{ + return m_attr_int32; +} + +void SAL_CALL OComponent::setALong( ::sal_Int32 _along ) throw (RuntimeException) +{ + m_attr_int32 = _along; +} + +::sal_uInt32 SAL_CALL OComponent::getAULong() throw (RuntimeException) +{ + return m_attr_uint32; +} + +void SAL_CALL OComponent::setAULong( ::sal_uInt32 _aulong ) throw (RuntimeException) +{ + m_attr_uint32 = _aulong; +} + +OUString SAL_CALL OComponent::getAString() throw (RuntimeException) +{ + return m_attr_string; +} + +void SAL_CALL OComponent::setAString( const OUString& _astring ) throw (RuntimeException) +{ + m_attr_string = _astring; +} + +::sal_Unicode SAL_CALL OComponent::getAChar() throw (RuntimeException) +{ + return m_attr_char; +} + +void SAL_CALL OComponent::setAChar( ::sal_Unicode _achar ) throw (RuntimeException) +{ + m_attr_char = _achar; +} + +Any SAL_CALL OComponent::getAAny() throw (RuntimeException) +{ + return m_attr_any; +} + +void SAL_CALL OComponent::setAAny( const Any& _aany ) throw (RuntimeException) +{ + m_attr_any = _aany; +} + +Type SAL_CALL OComponent::getAType() throw (RuntimeException) +{ + return m_attr_type; +} + +void SAL_CALL OComponent::setAType( const Type& _atype ) throw (RuntimeException) +{ + m_attr_type = _atype; +} + +Reference< XInterface > SAL_CALL OComponent::getAXInterface() throw (RuntimeException) +{ + return m_attr_xinterface; +} + +void SAL_CALL OComponent::setAXInterface( const Reference& _axinterface ) throw (RuntimeException) +{ + m_attr_xinterface = _axinterface; +} + +Reference SAL_CALL OComponent::getAXInvocation() throw (RuntimeException) +{ + return m_attr_xinvocation; +} + +void SAL_CALL OComponent::setAXInvocation( const Reference< XInvocation >& _axinvocation ) throw (RuntimeException) +{ + m_attr_xinvocation = _axinvocation; +} + +void SAL_CALL OComponent::testout_methodByte(sal_Int8& rOut) throw( RuntimeException ) +{ + rOut= m_int8; +} +void SAL_CALL OComponent::testout_methodFloat(float& rOut) throw( RuntimeException ) +{ + rOut= m_float; +} +void SAL_CALL OComponent::testout_methodDouble(double& rOut) throw( RuntimeException ) +{ + rOut= m_double; +} + +void SAL_CALL OComponent::testout_methodBool(sal_Bool& rOut) throw( RuntimeException ) +{ + rOut= m_bool; +} +void SAL_CALL OComponent::testout_methodShort(sal_Int16& rOut) throw( RuntimeException ) +{ + rOut= m_int16; +} +void SAL_CALL OComponent::testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException ) +{ + rOut= m_uint16; +} +void SAL_CALL OComponent::testout_methodLong(sal_Int32& rOut) throw( RuntimeException ) +{ + rOut = m_int32; +} +void SAL_CALL OComponent::testout_methodULong(sal_uInt32& rOut) throw( RuntimeException ) +{ + rOut= m_uint32; +} +void SAL_CALL OComponent::testout_methodHyper(sal_Int64& rOut) throw( RuntimeException ) +{ + rOut = m_int64; +} + +void SAL_CALL OComponent::testout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException ) +{ + rOut = m_uint64; +} + +void SAL_CALL OComponent::testout_methodString(OUString& rOut) throw( RuntimeException ) +{ + rOut= m_string; +} +void SAL_CALL OComponent::testout_methodChar(sal_Unicode& rOut) throw( RuntimeException ) +{ + rOut= m_char; +} +void SAL_CALL OComponent::testout_methodAny(Any& rOut) throw( RuntimeException) +{ + rOut = m_any; +} + +void SAL_CALL OComponent::testout_methodType(Type& rOut) throw( RuntimeException ) +{ + rOut = m_type; +} + +void SAL_CALL OComponent::testout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException) +{ + rOut.realloc(10); + for( sal_Int16 i= 0; i < rOut.getLength(); i++) rOut.getArray()[i]= i; +} +void SAL_CALL OComponent::testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException ) +{ + rOut.realloc( 10); + for( sal_Int16 i= 0; i < rOut.getLength(); i++){ + Sequence& rseq2= rOut.getArray()[i]; + rseq2.realloc( 10); + for (sal_Int16 j= 0; j < rseq2.getLength(); j++){ + rseq2.getArray()[j]= j; + } + } +} +void SAL_CALL OComponent::testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException ) +{ + rout1= 999; + rout2= 1111; +} +void SAL_CALL OComponent::testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException ) +{ + rout1= 1111; + rout2= 1222; + rout3= L" another string"; +} +void SAL_CALL OComponent::testout_methodMulParams3(const OUString&, OUString& sout) throw( RuntimeException ) +{ + sout= L"Out Hallo!"; +} +void SAL_CALL OComponent::testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 ) throw(RuntimeException) +{ + out1= in1 + 1; + out2= in2 + 1; +} + +void SAL_CALL OComponent::testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException) +{ + rOut = m_xinterface; +} + +// XTestInParameters ------------------------------------------------------------ +sal_Int8 SAL_CALL OComponent::in_methodByte( sal_Int8 rIn ) throw (RuntimeException) +{ + m_int8 = rIn; + return rIn; +} +float SAL_CALL OComponent::in_methodFloat( float rIn ) throw (RuntimeException) +{ + m_float = rIn; + return rIn; +} +double SAL_CALL OComponent::in_methodDouble( double rIn ) throw (RuntimeException) +{ + m_double = rIn; + return rIn; +} +sal_Bool SAL_CALL OComponent::in_methodBool( sal_Bool rIn ) throw (RuntimeException) +{ + m_bool = rIn; + return rIn; +} +sal_Int16 SAL_CALL OComponent::in_methodShort( sal_Int16 rIn ) throw (RuntimeException) +{ + m_int16 = rIn; + return rIn; +} +sal_uInt16 SAL_CALL OComponent::in_methodUShort( sal_uInt16 rIn ) throw (RuntimeException) +{ + m_uint16 = rIn; + return rIn; +} +sal_Int32 SAL_CALL OComponent::in_methodLong( sal_Int32 rIn ) throw (RuntimeException) +{ + m_int32 = rIn; + return rIn; +} +sal_uInt32 SAL_CALL OComponent::in_methodULong( sal_uInt32 rIn ) throw (RuntimeException) +{ + m_uint32 = rIn; + return rIn; +} +sal_Int64 SAL_CALL OComponent::in_methodHyper( sal_Int64 rIn ) throw (RuntimeException) +{ + m_int64 = rIn; + return rIn; +} + +sal_uInt64 SAL_CALL OComponent::in_methodUHyper( sal_uInt64 rIn ) throw (RuntimeException) +{ + m_uint64 = rIn; + return rIn; +} + +OUString SAL_CALL OComponent::in_methodString( const OUString& rIn ) throw (RuntimeException) +{ + m_string = rIn; + return rIn; +} +sal_Unicode SAL_CALL OComponent::in_methodChar( sal_Unicode rIn ) throw (RuntimeException) +{ + m_char = rIn; + return rIn; +} +Any SAL_CALL OComponent::in_methodAny( const Any& rIn ) throw (RuntimeException) +{ + m_any = rIn; + return rIn; +} + +Type SAL_CALL OComponent::in_methodType( const Type& rIn ) throw (RuntimeException) +{ + m_type = rIn; + return rIn; +} + +Reference SAL_CALL OComponent::in_methodInvocation( const Reference< XInvocation >& inv ) + throw (RuntimeException) +{ + //We expect the invocation results from a conversion of VBasicEventListener.VBEventListener +//which implements XEventListener + // extensions/test/ole/EventListenerSample + EventObject event( Reference(static_cast(this),UNO_QUERY)); + Any anyParam; + anyParam <<= event; + Sequence params( &anyParam, 1); + Sequence outIndex; + Sequence outParams; + try{ + inv->invoke( OUString("disposing"), + params, outIndex, outParams); + }catch(IllegalArgumentException &) { + } + catch(CannotConvertException &){ + } + catch(InvocationTargetException&) { + } + return inv; +} +Reference SAL_CALL OComponent::in_methodXInterface( const Reference& rIn ) throw (RuntimeException) +{ + m_xinterface = rIn; + return rIn; +} + +SimpleStruct SAL_CALL OComponent::in_methodStruct( const SimpleStruct& aStruct ) + throw (RuntimeException) +{ + SimpleStruct& s= const_cast(aStruct); + s.message= s.message + OUString( + "This string was set in OleTest"); + return aStruct; +} +void SAL_CALL OComponent::in_methodAll( + sal_Int8, float, double, sal_Bool, sal_Int16, sal_uInt16, + sal_Int32, sal_uInt32, const OUString&, sal_Unicode, + const Any&, const Type&, const Reference&) throw (RuntimeException) +{ +} + +// INOUT ----------------------------------------------------------------------------------- +void SAL_CALL OComponent::testinout_methodByte(sal_Int8& rOut) throw( RuntimeException ) +{ + sal_Int8 tmp = rOut; + rOut = m_int8; + m_int8 = tmp; +} +void SAL_CALL OComponent::testinout_methodFloat(float& rOut) throw( RuntimeException ) +{ + float tmp = rOut; + rOut = m_float; + m_float = tmp; +} + +void SAL_CALL OComponent::testinout_methodDouble(double& rOut) throw( RuntimeException ) +{ + double tmp = rOut; + rOut = m_double; + m_double = tmp; +} +void SAL_CALL OComponent::testinout_methodBool(sal_Bool& rOut) throw( RuntimeException ) +{ + sal_Bool tmp = rOut; + rOut = m_bool; + m_bool = tmp; +} +void SAL_CALL OComponent::testinout_methodShort(sal_Int16& rOut) throw( RuntimeException ) +{ + sal_Int16 tmp= rOut; + rOut = m_int16; + m_int16 = tmp; +} +void SAL_CALL OComponent::testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException ) +{ + sal_uInt16 tmp = rOut; + rOut = m_uint16; + m_uint16 = tmp; +} +void SAL_CALL OComponent::testinout_methodLong(sal_Int32& rOut) throw( RuntimeException ) +{ + sal_Int32 tmp = rOut; + rOut = m_int32; + m_int32 = tmp; +} +void SAL_CALL OComponent::testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException ) +{ + sal_uInt32 tmp = rOut; + rOut = m_uint32; + m_uint32 = tmp; +} +void SAL_CALL OComponent::testinout_methodHyper(sal_Int64& rOut) throw( RuntimeException ) +{ + sal_Int64 tmp = rOut; + rOut = m_int64; + m_int64 = tmp; +} + +void SAL_CALL OComponent::testinout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException ) +{ + sal_uInt64 tmp = rOut; + rOut = m_uint64; + m_uint64 = tmp; +} + +void SAL_CALL OComponent::testinout_methodString(OUString& rOut) throw( RuntimeException ) +{ + OUString tmp = rOut; + rOut = m_string; + m_string = tmp; +} +void SAL_CALL OComponent::testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException) +{ + sal_Unicode tmp = rOut; + rOut = m_char; + m_char = tmp; +} +void SAL_CALL OComponent::testinout_methodAny(Any& rOut) throw( RuntimeException) +{ + Any tmp = rOut; + rOut = m_any; + m_any = tmp; +} +void SAL_CALL OComponent::testinout_methodType(Type& rOut) throw( RuntimeException) +{ + Type tmp = rOut; + rOut = m_type; + m_type = tmp; +} + + +void SAL_CALL OComponent::testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException) +{ + + sal_Int32* arr= rOut.getArray(); + for ( sal_Int32 i=0; i < rOut.getLength(); i++) + { + rOut.getArray()[i] += 1; + } +} +void SAL_CALL OComponent::testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException ) +{ + for( sal_Int32 i=0; i < rOut.getLength(); i++) + { + Sequence< sal_Int32 >& seq= rOut.getArray()[i]; + + for ( sal_Int32 j=0; j < seq.getLength(); j++) + { + seq.getArray()[j] += seq.getArray()[j]; + } + } +} + +// The parameter should implement XInvocation and a Property "value" +void SAL_CALL OComponent::testinout_methodXInterface( Reference< XInvocation >& rOut ) throw(RuntimeException) +{ + Any any; + any= rOut->getValue( OUString( L"value")); + OUString _s; + any >>= _s; + OUString string(L"out"); + any <<= string; + rOut->setValue( OUString(L"value"), any); + + any= rOut->getValue( OUString( L"value")); + any >>= _s; + +} + +void SAL_CALL OComponent::testinout_methodXInterface2( Reference< XInterface > & rOut) throw( RuntimeException) +{ + Reference tmp = rOut; + rOut = m_xinterface; + m_xinterface = tmp; +} +Any SAL_CALL OComponent::methodAnyTest1(const Any& rIn) throw( RuntimeException ) +{ + return rIn; +} +Any SAL_CALL OComponent::getAttrAny2() throw( RuntimeException ) +{ + return m_any; +} +void SAL_CALL OComponent::setAttrAny2(const Any& AttrAny2_) throw( RuntimeException ) +{ + m_any= AttrAny2_; +} + + +// XTestStruct ======================================================================================= + +void SAL_CALL OComponent::methodStruct(const Property& aProp) throw( RuntimeException ) +{ + char buff[1024]; + buff[0]= 0; + sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S", + aProp.Attributes, aProp.Handle, (const sal_Unicode*)aProp.Name); + MessageBox( NULL, A2T(buff), _T("OleTest: methodStruct"), MB_OK); +} + +Property SAL_CALL OComponent::retMethodStruct() throw( RuntimeException ) +{ + Property a(L"OleTest_Property", 255, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID | + PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED | + PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY | + PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT ); + return a; +} + +Property SAL_CALL OComponent::getAttrStruct() throw( RuntimeException) +{ + Property a(L"OleTest_Property", 255, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID | + PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED | + PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY | + PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT ); + return a; + +} + +void SAL_CALL OComponent::setAttrStruct(const Property& AttrStruct_) throw( RuntimeException ) +{ + char buff[1024]; + buff[0]= 0; + sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S", + AttrStruct_.Attributes, AttrStruct_.Handle, (const sal_Unicode*)AttrStruct_.Name); +// MessageBox( NULL, A2T(buff), _T("OleTest: setAttrStruct"), MB_OK); +} + +Property SAL_CALL OComponent::methodStruct2( const Property& aProp ) throw (RuntimeException) +{ + return aProp; +} + +// XTestOther ================================================================================== +void SAL_CALL OComponent::other_methodAnyIn(const Any& ) throw( RuntimeException ) +{ +} +void SAL_CALL OComponent::other_methodAnyOut(Any& rAny) throw( RuntimeException ) +{ + rAny <<= OUString(L"Ein Any"); +} + +Any SAL_CALL OComponent::other_methodAnyRet() throw(RuntimeException ) +{ + Any a; + a <<= OUString(L"Ein Any"); + return a; +} +void SAL_CALL OComponent::in_float( float val) throw ( RuntimeException) +{ + USES_CONVERSION; + char buff[256]; + sprintf( buff, "parameter : %f", val); + MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK); +} +Any SAL_CALL OComponent::other_methodAny( const Any& rAny, const OUString& typeInAny ) + throw (RuntimeException) +{ + Type expectedType; + typelib_TypeDescription * pDesc= NULL; + typelib_typedescription_getByName( &pDesc, typeInAny.pData ); + if( pDesc) + { + expectedType = Type( pDesc->pWeakRef ); + typelib_typedescription_release( pDesc); + } + if (rAny.getValueType() != expectedType) + throw RuntimeException(); + + return rAny; +} + +// XTestInterfaces ------------------------------------------------------------------------------------- +void SAL_CALL OComponent::testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode ) throw(RuntimeException) +{ + USES_CONVERSION; + sal_Int32 i=0; + OUString aString; + char buff[1024]; + + Reference xSimple; + SimpleStruct aSimpleStruct; + SimpleEnum aSimpleEnum; + Sequence seqAny; + Sequence< sal_Int8 > seqByte; + Any outAny; + sal_Bool aBool; + sal_Unicode aChar; + float aFloat; + double aDouble; + sal_Int8 aByte; + sal_Int16 aShort; + sal_Int32 aLong; + + switch( mode) + { + case 1: + xCallback->func1(); break; + case 2: + xSimple= xCallback->returnInterface(); + xSimple->func(L"XCallback::returnInterface"); + break; + + + case 3: + xCallback->outInterface( xSimple); + sprintf( buff, "XCallback::outInterface, value: %x", xSimple.get()); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + xSimple->func(L"XCallback::outInterface works"); + break; + case 4: + xCallback->outStruct( aSimpleStruct); + sprintf( buff,"XCallback::outStruct, SimpleStruct::message: %s", OLE2A( aSimpleStruct.message)); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 5: + xCallback->outEnum( aSimpleEnum); + sprintf( buff,"XCallback::outEnum, SimpleEnum: %d", aSimpleEnum); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 6: + xCallback->outSeqAny( seqAny); + sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength()); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + for( i=0; i < seqAny.getLength(); i++) + { + Any any= seqAny[i]; + if( any.getValueTypeClass() == TypeClass_STRING) + { + any >>= aString; + OutputDebugStringW( aString); + } + + } + break; + case 7: + xCallback->outAny( outAny); + if( outAny.getValueTypeClass() == TypeClass_STRING) + outAny >>= aString; + sprintf( buff,"XCallback::outAny, Any : %s", W2A( aString)); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 8: + xCallback->outBool( aBool); + sprintf( buff,"XCallback::outBool, value: %d", aBool); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 9: + xCallback->outChar( aChar); + sprintf( buff,"XCallback::outChar, value: %C", aChar); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 10: + xCallback->outString( aString); + sprintf( buff,"XCallback::outString, value: %s", W2A( aString)); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 11: + xCallback->outFloat( aFloat); + sprintf( buff,"XCallback::outFloat, value: %f", aFloat); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 12: + xCallback->outDouble( aDouble); + sprintf( buff,"XCallback::outDouble, value: %f", aDouble); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 13: + xCallback->outByte( aByte); + sprintf( buff,"XCallback::outByte, value: %d", aByte); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 14: + xCallback->outShort( aShort); + sprintf( buff,"XCallback::outShort, value: %d", aShort); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 15: + xCallback->outLong( aLong); + sprintf( buff,"XCallback::outLong, value: %d", aLong); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + break; + case 18: + case 19: + case 30: + { + + long outLong= 0; + xCallback->outValuesMixed( 1111, outLong, OUString( L"in string") ); + + sprintf( buff, "oletest.testInterface: outValue: %d", outLong); + MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK); + break; + } + + case 31: + { + Reference< XSimple > xSimple; + SimpleStruct aSimpleStruct; + SimpleEnum aSimpleEnum; + Sequence seqAny; + Any aAny; + sal_Bool aBool; + sal_Unicode aChar; + OUString aString; + float aFloat; + double aDouble; + sal_Int8 aByte; + sal_Int16 aShort; + sal_Int32 aLong; + xCallback->outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool, + aChar, aString, + aFloat, aDouble, + aByte, + aShort, aLong); + + MessageBox( NULL, _T("XCallback::outValuesAll returned"), _T("OleTest::testInterface"), MB_OK); + break; + } + case 32: + { + + xCallback->outSeqByte( seqByte); + sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength()); + MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK); + for( i=0; i < seqAny.getLength(); i++) + { + Any any= seqAny[i]; + if( any.getValueTypeClass() == TypeClass_STRING) + { + any >>= aString; + OutputDebugStringW( aString); + } + } + break; + } + // ############################################################################ + // IN OUT parameter + // ############################################################################ + case 100: + { + Reference xSimple= static_cast(this); + xCallback->inoutInterface( xSimple); + xSimple->func(L"XSimple called from OleTest"); + break; + } + case 101: + { + Reference xRefl( theCoreReflection::get(comphelper::getComponentContext(m_rFactory)) ); + Reference xClass= xRefl->forName(L"oletest.SimpleStruct"); + Any any; + if( xClass.is()) + xClass->createObject( any); + + if( any.getValueTypeClass() == TypeClass_STRUCT) + { + SimpleStruct* pStruct= ( SimpleStruct*) any.getValue(); + pStruct->message= "This struct was created in OleTest"; + + SimpleStruct aStruct; + any >>= aStruct; + xCallback->inoutStruct( aStruct); + // a Struct should now contain a different message + MessageBox( NULL, W2T(aStruct.message), _T("OleTest in out parameter"), MB_OK); + } + + break; + } + case 102: + { + SimpleEnum aEnum= SimpleEnum_B; + xCallback->inoutEnum( aEnum); + char buff[1024]; + sprintf( buff, "Enum: %d", aEnum); + MessageBox( NULL, A2T(buff), _T("OleTest in out parameter"), MB_OK); + break; + } + case 103: + { + Any arAny[3]; + arAny[0] <<= OUString( L"string 0"); + arAny[1] <<= OUString( L"string 1"); + arAny[2] <<= OUString( L"string 2"); + + Sequence< Any >seqAny( arAny, 3); + xCallback->inoutSeqAny( seqAny); + char buff[1023]; + sprintf( buff, "Sequence length: %d", seqAny.getLength()); + MessageBox( NULL,A2T(buff) , _T("OleTest in out parameter"), MB_OK); + + for( int i=0; i < seqAny.getLength(); i++) + { + Any any; + any <<= seqAny[i]; + if(any.getValueTypeClass() == TypeClass_STRING) + { + OUString str; + any >>= str; + + } + } + + break; + } + case 104: + { + Any any; + OUString s(L" OleTest"); + any <<= s; + xCallback->inoutAny(any); + if( any.getValueTypeClass() == TypeClass_STRING) + { + OUString s= *( rtl_uString**) any.getValue(); + MessageBox( NULL, W2T( s), _T("OleTest: inout value any"), MB_OK); + } + break; + } + case 105: + { + sal_Bool b= sal_True; + xCallback->inoutBool( b); + char buff[1024]; + sprintf( buff, "out value bool: %d", b); + MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK); + break; + } + case 106: + { + sal_Unicode uc= L'A'; + xCallback->inoutChar( uc); + char buff[1024]; + sprintf( buff, "out value sal_Unicode: %C", uc); + MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK); + break; + } + case 107: + { + OUString s(L"OleTest"); + xCallback->inoutString( s); + char buff[1024]; + sprintf( buff, "out value string: %S", s.getStr()); + MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK); + break; + } + case 108: + { + float f= 3.14f; + xCallback->inoutFloat(f); + char buff[1024]; + sprintf( buff, "out value float: %f", f); + MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK); + break; + } + case 109: + { + double f= 3.145; + xCallback->inoutDouble( f); + char buff[1024]; + sprintf( buff, "out value double: %g", f); + MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK); + break; + } + case 110: + { + sal_Int8 aByte= 0xf; + xCallback->inoutByte( aByte); + char buff[1024]; + sprintf( buff, "out value sal_Int8: %d", aByte); + MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK); + break; + } + case 111: + { + sal_Int16 aShort= 0xff; + xCallback->inoutShort( aShort); + char buff[1024]; + sprintf( buff, "out value sal_Int16: %d", aShort); + MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK); + break; + } + case 112: + { + sal_Int32 aLong= 0xfffe; + xCallback->inoutLong( aLong); + char buff[1024]; + sprintf( buff, "out value sal_Int32: %d", aLong); + MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK); + break; + } + case 120: + { + Reference aXSimple= static_cast(this); + + SimpleStruct aStruct; + Reference xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY); + if( xRefl.is()) + { + Reference xClass= xRefl->forName(L"oletest.SimpleStruct"); + Any any; + if( xClass.is()) + xClass->createObject( any); + + if( any.getValueTypeClass() == TypeClass_STRUCT) + { + SimpleStruct* pStruct= ( SimpleStruct*) any.getValue(); + pStruct->message= "This struct was created in OleTest"; + any >>= aStruct; + } + } + + SimpleEnum aEnum= SimpleEnum_B; + + Sequence< Any > aSeq; + Any arAny[3]; + arAny[0] <<= OUString( L"string 0"); + arAny[1] <<= OUString( L"string 1"); + arAny[2] <<= OUString( L"string 2"); + aSeq = Sequence< Any >( arAny, 3); + + Any aAny; + OUString s(L" OleTest"); + aAny <<= s; + + sal_Bool aBool= sal_True; + sal_Unicode aChar= L'A'; + OUString aString( L"OleTest"); + float aFloat=3.14f; + double aDouble= 3.145; + sal_Int8 aByte= 0xf; + sal_Int16 aShort= 0xff; + sal_Int32 aLong= 0xffe; + + xCallback->inoutValuesAll( aXSimple, aStruct, aEnum, aSeq, + aAny, aBool, aChar, aString, aFloat, aDouble, + aByte, aShort, aLong ); + + aXSimple->func(L"XSimple called from OleTest"); + MessageBox( NULL, W2T(aStruct.message), _T("OleTest"), MB_OK); + + for( int i=0; i < aSeq.getLength(); i++) + { + Any any; + any <<= aSeq[i]; + if(any.getValueTypeClass() == TypeClass_STRING) + { + OUString str; + any >>= str; + + } + } + break; + } + + // ############################################################################ + // IN parameter + // ############################################################################ + + case 200: + + xCallback->inValues( L'a', 0xffffL, OUString(L" a string from OleTest")); + break; + case 201: + { + sal_Int8 arbyte[3]= { 1,2,3}; + Sequence< sal_Int8 > seq( arbyte, 3); + xCallback->inSeqByte( seq); + break; + } + case 202: + { + const int LISTENERS= 3; + Reference arListeners[LISTENERS]; + EventObject arEvents[LISTENERS]; + + for( int i= 0; i < LISTENERS; i++) + { + Reference aList= static_cast( new EventListener()); + arListeners[i].set( aList, UNO_QUERY); + } + + xCallback->inSeqXEventListener(Sequence > (arListeners, LISTENERS), + Sequence(arEvents, LISTENERS)); + break; + } + + // ############################################################################ + // Call a COM object that has not been passed as parameter to a UNO component and + // hence no type information is available in the COM wrapper + // ############################################################################ + case 300: + { + Reference xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory"); + + Reference oleFact(xIntFact, UNO_QUERY); + + Reference xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback"); + Reference xInv( xIntCallback, UNO_QUERY); + Sequence seqIndices; + Sequence seqOutParams; + xInv->invoke( OUString( L"outValuesAll"), Sequence(), seqIndices, seqOutParams); + + if( seqOutParams.getLength() == 12) + { + Reference xSimple= *(XSimple**)seqOutParams[0].getValue(); + xSimple->func( L"Call from OleTest on XSimple"); + SimpleStruct aStruct; + seqOutParams[1] >>= aStruct; + SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue(); + + Sequence seqAny; + seqOutParams[3] >>= seqAny; + for( int i=0; i>= _s; + } + + Any _any= *(Any*)seqOutParams[4].getValue(); + sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue(); + sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue(); + OUString _str= *( rtl_uString**)seqOutParams[7].getValue(); + + float _f= *( float*)seqOutParams[8].getValue(); + double _d= *( double*) seqOutParams[9].getValue(); + sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue(); + sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue(); + + sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue(); + + } + break; + } + case 301: + // in / out parameter + { + Reference xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory"); + + Reference oleFact(xIntFact, UNO_QUERY); + + Reference xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback"); + Reference xInv( xIntCallback, UNO_QUERY); + Sequence seqIndices; + Sequence seqOutParams; + + + Any arAny[13]; + Reference xSimple= static_cast( this); + + arAny[0] <<= xSimple; + SimpleStruct aStruct; + Reference xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY); + if( xRefl.is()) + { + Reference xClass= xRefl->forName(L"oletest.SimpleStruct"); + Any any; + if( xClass.is()) + xClass->createObject( any); + + if( any.getValueTypeClass() == TypeClass_STRUCT) + { + SimpleStruct* pStruct= ( SimpleStruct*) any.getValue(); + pStruct->message = "This struct was created in OleTest"; + any >>= aStruct; + } + } + arAny[1] <<= aStruct; + arAny[2] <<= SimpleEnum_C; + + Any arSeqAny[3]; + arSeqAny[0] <<= OUString( L"string 0"); + arSeqAny[1] <<= OUString( L"string 1"); + arSeqAny[2] <<= OUString( L"string 2"); + + arAny[3] <<= Sequence< Any >( arAny, 3); + + OUString str(L" Ein Any param"); + arAny[4] <<= str; + arAny[5] <<= sal_False; + arAny[6] <<= L'B'; + OUString stringParam(L" a string parameter"); + arAny[7] <<= stringParam; + float _float= 3.14f; + arAny[8] <<= _float; + double _double= 3.145; + arAny[9] <<= _double; + sal_Int8 _byte= -1; + arAny[10] <<= _byte; + sal_Int16 _short= -1; + arAny[11] <<= _short; + sal_Int32 _long= -1; + arAny[12] <<= _long; + + Sequence params( arAny, 13); + + xInv->invoke( OUString( L"inoutValuesAll"), params, seqIndices, seqOutParams); + + if( seqOutParams.getLength() == 12) + { + Reference xSimple= *(XSimple**)seqOutParams[0].getValue(); + xSimple->func( L"Call from OleTest on XSimple"); + SimpleStruct aStruct; + seqOutParams[1] >>= aStruct; + SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue(); + + Sequence seqAny; + seqOutParams[3] >>= seqAny; + for( int i=0; i>= _s; + } + + Any _any= *(Any*)seqOutParams[4].getValue(); + sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue(); + sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue(); + OUString _str= *( rtl_uString**)seqOutParams[7].getValue(); + + float _f= *( float*)seqOutParams[8].getValue(); + double _d= *( double*) seqOutParams[9].getValue(); + sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue(); + sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue(); + + sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue(); + + } + break; + } + case 303: + { + Reference xIntFact = m_rFactory->createInstance( + L"com.sun.star.bridge.oleautomation.Factory"); + + Reference oleFact(xIntFact, UNO_QUERY); + + Reference xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback"); + Reference xInv( xIntCallback, UNO_QUERY); + Sequence seqIndices; + Sequence seqOutParams; + + Any arAny[3]; + sal_Unicode aChar=L'a'; + arAny[0] <<= aChar; + sal_Int32 aLong= 0xffffffff; + arAny[1] <<= aLong; + OUString aString(L" a string parameter"); + arAny[2] <<= aString; + + xInv->invoke( OUString( L"inValues"), Sequence(arAny,3), seqIndices, seqOutParams); + + break; + } + // ############################################################################ + // Attributes + // ############################################################################ + + case 400: + Reference simple= xCallback->getsimple(); + simple->func(L"OleTest calls on XSimple"); + break; + + + } + +} + +void SAL_CALL OComponent::setObject( const Reference< XInterface >& val ) throw (RuntimeException) +{ + m_xIntIdentity= val; +} + +sal_Bool SAL_CALL OComponent::isSame( const Reference< XInterface >& val ) throw (RuntimeException) +{ + if( m_xIntIdentity == val) + return sal_True; + else + return sal_False; +} + +Reference< XInterface > SAL_CALL OComponent::getThis( ) throw (RuntimeException) +{ + Reference ret(static_cast(this), UNO_QUERY); + return ret; +} + +void SAL_CALL EventListener::disposing( const css::lang::EventObject& ) throw (RuntimeException) +{ + bCalled= sal_True; +} + +// XSimple -------------------------------------------------------------------------- +void SAL_CALL OComponent::func( const OUString &message)throw(css::uno::RuntimeException) +{ + USES_CONVERSION; + + MessageBox( NULL, W2T( message.getStr()), _T("OleTest: XSimple::func"), MB_OK); +} +// XSimple -------------------------------------------------------------------------- +OUString SAL_CALL OComponent::getName()throw(css::uno::RuntimeException) +{ + return L"XSimple"; +} +void SAL_CALL OComponent::testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode ) throw(RuntimeException) +{ + switch( mode) + { + case 0: + { + xSimple->func( L"OleTest is calling XSimple"); + Reference xSimple2( xSimple, UNO_QUERY); + if( xSimple2.is()) + xSimple2->func2( L"OleTest is calling XSimple2"); + Reference xSimple3( xSimple, UNO_QUERY); + if( xSimple3.is()) + xSimple3->func3( L"OleTest is calling XSimple3"); + + break; + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/cpnt/exports.dxp b/extensions/test/ole/cpnt/exports.dxp new file mode 100644 index 000000000..51703a046 --- /dev/null +++ b/extensions/test/ole/cpnt/exports.dxp @@ -0,0 +1,2 @@ +component_writeInfo +component_getFactory diff --git a/extensions/test/ole/cpnt/makefile.mk b/extensions/test/ole/cpnt/makefile.mk new file mode 100644 index 000000000..ad9d07bac --- /dev/null +++ b/extensions/test/ole/cpnt/makefile.mk @@ -0,0 +1,66 @@ +# +# 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= extensions +TARGET= oletest +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +INCPRE+= -I$(ATL_INCLUDE) + +SLOFILES= \ + $(SLO)$/cpnt.obj + +SHL1TARGET= $(TARGET) + +SHL1STDLIBS= \ + $(SALLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +ALLTAR : $(MISC)$/$(TARGET).cppumaker.done + + +.INCLUDE : target.mk + +ALLIDLFILES:= ..$/idl$/oletest.idl + +$(BIN)$/oletest.rdb: $(ALLIDLFILES) + idlc -I$(PRJ) -I$(SOLARIDLDIR) -O$(BIN) $? + regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)} + touch $@ + +$(MISC)$/$(TARGET).cppumaker.done: $(BIN)$/oletest.rdb + $(CPPUMAKER) -O$(INCCOM) -BUCR $< -X$(SOLARBINDIR)/types.rdb + $(TOUCH) $@ + diff --git a/extensions/test/ole/cpnt/readme.txt b/extensions/test/ole/cpnt/readme.txt new file mode 100644 index 000000000..ccac8066a --- /dev/null +++ b/extensions/test/ole/cpnt/readme.txt @@ -0,0 +1,21 @@ +cpnt.cxx contains a UNO component that is uses to test the olebridge within a +JavaScript context. In particular it has functions using out, in/out and +sequence parameter that have to be specifically treated in JScript because they +are represented by IDispatch objects. Other clients, such as VBScript, VB and +C++ applications can also use this component for testing. +The service name is oletest.OleTest. +The uno types are also build in this folder. The idl file is in ..\idl. The +types rdb is in wntmscixx.pro\bin\oletest.rdb + +The service is used by: +OleTest.htm +JScriptNewStyle.htm +ScriptTest.html + + +Prerequisites: + +The oletest.dll must be registered, for example in the services.rdb, using +regcomp. Then the uno types contained in oletest.rdb (wntmscixx/bin) must be merged +for example in the offapi.rdb. This is done with regmerge. + diff --git a/extensions/test/ole/cppToUno/makefile.mk b/extensions/test/ole/cppToUno/makefile.mk new file mode 100644 index 000000000..e40aa94f3 --- /dev/null +++ b/extensions/test/ole/cppToUno/makefile.mk @@ -0,0 +1,56 @@ +# +# 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=extensions +TARGET=testcppuno +TARGETTYPE=CUI +LIBTARGET=NO + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings --- + +.INCLUDE : settings.mk + +# --- Files --- + +INCPRE+=-I$(ATL_INCLUDE) + + + +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJ)$/testcppuno.obj + +APP1STDLIBS= \ + $(SALLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(USER32LIB) \ + $(KERNEL32LIB) \ + $(OLE32LIB) \ + $(OLEAUT32LIB) \ + $(UUIDLIB) \ + $(COMDLG32LIB) \ + $(GDI32LIB) + +APP1DEF= $(MISC)$/$(APP1TARGET).def + +# --- Targets --- +.INCLUDE : target.mk diff --git a/extensions/test/ole/cppToUno/readme.txt b/extensions/test/ole/cppToUno/readme.txt new file mode 100644 index 000000000..ae0189818 --- /dev/null +++ b/extensions/test/ole/cppToUno/readme.txt @@ -0,0 +1,8 @@ +testcppuno.exe currently tests the conversion of SAFEARRAYs. There is +no output from the program. Just step through the code. + +To run the test, the service oletest.OleTest ( extensions/test/ole/cpnt) +must be in the same directory as the office dlls and it must be registered +at the applicat.rdb. Also the type information must have been merged with +applicat.rdb. The program requires an office to be present. Put testcppuno +into the Office/program folder and run it there. diff --git a/extensions/test/ole/cppToUno/testcppuno.cxx b/extensions/test/ole/cppToUno/testcppuno.cxx new file mode 100644 index 000000000..e64541ed2 --- /dev/null +++ b/extensions/test/ole/cppToUno/testcppuno.cxx @@ -0,0 +1,206 @@ +/* -*- 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 . + */ + + +#pragma warning(disable: 4917) +#if !defined WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +using namespace com::sun::star::lang; +using namespace com::sun::star::uno; +using namespace com::sun::star::bridge; +using namespace com::sun::star::bridge::ModelDependent; +using namespace cppu; + +HRESULT doTest(); +bool incrementMultidimensionalIndex( + sal_Int32 dimensions, + const sal_Int32 * parDimensionLengths, + sal_Int32 * parMultidimensionalIndex); + +int SAL_CALL main( int /*argc*/, char** /*argv*/ ) +{ + HRESULT hr; + if( FAILED( hr=CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) + { + printf("CoInitializeEx failed \n"); + return -1; + } + + + if( FAILED(hr=doTest())) + { + _com_error err( hr); + const CHAR * errMsg= err.ErrorMessage(); + MessageBoxA( NULL, errMsg, "Test failed", MB_ICONERROR); + } + + CoUninitialize(); + return 0; +} + + +HRESULT doTest() +{ + HRESULT hr= S_OK; + long j = 0; + SAFEARRAY* par; + CComDispatchDriver disp; + CComVariant result; + CComVariant param1; + CComPtr spUnkFactory; + if( SUCCEEDED( spUnkFactory.CoCreateInstance(L"com.sun.star.ServiceManager"))) + { + disp= spUnkFactory; + param1= L"oletest.OleTest"; + disp.Invoke1( L"createInstance", ¶m1, &result); + + disp= result.pdispVal; + + // disp contains now oletest.OleTest + + // one dimensional array + par= SafeArrayCreateVector( VT_UI1, 0, 5); + unsigned char arbyte[]= { 1,2,3,4,5}; + for(long i= 0; i < 5;i++) + hr= SafeArrayPutElement( par, &i, &arbyte[i]); + + result.Clear(); + param1.vt= VT_ARRAY| VT_UI1; + param1.byref= par; + disp.Invoke1(L"methodByte", ¶m1, &result); + SafeArrayDestroy( par); + + + // two dimensional array + SAFEARRAYBOUND bounds[2]; + // least significant dimension first, Dimension 1 + bounds[0].cElements= 3; + bounds[0].lLbound= 0; + // Dimension 2 + bounds[1].cElements= 2; + bounds[1].lLbound= 0; + par= SafeArrayCreate( VT_I4, 2, bounds ); + + long uBound1; + long uBound2; + hr= SafeArrayGetUBound( par, 1, &uBound1); + hr= SafeArrayGetUBound( par, 2, &uBound2); + + long index2[2]; + memset( index2, 0, 2 * sizeof( long) ); + long dimLengths[]={3,2}; + + long data; + do + { + data= index2[1] * 3 + index2[0] +1; + hr= SafeArrayPutElement( par, index2, &data); + }while( incrementMultidimensionalIndex( 2, dimLengths, index2) ); + + long* pdata; + long (*dataL)[2][3]; + hr= SafeArrayAccessData( par, (void**)&pdata); + dataL= (long(*)[2][3])pdata; + + for (long i= 0; i < 2; i ++) + { + for(long j= 0; j < 3; j++) + data= (*dataL)[i][j]; + } + hr= SafeArrayUnaccessData(par); + + result.Clear(); + param1.vt= VT_ARRAY | VT_I4; + param1.byref= par; + disp.Invoke1(L"methodSequence", ¶m1, &result); + + SAFEARRAY* arRet= result.parray; + + for(long i= 0; i < 2 ; i++) + { + CComVariant varx; + varx.Clear(); + hr= SafeArrayGetElement( arRet, &i, &varx); + SAFEARRAY* ari= varx.parray; + + for( j= 0; j < 3; j++) + { + CComVariant varj; + varj.Clear(); + hr= SafeArrayGetElement( ari, &j, &varj); + } + + + } + SafeArrayDestroy( par); + } + + return hr; +} + +// left index is least significant +bool incrementMultidimensionalIndex( + sal_Int32 dimensions, + const sal_Int32 * parDimensionLengths, + sal_Int32 * parMultidimensionalIndex) +{ + if( dimensions < 1) + return sal_False; + + bool ret= sal_True; + bool carry= sal_True; // to get into the while loop + + sal_Int32 currentDimension= 0; //most significant is 1 + while( carry) + { + parMultidimensionalIndex[ currentDimension ]++; + // if carryover, set index to 0 and handle carry on a level above + if( parMultidimensionalIndex[ currentDimension] > (parDimensionLengths[ currentDimension] - 1)) + parMultidimensionalIndex[ currentDimension]= 0; + else + carry= sal_False; + + currentDimension ++; + // if dimensions drops below 1 and carry is set than then all indices are 0 again + // this is signalled by returning sal_False + if( currentDimension > dimensions - 1 && carry) + { + carry= sal_False; + ret= sal_False; + } + } + return ret; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/cpptest/cpptest.cxx b/extensions/test/ole/cpptest/cpptest.cxx new file mode 100644 index 000000000..ff083a052 --- /dev/null +++ b/extensions/test/ole/cpptest/cpptest.cxx @@ -0,0 +1,101 @@ +/* -*- 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 . + */ + +// cpptest.cpp : Defines the entry point for the console application. + +#ifdef _MSC_VER +#pragma once +#endif +#pragma warning(disable : 4917) +#include +#include +#include + +HRESULT doTest(); + +int main(int /*argc*/, char** /*argv*/) +{ + HRESULT hr; + if (FAILED(hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) + { + printf("CoInitializeEx failed \n"); + return -1; + } + + if (FAILED(hr = doTest())) + { + _com_error err(hr); + const CHAR* errMsg = err.ErrorMessage(); + MessageBoxA(NULL, errMsg, "Test failed", MB_ICONERROR); + } + + CoUninitialize(); + return 0; +} + +HRESULT doTest() +{ + HRESULT hr; + CComPtr spUnkMgr; + + if (FAILED(hr = spUnkMgr.CoCreateInstance(L"com.sun.star.ServiceManager"))) + return hr; + + IDispatchPtr starManager; + // var starManager=new ActiveXObject("com.sun.star.ServiceManager"); + if (FAILED(hr = starManager.CreateInstance(_T("com.sun.star.ServiceManager")))) + { + fprintf(stderr, "creating ServiceManager failed\n"); + return hr; + } + // var starDesktop=starManager.createInstance("com.sun.star.frame.Desktop"); + _variant_t varP1(L"com.sun.star.frame.Desktop"); + _variant_t varRet; + CComDispatchDriver dispMgr(starManager); + if (FAILED(hr = dispMgr.Invoke1(L"createInstance", &varP1, &varRet))) + { + fprintf(stderr, "createInstance of Desktop failed\n"); + return hr; + } + CComDispatchDriver dispDesk(varRet.pdispVal); + varP1.Clear(); + varRet.Clear(); + // var bOK=new Boolean(true); + + // var noArgs=new Array(); + // var oDoc=starDesktop.loadComponentFromURL("private:factory/swriter", "Test", 40, noArgs); + IDispatchPtr oDoc; + SAFEARRAY* ar = SafeArrayCreateVector(VT_DISPATCH, 0, 0); + _variant_t args[4]; + args[3] = _variant_t(L"private:factory/swriter"); + args[2] = _variant_t(L"Test"); + args[1] = _variant_t((long)40); + args[0].vt = VT_ARRAY | VT_DISPATCH; + args[0].parray = ar; + if (FAILED(hr = dispDesk.InvokeN(L"loadComponentFromURL", args, 4, &varRet))) + { + fprintf(stderr, "loadComponentFromURL failed\n"); + return hr; + } + CComDispatchDriver dispDoc(varRet.pdispVal); + varRet.Clear(); + return S_OK; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/cpptest/makefile.mk b/extensions/test/ole/cpptest/makefile.mk new file mode 100644 index 000000000..984701c15 --- /dev/null +++ b/extensions/test/ole/cpptest/makefile.mk @@ -0,0 +1,55 @@ +# +# 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=extensions +TARGET=cppTest +TARGETTYPE=CUI +LIBTARGET=NO + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings --- + +.INCLUDE : settings.mk + +# --- Files --- + +INCPRE+=-I$(ATL_INCLUDE) + + +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJ)$/cppTest.obj + +APP1STDLIBS= \ + $(SALLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(USER32LIB) \ + $(KERNEL32LIB) \ + $(OLE32LIB) \ + $(OLEAUT32LIB) \ + $(UUIDLIB) \ + $(COMDLG32LIB) \ + comsupp.lib + +APP1DEF= $(MISC)\$(APP1TARGET).def + +# --- Targets --- +.INCLUDE : target.mk diff --git a/extensions/test/ole/cpptest/readme.txt b/extensions/test/ole/cpptest/readme.txt new file mode 100644 index 000000000..0fd339280 --- /dev/null +++ b/extensions/test/ole/cpptest/readme.txt @@ -0,0 +1,4 @@ +Creates the com.sun.star.ServiceManager with CoCreateInstance in a cpp program. +This little program can be used as starting point for further tests. + +It needs uwinapi.dll, which is in the program folder of OOo (URE\bin in OOo 3.0) diff --git a/extensions/test/ole/idl/oletest.idl b/extensions/test/ole/idl/oletest.idl new file mode 100644 index 000000000..b23f20b21 --- /dev/null +++ b/extensions/test/ole/idl/oletest.idl @@ -0,0 +1,301 @@ +/* -*- 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 +#include +#include +#include + + +module oletest +{ + +interface XTestSequence: com::sun::star::uno::XInterface +{ + sequence methodByte( [in] sequence aSeq ); + sequence methodFloat( [in] sequence aSeq); + sequence methodDouble( [in] sequence aSeq); + sequence methodBool( [in] sequence aSeq); + sequence methodShort( [in] sequence aSeq); + sequence methodUShort( [in] sequence aSeq); + sequence methodLong( [in] sequence aSeq); + sequence methodULong( [in] sequence aSeq); + sequence methodString( [in] sequence aSeq); + sequence methodChar( [in] sequence aSeq); + sequence methodAny ( [in] sequence aSeq); + sequence methodType ( [in] sequence aSeq); + sequence methodXInterface ( [in] sequence aSeq); + sequence< sequence > methodSequence( [in] sequence< sequence< long > > aSeq); + sequence< sequence > > methodSequence2( [in] sequence< sequence< sequence > > aSeq); + sequence< com::sun::star::lang::XEventListener > methodXEventListeners( [in] sequence aSeq); + sequence< sequence< com::sun::star::lang::XEventListener > > methodXEventListenersMul( [in] sequence< sequence< com::sun::star::lang::XEventListener> > aSeq); + + [attribute] sequence AttrByte; + [attribute] sequence AttrFloat; + [attribute] sequence AttrDouble; + [attribute] sequence AttrBool; + [attribute] sequence AttrShort; + [attribute] sequence AttrUShort; + [attribute] sequence AttrLong; + [attribute] sequence AttrULong; + [attribute] sequence AttrString; + [attribute] sequence AttrChar; + [attribute] sequence AttrAny; + [attribute] sequence AttrType; + [attribute] sequence< sequence > AttrSequence; + [attribute] sequence< sequence< sequence > > AttrSequence2; + [attribute] sequence< com::sun::star::uno::XInterface > AttrXInterface; + + [attribute] byte AByte; + [attribute] float AFloat; + [attribute] double ADouble; + [attribute] boolean ABool; + [attribute] short AShort; + [attribute] unsigned short AUShort; + [attribute] long ALong; + [attribute] unsigned long AULong; + [attribute] string AString; + [attribute] char AChar; + [attribute] any AAny; + [attribute] type AType; + [attribute] com::sun::star::uno::XInterface AXInterface; + [attribute] com::sun::star::script::XInvocation AXInvocation; + + void testout_methodByte( [out] byte rOut ); + void testout_methodFloat( [out] float rOut); + void testout_methodDouble( [out] double rOut); + void testout_methodBool( [out] boolean rOut); + void testout_methodShort( [out] short rOut); + void testout_methodUShort( [out] unsigned short rOut); + void testout_methodLong( [out] long rOut); + void testout_methodULong( [out] unsigned long rOut); + void testout_methodHyper( [out] hyper rOut); + void testout_methodUHyper( [out] unsigned hyper rOut); + void testout_methodString( [out] string rOut); + void testout_methodChar( [out] char rOut); + void testout_methodAny ( [out] any rOut); + void testout_methodType ( [out] type rOut); + void testout_methodSequence( [out] sequence< long > rOut); + void testout_methodSequence2( [out] sequence < sequence< long > > rOut); + void testout_methodXInterface( [out] com::sun::star::uno::XInterface rOut); + + void testout_methodMulParams1( [out] long rout1, [out] long rout2); + void testout_methodMulParams2( [out] long rout1, [out] long rout2, [out] string rout3); + void testout_methodMulParams3( [in] string sin, [out] string sout); + void testout_methodMulParams4( [in] float in1, [out] float out1, [in] long in2, [out] long out2, [in] long in3); + + void testinout_methodByte( [inout] byte rOut ); + void testinout_methodFloat( [inout] float rOut); + void testinout_methodDouble( [inout] double rOut); + void testinout_methodBool( [inout] boolean rOut); + void testinout_methodShort( [inout] short rOut); + void testinout_methodUShort( [inout] unsigned short rOut); + void testinout_methodLong( [inout] long rOut); + void testinout_methodULong( [inout] unsigned long rOut); + void testinout_methodHyper( [inout] hyper rOut); + void testinout_methodUHyper( [inout] unsigned hyper rOut); + void testinout_methodString( [inout] string rOut); + void testinout_methodChar( [inout] char rOut); + void testinout_methodAny ( [inout] any rOut); + void testinout_methodType ( [inout] type rOut); + void testinout_methodSequence( [inout] sequence< long > rOut); + void testinout_methodSequence2( [inout] sequence < sequence< long > > rOut); + void testinout_methodXInterface( [inout] com::sun::star::script::XInvocation rOut); + void testinout_methodXInterface2( [inout] com::sun::star::uno::XInterface rOut); + + any methodAnyTest1( [in] any rIn); + [attribute] any AttrAny2; + +}; +interface XTestStruct: com::sun::star::uno::XInterface +{ +// Method taking structs as arguments + void methodStruct( [in] com::sun::star::beans::Property aProp); +// Methods returning structs + com::sun::star::beans::Property retMethodStruct(); +// Attributes as structs + [attribute] com::sun::star::beans::Property AttrStruct; + + com::sun::star::beans::Property methodStruct2( [in] com::sun::star::beans::Property aProp); +}; + + +struct SimpleStruct +{ + string message; +}; + +interface XTestInParameters: com::sun::star::uno::XInterface +{ + byte in_methodByte( [in] byte rIn ); + float in_methodFloat( [in] float rIn); + double in_methodDouble( [in] double rIn); + boolean in_methodBool( [in] boolean rIn); + short in_methodShort( [in] short rIn); + unsigned short in_methodUShort( [in] unsigned short rIn); + long in_methodLong( [in] long rIn); + unsigned long in_methodULong( [in] unsigned long rIn); + hyper in_methodHyper( [in] hyper rIn); + unsigned hyper in_methodUHyper( [in] unsigned hyper rIn); + string in_methodString( [in] string rIn); + char in_methodChar( [in] char rIn); + any in_methodAny ( [in] any rIn); + type in_methodType ( [in] type rIn); + com::sun::star::uno::XInterface in_methodXInterface([in] com::sun::star::uno::XInterface rIn); + com::sun::star::script::XInvocation in_methodInvocation( [in] com::sun::star::script::XInvocation inv); + SimpleStruct in_methodStruct( [in] SimpleStruct aStruct); + void in_methodAll( [in] byte b, [in] float f, [in] double d, [in] boolean abool, [in]short sh, + [in] unsigned short us, [in] long l, [in] unsigned long ul, + [in] string s, [in] char c, [in] any a, [in] type t, [in] com::sun::star::script::XInvocation inv); +}; + + +enum SimpleEnum +{ + A, + B, + C +}; + +interface XTestOther: com::sun::star::uno::XInterface +{ + // Any test + void other_methodAnyIn( [in] any rAny); + void other_methodAnyOut( [out] any rAny); + any other_methodAnyRet(); + void in_float( [in] float val); + //typeInAny determines what type must be in rAny. If rAny contains + //a different type then an exception is being thrown + any other_methodAny([in] any rAny, [in] string typeInAny); +}; + + +interface XSimple: com::sun::star::uno::XInterface +{ + void func( [in] string message); + string getName(); +}; + +interface XSimple2: com::sun::star::uno::XInterface +{ + void func2( [in] string message); + string getName2(); +}; + +interface XSimple3: com::sun::star::uno::XInterface +{ + void func3( [in] string message); + string getName3(); +}; + + +interface XCallback: com::sun::star::uno::XInterface +{ + void func1(); + oletest::XSimple returnInterface(); + void outInterface( [out] oletest::XSimple outInterface); + void outStruct( [out] oletest::SimpleStruct outStruct); + void outEnum( [out] oletest::SimpleEnum outEnum); + void outSeqAny( [out] sequence outSeqAny); + void outSeqByte( [out] sequence outVal); + void outAny( [out] any outAny); + void outBool( [out] boolean outBool); + void outChar( [out] char outChar); + void outString( [out] string outString); + void outFloat( [out] float outFloat); + void outDouble( [out] double outDouble); + void outByte( [out] byte outByte); + void outShort( [out] short outShort); + void outLong( [out] long outLong); + void outValuesMixed( [in] long lval, [out] long outval, [in] string sval); + void outValuesAll( [out] oletest::XSimple outInterface, + [out] SimpleStruct outStruct , + [out] SimpleEnum outEnum, + [out] sequence outSeqAny, + [out] any outAny, + [out] boolean outBool, + [out] char outChar, + [out] string outString, + [out] float outFloat, + [out] double outDouble, + [out] byte outByte, + [out] short outShort, + [out] long outLong); +// IN OUT parameters + void inoutInterface( [inout] oletest::XSimple inoutVal); + void inoutStruct( [inout] oletest::SimpleStruct inoutVal); + void inoutEnum( [inout] oletest::SimpleEnum inoutVal); + void inoutSeqAny( [inout] sequence inoutVal); + void inoutAny( [inout] any inoutVal); + void inoutBool( [inout] boolean inoutVal); + void inoutChar( [inout] char inoutVal); + void inoutString( [inout] string inoutVal); + void inoutFloat( [inout] float inoutVal); + void inoutDouble( [inout] double inoutVal); + void inoutByte( [inout] byte inoutVal); + void inoutShort( [inout] short inoutVal); + void inoutLong( [inout] long inoutVal); + + void inoutValuesAll( [inout] oletest::XSimple aXSimple, + [inout] oletest::SimpleStruct aStruct, + [inout] oletest::SimpleEnum aEnum, + [inout] sequence aSeq, + [inout] any aAny, + [inout] boolean aBool, + [inout] char aChar, + [inout] string aString, + [inout] float aFloat, + [inout] double aDouble, + [inout] byte aByte, + [inout] short aShort, + [inout] long aLong); + + // IN parameter + + void inValues( [in] char aChar, [in] long aLong, [in] string aString); + void inSeqByte( [in] sequence val); + void inSeqXEventListener( [in] sequence listener, [in] + sequence events); + + // Attributes + [attribute] oletest::XSimple simple; + + + + +}; + +interface XTestInterfaces: com::sun::star::uno::XInterface +{ + // Any test + void testInterface( [in] oletest::XCallback xCallback, [in] long mode); + void testInterface2( [in] oletest::XSimple xSimple, [in] long mode); +}; + +interface XIdentity: com::sun::star::uno::XInterface +{ + void setObject([in] com::sun::star::uno::XInterface val); + boolean isSame( [in] com::sun::star::uno::XInterface val); + + com::sun::star::uno::XInterface getThis(); +}; + +}; // oletest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unloading/makefile.mk b/extensions/test/ole/unloading/makefile.mk new file mode 100644 index 000000000..53c0b3d89 --- /dev/null +++ b/extensions/test/ole/unloading/makefile.mk @@ -0,0 +1,61 @@ +# +# 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= extensions +TARGET= unloadtest +TARGETTYPE=CUI +COMP1TYPELIST=$(TARGET1) + +ENABLE_EXCEPTIONS=TRUE + +USE_DEFFILE= TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# ------------------------------------------------------------------ + +APP1NOSAL=TRUE + +APP1TARGET= $(TARGET) + +APP1OBJS= $(OBJ)$/unloadTest.obj + +APP1STDLIBS= \ + $(SALLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) + +# all: \ +# $(BINDIR) \ +# $(BINDIR)$/test.ini \ +# ALLTAR + +# $(BINDIR) : +# @@-$(MKDIR) $(BINDIR) + +# $(BINDIR)$/test.ini : .$/unloadtest.ini +# -$(GNUCOPY) .$/unloadtest.ini $(BINDIR) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + diff --git a/extensions/test/ole/unloading/readme.txt b/extensions/test/ole/unloading/readme.txt new file mode 100644 index 000000000..d8b467ddf --- /dev/null +++ b/extensions/test/ole/unloading/readme.txt @@ -0,0 +1,6 @@ +This project builds a unloadtest.exe. + +Function: Tests if the unloading mechanism works with the olebrdg.dll. +In several tests, all services are created and destroyed and rtl_unloadUnusedModules is called. + +Usage: copy into the \program directory and run there. diff --git a/extensions/test/ole/unloading/unloadTest.cxx b/extensions/test/ole/unloading/unloadTest.cxx new file mode 100644 index 000000000..b6825fad2 --- /dev/null +++ b/extensions/test/ole/unloading/unloadTest.cxx @@ -0,0 +1,199 @@ +/* -*- 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace ::osl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::cppu; +using namespace ::com::sun::star::registry; + + +sal_Bool test1(); +sal_Bool test2(); +sal_Bool test3(); +sal_Bool test4(); + +int main(int, char**) +{ + sal_Bool bTest1= test1(); + sal_Bool bTest2= test2(); + sal_Bool bTest3= test3(); + sal_Bool bTest4= test4(); + + if( bTest1 && bTest2 && bTest3 && bTest4) + printf("\n#########################\n Test was successful\n#######################\n"); + + return 0; +} + +sal_Bool test1() +{ + printf("\n Test1: com.sun.star.bridge.oleautomation.BridgeSupplier\n"); + Reference xreg= createSimpleRegistry(); + xreg->open( OUString("services.rdb"), + sal_False, sal_False ); + + Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg); + Reference fac= context->getServiceManager(); + OUString sService1("com.sun.star.bridge.oleautomation.BridgeSupplier"); + Reference xint1= fac->createInstanceWithContext( sService1, context); + + OUString sModule("oleautobridge.uno" SAL_DLLEXTENSION); + oslModule hMod= osl_loadModule( sModule.pData, 0); + osl_unloadModule( hMod); + + rtl_unloadUnusedModules( NULL); + + OUString sFactoryFunc("component_getFactory"); + void* pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData); + // true, instance alive + sal_Bool bTest1= pSymbol ? sal_True : sal_False; + + xint1=0; + rtl_unloadUnusedModules( NULL); + pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData); + sal_Bool bTest2= pSymbol ? sal_False : sal_True; + + Reference xcomp( context, UNO_QUERY); + xcomp->dispose(); + + return bTest2 && bTest1; +} + +sal_Bool test2() +{ + printf("Test2: com.sun.star.bridge.OleBridgeSupplierVar1\n"); + Reference xreg= createSimpleRegistry(); + xreg->open( OUString("services.rdb"), + sal_False, sal_False ); + + Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg); + Reference fac= context->getServiceManager(); + OUString sService2("com.sun.star.bridge.OleBridgeSupplierVar1"); + Reference xint= fac->createInstanceWithContext( sService2, context); + + OUString sModule("oleautobridge.uno" SAL_DLLEXTENSION); + oslModule hMod= osl_loadModule( sModule.pData, 0); + osl_unloadModule( hMod); + + rtl_unloadUnusedModules( NULL); + OUString sFactoryFunc("component_getFactory"); + void* pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData); + // true, instance alive + sal_Bool bTest1= pSymbol ? sal_True : sal_False; + + xint=0; + rtl_unloadUnusedModules( NULL); + pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData); + sal_Bool bTest2= pSymbol ? sal_False : sal_True; + + Reference xcomp( context, UNO_QUERY); + xcomp->dispose(); + return bTest1 && bTest2; +} + +sal_Bool test3() +{ + printf("Test3: com.sun.star.bridge.oleautomation.Factory\n"); + Reference xreg= createSimpleRegistry(); + xreg->open( OUString("services.rdb"), + sal_False, sal_False ); + + Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg); + + Reference fac= context->getServiceManager(); + OUString sService("com.sun.star.bridge.oleautomation.Factory"); + Reference xint= fac->createInstanceWithContext( sService, context); + + + OUString sModule("oleautobridge.uno" SAL_DLLEXTENSION); + oslModule hMod= osl_loadModule( sModule.pData, 0); + osl_unloadModule( hMod); + + rtl_unloadUnusedModules( NULL); + OUString sFactoryFunc("component_getFactory"); + void* pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData); + // true, instance alive + sal_Bool bTest1= pSymbol ? sal_True : sal_False; + + xint=0; + rtl_unloadUnusedModules( NULL); + pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData); + sal_Bool bTest2= pSymbol ? sal_False : sal_True; + + Reference xcomp( context, UNO_QUERY); + xcomp->dispose(); + + return bTest1 && bTest2; +} + +sal_Bool test4() +{ + void* pSymbol= NULL; + sal_Bool bTest1= sal_False; + sal_Bool bTest2= sal_False; + oslModule hMod= NULL; + OUString sModule("oleautobridge.uno" SAL_DLLEXTENSION); + OUString sFactoryFunc("component_getFactory"); + { + printf("Test4: com.sun.star.bridge.oleautomation.ApplicationRegistration\n"); + Reference xreg= createSimpleRegistry(); + xreg->open( OUString("services.rdb"), + sal_False, sal_False ); + + Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg); + Reference fac= context->getServiceManager(); + OUString sService4("com.sun.star.bridge.oleautomation.ApplicationRegistration"); + Reference xint= fac->createInstanceWithContext( sService4, context); + + hMod= osl_loadModule( sModule.pData, 0); + osl_unloadModule( hMod); + + rtl_unloadUnusedModules( NULL); + void* pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData); + // true, instance alive + bTest1= pSymbol ? sal_True : sal_False; + // ApplicationRegistration is a one-instance-service, therefore kill service manager first + Reference xcomp( context, UNO_QUERY); + xcomp->dispose(); + + } + rtl_unloadUnusedModules( NULL); + pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData); + bTest2= pSymbol ? sal_False : sal_True; + + return bTest1 && bTest2; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp b/extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp new file mode 100644 index 000000000..fcefb8f0c --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp @@ -0,0 +1,28 @@ +/* -*- 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 . + */ +// stdafx.cpp : source file that includes just the standard includes +// Test.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/Test/StdAfx.h b/extensions/test/ole/unoTocomCalls/Test/StdAfx.h new file mode 100644 index 000000000..0274335ce --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/Test/StdAfx.h @@ -0,0 +1,47 @@ +/* -*- 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 . + */ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently + +#if !defined(AFX_STDAFX_H__180FF568_6F5C_11D4_8330_005004526AB4__INCLUDED_) +#define AFX_STDAFX_H__180FF568_6F5C_11D4_8330_005004526AB4__INCLUDED_ + +#ifdef _MSC_VER +#pragma once +#endif + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include +#include +#include +#include +extern CComModule _Module; +#include +#include + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__180FF568_6F5C_11D4_8330_005004526AB4__INCLUDED_) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/Test/Test.cpp b/extensions/test/ole/unoTocomCalls/Test/Test.cpp new file mode 100644 index 000000000..b10900dbc --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/Test/Test.cpp @@ -0,0 +1,240 @@ +/* -*- 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 . + */ +// Test.cpp : Defines the entry point for the console application. + + +#include "stdafx.h" +#include "../XCallback_Impl/XCallback_Impl.h" +#include "../XCallback_Impl/XCallback_Impl_i.c" + +CComModule _Module; +BEGIN_OBJECT_MAP(ObjectMap) +END_OBJECT_MAP() + +HRESULT doTest(); + +int main(int argc, char* argv[]) +{ + HRESULT hr; + if( FAILED( hr=CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) + { + _tprintf(_T("CoInitializeEx failed \n")); + return -1; + } + + + _Module.Init( ObjectMap, GetModuleHandle( NULL)); + + if( FAILED(hr=doTest())) + { + _com_error err( hr); + const TCHAR * errMsg= err.ErrorMessage(); + MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR); + } + + + _Module.Term(); + CoUninitialize(); + + + return 0; +} + + +HRESULT doTest() +{ + HRESULT hr= S_OK; + + CComPtr spUnk; + hr= spUnk.CoCreateInstance(L"com.sun.star.ServiceManager"); + if( FAILED( hr)) + return hr; + + CComDispatchDriver manager( spUnk); + CComVariant param( L"oletest.OleTest"); + CComVariant retVal; + hr= manager.Invoke1((LPCOLESTR)L"createInstance", ¶m, &retVal ); + + CComDispatchDriver oletest( retVal.punkVal); + + spUnk.Release(); + + hr= spUnk.CoCreateInstance(L"XCallback_Impl.Callback"); + if( FAILED( hr)) + return hr; + + CComQIPtr paramDisp(spUnk); + + + + // out parameters + + CComVariant param1( paramDisp); + CComVariant param2(1); + + // oletest calls XCallback::func1 + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::returnInterface + param2= 2; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outInterface + param2= 3; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outStruct + param2= 4; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outEnum + param2= 5; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outSeqAny + param2= 6; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outAny + param2= 7; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outBool + param2= 8; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outChar + param2= 9; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outString + param2= 10; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outFloat + param2= 11; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outDouble + param2= 12; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outByte + param2= 13; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outShort + param2= 14; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outLong + param2= 15; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outValuesMixed + param2= 30; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::outValuesAll + param2= 31; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + + // XCallback::outSeqByte + // Does not work currently because Sequences are always converted to + // SAFEARRAY( VARIANT) + // param2= 32; + // hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + + + // in / out parameters + + // XCallback::inoutInterface + param2= 100; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutStruct + param2= 101; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutEnum + param2= 102; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutSeqAny + param2= 103; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutAny + param2= 104; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutBool + param2= 105; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutChar + param2= 106; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutString + param2= 107; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutFloat + param2= 108; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutDouble + param2= 109; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutByte + param2= 110; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutShort + param2= 111; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutLong + param2= 112; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutValuesAll + param2=120; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + + // in parameters + + // XCallback::inValues + param2= 200; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inSeqByte + // SAFEARRAY( VARIANT) + param2= 201; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + //XCallback::inSeqXEventListener + param2= 202; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + + // The UNO test component OleTest calls on XCallback_Impl.Callback directly + // that is the COM object has not been past a parameter but rather OleTest + // creates the COM object itself + + // XCallback::outValuesAll + // does not work currently + param2= 300; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutValuesAll + param2= 301; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + // XCallback::inoutValues + param2= 302; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + + // XCallback::inValues + param2= 303; + hr= oletest.Invoke2(L"testInterface", ¶m1, ¶m2); + + // Test a COM object which implements several interfaces. + + + CComQIPtr dispSimple; + hr= dispSimple.CoCreateInstance(L"XCallback_Impl.Simple"); + CComVariant varSimple( dispSimple); + param2= 0; + hr= oletest.Invoke2(L"testInterface2", &varSimple, ¶m2); + + return hr; +} +// VARIANT CComVariant VT_UNKNOWN VT_DISPATCH V_UI1 CComDispatchDriver WINAPI + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/Test/Test.dsp b/extensions/test/ole/unoTocomCalls/Test/Test.dsp new file mode 100644 index 000000000..d9ef4e865 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/Test/Test.dsp @@ -0,0 +1,114 @@ +# Microsoft Developer Studio Project File - Name="Test" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=Test - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Test.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Test.mak" CFG="Test - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Test - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "Test - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Test - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "Test - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "Test - Win32 Release" +# Name "Test - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\Test.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project + diff --git a/extensions/test/ole/unoTocomCalls/Test/Test.sln b/extensions/test/ole/unoTocomCalls/Test/Test.sln new file mode 100644 index 000000000..428b73625 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/Test/Test.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "{13AE4BE8-2467-4B35-800F-154379D54C24}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {13AE4BE8-2467-4B35-800F-154379D54C24}.Debug|Win32.ActiveCfg = Debug|Win32 + {13AE4BE8-2467-4B35-800F-154379D54C24}.Debug|Win32.Build.0 = Debug|Win32 + {13AE4BE8-2467-4B35-800F-154379D54C24}.Release|Win32.ActiveCfg = Release|Win32 + {13AE4BE8-2467-4B35-800F-154379D54C24}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/extensions/test/ole/unoTocomCalls/Test/Test.vcproj b/extensions/test/ole/unoTocomCalls/Test/Test.vcproj new file mode 100644 index 000000000..f31d1ffc4 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/Test/Test.vcproj @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Basic.rgs b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Basic.rgs new file mode 100644 index 000000000..bc1525d7e --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Basic.rgs @@ -0,0 +1,27 @@ +HKCR +{ + XCallback_Impl.Basic.1 = s 'Basic Class' + { + CLSID = s '{A0F04CB7-8494-11D4-8335-005004526AB4}' + } + XCallback_Impl.Basic = s 'Basic Class' + { + CLSID = s '{A0F04CB7-8494-11D4-8335-005004526AB4}' + CurVer = s 'XCallback_Impl.Basic.1' + } + NoRemove CLSID + { + ForceRemove {A0F04CB7-8494-11D4-8335-005004526AB4} = s 'Basic Class' + { + ProgID = s 'XCallback_Impl.Basic.1' + VersionIndependentProgID = s 'XCallback_Impl.Basic' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{180FF553-6F5C-11D4-8330-005004526AB4}' + } + } +} + diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/BasicTest.rgs b/extensions/test/ole/unoTocomCalls/XCallback_Impl/BasicTest.rgs new file mode 100644 index 000000000..ee718304d --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/BasicTest.rgs @@ -0,0 +1,27 @@ +HKCR +{ + XCallback_Impl.BasicTest.1 = s 'BasicTest Class' + { + CLSID = s '{A0F04CBD-8494-11D4-8335-005004526AB4}' + } + XCallback_Impl.BasicTest = s 'BasicTest Class' + { + CLSID = s '{A0F04CBD-8494-11D4-8335-005004526AB4}' + CurVer = s 'XCallback_Impl.BasicTest.1' + } + NoRemove CLSID + { + ForceRemove {A0F04CBD-8494-11D4-8335-005004526AB4} = s 'BasicTest Class' + { + ProgID = s 'XCallback_Impl.BasicTest.1' + VersionIndependentProgID = s 'XCallback_Impl.BasicTest' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{180FF553-6F5C-11D4-8330-005004526AB4}' + } + } +} + diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.cpp b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.cpp new file mode 100644 index 000000000..c60a18219 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.cpp @@ -0,0 +1,505 @@ +/* -*- 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 . + */ +// Callback.cpp : Implementation of CCallback +#include "stdafx.h" +#include "XCallback_Impl.h" +#include "Callback.h" + + +// CCallback + + +STDMETHODIMP CCallback::func1() +{ + MessageBox( NULL, _T("Callback::func1 called"),_T(""), MB_OK); + return S_OK; +} + +STDMETHODIMP CCallback::returnInterface(IDispatch **ppdisp) +{ + if( ! ppdisp) + return E_POINTER; + CComPtr spDisp; + spDisp.CoCreateInstance( L"XCallback_Impl.Simple"); + *ppdisp= spDisp; + (*ppdisp)->AddRef(); + return S_OK; +} + +STDMETHODIMP CCallback::outInterface(IDispatch **ppdisp) +{ +// return S_OK; + if( ! ppdisp) + return E_POINTER; + CComPtr spDisp; + spDisp.CoCreateInstance( L"XCallback_Impl.Simple"); + *ppdisp= spDisp; + (*ppdisp)->AddRef(); + +// MessageBox( NULL, _T("CCallback::outInterface"), _T(""), MB_OK); + return S_OK; +} + +STDMETHODIMP CCallback::outValuesMixed(long val, long *pval, BSTR string) +{ + USES_CONVERSION; + char buff[1024]; + *pval = val+1; + sprintf( buff, "param1: %d, param2 out: %d, param3: %S", val, *pval, string); + MessageBox( NULL, A2T(buff), A2T("XCallback_Impl.Callback"), MB_OK); + return S_OK; +} + + +STDMETHODIMP CCallback::outValuesAll( + /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdisp, + /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppSimpleStruct, + /* [out] */ long __RPC_FAR *aSimpleEnum, + /* [out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *outSeq, + /* [out] */ VARIANT __RPC_FAR *varAny, + /* [out] */ VARIANT_BOOL __RPC_FAR *aBool, + /* [out] */ short __RPC_FAR *aChar, + /* [out] */ BSTR __RPC_FAR *aString, + /* [out] */ float __RPC_FAR *aFloat, + /* [out] */ double __RPC_FAR *aDouble, + /* [out] */ unsigned char __RPC_FAR *aByte, + /* [out] */ short __RPC_FAR *aShort, + /* [out] */ long __RPC_FAR *aLong) +//) +{ +// if( ! ppdisp || ! ppSimpleStruct || ! aSimpleEnum || +// ! outSeq || !varAny ||! aBool || ! aChar || +// ! aString || ! aFloat || ! aDouble || ! aByte || +// ! aShort || ! aLong || ! aUShort || ! aULong) +// return E_POINTER; + + HRESULT hr=S_OK; + hr= outInterface( ppdisp); + hr= outStruct( ppSimpleStruct); + hr= outEnum( aSimpleEnum); + hr= outSeqAny( outSeq); + hr= outAny( varAny); + hr= outBool( aBool); + hr= outChar( aChar); + hr= outString( aString); + hr= outFloat( aFloat); + hr= outDouble( aDouble); + hr= outByte( aByte); + hr= outShort( aShort); + hr= outLong( aLong); + return hr; +} + +STDMETHODIMP CCallback::outStruct(IDispatch **outStruct) +{ +// return S_OK; + if( !outStruct) + return E_POINTER; + HRESULT hr= E_FAIL; +// MessageBox( NULL, _T("CCallback::outStruct"), _T(""), MB_OK); + + CComPtr _dispMgr; + if( SUCCEEDED(hr= _dispMgr.CoCreateInstance(L"com.sun.star.ServiceManager"))) + { + CComDispatchDriver manager( _dispMgr); + CComVariant param1(L"com.sun.star.reflection.CoreReflection"); + CComVariant varRet; + hr= manager.Invoke1( L"createInstance", ¶m1, &varRet); + + CComDispatchDriver reflection( varRet.pdispVal); + param1= L"oletest.SimpleStruct"; + varRet.Clear(); + hr= reflection.Invoke1( L"forName", ¶m1, &varRet); + + CComDispatchDriver classSimpleStruct( varRet.pdispVal); + + CComPtr dispStruct; + param1.vt= VT_DISPATCH | VT_BYREF; + param1.ppdispVal= &dispStruct; + if( SUCCEEDED( hr= classSimpleStruct.Invoke1(L"createObject", ¶m1))) + { + // Set the value + CComDispatchDriver simpleStruct( dispStruct); + param1=L" this is a property string"; + hr= simpleStruct.PutPropertyByName(L"message", ¶m1); + *outStruct= dispStruct; + (*outStruct)->AddRef(); + hr= S_OK; + } + } + return hr; +} + +STDMETHODIMP CCallback::outEnum(long *outEnum) +{ + if( !outEnum) + return E_POINTER; + *outEnum= 1; + return S_OK; +} + +STDMETHODIMP CCallback::outSeqAny(LPSAFEARRAY* outSeq) +{ +// _CrtDbgBreak(); + SAFEARRAY* pArr= SafeArrayCreateVector( VT_VARIANT, 0, 3); + CComVariant var[3]; + var[0]=L" variant 0"; + var[1]=L" variant 1"; + var[2]=L"variant 2"; + for( long i=0; i<3; i++) + { + SafeArrayPutElement( pArr, &i, (void*)&var[i]); + } + + *outSeq= pArr; + return S_OK; +} + +// ATLASSERT //VT_EMPTY + + +STDMETHODIMP CCallback::outAny(VARIANT *outAny) +{ + if( ! outAny) + return E_POINTER; + outAny->vt= VT_BSTR; + outAny->bstrVal= SysAllocString( L"This is a string in a VARIANT"); + + return S_OK; +} + +STDMETHODIMP CCallback::outBool(VARIANT_BOOL *outBool) +{ + if( ! outBool) + return E_POINTER; + *outBool= VARIANT_TRUE; + return S_OK; +} + +STDMETHODIMP CCallback::outChar(short *outChar) +{ + if( !outChar) + return E_POINTER; + *outChar= (short)L'A'; + return S_OK; +} + +STDMETHODIMP CCallback::outString(BSTR *outString) +{ + if( !outString) + return E_POINTER; + *outString= SysAllocString(L"This is a BSTR"); + return S_OK; +} + +STDMETHODIMP CCallback::outFloat(float *outFloat) +{ + if( !outFloat) + return E_POINTER; + *outFloat= 3.14f; + return S_OK; +} + +STDMETHODIMP CCallback::outDouble(double *outDouble) +{ + if(!outDouble) + return E_POINTER; + + *outDouble= 3.145; + return S_OK; +} + + + +STDMETHODIMP CCallback::outShort(short *outShort) +{ + if(!outShort) + return E_POINTER; + *outShort= -1; + return S_OK; +} + +STDMETHODIMP CCallback::outLong(long *outLong) +{ + if(!outLong) + return E_POINTER; + *outLong= 0xffffffff; + return S_OK; +} + + + +STDMETHODIMP CCallback::outByte(unsigned char* outByte) +{ + if(!outByte) + return E_POINTER; + *outByte= 0xff; + return S_OK; +} + +STDMETHODIMP CCallback::inoutInterface(IDispatch **ppdisp) +{ + if( !ppdisp) + return E_POINTER; + CComDispatchDriver disp( *ppdisp); + CComVariant param1(L""); + disp.Invoke1(L"func", ¶m1); + + (*ppdisp)->Release(); + + CComPtr outDisp; + outDisp.CoCreateInstance( L"XCallback_Impl.Simple"); + *ppdisp= outDisp; + (*ppdisp)->AddRef(); + + return S_OK; +} + +STDMETHODIMP CCallback::inoutStruct(IDispatch **inoutVal) +{ + if( !inoutVal) + return E_POINTER; + HRESULT hr= S_OK; + USES_CONVERSION; + CComVariant var; + CComDispatchDriver disp( *inoutVal); + + hr= disp.GetPropertyByName(L"message", &var); + MessageBox( NULL, W2T(var.bstrVal), _T("XCallback_Impl.Callback"), MB_OK); + + (*inoutVal)->Release(); + + CComDispatchDriver dispStruct; + hr= outStruct( &dispStruct.p); + var.Clear(); + var= L"This struct was created in XCallback_Imp.Callback"; + hr= dispStruct.PutPropertyByName(L"message", &var); + + *inoutVal= dispStruct; + (*inoutVal)->AddRef(); + return hr; +} + +STDMETHODIMP CCallback::inoutEnum(long *inoutVal) +{ + if( !inoutVal) + return E_POINTER; + *inoutVal= *inoutVal+1; + + return S_OK; +} + +STDMETHODIMP CCallback::inoutSeqAny(LPSAFEARRAY *pArray) +{ + if( !pArray) + return E_POINTER; + HRESULT hr= S_OK; + long lbound=0; + long ubound=0; + hr= SafeArrayGetLBound( *pArray, 1, &lbound); + hr= SafeArrayGetUBound( *pArray, 1, &ubound); + long count= ubound - lbound + 1; + + // the Array is supposet to contain variants + CComVariant var; + for( long i=0; ivt= VT_BSTR) + MessageBox( NULL, W2T( inoutVal->bstrVal), _T("XCallback_Impl.Callback"), MB_OK); + + VariantClear( inoutVal); + inoutVal->vt= VT_BSTR; + inoutVal->bstrVal=SysAllocString( L" [string] XCallback_Impl.Callback inoutAny"); + return S_OK; +} + +STDMETHODIMP CCallback::inoutBool(VARIANT_BOOL *inoutVal) +{ + if( !inoutVal) + return E_POINTER; + + *inoutVal= *inoutVal == VARIANT_TRUE ? VARIANT_FALSE : VARIANT_TRUE; + return S_OK; +} + +STDMETHODIMP CCallback::inoutChar(short *inoutVal) +{ + if( !inoutVal) + return E_POINTER; + USES_CONVERSION; + char buff[256]; + sprintf( buff, "character value: %C", *inoutVal); + MessageBox( NULL, A2T(buff), _T("XCallback_Impl.Callback"), MB_OK); + *inoutVal= L'B'; + return S_OK; +} + +STDMETHODIMP CCallback::inoutString(BSTR *inoutVal) +{ + if( !inoutVal) + return E_POINTER; + USES_CONVERSION; + MessageBox( NULL, W2T(*inoutVal), _T("XCallback_Impl.Callback"), MB_OK); + SysFreeString(*inoutVal); + *inoutVal= SysAllocString(L"a string from XCallback_Impl.Callback"); + + return S_OK; +} + +STDMETHODIMP CCallback::inoutFloat(float *inoutVal) +{ + if( !inoutVal) + return E_POINTER; + *inoutVal = *inoutVal+1; + return S_OK; +} + +STDMETHODIMP CCallback::inoutDouble(double *inoutVal) +{ + if( !inoutVal) + return E_POINTER; + *inoutVal= *inoutVal+1; + return S_OK; +} + +STDMETHODIMP CCallback::inoutByte(unsigned char *inoutVal) +{ + if( !inoutVal) + return E_POINTER; + *inoutVal= 0xff; + return S_OK; +} + +STDMETHODIMP CCallback::inoutShort(short *inoutVal) +{ + if( !inoutVal) + return E_POINTER; + *inoutVal= -1; + return S_OK; +} + +STDMETHODIMP CCallback::inoutLong(long* inoutVal) +{ + if( !inoutVal) + return E_POINTER; + *inoutVal= 0xffffffff; + return S_OK; +} + +STDMETHODIMP CCallback::inoutValuesAll( + /* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *aXSimple, + /* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *aStruct, + /* [out][in] */ long __RPC_FAR *aEnum, + /* [out][in] */ SAFEARRAY __RPC_FAR * __RPC_FAR *aSeq, + /* [out][in] */ VARIANT __RPC_FAR *aAny, + /* [out][in] */ VARIANT_BOOL __RPC_FAR *aBool, + /* [out][in] */ short __RPC_FAR *aChar, + /* [out][in] */ BSTR __RPC_FAR *aString, + /* [out][in] */ float __RPC_FAR *aFloat, + /* [out][in] */ double __RPC_FAR *aDouble, + /* [out][in] */ unsigned char __RPC_FAR *aByte, + /* [out][in] */ short __RPC_FAR *aShort, + /* [out][in] */ long __RPC_FAR *aLong) +{ + inoutInterface( aXSimple); + inoutStruct( aStruct); + inoutEnum( aEnum); + inoutSeqAny( aSeq); + inoutAny( aAny); + inoutBool( aBool); + inoutChar( aChar); + inoutString( aString); + inoutFloat( aFloat); + inoutDouble( aDouble); + inoutByte( aByte); + inoutShort( aShort); + inoutLong( aLong); + + return S_OK; +} + + +STDMETHODIMP CCallback::inValues(short aChar, long aLong, BSTR aString) +{ + USES_CONVERSION; + wchar_t _char= (wchar_t) aChar; + char buff[1024]; + sprintf( buff, "Parameters: char= %C, long= %d, string= %s", _char, aLong, W2A(aString)); + MessageBox( NULL, A2T(buff), _T("XCallback_Impl.Callback"), MB_OK); + return S_OK; +} + +STDMETHODIMP CCallback::outSeqByte(LPSAFEARRAY * outVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CCallback::inSeqByte( LPSAFEARRAY listeners) +{ + + return S_OK; +} + +STDMETHODIMP CCallback::inSeqXEventListener( LPSAFEARRAY listeners, LPSAFEARRAY events) +{ + HRESULT hr= S_OK; + long ubound= 0; + long lbound= 0; + long count= 0; + hr= SafeArrayGetUBound( listeners, 1, &ubound); + hr= SafeArrayGetLBound( listeners, 1, &lbound); + count= ubound - lbound +1; + + // We assume that the count of EventObjects in events is the same + for( long i = 0; i < count; i++) + { + CComVariant varListener; + CComVariant varEvent; + hr= SafeArrayGetElement( listeners, &i, &varListener); + hr= SafeArrayGetElement( events, &i, &varEvent); + if( varListener.vt == VT_DISPATCH && varEvent.vt == VT_DISPATCH) + { + CComDispatchDriver disp( varListener.pdispVal); + hr= disp.Invoke1(L"disposing", &varEvent); + } + + } + + return S_OK; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.h b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.h new file mode 100644 index 000000000..941d1202f --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.h @@ -0,0 +1,126 @@ +/* -*- 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 . + */ +// Callback.h : Declaration of the CCallback + +#pragma once + +#include "resource.h" + + +// CCallback +class ATL_NO_VTABLE CCallback : + public CComObjectRootEx, + public CComCoClass, + public IDispatchImpl +{ +public: + CCallback() + { + } + +DECLARE_REGISTRY_RESOURCEID(IDR_CALLBACK) + +DECLARE_PROTECT_FINAL_CONSTRUCT() + +BEGIN_COM_MAP(CCallback) + COM_INTERFACE_ENTRY(ICallback) + COM_INTERFACE_ENTRY(IDispatch) +END_COM_MAP() + +// ICallback +public: + STDMETHOD(inSeqByte)(/*[in]*/ LPSAFEARRAY val); + STDMETHOD(inSeqXEventListener)(/*[in]*/ LPSAFEARRAY listener, LPSAFEARRAY event); + STDMETHOD(outSeqByte)(/*[out]*/ LPSAFEARRAY* outVal); + STDMETHOD(inValues)(/*[in]*/short aChar, /*[in]*/ long aLong, /*[in]*/ BSTR aString); + STDMETHOD(inoutLong)(/*[in,out]*/ long* inoutVal); + STDMETHOD(inoutShort)(/*[in,out]*/ short* inoutVal); + STDMETHOD(inoutByte)(/*[in,out]*/ unsigned char* inoutVal); + STDMETHOD(inoutDouble)(/*[in,out]*/ double* inoutVal); + STDMETHOD(inoutFloat)(/*[in,out]*/ float* inoutVal); + STDMETHOD(inoutString)(/*[in,out]*/ BSTR *inoutVal); + STDMETHOD(inoutChar)(/*[in,out]*/ short* inoutVal); + STDMETHOD(inoutBool)(/*[in,out]*/ VARIANT_BOOL * inoutVal); + STDMETHOD(inoutAny)(/*[in,out]*/ VARIANT* inoutVal); + STDMETHOD(inoutSeqAny)(/*[in,out]*/ LPSAFEARRAY* pArray); + STDMETHOD(inoutEnum)(/*[in,out]*/ long * inoutVal); + STDMETHOD(inoutStruct)(/*[in,out]*/ IDispatch** inoutVal); + STDMETHOD(inoutInterface)(/*[in,out]*/ IDispatch** ppdisp); + STDMETHOD(inoutValuesAll)( + /* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *aXSimple, + /* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *aStruct, + /* [out][in] */ long __RPC_FAR *aEnum, + /* [out][in] */ SAFEARRAY __RPC_FAR * __RPC_FAR *aSeq, + /* [out][in] */ VARIANT __RPC_FAR *aAny, + /* [out][in] */ VARIANT_BOOL __RPC_FAR *aBool, + /* [out][in] */ short __RPC_FAR *aChar, + /* [out][in] */ BSTR __RPC_FAR *aString, + /* [out][in] */ float __RPC_FAR *aFloat, + /* [out][in] */ double __RPC_FAR *aDouble, + /* [out][in] */ unsigned char __RPC_FAR *aByte, + /* [out][in] */ short __RPC_FAR *aShort, + /* [out][in] */ long __RPC_FAR *aLong); + + STDMETHOD(outByte)( unsigned char* outByte); + STDMETHOD(outLong)(/*[out]*/ long* outLong); + STDMETHOD(outShort)(/*[out]*/ short *outShort); + STDMETHOD(outDouble)(/*[out]*/ double* outDouble); + STDMETHOD(outFloat)(/*[out]*/ float* outFloat); + STDMETHOD(outString)(/*[out]*/ BSTR * outString); + STDMETHOD(outChar)(short* outChar); + STDMETHOD(outBool)(VARIANT_BOOL* outBool); + STDMETHOD(outAny)(VARIANT* outAny); + STDMETHOD(outSeqAny)(/*[out]*/LPSAFEARRAY* outSeq); + STDMETHOD(outEnum)(/*[out]*/ long* outEnum); + STDMETHOD(outStruct)(/*[out]*/ IDispatch** outStruct); + virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE outValuesAll( + /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdisp, + /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppSimpleStruct, + /* [out] */ long __RPC_FAR *aSimpleEnum, + /* [out] */ LPSAFEARRAY* outSeq, + /* [out] */ VARIANT __RPC_FAR *varAny, + /* [out] */ VARIANT_BOOL __RPC_FAR *aBool, + /* [out] */ short __RPC_FAR *aChar, + /* [out] */ BSTR __RPC_FAR *aString, + /* [out] */ float __RPC_FAR *aFloat, + /* [out] */ double __RPC_FAR *aDouble, + /* [out] */ unsigned char __RPC_FAR *aByte, + /* [out] */ short __RPC_FAR *aShort, + /* [out] */ long __RPC_FAR *aLong); +// ); + +// STDMETHOD(outValuesAll)( +// /*[out]*/ IDispatch** ppdisp, +// /*[out]*/ IUnknown** ppSimpleStruct, +// /*[out]*/ long* aSimpleEnum, +// /*[out]*/ VARIANT* ArrayAny, +// /*[out]*/ VARIANT* varAny, +// /*[out]*/ VARIANT_BOOL * aBool, +// /*[out]*/ unsigned short* aChar, +// /*[out]*/ BSTR* aString, /*[out]*/ float* aFloat, +// /*[out]*/ double* aDouble, +// /*[out]*/ signed char* aByte, /*[out]*/ short* aShort, /*[out]*/long* aLong, /*[out]*/ unsigned short* aUShort, /*[out]*/ unsigned long* aULong); + STDMETHOD(outValuesMixed)(/*[in]*/ long val, /*[out]*/ long* pval, /*[in]*/ BSTR string); + STDMETHOD(outInterface)(/*[out]*/ IDispatch** ppdisp); + STDMETHOD(returnInterface)(/*[out, retval]*/ IDispatch** ppdisp); + STDMETHOD(func1)(); +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.rgs b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.rgs new file mode 100644 index 000000000..b3f9e071b --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.rgs @@ -0,0 +1,27 @@ +HKCR +{ + XCallback_Impl.Callback.1 = s 'Callback Class' + { + CLSID = s '{180FF560-6F5C-11D4-8330-005004526AB4}' + } + XCallback_Impl.Callback = s 'Callback Class' + { + CLSID = s '{180FF560-6F5C-11D4-8330-005004526AB4}' + CurVer = s 'XCallback_Impl.Callback.1' + } + NoRemove CLSID + { + ForceRemove {180FF560-6F5C-11D4-8330-005004526AB4} = s 'Callback Class' + { + ProgID = s 'XCallback_Impl.Callback.1' + VersionIndependentProgID = s 'XCallback_Impl.Callback' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{180FF553-6F5C-11D4-8330-005004526AB4}' + } + } +} + diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.cpp b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.cpp new file mode 100644 index 000000000..5b7183cdb --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.cpp @@ -0,0 +1,73 @@ +/* -*- 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 . + */ +// Simple.cpp : Implementation of CSimple +#include "stdafx.h" +#include "XCallback_Impl.h" +#include "Simple.h" + + +// CSimple + + +STDMETHODIMP CSimple::func(BSTR message) +{ + USES_CONVERSION; + MessageBox( NULL, W2T( message), _T("XCallback_Impl.Simple"), MB_OK); + return S_OK; +} + + +STDMETHODIMP CSimple::func2(BSTR message) +{ + USES_CONVERSION; + MessageBox( NULL, W2T( message), _T("XCallback_Impl.Simple"), MB_OK); + return S_OK; +} + +STDMETHODIMP CSimple::func3(BSTR message) +{ + USES_CONVERSION; + MessageBox( NULL, W2T( message), _T("XCallback_Impl.Simple"), MB_OK); + return S_OK; +} + + +STDMETHODIMP CSimple::get__implementedInterfaces(LPSAFEARRAY *pVal) +{ + HRESULT hr= S_OK; + SAFEARRAY *pArr= SafeArrayCreateVector( VT_BSTR, 0, 3); + if( pArr) + { long index=0; + BSTR name1= SysAllocString(L"oletest.XSimple"); + BSTR name2= SysAllocString(L"oletest.XSimple2"); + BSTR name3= SysAllocString(L"oletest.XSimple3"); + + hr= SafeArrayPutElement( pArr, & index, name1); + index++; + hr|= SafeArrayPutElement( pArr, &index, name2); + index++; + hr|= SafeArrayPutElement( pArr, &index, name3); + *pVal= pArr; + + } + *pVal= pArr; + return hr; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.h b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.h new file mode 100644 index 000000000..8abe56270 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.h @@ -0,0 +1,55 @@ +/* -*- 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 . + */ +// Simple.h : Declaration of the CSimple + +#pragma once + +#include "resource.h" + + +// CSimple +class ATL_NO_VTABLE CSimple : + public CComObjectRootEx, + public CComCoClass, + public IDispatchImpl +{ +public: + CSimple() + { + } + +DECLARE_REGISTRY_RESOURCEID(IDR_SIMPLE) + +DECLARE_PROTECT_FINAL_CONSTRUCT() + +BEGIN_COM_MAP(CSimple) + COM_INTERFACE_ENTRY(ISimple) + COM_INTERFACE_ENTRY(IDispatch) +END_COM_MAP() + +// ISimple +public: + + STDMETHOD(get__implementedInterfaces)(/*[out, retval]*/ LPSAFEARRAY *pVal); + STDMETHOD(func3)(/*[in]*/ BSTR message); + STDMETHOD(func2)(/*[in]*/ BSTR message); + STDMETHOD(func)( BSTR message); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.rgs b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.rgs new file mode 100644 index 000000000..19237bf36 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.rgs @@ -0,0 +1,27 @@ +HKCR +{ + XCallback_Impl.Simple.1 = s 'Simple Class' + { + CLSID = s '{180FF565-6F5C-11D4-8330-005004526AB4}' + } + XCallback_Impl.Simple = s 'Simple Class' + { + CLSID = s '{180FF565-6F5C-11D4-8330-005004526AB4}' + CurVer = s 'XCallback_Impl.Simple.1' + } + NoRemove CLSID + { + ForceRemove {180FF565-6F5C-11D4-8330-005004526AB4} = s 'Simple Class' + { + ProgID = s 'XCallback_Impl.Simple.1' + VersionIndependentProgID = s 'XCallback_Impl.Simple' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{180FF553-6F5C-11D4-8330-005004526AB4}' + } + } +} + diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.cpp b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.cpp new file mode 100644 index 000000000..da0608bfd --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.cpp @@ -0,0 +1,32 @@ +/* -*- 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 . + */ +// stdafx.cpp : source file that includes just the standard includes +// stdafx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +#ifdef _ATL_STATIC_REGISTRY +#include +#include +#endif + +#include + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h new file mode 100644 index 000000000..678114bae --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h @@ -0,0 +1,45 @@ +/* -*- 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 . + */ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#if !defined(AFX_STDAFX_H__180FF556_6F5C_11D4_8330_005004526AB4__INCLUDED_) +#define AFX_STDAFX_H__180FF556_6F5C_11D4_8330_005004526AB4__INCLUDED_ + +#ifdef _MSC_VER +#pragma once +#endif + +#define STRICT +#define _ATL_APARTMENT_THREADED + +#include +#include +//You may derive a class from CComModule and use it if you want to override +//something, but do not change the name of _Module +extern CComModule _Module; +#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__180FF556_6F5C_11D4_8330_005004526AB4__INCLUDED) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.cpp b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.cpp new file mode 100644 index 000000000..739695914 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.cpp @@ -0,0 +1,78 @@ +/* -*- 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 . + */ +// XCallback_Impl.cpp : Implementation of DLL Exports. + +// Note: Proxy/Stub Information +// To build a separate proxy/stub DLL, +// run nmake -f XCallback_Implps.mk in the project directory. + +#include "stdafx.h" +#include "resource.h" +#include +#include "XCallback_Impl.h" + +#include "XCallback_Impl_i.c" +#include "Callback.h" +#include "Simple.h" + +CComModule _Module; + +BEGIN_OBJECT_MAP(ObjectMap) +OBJECT_ENTRY(CLSID_Callback, CCallback) +OBJECT_ENTRY(CLSID_Simple, CSimple) +END_OBJECT_MAP() + +// DLL Entry Point + +extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) +{ + if (dwReason == DLL_PROCESS_ATTACH) + { + _Module.Init(ObjectMap, hInstance, &LIBID_XCALLBACK_IMPLLib); + DisableThreadLibraryCalls(hInstance); + } + else if (dwReason == DLL_PROCESS_DETACH) + _Module.Term(); + return TRUE; // ok +} + +// Used to determine whether the DLL can be unloaded by OLE + +STDAPI DllCanUnloadNow(void) { return (_Module.GetLockCount() == 0) ? S_OK : S_FALSE; } + +// Returns a class factory to create an object of the requested type + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) +{ + return _Module.GetClassObject(rclsid, riid, ppv); +} + +// DllRegisterServer - Adds entries to the system registry + +STDAPI DllRegisterServer(void) +{ + // registers object, typelib and all interfaces in typelib + return _Module.RegisterServer(TRUE); +} + +// DllUnregisterServer - Removes entries from the system registry + +STDAPI DllUnregisterServer(void) { return _Module.UnregisterServer(TRUE); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.def b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.def new file mode 100644 index 000000000..b2d5e9627 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.def @@ -0,0 +1,10 @@ +; XCallback_Impl.def : Declares the module parameters. + +LIBRARY "XCallback_Impl.DLL" + +EXPORTS + DllCanUnloadNow PRIVATE + DllGetClassObject PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE + diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.dsp b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.dsp new file mode 100644 index 000000000..6897d0d81 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.dsp @@ -0,0 +1,337 @@ +# Microsoft Developer Studio Project File - Name="XCallback_Impl" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=XCallback_Impl - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "XCallback_Impl.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "XCallback_Impl.mak" CFG="XCallback_Impl - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "XCallback_Impl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "XCallback_Impl - Win32 Unicode Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "XCallback_Impl - Win32 Release MinSize" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "XCallback_Impl - Win32 Release MinDependency" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "XCallback_Impl - Win32 Unicode Release MinSize" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "XCallback_Impl - Win32 Unicode Release MinDependency" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "XCallback_Impl - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# Begin Custom Build - Performing registration +OutDir=.\Debug +TargetPath=.\Debug\XCallback_Impl.dll +InputPath=.\Debug\XCallback_Impl.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + +# End Custom Build + +!ELSEIF "$(CFG)" == "XCallback_Impl - Win32 Unicode Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugU" +# PROP BASE Intermediate_Dir "DebugU" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugU" +# PROP Intermediate_Dir "DebugU" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# Begin Custom Build - Performing registration +OutDir=.\DebugU +TargetPath=.\DebugU\XCallback_Impl.dll +InputPath=.\DebugU\XCallback_Impl.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + goto end + :NOTNT + echo Warning : Cannot register Unicode DLL on Windows 95 + :end + +# End Custom Build + +!ELSEIF "$(CFG)" == "XCallback_Impl - Win32 Release MinSize" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseMinSize" +# PROP BASE Intermediate_Dir "ReleaseMinSize" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseMinSize" +# PROP Intermediate_Dir "ReleaseMinSize" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# Begin Custom Build - Performing registration +OutDir=.\ReleaseMinSize +TargetPath=.\ReleaseMinSize\XCallback_Impl.dll +InputPath=.\ReleaseMinSize\XCallback_Impl.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + +# End Custom Build + +!ELSEIF "$(CFG)" == "XCallback_Impl - Win32 Release MinDependency" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseMinDependency" +# PROP BASE Intermediate_Dir "ReleaseMinDependency" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseMinDependency" +# PROP Intermediate_Dir "ReleaseMinDependency" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# Begin Custom Build - Performing registration +OutDir=.\ReleaseMinDependency +TargetPath=.\ReleaseMinDependency\XCallback_Impl.dll +InputPath=.\ReleaseMinDependency\XCallback_Impl.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + +# End Custom Build + +!ELSEIF "$(CFG)" == "XCallback_Impl - Win32 Unicode Release MinSize" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseUMinSize" +# PROP BASE Intermediate_Dir "ReleaseUMinSize" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseUMinSize" +# PROP Intermediate_Dir "ReleaseUMinSize" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# Begin Custom Build - Performing registration +OutDir=.\ReleaseUMinSize +TargetPath=.\ReleaseUMinSize\XCallback_Impl.dll +InputPath=.\ReleaseUMinSize\XCallback_Impl.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + goto end + :NOTNT + echo Warning : Cannot register Unicode DLL on Windows 95 + :end + +# End Custom Build + +!ELSEIF "$(CFG)" == "XCallback_Impl - Win32 Unicode Release MinDependency" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseUMinDependency" +# PROP BASE Intermediate_Dir "ReleaseUMinDependency" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseUMinDependency" +# PROP Intermediate_Dir "ReleaseUMinDependency" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# Begin Custom Build - Performing registration +OutDir=.\ReleaseUMinDependency +TargetPath=.\ReleaseUMinDependency\XCallback_Impl.dll +InputPath=.\ReleaseUMinDependency\XCallback_Impl.dll +SOURCE="$(InputPath)" + +"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg" + goto end + :NOTNT + echo Warning : Cannot register Unicode DLL on Windows 95 + :end + +# End Custom Build + +!ENDIF + +# Begin Target + +# Name "XCallback_Impl - Win32 Debug" +# Name "XCallback_Impl - Win32 Unicode Debug" +# Name "XCallback_Impl - Win32 Release MinSize" +# Name "XCallback_Impl - Win32 Release MinDependency" +# Name "XCallback_Impl - Win32 Unicode Release MinSize" +# Name "XCallback_Impl - Win32 Unicode Release MinDependency" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\Callback.cpp +# End Source File +# Begin Source File + +SOURCE=.\Simple.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\XCallback_Impl.cpp +# End Source File +# Begin Source File + +SOURCE=.\XCallback_Impl.def +# End Source File +# Begin Source File + +SOURCE=.\XCallback_Impl.idl +# ADD MTL /tlb ".\XCallback_Impl.tlb" /h "XCallback_Impl.h" /iid "XCallback_Impl_i.c" /Oicf +# End Source File +# Begin Source File + +SOURCE=.\XCallback_Impl.rc +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Callback.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\Simple.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\Callback.rgs +# End Source File +# Begin Source File + +SOURCE=.\Simple.rgs +# End Source File +# End Group +# End Target +# End Project + + diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.idl b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.idl new file mode 100644 index 000000000..de56aac45 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.idl @@ -0,0 +1,144 @@ +/* -*- 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 . + */ +// XCallback_Impl.idl : IDL source for XCallback_Impl.dll + + +// This file will be processed by the MIDL tool to +// produce the type library (XCallback_Impl.tlb) and marshalling code. + +import "oaidl.idl"; +import "ocidl.idl"; + [ + object, + uuid(180FF55F-6F5C-11D4-8330-005004526AB4), + dual, + helpstring("ICallback Interface"), + pointer_default(unique) + ] + interface ICallback : IDispatch + { + [id(1), helpstring("method func1")] HRESULT func1(); + [id(2), helpstring("method returnInterface")] HRESULT returnInterface([out, retval] IDispatch** ppdisp); + [id(3), helpstring("method outInterface")] HRESULT outInterface([out] IDispatch** ppdisp); + [id(4), helpstring("method outValuesMixed")] HRESULT outValuesMixed([in] long val, [out] long* pval, [in] BSTR string); + [id(5), helpstring("method outValuesAll")] HRESULT outValuesAll([out] IDispatch** ppdisp, [out] IDispatch** ppSimpleStruct, [out] long* aSimpleEnum, + [out] SAFEARRAY( VARIANT)* outSeq, + [out] VARIANT* varAny, + [out] VARIANT_BOOL * aBool, + [out] short* aChar, + [out] BSTR* aString , + [out] float* aFloat, + [out] double* aDouble, + [out] unsigned char* aByte, + [out] short* aShort, + [out]long* aLong); +// ); + [id(6), helpstring("method outStruct")] HRESULT outStruct([out] IDispatch** outStruct); + [id(7), helpstring("method outEnum")] HRESULT outEnum([out] long* outEnum); + [id(8), helpstring("method outSeqAny")] HRESULT outSeqAny([out] SAFEARRAY( VARIANT)* outSeq); + [id(9), helpstring("method outAny")] HRESULT outAny([out] VARIANT* outAny); + [id(10), helpstring("method outBool")] HRESULT outBool([out]VARIANT_BOOL* outBool); + [id(11), helpstring("method outChar")] HRESULT outChar([out] short* outChar); + [id(12), helpstring("method outString")] HRESULT outString([out] BSTR * outString); + [id(13), helpstring("method outFloat")] HRESULT outFloat([out] float* outFloat); + [id(14), helpstring("method outDouble")] HRESULT outDouble([out] double* outDouble); + [id(16), helpstring("method outShort")] HRESULT outShort([out] short *outShort); + [id(17), helpstring("method outLong")] HRESULT outLong([out] long* outLong); + [id(20), helpstring("method outByte")] HRESULT outByte([out] unsigned char* outByte); + [id(21), helpstring("method inoutInterface")] HRESULT inoutInterface([in,out] IDispatch** ppdisp); + [id(22), helpstring("method inoutStruct")] HRESULT inoutStruct([in,out] IDispatch** inoutVal); + [id(23), helpstring("method inoutEnum")] HRESULT inoutEnum([in,out] long * inoutVal); + [id(24), helpstring("method inoutSeqAny")] HRESULT inoutSeqAny([in,out] SAFEARRAY(VARIANT)* pArray); + [id(25), helpstring("method inoutAny")] HRESULT inoutAny([in,out] VARIANT* inoutVal); + [id(26), helpstring("method inoutBool")] HRESULT inoutBool([in,out] VARIANT_BOOL * inoutVal); + [id(27), helpstring("method inoutChar")] HRESULT inoutChar([in,out] short* inoutVal); + [id(28), helpstring("method inoutString")] HRESULT inoutString([in,out] BSTR *inoutVal); + [id(29), helpstring("method inoutFloat")] HRESULT inoutFloat([in,out] float* inoutVal); + [id(30), helpstring("method inoutDouble")] HRESULT inoutDouble([in,out] double* inoutVal); + [id(31), helpstring("method inoutByte")] HRESULT inoutByte([in,out] unsigned char* inoutVal); + [id(32), helpstring("method inoutShort")] HRESULT inoutShort([in,out] short* inoutVal); + [id(33), helpstring("method inoutLong")] HRESULT inoutLong([in,out] long* inoutVal); + [id(34), helpstring("method inoutValueAll")] HRESULT inoutValuesAll( + [in,out] IDispatch** aXSimple, + [in,out] IDispatch** aStruct, + [in,out] long* aEnum, + [in,out] SAFEARRAY( VARIANT)* aSeq, + [in,out] VARIANT* aAny, + [in,out] VARIANT_BOOL* aBool, + [in,out] short* aChar, + [in,out] BSTR* aString, + [in,out] float* aFloat, + [in,out] double* aDouble, + [in,out] unsigned char* aByte, + [in,out] short* aShort, + [in,out] long* aLong); + [id(35), helpstring("method inValues")] HRESULT inValues([in]short aChar, [in] long aLong, [in] BSTR aString); + [id(36), helpstring("method outSeqByte")] HRESULT outSeqByte([out] SAFEARRAY(unsigned char)* outVal); + [id(37), helpstring("method inSeqByte")] HRESULT inSeqByte([in] SAFEARRAY(VARIANT) val); + [id(38), helpstring("method inSeqXEventListener")] HRESULT inSeqXEventListener([in] SAFEARRAY(VARIANT) listener, + [in] SAFEARRAY(VARIANT) event); + + }; + [ + object, + uuid(180FF564-6F5C-11D4-8330-005004526AB4), + dual, + helpstring("ISimple Interface"), + pointer_default(unique) + ] + interface ISimple : IDispatch + { + [id(1), helpstring("method func")] HRESULT func( [in] BSTR message); + [id(2), helpstring("method func2")] HRESULT func2([in] BSTR message); + [id(3), helpstring("method func3")] HRESULT func3([in] BSTR message); + [propget, id(4), helpstring("property _implementedInterfaces")] HRESULT _implementedInterfaces([out, retval] SAFEARRAY(BSTR) *pVal); + }; + + + +[ + uuid(180FF553-6F5C-11D4-8330-005004526AB4), + version(1.0), + helpstring("XCallback_Impl 1.0 Type Library") +] +library XCALLBACK_IMPLLib +{ + importlib("stdole32.tlb"); + importlib("stdole2.tlb"); + + [ + uuid(180FF560-6F5C-11D4-8330-005004526AB4), + helpstring("Callback Class") + ] + coclass Callback + { + [default] interface ICallback; + }; + [ + uuid(180FF565-6F5C-11D4-8330-005004526AB4), + helpstring("Simple Class") + ] + coclass Simple + { + [default] interface ISimple; + }; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.rc b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.rc new file mode 100644 index 000000000..f544b17ca --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.rc @@ -0,0 +1,154 @@ +/* + * 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 "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + + +// Generated from the TEXTINCLUDE 2 resource. + +#include "winres.h" + + +#undef APSTUDIO_READONLY_SYMBOLS + + +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + + + +// REGISTRY + + +IDR_CALLBACK REGISTRY DISCARDABLE "Callback.rgs" +IDR_SIMPLE REGISTRY DISCARDABLE "Simple.rgs" +#endif // German (Germany) resources + + + + +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED + + +// TEXTINCLUDE + + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "1 TYPELIB ""XCallback_Impl.tlb""\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC + + +// Version + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "XCallback_Impl Module\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "XCallback_Impl\0" + VALUE "LegalCopyright", "Copyright 2000\0" + VALUE "OriginalFilename", "XCallback_Impl.DLL\0" + VALUE "ProductName", "XCallback_Impl Module\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + VALUE "OLESelfRegister", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + + + +// String Table + + +STRINGTABLE DISCARDABLE +BEGIN + IDS_PROJNAME "XCallback_Impl" +END + +#endif // English (U.S.) resources + + + + +#ifndef APSTUDIO_INVOKED + + +// Generated from the TEXTINCLUDE 3 resource. + +1 TYPELIB "XCallback_Impl.tlb" + + +#endif // not APSTUDIO_INVOKED + + diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.sln b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.sln new file mode 100644 index 000000000..62b109fe4 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.sln @@ -0,0 +1,31 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XCallback_Impl", "XCallback_Impl.vcproj", "{92A6B531-401E-4900-8217-169A96F4168D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release MinDependency|Win32 = Release MinDependency|Win32 + Release MinSize|Win32 = Release MinSize|Win32 + Unicode Debug|Win32 = Unicode Debug|Win32 + Unicode Release MinDependency|Win32 = Unicode Release MinDependency|Win32 + Unicode Release MinSize|Win32 = Unicode Release MinSize|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {92A6B531-401E-4900-8217-169A96F4168D}.Debug|Win32.ActiveCfg = Debug|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Debug|Win32.Build.0 = Debug|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Release MinDependency|Win32.ActiveCfg = Release MinDependency|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Release MinDependency|Win32.Build.0 = Release MinDependency|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Release MinSize|Win32.ActiveCfg = Release MinSize|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Release MinSize|Win32.Build.0 = Release MinSize|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Debug|Win32.ActiveCfg = Unicode Debug|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Debug|Win32.Build.0 = Unicode Debug|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Release MinDependency|Win32.ActiveCfg = Unicode Release MinDependency|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Release MinDependency|Win32.Build.0 = Unicode Release MinDependency|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Release MinSize|Win32.ActiveCfg = Unicode Release MinSize|Win32 + {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Release MinSize|Win32.Build.0 = Unicode Release MinSize|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.vcproj b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.vcproj new file mode 100644 index 000000000..1a9068d31 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.vcproj @@ -0,0 +1,816 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h b/extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h new file mode 100644 index 000000000..2864478cd --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h @@ -0,0 +1,39 @@ +/* -*- 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 . + */ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by XCallback_Impl.rc + +#define IDS_PROJNAME 100 +#define IDR_CALLBACK 101 +#define IDR_SIMPLE 102 +#define IDR_SIMPLESTRUCT 103 + +// Next default values for new objects + +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_COMMAND_VALUE 32768 +#define _APS_NEXT_CONTROL_VALUE 201 +#define _APS_NEXT_SYMED_VALUE 104 +#endif +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/test/ole/unoTocomCalls/readme.txt b/extensions/test/ole/unoTocomCalls/readme.txt new file mode 100644 index 000000000..feb46b11e --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/readme.txt @@ -0,0 +1,9 @@ +The directory XCallback_Impl contains a MSDEV project that +creates a dll containing the ActiveX components +XCallback_Impl.Simple and XCallback_Impl.Callback +Callback implements functions defined in oletest.XCallback +and Simple implements functions defined in oletest.XSimple. +These interfaces are build in extensions/test/ole/cpnt + +The projects in unoToComCalls test the functionality of COM +and JScript object which implement UNO interfaces. -- cgit v1.2.3